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
da54d798
Commit
da54d798
authored
May 07, 2017
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐛
修复皮肤动态切换问题
parent
f71ba465
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
18 deletions
+36
-18
src/main/java/org/b3log/solo/SoloServletListener.java
src/main/java/org/b3log/solo/SoloServletListener.java
+1
-2
src/main/java/org/b3log/solo/processor/IndexProcessor.java
src/main/java/org/b3log/solo/processor/IndexProcessor.java
+19
-7
src/main/java/org/b3log/solo/service/UserMgmtService.java
src/main/java/org/b3log/solo/service/UserMgmtService.java
+4
-1
src/main/java/org/b3log/solo/util/Skins.java
src/main/java/org/b3log/solo/util/Skins.java
+12
-8
No files found.
src/main/java/org/b3log/solo/SoloServletListener.java
View file @
da54d798
...
@@ -61,7 +61,7 @@ import java.util.Set;
...
@@ -61,7 +61,7 @@ import java.util.Set;
* Solo Servlet listener.
* Solo Servlet listener.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.9.
2.20, Apr 10
, 2017
* @version 1.9.
3.20, May 7
, 2017
* @since 0.3.1
* @since 0.3.1
*/
*/
public
final
class
SoloServletListener
extends
AbstractServletListener
{
public
final
class
SoloServletListener
extends
AbstractServletListener
{
...
@@ -315,7 +315,6 @@ public final class SoloServletListener extends AbstractServletListener {
...
@@ -315,7 +315,6 @@ public final class SoloServletListener extends AbstractServletListener {
final
String
requestURI
=
httpServletRequest
.
getRequestURI
();
final
String
requestURI
=
httpServletRequest
.
getRequestURI
();
String
desiredView
=
Requests
.
mobileSwitchToggle
(
httpServletRequest
);
String
desiredView
=
Requests
.
mobileSwitchToggle
(
httpServletRequest
);
if
(
desiredView
==
null
&&
!
Requests
.
mobileRequest
(
httpServletRequest
)
||
desiredView
!=
null
&&
desiredView
.
equals
(
"normal"
))
{
if
(
desiredView
==
null
&&
!
Requests
.
mobileRequest
(
httpServletRequest
)
||
desiredView
!=
null
&&
desiredView
.
equals
(
"normal"
))
{
desiredView
=
preference
.
getString
(
Skin
.
SKIN_DIR_NAME
);
desiredView
=
preference
.
getString
(
Skin
.
SKIN_DIR_NAME
);
}
else
{
}
else
{
...
...
src/main/java/org/b3log/solo/processor/IndexProcessor.java
View file @
da54d798
...
@@ -52,13 +52,14 @@ import java.io.IOException;
...
@@ -52,13 +52,14 @@ import java.io.IOException;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
/**
/**
* Index processor.
* Index processor.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:385321165@qq.com">DASHU</a>
* @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 1.2.
2.6, Dec 27, 2015
* @version 1.2.
3.6, May 7, 2017
* @since 0.3.1
* @since 0.3.1
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -117,13 +118,22 @@ public class IndexProcessor {
...
@@ -117,13 +118,22 @@ public class IndexProcessor {
if
(
null
!=
specifiedSkin
)
{
if
(
null
!=
specifiedSkin
)
{
if
(
"default"
.
equals
(
specifiedSkin
))
{
if
(
"default"
.
equals
(
specifiedSkin
))
{
specifiedSkin
=
preference
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
);
specifiedSkin
=
preference
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
);
final
Cookie
cookie
=
new
Cookie
(
"skin"
,
null
);
cookie
.
setMaxAge
(
0
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
}
}
}
else
{
}
else
{
specifiedSkin
=
preference
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
);
specifiedSkin
=
preference
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
);
}
}
Templates
.
MAIN_CFG
.
setServletContextForTemplateLoading
(
SoloServletListener
.
getServletContext
(),
"/skins/"
+
specifiedSkin
);
final
Set
<
String
>
skinDirNames
=
Skins
.
getSkinDirNames
();
request
.
setAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
,
specifiedSkin
);
if
(
skinDirNames
.
contains
(
specifiedSkin
))
{
Templates
.
MAIN_CFG
.
setServletContextForTemplateLoading
(
SoloServletListener
.
getServletContext
(),
"/skins/"
+
specifiedSkin
);
request
.
setAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
,
specifiedSkin
);
}
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
...
@@ -146,9 +156,11 @@ public class IndexProcessor {
...
@@ -146,9 +156,11 @@ public class IndexProcessor {
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
// https://github.com/b3log/solo/issues/12060
// https://github.com/b3log/solo/issues/12060
final
Cookie
cookie
=
new
Cookie
(
Skin
.
SKIN
,
specifiedSkin
);
if
(!
preference
.
optString
(
Skin
.
SKIN_DIR_NAME
).
equals
(
specifiedSkin
)
&&
!
Requests
.
mobileRequest
(
request
))
{
cookie
.
setPath
(
"/"
);
final
Cookie
cookie
=
new
Cookie
(
Skin
.
SKIN
,
specifiedSkin
);
response
.
addCookie
(
cookie
);
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
}
}
catch
(
final
ServiceException
e
)
{
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
src/main/java/org/b3log/solo/service/UserMgmtService.java
View file @
da54d798
...
@@ -57,15 +57,18 @@ public class UserMgmtService {
...
@@ -57,15 +57,18 @@ public class UserMgmtService {
* Logger.
* Logger.
*/
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
UserMgmtService
.
class
);
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
UserMgmtService
.
class
);
/**
/**
* Length of hashed password.
* Length of hashed password.
*/
*/
private
static
final
int
HASHED_PASSWORD_LENGTH
=
32
;
private
static
final
int
HASHED_PASSWORD_LENGTH
=
32
;
/**
/**
* User repository.
* User repository.
*/
*/
@Inject
@Inject
private
UserRepository
userRepository
;
private
UserRepository
userRepository
;
/**
/**
* Language service.
* Language service.
*/
*/
...
@@ -120,7 +123,6 @@ public class UserMgmtService {
...
@@ -120,7 +123,6 @@ public class UserMgmtService {
LOGGER
.
log
(
Level
.
TRACE
,
"Parses cookie failed, clears the cookie [name=b3log-latke]"
);
LOGGER
.
log
(
Level
.
TRACE
,
"Parses cookie failed, clears the cookie [name=b3log-latke]"
);
final
Cookie
cookie
=
new
Cookie
(
"b3log-latke"
,
null
);
final
Cookie
cookie
=
new
Cookie
(
"b3log-latke"
,
null
);
cookie
.
setMaxAge
(
0
);
cookie
.
setMaxAge
(
0
);
cookie
.
setPath
(
"/"
);
cookie
.
setPath
(
"/"
);
...
@@ -230,6 +232,7 @@ public class UserMgmtService {
...
@@ -230,6 +232,7 @@ public class UserMgmtService {
}
}
userRepository
.
update
(
userId
,
oldUser
);
userRepository
.
update
(
userId
,
oldUser
);
transaction
.
commit
();
transaction
.
commit
();
}
catch
(
final
RepositoryException
e
)
{
}
catch
(
final
RepositoryException
e
)
{
if
(
transaction
.
isActive
())
{
if
(
transaction
.
isActive
())
{
...
...
src/main/java/org/b3log/solo/util/Skins.java
View file @
da54d798
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
b3log
.
solo
.
util
;
package
org
.
b3log
.
solo
.
util
;
import
freemarker.template.TemplateExceptionHandler
;
import
freemarker.template.TemplateExceptionHandler
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.ioc.LatkeBeanManager
;
import
org.b3log.latke.ioc.LatkeBeanManager
;
import
org.b3log.latke.ioc.Lifecycle
;
import
org.b3log.latke.ioc.Lifecycle
;
...
@@ -25,6 +26,7 @@ import org.b3log.latke.service.LangPropsService;
...
@@ -25,6 +26,7 @@ import org.b3log.latke.service.LangPropsService;
import
org.b3log.latke.service.LangPropsServiceImpl
;
import
org.b3log.latke.service.LangPropsServiceImpl
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.service.ServiceException
;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Stopwatchs
;
import
org.b3log.latke.util.Stopwatchs
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.latke.util.freemarker.Templates
;
import
org.b3log.latke.util.freemarker.Templates
;
...
@@ -42,7 +44,7 @@ import java.util.*;
...
@@ -42,7 +44,7 @@ import java.util.*;
* Skin utilities.
* Skin utilities.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.
4.8, Nov 2, 2016
* @version 1.1.
5.8, May 7, 2017
* @since 0.3.1
* @since 0.3.1
*/
*/
public
final
class
Skins
{
public
final
class
Skins
{
...
@@ -67,9 +69,9 @@ public final class Skins {
...
@@ -67,9 +69,9 @@ public final class Skins {
* Fills the specified data model with the current skink's (WebRoot/skins/${skinName}/lang/lang_xx_XX.properties)
* Fills the specified data model with the current skink's (WebRoot/skins/${skinName}/lang/lang_xx_XX.properties)
* and core language (WebRoot/WEB-INF/classes/lang_xx_XX.properties) configurations.
* and core language (WebRoot/WEB-INF/classes/lang_xx_XX.properties) configurations.
*
*
* @param localeString the specified locale string
* @param localeString
the specified locale string
* @param currentSkinDirName the specified current skin directory name
* @param currentSkinDirName the specified current skin directory name
* @param dataModel the specified data model
* @param dataModel
the specified data model
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
public
static
void
fillLangs
(
final
String
localeString
,
final
String
currentSkinDirName
,
final
Map
<
String
,
Object
>
dataModel
)
public
static
void
fillLangs
(
final
String
localeString
,
final
String
currentSkinDirName
,
final
Map
<
String
,
Object
>
dataModel
)
...
@@ -157,8 +159,7 @@ public final class Skins {
...
@@ -157,8 +159,7 @@ public final class Skins {
final
Set
<
String
>
ret
=
new
HashSet
<
String
>();
final
Set
<
String
>
ret
=
new
HashSet
<
String
>();
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
final
Set
<
String
>
resourcePaths
=
servletContext
.
getResourcePaths
(
"/skins"
);
final
Set
<
String
>
resourcePaths
=
servletContext
.
getResourcePaths
(
"/skins"
);
for
(
final
String
path
:
resourcePaths
)
{
for
(
final
String
path
:
resourcePaths
)
{
final
String
dirName
=
path
.
substring
(
"/skins"
.
length
()
+
1
,
path
.
length
()
-
1
);
final
String
dirName
=
path
.
substring
(
"/skins"
.
length
()
+
1
,
path
.
length
()
-
1
);
...
@@ -174,7 +175,8 @@ public final class Skins {
...
@@ -174,7 +175,8 @@ public final class Skins {
}
}
/**
/**
* Gets skin directory name from the specified request.
* Gets skin directory name from the specified request. Refers to https://github.com/b3log/solo/issues/12060 for
* more details.
*
*
* @param request the specified request
* @param request the specified request
* @return directory name, or {@code "default"} if not found
* @return directory name, or {@code "default"} if not found
...
@@ -182,16 +184,18 @@ public final class Skins {
...
@@ -182,16 +184,18 @@ public final class Skins {
public
static
String
getSkinDirName
(
final
HttpServletRequest
request
)
{
public
static
String
getSkinDirName
(
final
HttpServletRequest
request
)
{
// https://github.com/b3log/solo/issues/12060
// https://github.com/b3log/solo/issues/12060
if
(
Requests
.
mobileRequest
(
request
))
{
return
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
);
// resolved in listener
}
// 1. Get skin from query
// 1. Get skin from query
final
String
specifiedSkin
=
request
.
getParameter
(
Skin
.
SKIN
);
final
String
specifiedSkin
=
request
.
getParameter
(
Skin
.
SKIN
);
if
(
"default"
.
equals
(
specifiedSkin
))
{
if
(
"default"
.
equals
(
specifiedSkin
))
{
return
"default"
;
return
"default"
;
}
}
if
(!
Strings
.
isEmptyOrNull
(
specifiedSkin
))
{
if
(!
Strings
.
isEmptyOrNull
(
specifiedSkin
))
{
final
Set
<
String
>
skinDirNames
=
Skins
.
getSkinDirNames
();
final
Set
<
String
>
skinDirNames
=
Skins
.
getSkinDirNames
();
if
(
skinDirNames
.
contains
(
specifiedSkin
))
{
if
(
skinDirNames
.
contains
(
specifiedSkin
))
{
return
specifiedSkin
;
return
specifiedSkin
;
}
else
{
}
else
{
...
...
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