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