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
a7725d0c
Unverified
Commit
a7725d0c
authored
Jan 09, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
#19 看板娘处理
parent
b657bbd3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
src/main/java/org/b3log/solo/processor/KanBanNiangProcessor.java
...n/java/org/b3log/solo/processor/KanBanNiangProcessor.java
+6
-6
src/main/java/org/b3log/solo/processor/StaticSiteProcessor.java
...in/java/org/b3log/solo/processor/StaticSiteProcessor.java
+12
-2
No files found.
src/main/java/org/b3log/solo/processor/KanBanNiangProcessor.java
View file @
a7725d0c
...
@@ -19,7 +19,6 @@ package org.b3log.solo.processor;
...
@@ -19,7 +19,6 @@ package org.b3log.solo.processor;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.math.RandomUtils
;
import
org.apache.commons.lang.math.RandomUtils
;
import
org.b3log.latke.http.HttpMethod
;
import
org.b3log.latke.http.RequestContext
;
import
org.b3log.latke.http.RequestContext
;
import
org.b3log.latke.http.annotation.RequestProcessing
;
import
org.b3log.latke.http.annotation.RequestProcessing
;
import
org.b3log.latke.http.annotation.RequestProcessor
;
import
org.b3log.latke.http.annotation.RequestProcessor
;
...
@@ -30,12 +29,13 @@ import org.json.JSONArray;
...
@@ -30,12 +29,13 @@ import org.json.JSONArray;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
/**
/**
* KanBanNiang processor. https://github.com/b3log/solo/issues/12472
* KanBanNiang processor. https://github.com/b3log/solo/issues/12472
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
2, Mar 4, 2019
* @version 1.0.0.
3, Jan 9, 2020
* @since 2.9.2
* @since 2.9.2
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -51,7 +51,7 @@ public class KanBanNiangProcessor {
...
@@ -51,7 +51,7 @@ public class KanBanNiangProcessor {
*
*
* @param context the specified request context
* @param context the specified request context
*/
*/
@RequestProcessing
(
value
=
"/plugins/kanbanniang/assets/model
"
,
method
=
HttpMethod
.
GET
)
@RequestProcessing
(
value
=
"/plugins/kanbanniang/assets/model
.json"
)
public
void
randomModel
(
final
RequestContext
context
)
{
public
void
randomModel
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
context
.
setRenderer
(
renderer
);
...
@@ -59,17 +59,17 @@ public class KanBanNiangProcessor {
...
@@ -59,17 +59,17 @@ public class KanBanNiangProcessor {
final
String
assets
=
"/plugins/kanbanniang/assets"
;
final
String
assets
=
"/plugins/kanbanniang/assets"
;
String
model
;
String
model
;
try
(
final
InputStream
inputStream
=
KanBanNiangProcessor
.
class
.
getResourceAsStream
(
assets
+
"/model-list.json"
))
{
try
(
final
InputStream
inputStream
=
KanBanNiangProcessor
.
class
.
getResourceAsStream
(
assets
+
"/model-list.json"
))
{
final
JSONArray
models
=
new
JSONArray
(
IOUtils
.
toString
(
inputStream
,
"UTF-8"
));
final
JSONArray
models
=
new
JSONArray
(
IOUtils
.
toString
(
inputStream
,
StandardCharsets
.
UTF_8
));
final
int
i
=
RandomUtils
.
nextInt
(
models
.
length
());
final
int
i
=
RandomUtils
.
nextInt
(
models
.
length
());
model
=
models
.
getString
(
i
);
model
=
models
.
getString
(
i
);
}
}
try
(
final
InputStream
modelResource
=
KanBanNiangProcessor
.
class
.
getResourceAsStream
(
assets
+
"/model/"
+
model
+
"/index.json"
))
{
try
(
final
InputStream
modelResource
=
KanBanNiangProcessor
.
class
.
getResourceAsStream
(
assets
+
"/model/"
+
model
+
"/index.json"
))
{
final
JSONObject
index
=
new
JSONObject
(
IOUtils
.
toString
(
modelResource
,
"UTF-8"
));
final
JSONObject
index
=
new
JSONObject
(
IOUtils
.
toString
(
modelResource
,
StandardCharsets
.
UTF_8
));
final
JSONArray
textures
=
index
.
optJSONArray
(
"textures"
);
final
JSONArray
textures
=
index
.
optJSONArray
(
"textures"
);
if
(
textures
.
isEmpty
())
{
if
(
textures
.
isEmpty
())
{
try
(
final
InputStream
texturesRes
=
KanBanNiangProcessor
.
class
.
getResourceAsStream
(
assets
+
"/model/"
+
model
+
"/textures.json"
))
{
try
(
final
InputStream
texturesRes
=
KanBanNiangProcessor
.
class
.
getResourceAsStream
(
assets
+
"/model/"
+
model
+
"/textures.json"
))
{
final
JSONArray
texturesArray
=
new
JSONArray
(
IOUtils
.
toString
(
texturesRes
,
"UTF-8"
));
final
JSONArray
texturesArray
=
new
JSONArray
(
IOUtils
.
toString
(
texturesRes
,
StandardCharsets
.
UTF_8
));
final
Object
element
=
texturesArray
.
opt
(
RandomUtils
.
nextInt
(
texturesArray
.
length
()));
final
Object
element
=
texturesArray
.
opt
(
RandomUtils
.
nextInt
(
texturesArray
.
length
()));
if
(
element
instanceof
JSONArray
)
{
if
(
element
instanceof
JSONArray
)
{
index
.
put
(
"textures"
,
element
);
index
.
put
(
"textures"
,
element
);
...
...
src/main/java/org/b3log/solo/processor/StaticSiteProcessor.java
View file @
a7725d0c
...
@@ -88,8 +88,8 @@ public class StaticSiteProcessor {
...
@@ -88,8 +88,8 @@ public class StaticSiteProcessor {
// 切换至静态站点生成模式
// 切换至静态站点生成模式
Latkes
.
setServerScheme
(
"https"
);
Latkes
.
setServerScheme
(
"https"
);
// TODO: 前端传入生成站点域名
// TODO: 前端传入生成站点域名
//
Latkes.setServerHost("88250.github.io");
Latkes
.
setServerHost
(
"88250.github.io"
);
Latkes
.
setServerHost
(
"dl88250.gitee.io"
);
//
Latkes.setServerHost("dl88250.gitee.io");
Latkes
.
setServerPort
(
""
);
Latkes
.
setServerPort
(
""
);
Solos
.
GEN_STATIC_SITE
=
true
;
Solos
.
GEN_STATIC_SITE
=
true
;
...
@@ -109,6 +109,7 @@ public class StaticSiteProcessor {
...
@@ -109,6 +109,7 @@ public class StaticSiteProcessor {
genSkins
();
genSkins
();
genJS
();
genJS
();
genImages
();
genImages
();
genPlugins
();
genFile
(
"sw.js"
);
genFile
(
"sw.js"
);
genFile
(
"robots.txt"
);
genFile
(
"robots.txt"
);
genFile
(
"CHANGE_LOGS.md"
);
genFile
(
"CHANGE_LOGS.md"
);
...
@@ -267,6 +268,15 @@ public class StaticSiteProcessor {
...
@@ -267,6 +268,15 @@ public class StaticSiteProcessor {
LOGGER
.
log
(
Level
.
INFO
,
"Generated images"
);
LOGGER
.
log
(
Level
.
INFO
,
"Generated images"
);
}
}
private
static
void
genPlugins
()
throws
Exception
{
FileUtils
.
deleteDirectory
(
new
File
(
staticSitePath
+
"/plugins"
));
FileUtils
.
forceMkdir
(
new
File
(
staticSitePath
+
"/plugins"
));
FileUtils
.
copyDirectory
(
new
File
(
StaticSiteProcessor
.
class
.
getResource
(
"/plugins"
).
toURI
()),
new
File
(
staticSitePath
+
"/plugins"
));
genURI
(
"/plugins/kanbanniang/assets/model.json"
);
LOGGER
.
log
(
Level
.
INFO
,
"Generated plugins"
);
}
private
static
void
genFile
(
final
String
file
)
throws
Exception
{
private
static
void
genFile
(
final
String
file
)
throws
Exception
{
FileUtils
.
forceMkdirParent
(
new
File
(
staticSitePath
+
"/"
+
file
));
FileUtils
.
forceMkdirParent
(
new
File
(
staticSitePath
+
"/"
+
file
));
final
String
staticSitePath
=
StaticSiteProcessor
.
class
.
getResource
(
"/"
+
STATIC_SITE
).
toURI
().
getPath
();
final
String
staticSitePath
=
StaticSiteProcessor
.
class
.
getResource
(
"/"
+
STATIC_SITE
).
toURI
().
getPath
();
...
...
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