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
4f3624a7
Unverified
Commit
4f3624a7
authored
Mar 29, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
#12724
parent
bc29399f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
120 deletions
+27
-120
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
...n/java/org/b3log/solo/processor/console/AdminConsole.java
+1
-1
src/main/java/org/b3log/solo/processor/console/SkinConsole.java
...in/java/org/b3log/solo/processor/console/SkinConsole.java
+22
-100
src/main/java/org/b3log/solo/service/SkinMgmtService.java
src/main/java/org/b3log/solo/service/SkinMgmtService.java
+4
-19
No files found.
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
View file @
4f3624a7
...
@@ -144,7 +144,7 @@ public class AdminConsole {
...
@@ -144,7 +144,7 @@ public class AdminConsole {
dataModel
.
put
(
Option
.
ID_C_ARTICLE_LIST_DISPLAY_COUNT
,
preference
.
getInt
(
Option
.
ID_C_ARTICLE_LIST_DISPLAY_COUNT
));
dataModel
.
put
(
Option
.
ID_C_ARTICLE_LIST_DISPLAY_COUNT
,
preference
.
getInt
(
Option
.
ID_C_ARTICLE_LIST_DISPLAY_COUNT
));
dataModel
.
put
(
Option
.
ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE
,
preference
.
getInt
(
Option
.
ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE
));
dataModel
.
put
(
Option
.
ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE
,
preference
.
getInt
(
Option
.
ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE
));
final
JSONObject
skin
=
optionQueryService
.
getSkin
();
final
JSONObject
skin
=
optionQueryService
.
getSkin
();
dataModel
.
put
(
Option
.
CATEGORY_C_SKIN
,
skin
.
optString
(
Option
.
OPTION_VALU
E
));
dataModel
.
put
(
Option
.
CATEGORY_C_SKIN
,
skin
.
optString
(
Option
.
ID_C_SKIN_DIR_NAM
E
));
Keys
.
fillRuntime
(
dataModel
);
Keys
.
fillRuntime
(
dataModel
);
dataModelService
.
fillMinified
(
dataModel
);
dataModelService
.
fillMinified
(
dataModel
);
// 使用 Marked 时代码高亮问题 https://github.com/b3log/solo/issues/12614
// 使用 Marked 时代码高亮问题 https://github.com/b3log/solo/issues/12614
...
...
src/main/java/org/b3log/solo/processor/console/SkinConsole.java
View file @
4f3624a7
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
package
org
.
b3log
.
solo
.
processor
.
console
;
package
org
.
b3log
.
solo
.
processor
.
console
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
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.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
...
@@ -30,10 +31,13 @@ import org.b3log.latke.servlet.renderer.JsonRenderer;
...
@@ -30,10 +31,13 @@ import org.b3log.latke.servlet.renderer.JsonRenderer;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.SkinMgmtService
;
import
org.b3log.solo.service.SkinMgmtService
;
import
org.b3log.solo.util.Skins
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Set
;
/**
/**
* Skin console request processing.
* Skin console request processing.
...
@@ -101,6 +105,22 @@ public class SkinConsole {
...
@@ -101,6 +105,22 @@ public class SkinConsole {
return
;
return
;
}
}
final
Set
<
String
>
skinDirNames
=
Skins
.
getSkinDirNames
();
final
JSONArray
skinArray
=
new
JSONArray
();
for
(
final
String
dirName
:
skinDirNames
)
{
final
JSONObject
s
=
new
JSONObject
();
final
String
name
=
Latkes
.
getSkinName
(
dirName
);
if
(
null
==
name
)
{
LOGGER
.
log
(
Level
.
WARN
,
"The directory [{0}] does not contain any skin, ignored it"
,
dirName
);
continue
;
}
s
.
put
(
Option
.
ID_C_SKIN_DIR_NAME
,
dirName
);
skinArray
.
put
(
s
);
}
skin
.
put
(
"skins"
,
skinArray
.
toString
());
final
JSONObject
ret
=
new
JSONObject
();
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
renderer
.
setJSONObject
(
ret
);
ret
.
put
(
Option
.
CATEGORY_C_SKIN
,
skin
);
ret
.
put
(
Option
.
CATEGORY_C_SKIN
,
skin
);
...
@@ -121,7 +141,8 @@ public class SkinConsole {
...
@@ -121,7 +141,8 @@ public class SkinConsole {
* <pre>
* <pre>
* {
* {
* "skin": {
* "skin": {
* "skinDirName": ""
* "skinDirName": "",
* "mobileSkinDirName": "",
* }
* }
* }
* }
* </pre>
* </pre>
...
@@ -138,9 +159,6 @@ public class SkinConsole {
...
@@ -138,9 +159,6 @@ public class SkinConsole {
final
JSONObject
skin
=
requestJSONObject
.
getJSONObject
(
Option
.
CATEGORY_C_SKIN
);
final
JSONObject
skin
=
requestJSONObject
.
getJSONObject
(
Option
.
CATEGORY_C_SKIN
);
final
JSONObject
ret
=
new
JSONObject
();
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
renderer
.
setJSONObject
(
ret
);
if
(
isInvalid
(
skin
,
ret
))
{
return
;
}
skinMgmtService
.
updateSkin
(
skin
);
skinMgmtService
.
updateSkin
(
skin
);
...
@@ -161,102 +179,6 @@ public class SkinConsole {
...
@@ -161,102 +179,6 @@ public class SkinConsole {
}
}
}
}
/**
* Checks whether the specified preference is invalid and sets the specified response object.
*
* @param preference the specified preference
* @param responseObject the specified response object
* @return {@code true} if the specified preference is invalid, returns {@code false} otherwise
*/
private
boolean
isInvalid
(
final
JSONObject
preference
,
final
JSONObject
responseObject
)
{
responseObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
final
StringBuilder
errMsgBuilder
=
new
StringBuilder
(
'['
+
langPropsService
.
get
(
"paramSettingsLabel"
));
errMsgBuilder
.
append
(
" - "
);
String
input
=
preference
.
optString
(
Option
.
ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"externalRelevantArticlesDisplayCntLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
input
=
preference
.
optString
(
Option
.
ID_C_RELEVANT_ARTICLES_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"relevantArticlesDisplayCntLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
input
=
preference
.
optString
(
Option
.
ID_C_RANDOM_ARTICLES_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"randomArticlesDisplayCntLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
input
=
preference
.
optString
(
Option
.
ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"indexMostCommentArticleDisplayCntLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
input
=
preference
.
optString
(
Option
.
ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"indexMostViewArticleDisplayCntLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
input
=
preference
.
optString
(
Option
.
ID_C_RECENT_COMMENT_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"indexRecentCommentDisplayCntLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
input
=
preference
.
optString
(
Option
.
ID_C_MOST_USED_TAG_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"indexTagDisplayCntLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
input
=
preference
.
optString
(
Option
.
ID_C_ARTICLE_LIST_DISPLAY_COUNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"pageSizeLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
input
=
preference
.
optString
(
Option
.
ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"windowSizeLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
input
=
preference
.
optString
(
Option
.
ID_C_FEED_OUTPUT_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"feedOutputCntLabel"
)).
append
(
"] "
)
.
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
responseObject
.
put
(
Keys
.
MSG
,
errMsgBuilder
.
toString
());
return
true
;
}
return
false
;
}
/**
/**
* Checks whether the specified input is a non-negative integer.
* Checks whether the specified input is a non-negative integer.
*
*
...
...
src/main/java/org/b3log/solo/service/SkinMgmtService.java
View file @
4f3624a7
...
@@ -76,28 +76,13 @@ public class SkinMgmtService {
...
@@ -76,28 +76,13 @@ public class SkinMgmtService {
*/
*/
public
void
loadSkins
(
final
JSONObject
skin
)
throws
Exception
{
public
void
loadSkins
(
final
JSONObject
skin
)
throws
Exception
{
final
Set
<
String
>
skinDirNames
=
Skins
.
getSkinDirNames
();
final
Set
<
String
>
skinDirNames
=
Skins
.
getSkinDirNames
();
LOGGER
.
log
(
Level
.
DEBUG
,
"Loaded skins [dirNames={0}]"
,
skinDirNames
);
final
JSONArray
skinArray
=
new
JSONArray
();
for
(
final
String
dirName
:
skinDirNames
)
{
final
JSONObject
s
=
new
JSONObject
();
final
String
name
=
Latkes
.
getSkinName
(
dirName
);
if
(
null
==
name
)
{
LOGGER
.
log
(
Level
.
WARN
,
"The directory [{0}] does not contain any skin, ignored it"
,
dirName
);
continue
;
}
s
.
put
(
Option
.
ID_C_SKIN_DIR_NAME
,
dirName
);
skinArray
.
put
(
s
);
}
final
String
currentSkinDirName
=
skin
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
);
final
String
currentSkinDirName
=
skin
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
);
if
(!
skinDirNames
.
contains
(
currentSkinDirName
))
{
if
(!
skinDirNames
.
contains
(
currentSkinDirName
))
{
LOGGER
.
log
(
Level
.
WARN
,
"
Configured skin [dirName={0}] can not find, try to use "
+
"
default skin [dirName="
LOGGER
.
log
(
Level
.
WARN
,
"
Not found skin [dirName={0}] configured, try to use
default skin [dirName="
+
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
+
"] instead
.
"
,
currentSkinDirName
);
+
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
+
"] instead"
,
currentSkinDirName
);
if
(!
skinDirNames
.
contains
(
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
))
{
if
(!
skinDirNames
.
contains
(
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
))
{
LOGGER
.
log
(
Level
.
ERROR
,
"
Can not fi
nd default skin [dirName="
+
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
LOGGER
.
log
(
Level
.
ERROR
,
"
Not fou
nd default skin [dirName="
+
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
+
"], please redeploy your Solo and make sure contains the default skin. If you are using git, try to
re-
pull with 'git pull --recurse-submodules'"
);
+
"], please redeploy your Solo and make sure contains the default skin. If you are using git, try to pull with 'git pull --recurse-submodules'"
);
System
.
exit
(-
1
);
System
.
exit
(-
1
);
}
}
...
...
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