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
cf494e8e
Unverified
Commit
cf494e8e
authored
May 23, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
优化静态缓存
parent
06645be1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
src/main/java/org/b3log/solo/processor/PermalinkHandler.java
src/main/java/org/b3log/solo/processor/PermalinkHandler.java
+11
-1
src/main/java/org/b3log/solo/util/Statics.java
src/main/java/org/b3log/solo/util/Statics.java
+16
-4
No files found.
src/main/java/org/b3log/solo/processor/PermalinkHandler.java
View file @
cf494e8e
...
...
@@ -29,13 +29,14 @@ import org.b3log.solo.service.InitService;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.PermalinkQueryService
;
import
org.b3log.solo.util.Solos
;
import
org.b3log.solo.util.Statics
;
import
org.json.JSONObject
;
/**
* Article permalink handler.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
4, Jan 12
, 2020
* @version 1.0.0.
5, May 23
, 2020
* @since 3.2.0
*/
public
class
PermalinkHandler
implements
Handler
{
...
...
@@ -71,6 +72,15 @@ public class PermalinkHandler implements Handler {
return
;
}
// 尝试走静态化缓存
final
String
html
=
Statics
.
get
(
context
);
if
(
StringUtils
.
isNotBlank
(
html
))
{
context
.
getResponse
().
setContentType
(
"text/html; charset=utf-8"
);
context
.
sendString
(
html
);
context
.
abort
();
return
;
}
final
ArticleRepository
articleRepository
=
beanManager
.
getReference
(
ArticleRepository
.
class
);
article
=
articleRepository
.
getByPermalink
(
permalink
);
if
(
null
==
article
)
{
...
...
src/main/java/org/b3log/solo/util/Statics.java
View file @
cf494e8e
...
...
@@ -11,16 +11,20 @@
*/
package
org
.
b3log
.
solo
.
util
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.apache.logging.log4j.Level
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.http.RequestContext
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.processor.SkinRenderer
;
import
org.json.JSONObject
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
...
...
@@ -39,7 +43,7 @@ import java.util.zip.GZIPOutputStream;
* Static utilities. 页面静态化 https://github.com/88250/solo/issues/107
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.
0, May 19
, 2020
* @version 1.0.1.
1, May 23
, 2020
* @since 4.1.0
*/
public
final
class
Statics
{
...
...
@@ -204,18 +208,26 @@ public final class Statics {
return
null
;
}
String
ret
;
String
requestURL
=
context
.
requestURI
();
String
ret
,
requestURL
;
// 判断文章自定义链接
final
JSONObject
article
=
(
JSONObject
)
context
.
attr
(
Article
.
ARTICLE
);
if
(
null
!=
article
)
{
requestURL
=
article
.
optString
(
Article
.
ARTICLE_PERMALINK
);
}
else
{
requestURL
=
context
.
requestURI
();
}
String
requestQueryStr
=
context
.
requestQueryStr
();
if
(
StringUtils
.
isNotBlank
(
requestQueryStr
))
{
requestURL
+=
"?"
+
requestQueryStr
;
}
ret
=
StringUtils
.
replace
(
requestURL
,
"/"
,
"_"
);
ret
=
StringUtils
.
replace
(
ret
,
"?"
,
"_"
);
if
(
Solos
.
isMobile
(
context
.
getRequest
()))
{
ret
=
"m"
+
ret
;
}
ret
=
DigestUtils
.
md5Hex
(
ret
);
return
ret
;
}
...
...
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