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
3f6af5a6
Unverified
Commit
3f6af5a6
authored
Jan 09, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔥
Fix #34
parent
c63062d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
87 deletions
+0
-87
src/main/java/org/b3log/solo/processor/KanBanNiangProcessor.java
...n/java/org/b3log/solo/processor/KanBanNiangProcessor.java
+0
-87
No files found.
src/main/java/org/b3log/solo/processor/KanBanNiangProcessor.java
deleted
100644 → 0
View file @
c63062d7
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-present, b3log.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package
org
.
b3log
.
solo
.
processor
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.math.RandomUtils
;
import
org.b3log.latke.http.RequestContext
;
import
org.b3log.latke.http.annotation.RequestProcessing
;
import
org.b3log.latke.http.annotation.RequestProcessor
;
import
org.b3log.latke.http.renderer.JsonRenderer
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
/**
* KanBanNiang processor. https://github.com/b3log/solo/issues/12472
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.3, Jan 9, 2020
* @since 2.9.2
*/
@RequestProcessor
public
class
KanBanNiangProcessor
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
KanBanNiangProcessor
.
class
);
/**
* Returns a random model.
*
* @param context the specified request context
*/
@RequestProcessing
(
value
=
"/plugins/kanbanniang/assets/model.json"
)
public
void
randomModel
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
try
{
final
String
assets
=
"/plugins/kanbanniang/assets"
;
String
model
;
try
(
final
InputStream
inputStream
=
KanBanNiangProcessor
.
class
.
getResourceAsStream
(
assets
+
"/model-list.json"
))
{
final
JSONArray
models
=
new
JSONArray
(
IOUtils
.
toString
(
inputStream
,
StandardCharsets
.
UTF_8
));
final
int
i
=
RandomUtils
.
nextInt
(
models
.
length
());
model
=
models
.
getString
(
i
);
}
try
(
final
InputStream
modelResource
=
KanBanNiangProcessor
.
class
.
getResourceAsStream
(
assets
+
"/model/"
+
model
+
"/index.json"
))
{
final
JSONObject
index
=
new
JSONObject
(
IOUtils
.
toString
(
modelResource
,
StandardCharsets
.
UTF_8
));
final
JSONArray
textures
=
index
.
optJSONArray
(
"textures"
);
if
(
textures
.
isEmpty
())
{
try
(
final
InputStream
texturesRes
=
KanBanNiangProcessor
.
class
.
getResourceAsStream
(
assets
+
"/model/"
+
model
+
"/textures.json"
))
{
final
JSONArray
texturesArray
=
new
JSONArray
(
IOUtils
.
toString
(
texturesRes
,
StandardCharsets
.
UTF_8
));
final
Object
element
=
texturesArray
.
opt
(
RandomUtils
.
nextInt
(
texturesArray
.
length
()));
if
(
element
instanceof
JSONArray
)
{
index
.
put
(
"textures"
,
element
);
}
else
{
index
.
put
(
"textures"
,
new
JSONArray
().
put
(
element
));
}
}
}
renderer
.
setJSONObject
(
index
);
}
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Returns a random KanBanNiang model failed"
,
e
);
}
}
}
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