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
c8d3140e
Unverified
Commit
c8d3140e
authored
Mar 29, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
#12726
parent
715c42eb
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
50 additions
and
80 deletions
+50
-80
src/main/java/org/b3log/solo/SoloServletListener.java
src/main/java/org/b3log/solo/SoloServletListener.java
+14
-16
src/main/java/org/b3log/solo/model/Option.java
src/main/java/org/b3log/solo/model/Option.java
+8
-3
src/main/java/org/b3log/solo/model/Skin.java
src/main/java/org/b3log/solo/model/Skin.java
+1
-6
src/main/java/org/b3log/solo/processor/IndexProcessor.java
src/main/java/org/b3log/solo/processor/IndexProcessor.java
+3
-1
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+7
-12
src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
...in/java/org/b3log/solo/service/PreferenceMgmtService.java
+12
-20
src/main/java/org/b3log/solo/upgrade/V340_350.java
src/main/java/org/b3log/solo/upgrade/V340_350.java
+2
-0
src/main/java/org/b3log/solo/util/Skins.java
src/main/java/org/b3log/solo/util/Skins.java
+1
-5
src/main/java/org/b3log/solo/util/Solos.java
src/main/java/org/b3log/solo/util/Solos.java
+1
-14
src/main/resources/solo.properties
src/main/resources/solo.properties
+1
-3
No files found.
src/main/java/org/b3log/solo/SoloServletListener.java
View file @
c8d3140e
...
...
@@ -255,25 +255,23 @@ public final class SoloServletListener extends AbstractServletListener {
private
void
resolveSkinDir
(
final
HttpServletRequest
httpServletRequest
)
{
String
skin
=
Skins
.
getSkinDirNameFromCookie
(
httpServletRequest
);
if
(
StringUtils
.
isBlank
(
skin
))
{
try
{
final
InitService
initService
=
beanManager
.
getReference
(
InitService
.
class
);
if
(
initService
.
isInited
())
{
final
OptionQueryService
optionQueryService
=
beanManager
.
getReference
(
OptionQueryService
.
class
);
final
JSONObject
preference
=
optionQueryService
.
getPreference
();
if
(
null
!=
preference
)
{
skin
=
preference
.
getString
(
Skin
.
SKIN_DIR_NAME
);
}
final
OptionQueryService
optionQueryService
=
beanManager
.
getReference
(
OptionQueryService
.
class
);
final
JSONObject
preference
=
optionQueryService
.
getPreference
();
if
(
Solos
.
isMobile
(
httpServletRequest
))
{
if
(
null
!=
preference
)
{
skin
=
preference
.
optString
(
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
);
}
else
{
skin
=
Option
.
DefaultPreference
.
DEFAULT_MOBILE_SKIN_DIR_NAME
;
}
}
else
{
if
(
null
!=
preference
)
{
skin
=
preference
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
);
}
else
{
skin
=
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
;
}
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Resolves skin failed"
,
e
);
}
}
if
(
StringUtils
.
isBlank
(
skin
))
{
skin
=
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
;
}
if
(
Solos
.
isMobile
(
httpServletRequest
))
{
skin
=
Solos
.
MOBILE_SKIN
;
}
httpServletRequest
.
setAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
,
skin
);
}
...
...
src/main/java/org/b3log/solo/model/Option.java
View file @
c8d3140e
...
...
@@ -26,7 +26,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/hzchendou">hzchendou</a>
* @version 1.
5.0.6, Mar 20
, 2019
* @version 1.
6.0.0, Mar 29
, 2019
* @since 0.6.0
*/
public
final
class
Option
{
...
...
@@ -228,9 +228,9 @@ public final class Option {
public
static
final
String
ID_C_SKIN_DIR_NAME
=
"skinDirName"
;
/**
* Key of
skin
name.
* Key of
mobile skin dir
name.
*/
public
static
final
String
ID_C_
SKIN_NAME
=
"skin
Name"
;
public
static
final
String
ID_C_
MOBILE_SKIN_DIR_NAME
=
"mobileSkinDir
Name"
;
/**
* Key of footer content.
...
...
@@ -359,6 +359,11 @@ public final class Option {
*/
public
static
final
String
DEFAULT_SKIN_DIR_NAME
=
"Pinghsu"
;
/**
* Default mobile skin directory name.
*/
public
static
final
String
DEFAULT_MOBILE_SKIN_DIR_NAME
=
"Pinghsu"
;
/**
* Default language.
*/
...
...
src/main/java/org/b3log/solo/model/Skin.java
View file @
c8d3140e
...
...
@@ -21,7 +21,7 @@ package org.b3log.solo.model;
* This class defines all skin model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.0.1, Aug 22, 2010
* @version 1.
1.0.0, Mar 29, 2019
*/
public
final
class
Skin
{
...
...
@@ -35,11 +35,6 @@ public final class Skin {
*/
public
static
final
String
SKINS
=
"skins"
;
/**
* Key of skin name, current selected skin name.
*/
public
static
final
String
SKIN_NAME
=
"skinName"
;
/**
* Key of skin directory name.
*/
...
...
src/main/java/org/b3log/solo/processor/IndexProcessor.java
View file @
c8d3140e
...
...
@@ -117,7 +117,9 @@ public class IndexProcessor {
// 前台皮肤切换 https://github.com/b3log/solo/issues/12060
String
specifiedSkin
=
Skins
.
getSkinDirName
(
context
);
if
(
StringUtils
.
isBlank
(
specifiedSkin
))
{
specifiedSkin
=
preference
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
);
specifiedSkin
=
Solos
.
isMobile
(
request
)
?
preference
.
optString
(
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
)
:
preference
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
);
}
request
.
setAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
,
specifiedSkin
);
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
c8d3140e
...
...
@@ -55,7 +55,7 @@ import java.util.Set;
* Solo initialization service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.3
1, Mar 23
, 2019
* @version 1.5.2.3
2, Mar 29
, 2019
* @since 0.4.0
*/
@Service
...
...
@@ -660,28 +660,23 @@ public class InitService {
footerContentOpt
.
put
(
Option
.
OPTION_VALUE
,
DefaultPreference
.
DEFAULT_FOOTER_CONTENT
);
optionRepository
.
add
(
footerContentOpt
);
final
String
skinDirName
=
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
;
final
JSONObject
skinDirNameOpt
=
new
JSONObject
();
skinDirNameOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_SKIN_DIR_NAME
);
skinDirNameOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
skinDirNameOpt
.
put
(
Option
.
OPTION_VALUE
,
skinDirName
);
skinDirNameOpt
.
put
(
Option
.
OPTION_VALUE
,
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
);
optionRepository
.
add
(
skinDirNameOpt
);
final
String
skinName
=
Latkes
.
getSkinName
(
skinDirName
);
final
JSONObject
skinNameOpt
=
new
JSONObject
();
skinNameOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_SKIN_NAME
);
skinNameOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
skinNameOpt
.
put
(
Option
.
OPTION_VALUE
,
skinName
);
optionRepository
.
add
(
skinNameOpt
);
final
JSONObject
mobileSkinDirNameOpt
=
new
JSONObject
();
mobileSkinDirNameOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
);
mobileSkinDirNameOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
mobileSkinDirNameOpt
.
put
(
Option
.
OPTION_VALUE
,
DefaultPreference
.
DEFAULT_MOBILE_SKIN_DIR_NAME
);
optionRepository
.
add
(
mobileSkinDirNameOpt
);
final
Set
<
String
>
skinDirNames
=
Skins
.
getSkinDirNames
();
final
JSONArray
skinArray
=
new
JSONArray
();
for
(
final
String
dirName
:
skinDirNames
)
{
final
JSONObject
skin
=
new
JSONObject
();
skinArray
.
put
(
skin
);
final
String
name
=
Latkes
.
getSkinName
(
dirName
);
skin
.
put
(
Skin
.
SKIN_NAME
,
name
);
skin
.
put
(
Skin
.
SKIN_DIR_NAME
,
dirName
);
}
...
...
src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
View file @
c8d3140e
...
...
@@ -103,17 +103,11 @@ public class PreferenceMgmtService {
continue
;
}
skin
.
put
(
SKIN_NAME
,
name
);
skin
.
put
(
SKIN_DIR_NAME
,
dirName
);
skinArray
.
put
(
skin
);
}
final
String
currentSkinDirName
=
preference
.
optString
(
SKIN_DIR_NAME
);
final
String
skinName
=
preference
.
optString
(
SKIN_NAME
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Current skin[name={0}]"
,
skinName
);
if
(!
skinDirNames
.
contains
(
currentSkinDirName
))
{
LOGGER
.
log
(
Level
.
WARN
,
"Configured skin [dirName={0}] can not find, try to use "
+
"default skin [dirName="
+
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
+
"] instead."
,
currentSkinDirName
);
...
...
@@ -124,8 +118,6 @@ public class PreferenceMgmtService {
}
preference
.
put
(
SKIN_DIR_NAME
,
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
);
preference
.
put
(
SKIN_NAME
,
Latkes
.
getSkinName
(
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
));
updatePreference
(
preference
);
}
...
...
@@ -160,22 +152,13 @@ public class PreferenceMgmtService {
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
try
{
final
String
skinDirName
=
preference
.
getString
(
Skin
.
SKIN_DIR_NAME
);
final
String
skinName
=
Latkes
.
getSkinName
(
skinDirName
);
preference
.
put
(
Skin
.
SKIN_NAME
,
skinName
);
final
Set
<
String
>
skinDirNames
=
Skins
.
getSkinDirNames
();
final
JSONArray
skinArray
=
new
JSONArray
();
for
(
final
String
dirName
:
skinDirNames
)
{
final
JSONObject
skin
=
new
JSONObject
();
skinArray
.
put
(
skin
);
final
String
name
=
Latkes
.
getSkinName
(
dirName
);
skin
.
put
(
Skin
.
SKIN_NAME
,
name
);
skin
.
put
(
Skin
.
SKIN_DIR_NAME
,
dirName
);
}
preference
.
put
(
Skin
.
SKINS
,
skinArray
.
toString
());
preference
.
put
(
Option
.
ID_C_SIGNS
,
preference
.
get
(
Option
.
ID_C_SIGNS
).
toString
());
...
...
@@ -292,9 +275,18 @@ public class PreferenceMgmtService {
skinDirNameOpt
.
put
(
Option
.
OPTION_VALUE
,
preference
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
));
optionRepository
.
update
(
Option
.
ID_C_SKIN_DIR_NAME
,
skinDirNameOpt
);
final
JSONObject
skinNameOpt
=
optionRepository
.
get
(
Option
.
ID_C_SKIN_NAME
);
skinNameOpt
.
put
(
Option
.
OPTION_VALUE
,
preference
.
optString
(
Option
.
ID_C_SKIN_NAME
));
optionRepository
.
update
(
Option
.
ID_C_SKIN_NAME
,
skinNameOpt
);
JSONObject
mobileSkinDirNameOpt
=
optionRepository
.
get
(
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
);
// TODO: 在 v3.5.0 发布后可移除判空
if
(
null
==
mobileSkinDirNameOpt
)
{
mobileSkinDirNameOpt
=
new
JSONObject
();
mobileSkinDirNameOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
);
mobileSkinDirNameOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
mobileSkinDirNameOpt
.
put
(
Option
.
OPTION_VALUE
,
Option
.
DefaultPreference
.
DEFAULT_MOBILE_SKIN_DIR_NAME
);
optionRepository
.
add
(
mobileSkinDirNameOpt
);
}
else
{
mobileSkinDirNameOpt
.
put
(
Option
.
OPTION_VALUE
,
preference
.
optString
(
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
));
optionRepository
.
update
(
Option
.
ID_C_MOBILE_SKIN_DIR_NAME
,
mobileSkinDirNameOpt
);
}
final
JSONObject
skinsOpt
=
optionRepository
.
get
(
Option
.
ID_C_SKINS
);
skinsOpt
.
put
(
Option
.
OPTION_VALUE
,
preference
.
optString
(
Option
.
ID_C_SKINS
));
...
...
src/main/java/org/b3log/solo/upgrade/V340_350.java
View file @
c8d3140e
...
...
@@ -57,6 +57,8 @@ public final class V340_350 {
try
{
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
optionRepository
.
remove
(
"skinName"
);
JSONObject
hljsThemeOpt
=
optionRepository
.
get
(
Option
.
ID_C_HLJS_THEME
);
if
(
null
==
hljsThemeOpt
)
{
hljsThemeOpt
=
new
JSONObject
();
...
...
src/main/java/org/b3log/solo/util/Skins.java
View file @
c8d3140e
...
...
@@ -48,7 +48,7 @@ import java.util.*;
* Skin utilities.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.6.
5, Feb 26
, 2019
* @version 1.1.6.
6, Mar 29
, 2019
* @since 0.3.1
*/
public
final
class
Skins
{
...
...
@@ -218,10 +218,6 @@ public final class Skins {
* @return directory name, or {@code null} if not found
*/
public
static
String
getSkinDirName
(
final
RequestContext
context
)
{
if
(
Solos
.
isMobile
(
context
.
getRequest
()))
{
return
Solos
.
MOBILE_SKIN
;
}
// 1. Get skin from query
final
String
specifiedSkin
=
context
.
param
(
Skin
.
SKIN
);
if
(
StringUtils
.
isNotBlank
(
specifiedSkin
))
{
...
...
src/main/java/org/b3log/solo/util/Solos.java
View file @
c8d3140e
...
...
@@ -36,7 +36,6 @@ import org.b3log.latke.util.Strings;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.UserExt
;
import
org.b3log.solo.repository.UserRepository
;
import
org.json.JSONObject
;
...
...
@@ -54,7 +53,7 @@ import java.util.ResourceBundle;
* Solo utilities.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.8.0.
0, Mar 20
, 2019
* @version 1.8.0.
1, Mar 29
, 2019
* @since 2.8.0
*/
public
final
class
Solos
{
...
...
@@ -74,11 +73,6 @@ public final class Solos {
*/
public
static
final
String
GRAVATAR
;
/**
* Mobile skin.
*/
public
static
final
String
MOBILE_SKIN
;
/**
* Solo User-Agent.
*/
...
...
@@ -114,13 +108,6 @@ public final class Solos {
FAVICON_API
=
solo
.
getString
(
"faviconAPI"
);
GRAVATAR
=
solo
.
getString
(
"gravatar"
);
String
mobileSkin
=
Option
.
DefaultPreference
.
DEFAULT_SKIN_DIR_NAME
;
try
{
mobileSkin
=
solo
.
getString
(
"mobile.skin"
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Loads [mobile.skin] in solo.props failed ["
+
e
.
getMessage
()
+
"], using ["
+
mobileSkin
+
"] as the default mobile skin"
);
}
MOBILE_SKIN
=
mobileSkin
;
}
static
{
...
...
src/main/resources/solo.properties
View file @
c8d3140e
...
...
@@ -18,11 +18,9 @@
#
# Description: Solo configurations.
# Version: 2.
4.0.5, Feb 28
, 2019
# Version: 2.
5.0.0, Mar 29
, 2019
# Author: Liang Ding
#
mobile.skin
=
Pinghsu
gravatar
=
https://secure.gravatar.com/avatar/
faviconAPI
=
https://api.byi.pw/favicon?url=
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