Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
ff58a432
Unverified
Commit
ff58a432
authored
Oct 02, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
Fix #12901
parent
fe6e4cc2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
12 deletions
+54
-12
src/main/java/org/b3log/solo/processor/BlogProcessor.java
src/main/java/org/b3log/solo/processor/BlogProcessor.java
+50
-7
src/main/resources/manifest.json.tpl
src/main/resources/manifest.json.tpl
+3
-3
src/main/webapp/WEB-INF/static-resources.xml
src/main/webapp/WEB-INF/static-resources.xml
+1
-2
No files found.
src/main/java/org/b3log/solo/processor/BlogProcessor.java
View file @
ff58a432
...
@@ -17,10 +17,13 @@
...
@@ -17,10 +17,13 @@
*/
*/
package
org
.
b3log
.
solo
.
processor
;
package
org
.
b3log
.
solo
.
processor
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.ioc.Inject
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.model.Pagination
;
import
org.b3log.latke.model.Pagination
;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.servlet.HttpMethod
;
import
org.b3log.latke.servlet.HttpMethod
;
...
@@ -35,16 +38,23 @@ import org.b3log.solo.service.*;
...
@@ -35,16 +38,23 @@ import org.b3log.solo.service.*;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.io.InputStream
;
/**
/**
* Blog processor.
* Blog processor.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
3.1.8, Feb 7
, 2019
* @version 1.
4.0.0, Oct 2
, 2019
* @since 0.4.6
* @since 0.4.6
*/
*/
@RequestProcessor
@RequestProcessor
public
class
BlogProcessor
{
public
class
BlogProcessor
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
BlogProcessor
.
class
);
/**
/**
* Article query service.
* Article query service.
*/
*/
...
@@ -75,6 +85,44 @@ public class BlogProcessor {
...
@@ -75,6 +85,44 @@ public class BlogProcessor {
@Inject
@Inject
private
OptionQueryService
optionQueryService
;
private
OptionQueryService
optionQueryService
;
/**
* PWA manifest JSON template.
*/
private
static
String
PWA_MANIFESTO_JSON
;
static
{
try
(
final
InputStream
tplStream
=
BlogProcessor
.
class
.
getResourceAsStream
(
"/manifest.json.tpl"
))
{
PWA_MANIFESTO_JSON
=
IOUtils
.
toString
(
tplStream
,
"UTF-8"
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Loads PWA manifest.json template failed"
,
e
);
}
}
/**
* Gets PWA manifest.json.
*
* @param context the specified context
*/
@RequestProcessing
(
value
=
"/manifest.json"
,
method
=
HttpMethod
.
GET
)
public
void
getPWAManifestJSON
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
renderer
.
setPretty
(
true
);
context
.
setRenderer
(
renderer
);
final
JSONObject
preference
=
optionQueryService
.
getPreference
();
if
(
null
==
preference
)
{
return
;
}
final
String
name
=
preference
.
optString
(
Option
.
ID_C_BLOG_TITLE
);
PWA_MANIFESTO_JSON
=
StringUtils
.
replace
(
PWA_MANIFESTO_JSON
,
"${name}"
,
name
);
final
String
description
=
preference
.
optString
(
Option
.
ID_C_BLOG_SUBTITLE
);
PWA_MANIFESTO_JSON
=
StringUtils
.
replace
(
PWA_MANIFESTO_JSON
,
"${description}"
,
description
);
final
JSONObject
jsonObject
=
new
JSONObject
(
PWA_MANIFESTO_JSON
);
final
JSONObject
admin
=
userQueryService
.
getAdmin
();
final
String
adminName
=
admin
.
optString
(
User
.
USER_NAME
);
PWA_MANIFESTO_JSON
=
StringUtils
.
replace
(
PWA_MANIFESTO_JSON
,
"${shortName}"
,
adminName
);
renderer
.
setJSONObject
(
jsonObject
);
}
/**
/**
* Gets blog information.
* Gets blog information.
* <ul>
* <ul>
...
@@ -111,12 +159,7 @@ public class BlogProcessor {
...
@@ -111,12 +159,7 @@ public class BlogProcessor {
jsonObject
.
put
(
"runtimeMode"
,
Latkes
.
getRuntimeMode
());
jsonObject
.
put
(
"runtimeMode"
,
Latkes
.
getRuntimeMode
());
jsonObject
.
put
(
"runtimeDatabase"
,
Latkes
.
getRuntimeDatabase
());
jsonObject
.
put
(
"runtimeDatabase"
,
Latkes
.
getRuntimeDatabase
());
jsonObject
.
put
(
"locale"
,
Latkes
.
getLocale
());
jsonObject
.
put
(
"locale"
,
Latkes
.
getLocale
());
String
userName
=
""
;
final
String
userName
=
userQueryService
.
getAdmin
().
optString
(
User
.
USER_NAME
);
try
{
userName
=
userQueryService
.
getAdmin
().
optString
(
User
.
USER_NAME
);
}
catch
(
final
Exception
e
)
{
// ignored
}
jsonObject
.
put
(
"userName"
,
userName
);
jsonObject
.
put
(
"userName"
,
userName
);
}
}
...
...
src/main/
webapp/manifest.json
→
src/main/
resources/manifest.json.tpl
View file @
ff58a432
{
{
"name"
:
"
Solo - 博客
"
,
"name": "
$
{
name
}
",
"short_name"
:
"
Solo
"
,
"short_name": "
$
{
shortName
}
",
"start_url": ".",
"start_url": ".",
"display": "standalone",
"display": "standalone",
"background_color": "#f1f2f7",
"background_color": "#f1f2f7",
"orientation": "portrait",
"orientation": "portrait",
"theme_color": "#1fb5ad",
"theme_color": "#1fb5ad",
"description"
:
"
一个用 Java 实现的博客系统,为你或你的团队创建个博客吧!
"
,
"description": "
$
{
description
}
",
"icons": [
"icons": [
{
{
"src": "images/logo/logo@48.png",
"src": "images/logo/logo@48.png",
...
...
src/main/webapp/WEB-INF/static-resources.xml
View file @
ff58a432
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
-->
-->
<!--
<!--
Description: Static resources definition.
Description: Static resources definition.
Version: 2.8.0.6
1, Mar 17
, 2019
Version: 2.8.0.6
2, Oct 2
, 2019
Author: Liang Ding
Author: Liang Ding
Author: Liyuan Li
Author: Liyuan Li
-->
-->
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
<include
path=
"/robots.txt"
/>
<include
path=
"/robots.txt"
/>
<include
path=
"/sw.js"
/>
<include
path=
"/sw.js"
/>
<include
path=
"/manifest.json"
/>
<include
path=
"/js/**.js"
/>
<include
path=
"/js/**.js"
/>
<include
path=
"/js/**/*.js"
/>
<include
path=
"/js/**/*.js"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment