Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
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
Commits
315df631
Commit
315df631
authored
Nov 08, 2016
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#12159
parent
8cc8dd46
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
38 deletions
+42
-38
src/main/java/org/b3log/solo/processor/PageProcessor.java
src/main/java/org/b3log/solo/processor/PageProcessor.java
+6
-6
src/main/java/org/b3log/solo/processor/console/ArticleConsole.java
...java/org/b3log/solo/processor/console/ArticleConsole.java
+23
-24
src/main/java/org/b3log/solo/service/ArticleQueryService.java
...main/java/org/b3log/solo/service/ArticleQueryService.java
+13
-8
No files found.
src/main/java/org/b3log/solo/processor/PageProcessor.java
View file @
315df631
...
...
@@ -15,7 +15,6 @@
*/
package
org
.
b3log
.
solo
.
processor
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -41,16 +40,16 @@ import org.b3log.solo.processor.util.Filler;
import
org.b3log.solo.service.CommentQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.StatisticMgmtService
;
import
org.b3log.solo.util.Emotions
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.Skins
;
import
org.json.JSONObject
;
/**
* Page processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
5, Nov 20, 2015
* @version 1.1.0.
6, Nov 8, 2016
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -139,9 +138,10 @@ public class PageProcessor {
if
(
"CodeMirror-Markdown"
.
equals
(
page
.
optString
(
Page
.
PAGE_EDITOR_TYPE
)))
{
Stopwatchs
.
start
(
"Markdown Page[id="
+
page
.
optString
(
Keys
.
OBJECT_ID
)
+
"]"
);
final
String
content
=
page
.
optString
(
Page
.
PAGE_CONTENT
);
page
.
put
(
Page
.
PAGE_CONTENT
,
Markdowns
.
toHTML
(
content
));
String
content
=
page
.
optString
(
Page
.
PAGE_CONTENT
);
content
=
Emotions
.
convert
(
content
);
content
=
Markdowns
.
toHTML
(
content
);
page
.
put
(
Page
.
PAGE_CONTENT
,
content
);
Stopwatchs
.
end
();
}
...
...
src/main/java/org/b3log/solo/processor/console/ArticleConsole.java
View file @
315df631
...
...
@@ -15,7 +15,6 @@
*/
package
org
.
b3log
.
solo
.
processor
.
console
;
import
javax.inject.Inject
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -38,12 +37,12 @@ import org.b3log.solo.model.Article;
import
org.b3log.solo.service.ArticleMgmtService
;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.UserQueryService
;
import
org.b3log.solo.util.Emotions
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.QueryResults
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
/**
* Article console request processing.
*
...
...
@@ -95,19 +94,19 @@ public class ArticleConsole {
* </pre>
* </p>
*
* @param request the specified http servlet request, for example,
* <pre>
* @param request the specified http servlet request, for example, <pre>
* {
* "markdownText": ""
* }
* </pre>
*
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
*/
@RequestProcessing
(
value
=
"/console/markdown/2html"
,
method
=
HTTPRequestMethod
.
POST
)
public
void
markdown2HTML
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
,
final
HTTPRequestContext
context
)
throws
Exception
{
throws
Exception
{
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
...
...
@@ -132,7 +131,8 @@ public class ArticleConsole {
}
try
{
final
String
html
=
Markdowns
.
toHTML
(
markdownText
);
String
html
=
Emotions
.
convert
(
markdownText
);
html
=
Markdowns
.
toHTML
(
html
);
result
.
put
(
"html"
,
html
);
}
catch
(
final
Exception
e
)
{
...
...
@@ -179,7 +179,7 @@ public class ArticleConsole {
*/
@RequestProcessing
(
value
=
"/console/article/*"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
getArticle
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
,
final
HTTPRequestContext
context
)
throws
Exception
{
throws
Exception
{
if
(!
userQueryService
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
...
...
@@ -207,13 +207,12 @@ public class ArticleConsole {
}
/**
* Gets articles(by crate date descending) by the specified request json
* object.
* Gets articles(by crate date descending) by the specified request json object.
*
* <p>
* The request URI contains the pagination arguments. For example, the
*
request URI is /console/articles/status/published/1/10/20, means th
e
*
current page is 1, the page size is 10, and the window size
is 20.
* The request URI contains the pagination arguments. For example, the
request URI is
*
/console/articles/status/published/1/10/20, means the current page is 1, the page size is 10, and the window siz
e
* is 20.
* </p>
*
* <p>
...
...
@@ -245,9 +244,9 @@ public class ArticleConsole {
* @throws Exception exception
*/
@RequestProcessing
(
value
=
"/console/articles/status/*/*/*/*"
/* Requests.PAGINATION_PATH_PATTERN */
,
method
=
HTTPRequestMethod
.
GET
)
method
=
HTTPRequestMethod
.
GET
)
public
void
getArticles
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
,
final
HTTPRequestContext
context
)
throws
Exception
{
throws
Exception
{
if
(!
userQueryService
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
...
...
@@ -315,7 +314,7 @@ public class ArticleConsole {
*/
@RequestProcessing
(
value
=
"/console/article/{articleId}"
,
method
=
HTTPRequestMethod
.
DELETE
)
public
void
removeArticle
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
,
final
String
articleId
)
throws
Exception
{
final
String
articleId
)
throws
Exception
{
if
(!
userQueryService
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
...
...
@@ -372,7 +371,7 @@ public class ArticleConsole {
*/
@RequestProcessing
(
value
=
"/console/article/unpublish/*"
,
method
=
HTTPRequestMethod
.
PUT
)
public
void
cancelPublishArticle
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
Exception
{
throws
Exception
{
if
(!
userQueryService
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
...
...
@@ -431,7 +430,7 @@ public class ArticleConsole {
*/
@RequestProcessing
(
value
=
"/console/article/canceltop/*"
,
method
=
HTTPRequestMethod
.
PUT
)
public
void
cancelTopArticle
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
Exception
{
throws
Exception
{
if
(!
userQueryService
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
...
...
@@ -490,7 +489,7 @@ public class ArticleConsole {
*/
@RequestProcessing
(
value
=
"/console/article/puttop/*"
,
method
=
HTTPRequestMethod
.
PUT
)
public
void
putTopArticle
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
Exception
{
throws
Exception
{
if
(!
userQueryService
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
...
...
@@ -543,8 +542,7 @@ public class ArticleConsole {
* </p>
*
* @param context the specified http request context
* @param request the specified http servlet request, for example,
* <pre>
* @param request the specified http servlet request, for example, <pre>
* {
* "article": {
* "oId": "",
...
...
@@ -561,12 +559,13 @@ public class ArticleConsole {
* }
* }
* </pre>
*
* @param response the specified http servlet response
* @throws Exception exception
*/
@RequestProcessing
(
value
=
"/console/article/"
,
method
=
HTTPRequestMethod
.
PUT
)
public
void
updateArticle
(
final
HTTPRequestContext
context
,
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
Exception
{
throws
Exception
{
if
(!
userQueryService
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
...
...
@@ -621,8 +620,7 @@ public class ArticleConsole {
* </pre>
* </p>
*
* @param request the specified http servlet request, for example,
* <pre>
* @param request the specified http servlet request, for example, <pre>
* {
* "article": {
* "articleTitle": "",
...
...
@@ -638,13 +636,14 @@ public class ArticleConsole {
* }
* }
* </pre>
*
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
*/
@RequestProcessing
(
value
=
"/console/article/"
,
method
=
HTTPRequestMethod
.
POST
)
public
void
addArticle
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
,
final
HTTPRequestContext
context
)
throws
Exception
{
throws
Exception
{
if
(!
userQueryService
.
isLoggedIn
(
request
,
response
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
...
...
src/main/java/org/b3log/solo/service/ArticleQueryService.java
View file @
315df631
...
...
@@ -51,6 +51,7 @@ import org.b3log.solo.repository.ArticleRepository;
import
org.b3log.solo.repository.TagArticleRepository
;
import
org.b3log.solo.repository.TagRepository
;
import
org.b3log.solo.repository.UserRepository
;
import
org.b3log.solo.util.Emotions
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.comparator.Comparators
;
import
org.json.JSONArray
;
...
...
@@ -964,9 +965,10 @@ public class ArticleQueryService {
}
else
if
(
"CodeMirror-Markdown"
.
equals
(
article
.
optString
(
ARTICLE_EDITOR_TYPE
)))
{
// Markdown to HTML for content and abstract
Stopwatchs
.
start
(
"Get Article Content [Markdown]"
);
final
String
content
=
article
.
optString
(
ARTICLE_CONTENT
);
article
.
put
(
ARTICLE_CONTENT
,
Markdowns
.
toHTML
(
content
));
String
content
=
article
.
optString
(
ARTICLE_CONTENT
);
content
=
Emotions
.
convert
(
content
);
content
=
Markdowns
.
toHTML
(
content
);
article
.
put
(
ARTICLE_CONTENT
,
content
);
Stopwatchs
.
end
();
}
...
...
@@ -1001,16 +1003,19 @@ public class ArticleQueryService {
Stopwatchs
.
start
(
"Markdown Article[id="
+
article
.
optString
(
Keys
.
OBJECT_ID
)
+
"]"
);
Stopwatchs
.
start
(
"Content"
);
final
String
content
=
article
.
optString
(
ARTICLE_CONTENT
);
article
.
put
(
ARTICLE_CONTENT
,
Markdowns
.
toHTML
(
content
));
String
content
=
article
.
optString
(
ARTICLE_CONTENT
);
content
=
Emotions
.
convert
(
content
);
content
=
Markdowns
.
toHTML
(
content
);
article
.
put
(
ARTICLE_CONTENT
,
content
);
Stopwatchs
.
end
();
final
String
abstractContent
=
article
.
optString
(
ARTICLE_ABSTRACT
);
String
abstractContent
=
article
.
optString
(
ARTICLE_ABSTRACT
);
if
(!
Strings
.
isEmptyOrNull
(
abstractContent
))
{
Stopwatchs
.
start
(
"Abstract"
);
article
.
put
(
ARTICLE_ABSTRACT
,
Markdowns
.
toHTML
(
abstractContent
));
abstractContent
=
Emotions
.
convert
(
abstractContent
);
abstractContent
=
Markdowns
.
toHTML
(
abstractContent
);
article
.
put
(
ARTICLE_ABSTRACT
,
abstractContent
);
Stopwatchs
.
end
();
}
...
...
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