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
c9e1e51e
Commit
c9e1e51e
authored
Nov 20, 2015
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#12042
重构代码引用的 key
parent
7c1b49c2
Changes
33
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
339 additions
and
556 deletions
+339
-556
src/main/java/org/b3log/solo/api/metaweblog/MetaWeblogAPI.java
...ain/java/org/b3log/solo/api/metaweblog/MetaWeblogAPI.java
+3
-3
src/main/java/org/b3log/solo/api/symphony/ArticleReceiver.java
...ain/java/org/b3log/solo/api/symphony/ArticleReceiver.java
+4
-4
src/main/java/org/b3log/solo/api/symphony/CommentReceiver.java
...ain/java/org/b3log/solo/api/symphony/CommentReceiver.java
+3
-8
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
...b3log/solo/event/comment/ArticleCommentReplyNotifier.java
+4
-4
src/main/java/org/b3log/solo/event/comment/PageCommentReplyNotifier.java
...rg/b3log/solo/event/comment/PageCommentReplyNotifier.java
+4
-4
src/main/java/org/b3log/solo/event/ping/AddArticleGoogleBlogSearchPinger.java
...log/solo/event/ping/AddArticleGoogleBlogSearchPinger.java
+3
-3
src/main/java/org/b3log/solo/event/ping/UpdateArticleGoogleBlogSearchPinger.java
.../solo/event/ping/UpdateArticleGoogleBlogSearchPinger.java
+3
-3
src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
+5
-5
src/main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
...main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
+5
-5
src/main/java/org/b3log/solo/event/symphony/CommentSender.java
...ain/java/org/b3log/solo/event/symphony/CommentSender.java
+4
-4
src/main/java/org/b3log/solo/model/Preference.java
src/main/java/org/b3log/solo/model/Preference.java
+0
-180
src/main/java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
...java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
+4
-5
src/main/java/org/b3log/solo/processor/ArticleProcessor.java
src/main/java/org/b3log/solo/processor/ArticleProcessor.java
+40
-48
src/main/java/org/b3log/solo/processor/BlogProcessor.java
src/main/java/org/b3log/solo/processor/BlogProcessor.java
+3
-3
src/main/java/org/b3log/solo/processor/FeedProcessor.java
src/main/java/org/b3log/solo/processor/FeedProcessor.java
+42
-44
src/main/java/org/b3log/solo/processor/IndexProcessor.java
src/main/java/org/b3log/solo/processor/IndexProcessor.java
+3
-3
src/main/java/org/b3log/solo/processor/LoginProcessor.java
src/main/java/org/b3log/solo/processor/LoginProcessor.java
+4
-5
src/main/java/org/b3log/solo/processor/PageProcessor.java
src/main/java/org/b3log/solo/processor/PageProcessor.java
+4
-4
src/main/java/org/b3log/solo/processor/RepairProcessor.java
src/main/java/org/b3log/solo/processor/RepairProcessor.java
+5
-5
src/main/java/org/b3log/solo/processor/TagProcessor.java
src/main/java/org/b3log/solo/processor/TagProcessor.java
+5
-5
src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
.../java/org/b3log/solo/processor/UserTemplateProcessor.java
+3
-3
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
...n/java/org/b3log/solo/processor/console/AdminConsole.java
+11
-12
src/main/java/org/b3log/solo/processor/console/PreferenceConsole.java
...a/org/b3log/solo/processor/console/PreferenceConsole.java
+14
-14
src/main/java/org/b3log/solo/processor/util/Filler.java
src/main/java/org/b3log/solo/processor/util/Filler.java
+42
-45
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
+10
-4
src/main/java/org/b3log/solo/service/ArticleQueryService.java
...main/java/org/b3log/solo/service/ArticleQueryService.java
+33
-47
src/main/java/org/b3log/solo/service/CommentMgmtService.java
src/main/java/org/b3log/solo/service/CommentMgmtService.java
+6
-6
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+1
-1
src/main/java/org/b3log/solo/service/PageMgmtService.java
src/main/java/org/b3log/solo/service/PageMgmtService.java
+4
-4
src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
...in/java/org/b3log/solo/service/PreferenceMgmtService.java
+9
-10
src/main/java/org/b3log/solo/service/UpgradeService.java
src/main/java/org/b3log/solo/service/UpgradeService.java
+33
-33
src/test/java/org/b3log/solo/service/PreferenceMgmtServiceTestCase.java
...org/b3log/solo/service/PreferenceMgmtServiceTestCase.java
+12
-18
src/test/java/org/b3log/solo/service/PreferenceQueryServiceTestCase.java
...rg/b3log/solo/service/PreferenceQueryServiceTestCase.java
+13
-14
No files found.
src/main/java/org/b3log/solo/api/metaweblog/MetaWeblogAPI.java
View file @
c9e1e51e
...
...
@@ -40,7 +40,7 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
import
org.b3log.latke.servlet.renderer.TextXMLRenderer
;
import
org.b3log.latke.util.MD5
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.service.ArticleMgmtService
;
...
...
@@ -71,7 +71,7 @@ import org.jsoup.Jsoup;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1
1, May 17, 2013
* @version 1.0.0.1
2, Nov 20, 2015
* @since 0.4.0
*/
@RequestProcessor
...
...
@@ -629,7 +629,7 @@ public class MetaWeblogAPI {
throws
JSONException
{
final
String
blogId
=
preference
.
getString
(
Keys
.
OBJECT_ID
);
final
String
blogTitle
=
StringEscapeUtils
.
escapeXml
(
preference
.
getString
(
Preference
.
BLOG_TITLE
));
final
String
blogTitle
=
StringEscapeUtils
.
escapeXml
(
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
));
final
StringBuilder
stringBuilder
=
new
StringBuilder
(
"<member><name>blogid</name><value>"
).
append
(
blogId
).
append
(
"</value></member>"
);
...
...
src/main/java/org/b3log/solo/api/symphony/ArticleReceiver.java
View file @
c9e1e51e
...
...
@@ -32,7 +32,7 @@ import org.b3log.latke.servlet.renderer.JSONRenderer;
import
org.b3log.latke.util.Requests
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.service.ArticleMgmtService
;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
...
...
@@ -46,7 +46,7 @@ import org.jsoup.Jsoup;
* Article receiver (from B3log Symphony).
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
5, Mar 18, 2013
* @version 1.0.0.
6, Nov 20, 2015
* @since 0.5.5
*/
@RequestProcessor
...
...
@@ -132,7 +132,7 @@ public class ArticleReceiver {
final
String
userB3Key
=
article
.
optString
(
"userB3Key"
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
if
(!
userB3Key
.
equals
(
preference
.
optString
(
Preference
.
KEY_OF_SOLO
)))
{
if
(!
userB3Key
.
equals
(
preference
.
optString
(
Option
.
ID_C_
KEY_OF_SOLO
)))
{
LOGGER
.
log
(
Level
.
WARN
,
"B3 key not match, ignored add article"
);
return
;
...
...
@@ -224,7 +224,7 @@ public class ArticleReceiver {
final
String
userB3Key
=
article
.
optString
(
"userB3Key"
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
if
(!
userB3Key
.
equals
(
preference
.
optString
(
Preference
.
KEY_OF_SOLO
)))
{
if
(!
userB3Key
.
equals
(
preference
.
optString
(
Option
.
ID_C_
KEY_OF_SOLO
)))
{
LOGGER
.
log
(
Level
.
WARN
,
"B3 key not match, ignored update article"
);
return
;
...
...
src/main/java/org/b3log/solo/api/symphony/CommentReceiver.java
View file @
c9e1e51e
...
...
@@ -42,7 +42,7 @@ import org.b3log.solo.SoloServletListener;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.repository.ArticleRepository
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.service.ArticleMgmtService
;
...
...
@@ -57,7 +57,7 @@ import org.json.JSONObject;
* Comment receiver (from B3log Symphony).
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
9, Nov 5
, 2015
* @version 1.1.0.
10, Nov 20
, 2015
* @since 0.5.5
*/
@RequestProcessor
...
...
@@ -98,11 +98,6 @@ public class CommentReceiver {
@Inject
private
ArticleRepository
articleRepository
;
/**
* Default user thumbnail.
*/
private
static
final
String
DEFAULT_USER_THUMBNAIL
=
"default-user-thumbnail.png"
;
/**
* URL fetch service.
*/
...
...
@@ -168,7 +163,7 @@ public class CommentReceiver {
final
JSONObject
requestJSONObject
=
Requests
.
parseRequestJSONObject
(
request
,
response
);
final
JSONObject
symphonyCmt
=
requestJSONObject
.
optJSONObject
(
Comment
.
COMMENT
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
String
keyOfSolo
=
preference
.
optString
(
Preference
.
KEY_OF_SOLO
);
final
String
keyOfSolo
=
preference
.
optString
(
Option
.
ID_C_
KEY_OF_SOLO
);
final
String
key
=
symphonyCmt
.
optString
(
"userB3Key"
);
if
(
Strings
.
isEmptyOrNull
(
keyOfSolo
)
||
!
keyOfSolo
.
equals
(
key
))
{
...
...
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
View file @
c9e1e51e
...
...
@@ -32,7 +32,7 @@ import org.b3log.solo.SoloServletListener;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.repository.impl.CommentRepositoryImpl
;
import
org.b3log.solo.service.PreferenceQueryService
;
...
...
@@ -42,7 +42,7 @@ import org.json.JSONObject;
* This listener is responsible for processing article comment reply.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.
6, Oct 1
, 2015
* @version 1.1.1.
7, Nov 20
, 2015
* @since 0.3.1
*/
public
final
class
ArticleCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
...
...
@@ -99,8 +99,8 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
throw
new
EventException
(
"Not found preference"
);
}
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
adminEmail
=
preference
.
getString
(
Preference
.
ADMIN_EMAIL
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
final
String
adminEmail
=
preference
.
getString
(
Option
.
ID_C_
ADMIN_EMAIL
);
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
SoloServletListener
.
ENTER_ESC
,
"<br/>"
);
final
String
commentSharpURL
=
comment
.
getString
(
Comment
.
COMMENT_SHARP_URL
);
...
...
src/main/java/org/b3log/solo/event/comment/PageCommentReplyNotifier.java
View file @
c9e1e51e
...
...
@@ -32,8 +32,8 @@ import org.b3log.latke.util.Strings;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.repository.impl.CommentRepositoryImpl
;
import
org.b3log.solo.service.PreferenceQueryService
;
...
...
@@ -44,7 +44,7 @@ import org.json.JSONObject;
* This listener is responsible for processing page comment reply.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.
2, May 17, 2013
* @version 1.0.1.
3, Nov 20, 2015
* @since 0.3.1
*/
public
final
class
PageCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
...
...
@@ -94,8 +94,8 @@ public final class PageCommentReplyNotifier extends AbstractEventListener<JSONOb
throw
new
EventException
(
"Not found preference"
);
}
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
adminEmail
=
preference
.
getString
(
Preference
.
ADMIN_EMAIL
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
final
String
adminEmail
=
preference
.
getString
(
Option
.
ID_C_
ADMIN_EMAIL
);
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
SoloServletListener
.
ENTER_ESC
,
"<br/>"
);
final
String
commentSharpURL
=
comment
.
getString
(
Comment
.
COMMENT_SHARP_URL
);
...
...
src/main/java/org/b3log/solo/event/ping/AddArticleGoogleBlogSearchPinger.java
View file @
c9e1e51e
...
...
@@ -31,7 +31,7 @@ import org.b3log.latke.urlfetch.URLFetchService;
import
org.b3log.latke.urlfetch.URLFetchServiceFactory
;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.json.JSONObject
;
...
...
@@ -48,7 +48,7 @@ import org.json.JSONObject;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
3, May 17, 2013
* @version 1.0.0.
4, Nov 20, 2015
* @see UpdateArticleGoogleBlogSearchPinger
* @since 0.3.1
*/
...
...
@@ -88,7 +88,7 @@ public final class AddArticleGoogleBlogSearchPinger extends AbstractEventListene
articleTitle
=
article
.
getString
(
Article
.
ARTICLE_TITLE
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
LOGGER
.
log
(
Level
.
INFO
,
...
...
src/main/java/org/b3log/solo/event/ping/UpdateArticleGoogleBlogSearchPinger.java
View file @
c9e1e51e
...
...
@@ -31,7 +31,7 @@ import org.b3log.latke.urlfetch.URLFetchService;
import
org.b3log.latke.urlfetch.URLFetchServiceFactory
;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.json.JSONObject
;
...
...
@@ -48,7 +48,7 @@ import org.json.JSONObject;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
3, May 17, 2013
* @version 1.0.0.
4, Nov 20, 2015
* @see AddArticleGoogleBlogSearchPinger
* @since 0.3.1
*/
...
...
@@ -88,7 +88,7 @@ public final class UpdateArticleGoogleBlogSearchPinger extends AbstractEventList
articleTitle
=
article
.
getString
(
Article
.
ARTICLE_TITLE
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
LOGGER
.
log
(
Level
.
INFO
,
...
...
src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java
View file @
c9e1e51e
...
...
@@ -36,7 +36,7 @@ import org.b3log.solo.SoloServletListener;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.json.JSONObject
;
...
...
@@ -49,7 +49,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author ArmstrongCN
* @version 1.0.2.
7, Jun 13, 2013
* @version 1.0.2.
8, Nov 20, 2015
* @since 0.3.1
*/
public
final
class
ArticleSender
extends
AbstractEventListener
<
JSONObject
>
{
...
...
@@ -134,10 +134,10 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
requestJSONObject
.
put
(
Article
.
ARTICLE
,
article
);
requestJSONObject
.
put
(
Common
.
BLOG_VERSION
,
SoloServletListener
.
VERSION
);
requestJSONObject
.
put
(
Common
.
BLOG
,
"B3log Solo"
);
requestJSONObject
.
put
(
Preference
.
BLOG_TITLE
,
preference
.
getString
(
Preference
.
BLOG_TITLE
));
requestJSONObject
.
put
(
Option
.
ID_C_BLOG_TITLE
,
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
));
requestJSONObject
.
put
(
"blogHost"
,
Latkes
.
getServePath
());
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Preference
.
KEY_OF_SOLO
));
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Preference
.
ADMIN_EMAIL
));
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Option
.
ID_C_
KEY_OF_SOLO
));
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Option
.
ID_C_
ADMIN_EMAIL
));
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
Latkes
.
getRuntimeEnv
().
name
());
httpRequest
.
setPayload
(
requestJSONObject
.
toString
().
getBytes
(
"UTF-8"
));
...
...
src/main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java
View file @
c9e1e51e
...
...
@@ -36,7 +36,7 @@ import org.b3log.solo.SoloServletListener;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.json.JSONObject
;
...
...
@@ -48,7 +48,7 @@ import org.json.JSONObject;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
1, May 17, 2013
* @version 1.0.0.
2, Nov 20, 2015
* @since 0.6.0
*/
public
final
class
ArticleUpdater
extends
AbstractEventListener
<
JSONObject
>
{
...
...
@@ -133,10 +133,10 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
requestJSONObject
.
put
(
Article
.
ARTICLE
,
article
);
requestJSONObject
.
put
(
Common
.
BLOG_VERSION
,
SoloServletListener
.
VERSION
);
requestJSONObject
.
put
(
Common
.
BLOG
,
"B3log Solo"
);
requestJSONObject
.
put
(
Preference
.
BLOG_TITLE
,
preference
.
getString
(
Preference
.
BLOG_TITLE
));
requestJSONObject
.
put
(
Option
.
ID_C_BLOG_TITLE
,
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
));
requestJSONObject
.
put
(
"blogHost"
,
Latkes
.
getServerHost
()
+
":"
+
Latkes
.
getServerPort
());
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Preference
.
KEY_OF_SOLO
));
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Preference
.
ADMIN_EMAIL
));
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Option
.
ID_C_
KEY_OF_SOLO
));
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Option
.
ID_C_
ADMIN_EMAIL
));
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
Latkes
.
getRuntimeEnv
().
name
());
httpRequest
.
setPayload
(
requestJSONObject
.
toString
().
getBytes
(
"UTF-8"
));
...
...
src/main/java/org/b3log/solo/event/symphony/CommentSender.java
View file @
c9e1e51e
...
...
@@ -35,7 +35,7 @@ import org.b3log.solo.SoloServletListener;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.event.rhythm.ArticleSender
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.json.JSONObject
;
...
...
@@ -44,7 +44,7 @@ import org.json.JSONObject;
* This listener is responsible for sending comment to B3log Symphony.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
3, Mar 5, 2013
* @version 1.0.0.
4, Nov 20, 2015
* @since 0.5.5
*/
public
final
class
CommentSender
extends
AbstractEventListener
<
JSONObject
>
{
...
...
@@ -115,8 +115,8 @@ public final class CommentSender extends AbstractEventListener<JSONObject> {
requestJSONObject
.
put
(
"clientRuntimeEnv"
,
Latkes
.
getRuntimeEnv
().
name
());
requestJSONObject
.
put
(
"clientName"
,
"B3log Solo"
);
requestJSONObject
.
put
(
"clientHost"
,
Latkes
.
getServerHost
()
+
":"
+
Latkes
.
getServerPort
());
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Preference
.
ADMIN_EMAIL
));
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Preference
.
KEY_OF_SOLO
));
requestJSONObject
.
put
(
"clientAdminEmail"
,
preference
.
optString
(
Option
.
ID_C_
ADMIN_EMAIL
));
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Option
.
ID_C_
KEY_OF_SOLO
));
httpRequest
.
setPayload
(
requestJSONObject
.
toString
().
getBytes
(
"UTF-8"
));
...
...
src/main/java/org/b3log/solo/model/Preference.java
View file @
c9e1e51e
...
...
@@ -35,186 +35,6 @@ public final class Preference {
*/
public
static
final
String
PREFERENCE
=
"preference"
;
/**
* Blog title.
*/
public
static
final
String
BLOG_TITLE
=
"blogTitle"
;
/**
* Blog subtitle.
*/
public
static
final
String
BLOG_SUBTITLE
=
"blogSubtitle"
;
/**
* Relevant articles display count.
*/
public
static
final
String
RELEVANT_ARTICLES_DISPLAY_CNT
=
"relevantArticlesDisplayCount"
;
/**
* Random articles display count.
*/
public
static
final
String
RANDOM_ARTICLES_DISPLAY_CNT
=
"randomArticlesDisplayCount"
;
/**
* External relevant articles display count.
*/
public
static
final
String
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
=
"externalRelevantArticlesDisplayCount"
;
/**
* Recent article display count.
*/
public
static
final
String
RECENT_ARTICLE_DISPLAY_CNT
=
"recentArticleDisplayCount"
;
/**
* Recent comment display count.
*/
public
static
final
String
RECENT_COMMENT_DISPLAY_CNT
=
"recentCommentDisplayCount"
;
/**
* Most used tag display count.
*/
public
static
final
String
MOST_USED_TAG_DISPLAY_CNT
=
"mostUsedTagDisplayCount"
;
/**
* Most comment article display count.
*/
public
static
final
String
MOST_COMMENT_ARTICLE_DISPLAY_CNT
=
"mostCommentArticleDisplayCount"
;
/**
* Most view article display count.
*/
public
static
final
String
MOST_VIEW_ARTICLE_DISPLAY_CNT
=
"mostViewArticleDisplayCount"
;
/**
* Article list display count.
*/
public
static
final
String
ARTICLE_LIST_DISPLAY_COUNT
=
"articleListDisplayCount"
;
/**
* Article list pagination window size.
*/
public
static
final
String
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
=
"articleListPaginationWindowSize"
;
/**
* Administrator's email.
*/
public
static
final
String
ADMIN_EMAIL
=
"adminEmail"
;
/**
* Locale string.
*/
public
static
final
String
LOCALE_STRING
=
"localeString"
;
/**
* Time zone id.
*/
public
static
final
String
TIME_ZONE_ID
=
"timeZoneId"
;
/**
* Notice board.
*/
public
static
final
String
NOTICE_BOARD
=
"noticeBoard"
;
/**
* HTML head.
*/
public
static
final
String
HTML_HEAD
=
"htmlHead"
;
/**
* Key of meta keywords.
*/
public
static
final
String
META_KEYWORDS
=
"metaKeywords"
;
/**
* Key of meta description.
*/
public
static
final
String
META_DESCRIPTION
=
"metaDescription"
;
/**
* Key of article update hint flag.
*/
public
static
final
String
ENABLE_ARTICLE_UPDATE_HINT
=
"enableArticleUpdateHint"
;
/**
* Key of signs.
*/
public
static
final
String
SIGNS
=
"signs"
;
/**
* Key of key of Solo.
*/
public
static
final
String
KEY_OF_SOLO
=
"keyOfSolo"
;
/**
* Key of allow visit draft via permalink.
*/
public
static
final
String
ALLOW_VISIT_DRAFT_VIA_PERMALINK
=
"allowVisitDraftViaPermalink"
;
/**
* Key of allow register.
*/
public
static
final
String
ALLOW_REGISTER
=
"allowRegister"
;
/**
* Key of version.
*/
public
static
final
String
VERSION
=
"version"
;
/**
* Key of article list display style.
*
* <p>
* Optional values:
* <ul>
* <li>"titleOnly"</li>
* <li>"titleAndContent"</li>
* <li>"titleAndAbstract"</li>
* </ul>
* </p>
*/
public
static
final
String
ARTICLE_LIST_STYLE
=
"articleListStyle"
;
/**
* Key of reply notification template.
*/
public
static
final
String
REPLY_NOTIFICATION_TEMPLATE
=
"replyNotificationTemplate"
;
/**
* Key of article/page comment-able.
*/
public
static
final
String
COMMENTABLE
=
"commentable"
;
/**
* Key of feed (Atom/RSS) output mode.
*
* <p>
* Optional values:
* <ul>
* <li>"abstract"</li>
* <li>"fullContent"</li>
* </ul>
* </p>
*/
public
static
final
String
FEED_OUTPUT_MODE
=
"feedOutputMode"
;
/**
* Key of feed (Atom/RSS) output entry count.
*/
public
static
final
String
FEED_OUTPUT_CNT
=
"feedOutputCnt"
;
/**
* Key of editor type.
*
* Optional values:
* <p>
* <ul>
* <li>"tinyMCE"</li>
* <li>"CodeMirror-Markdown"</li>
* </ul>
* </p>
*/
public
static
final
String
EDITOR_TYPE
=
"editorType"
;
/**
* Private default constructor.
*/
...
...
src/main/java/org/b3log/solo/plugin/broadcast/ChanceProcessor.java
View file @
c9e1e51e
...
...
@@ -39,7 +39,6 @@ import org.b3log.latke.util.Requests;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.service.OptionMgmtService
;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
...
...
@@ -52,7 +51,7 @@ import org.json.JSONObject;
* Broadcast chance processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
9, Jun 13, 2013
* @version 1.0.0.
10, Nov 20, 2015
* @since 0.6.0
*/
@RequestProcessor
...
...
@@ -285,11 +284,11 @@ public class ChanceProcessor {
final
JSONObject
broadcast
=
requestJSONObject
.
getJSONObject
(
"broadcast"
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
String
b3logKey
=
preference
.
getString
(
Preference
.
KEY_OF_SOLO
);
final
String
email
=
preference
.
getString
(
Preference
.
ADMIN_EMAIL
);
final
String
b3logKey
=
preference
.
getString
(
Option
.
ID_C_
KEY_OF_SOLO
);
final
String
email
=
preference
.
getString
(
Option
.
ID_C_
ADMIN_EMAIL
);
final
String
clientName
=
"B3log Solo"
;
final
String
clientVersion
=
SoloServletListener
.
VERSION
;
final
String
clientTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
clientTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
final
String
clientRuntimeEnv
=
Latkes
.
getRuntimeEnv
().
name
();
final
JSONObject
broadcastRequest
=
new
JSONObject
();
...
...
src/main/java/org/b3log/solo/processor/ArticleProcessor.java
View file @
c9e1e51e
...
...
@@ -68,7 +68,7 @@ import org.jsoup.Jsoup;
* Article processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.2.1
4, Jun 13
, 2015
* @version 1.4.2.1
5, Nov 20
, 2015
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -193,7 +193,7 @@ public class ArticleProcessor {
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
dataModel
.
put
(
Preference
.
BLOG_TITLE
,
preference
.
getString
(
Preference
.
BLOG_TITLE
));
dataModel
.
put
(
Option
.
ID_C_BLOG_TITLE
,
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
));
dataModel
.
put
(
Common
.
VERSION
,
SoloServletListener
.
VERSION
);
dataModel
.
put
(
Common
.
STATIC_RESOURCE_VERSION
,
Latkes
.
getStaticResourceVersion
());
dataModel
.
put
(
Common
.
YEAR
,
String
.
valueOf
(
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
)));
...
...
@@ -259,7 +259,7 @@ public class ArticleProcessor {
final
JSONObject
jsonObject
=
new
JSONObject
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
displayCnt
=
preference
.
getInt
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
);
final
int
displayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RANDOM_ARTICLES_DISPLAY_CNT
);
if
(
0
==
displayCnt
)
{
jsonObject
.
put
(
Common
.
RANDOM_ARTICLES
,
new
ArrayList
<
JSONObject
>());
...
...
@@ -300,7 +300,7 @@ public class ArticleProcessor {
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
displayCnt
=
preference
.
getInt
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
);
final
int
displayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RELEVANT_ARTICLES_DISPLAY_CNT
);
if
(
0
==
displayCnt
)
{
jsonObject
.
put
(
Common
.
RANDOM_ARTICLES
,
new
ArrayList
<
JSONObject
>());
...
...
@@ -395,8 +395,8 @@ public class ArticleProcessor {
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
StringBuilder
pathBuilder
=
new
StringBuilder
();
...
...
@@ -413,13 +413,11 @@ public class ArticleProcessor {
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
}
else
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
jsonObject
.
put
(
Keys
.
RESULTS
,
result
);
}
catch
(
final
Exception
e
)
{
...
...
@@ -462,7 +460,7 @@ public class ArticleProcessor {
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
JSONObject
tagQueryResult
=
tagQueryService
.
getTagByTitle
(
tagTitle
);
...
...
@@ -481,13 +479,11 @@ public class ArticleProcessor {
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
}
else
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
...
...
@@ -532,7 +528,7 @@ public class ArticleProcessor {
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
JSONObject
archiveQueryResult
=
archiveDateQueryService
.
getByArchiveDateString
(
archiveDateString
);
...
...
@@ -552,13 +548,11 @@ public class ArticleProcessor {
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
}
else
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
...
...
@@ -604,7 +598,7 @@ public class ArticleProcessor {
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
true
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
JSONObject
authorRet
=
userQueryService
.
getUser
(
authorId
);
...
...
@@ -694,8 +688,8 @@ public class ArticleProcessor {
return
;
}
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
JSONObject
result
=
userQueryService
.
getUser
(
authorId
);
...
...
@@ -720,7 +714,7 @@ public class ArticleProcessor {
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
if
(
preference
.
optBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
if
(
preference
.
optBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
))
{
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_UPDATE_DATE_COMPARATOR
);
}
else
{
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
...
...
@@ -737,7 +731,7 @@ public class ArticleProcessor {
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
ServiceException
e
)
{
...
...
@@ -795,7 +789,7 @@ public class ArticleProcessor {
final
String
archiveDateId
=
archiveDate
.
getString
(
Keys
.
OBJECT_ID
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
articleCount
=
archiveDate
.
getInt
(
ArchiveDate
.
ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT
);
final
int
pageCount
=
(
int
)
Math
.
ceil
((
double
)
articleCount
/
(
double
)
pageSize
);
...
...
@@ -815,19 +809,17 @@ public class ArticleProcessor {
if
(
hasMultipleUsers
)
{
filler
.
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
}
else
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
filler
.
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
sort
(
preference
,
articles
);
final
Map
<
String
,
Object
>
dataModel
=
renderer
.
getDataModel
();
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
prepareShowArchiveArticles
(
preference
,
dataModel
,
articles
,
currentPageNum
,
pageCount
,
archiveDateString
,
archiveDate
);
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
...
...
@@ -899,7 +891,7 @@ public class ArticleProcessor {
try
{
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
boolean
allowVisitDraftViaPermalink
=
preference
.
getBoolean
(
Preference
.
ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
final
boolean
allowVisitDraftViaPermalink
=
preference
.
getBoolean
(
Option
.
ID_C_
ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
if
(!
article
.
optBoolean
(
Article
.
ARTICLE_IS_PUBLISHED
)
&&
!
allowVisitDraftViaPermalink
)
{
response
.
sendError
(
HttpServletResponse
.
SC_NOT_FOUND
);
...
...
@@ -916,7 +908,7 @@ public class ArticleProcessor {
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
metaDescription
);
if
(
preference
.
getBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
if
(
preference
.
getBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
))
{
article
.
put
(
Common
.
HAS_UPDATED
,
articleQueryService
.
hasUpdated
(
article
));
}
else
{
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
...
...
@@ -945,7 +937,7 @@ public class ArticleProcessor {
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
filler
.
fillSide
(
request
,
dataModel
,
preference
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
if
(!
Requests
.
hasBeenServed
(
request
,
response
))
{
articleMgmtService
.
incViewCount
(
articleId
);
...
...
@@ -983,7 +975,7 @@ public class ArticleProcessor {
* @see Comparators#ARTICLE_CREATE_DATE_COMPARATOR
*/
private
void
sort
(
final
JSONObject
preference
,
final
List
<
JSONObject
>
articles
)
throws
JSONException
{
// if (preference.getBoolean(
Preference.
ENABLE_ARTICLE_UPDATE_HINT)) {
// if (preference.getBoolean(
Option.ID_C_
ENABLE_ARTICLE_UPDATE_HINT)) {
// Collections.sort(articles, Comparators.ARTICLE_UPDATE_DATE_COMPARATOR);
// } else {
Collections
.
sort
(
articles
,
Comparators
.
ARTICLE_CREATE_DATE_COMPARATOR
);
...
...
@@ -1143,7 +1135,7 @@ public class ArticleProcessor {
*/
private
List
<
JSONObject
>
getRandomArticles
(
final
JSONObject
preference
)
{
try
{
final
int
displayCnt
=
preference
.
getInt
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
);
final
int
displayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RANDOM_ARTICLES_DISPLAY_CNT
);
final
List
<
JSONObject
>
ret
=
articleQueryService
.
getArticlesRandomly
(
displayCnt
);
return
ret
;
...
...
@@ -1227,8 +1219,8 @@ public class ArticleProcessor {
final
int
pageCount
,
final
String
archiveDateString
,
final
JSONObject
archiveDate
)
throws
Exception
{
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
List
<
Integer
>
pageNums
=
Paginator
.
paginate
(
currentPageNum
,
pageSize
,
pageCount
,
windowSize
);
...
...
@@ -1256,7 +1248,7 @@ public class ArticleProcessor {
final
String
month
=
dateStrings
[
1
];
archiveDate
.
put
(
ArchiveDate
.
ARCHIVE_DATE_YEAR
,
year
);
final
String
language
=
Locales
.
getLanguage
(
preference
.
getString
(
Preference
.
LOCALE_STRING
));
final
String
language
=
Locales
.
getLanguage
(
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
));
String
ret
;
if
(
"en"
.
equals
(
language
))
{
...
...
@@ -1281,7 +1273,7 @@ public class ArticleProcessor {
*/
private
void
prepareShowArticle
(
final
JSONObject
preference
,
final
Map
<
String
,
Object
>
dataModel
,
final
JSONObject
article
)
throws
Exception
{
article
.
put
(
Common
.
COMMENTABLE
,
preference
.
getBoolean
(
Preference
.
COMMENTABLE
)
&&
article
.
getBoolean
(
Article
.
ARTICLE_COMMENTABLE
));
article
.
put
(
Common
.
COMMENTABLE
,
preference
.
getBoolean
(
Option
.
ID_C_
COMMENTABLE
)
&&
article
.
getBoolean
(
Article
.
ARTICLE_COMMENTABLE
));
article
.
put
(
Common
.
PERMALINK
,
article
.
getString
(
Article
.
ARTICLE_PERMALINK
));
dataModel
.
put
(
Article
.
ARTICLE
,
article
);
final
String
articleId
=
article
.
getString
(
Keys
.
OBJECT_ID
);
...
...
@@ -1330,9 +1322,9 @@ public class ArticleProcessor {
LOGGER
.
debug
(
"Got article's comments"
);
Stopwatchs
.
end
();
dataModel
.
put
(
Preference
.
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Preference
.
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
));
dataModel
.
put
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
));
dataModel
.
put
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
));
dataModel
.
put
(
Option
.
ID_C_
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Option
.
ID_C_
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
));
dataModel
.
put
(
Option
.
ID_C_RANDOM_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Option
.
ID_C_
RANDOM_ARTICLES_DISPLAY_CNT
));
dataModel
.
put
(
Option
.
ID_C_RELEVANT_ARTICLES_DISPLAY_CNT
,
preference
.
getInt
(
Option
.
ID_C_
RELEVANT_ARTICLES_DISPLAY_CNT
));
}
}
src/main/java/org/b3log/solo/processor/BlogProcessor.java
View file @
c9e1e51e
...
...
@@ -38,7 +38,7 @@ import org.b3log.latke.util.MD5;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.model.Statistic
;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
...
...
@@ -53,7 +53,7 @@ import org.json.JSONObject;
* Blog processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.
3, Mar 12
, 2015
* @version 1.2.0.
4, Nov 20
, 2015
* @since 0.4.6
*/
@RequestProcessor
...
...
@@ -183,7 +183,7 @@ public class BlogProcessor {
requestJSONObject
.
put
(
User
.
USER_NAME
,
admin
.
getString
(
User
.
USER_NAME
));
requestJSONObject
.
put
(
User
.
USER_EMAIL
,
admin
.
getString
(
User
.
USER_EMAIL
));
requestJSONObject
.
put
(
User
.
USER_PASSWORD
,
admin
.
getString
(
User
.
USER_PASSWORD
));
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Preference
.
KEY_OF_SOLO
));
requestJSONObject
.
put
(
"userB3Key"
,
preference
.
optString
(
Option
.
ID_C_
KEY_OF_SOLO
));
requestJSONObject
.
put
(
"clientHost"
,
Latkes
.
getServePath
());
httpRequest
.
setPayload
(
requestJSONObject
.
toString
().
getBytes
(
"UTF-8"
));
...
...
src/main/java/org/b3log/solo/processor/FeedProcessor.java
View file @
c9e1e51e
...
...
@@ -15,7 +15,6 @@
*/
package
org
.
b3log
.
solo
.
processor
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Date
;
...
...
@@ -46,7 +45,7 @@ import org.b3log.latke.util.Locales;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.model.feed.atom.Category
;
import
org.b3log.solo.model.feed.atom.Entry
;
...
...
@@ -62,12 +61,11 @@ import org.b3log.solo.service.UserQueryService;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
/**
* Feed (Atom/RSS) processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
4, May 17, 2013
* @version 1.1.0.
5, Nov 20, 2015
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -119,7 +117,7 @@ public class FeedProcessor {
*
* @param context the specified context
*/
@RequestProcessing
(
value
=
{
"/blog-articles-feed.do"
},
method
=
{
HTTPRequestMethod
.
GET
,
HTTPRequestMethod
.
HEAD
})
@RequestProcessing
(
value
=
{
"/blog-articles-feed.do"
},
method
=
{
HTTPRequestMethod
.
GET
,
HTTPRequestMethod
.
HEAD
})
public
void
blogArticlesAtom
(
final
HTTPRequestContext
context
)
{
final
AtomRenderer
renderer
=
new
AtomRenderer
();
...
...
@@ -130,9 +128,9 @@ public class FeedProcessor {
try
{
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogSubtitle
=
preference
.
getString
(
Preference
.
BLOG_SUBTITLE
);
final
int
outputCnt
=
preference
.
getInt
(
Preference
.
FEED_OUTPUT_CNT
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
final
String
blogSubtitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_SUBTITLE
);
final
int
outputCnt
=
preference
.
getInt
(
Option
.
ID_C_
FEED_OUTPUT_CNT
);
feed
.
setTitle
(
StringEscapeUtils
.
escapeXml
(
blogTitle
));
feed
.
setSubtitle
(
StringEscapeUtils
.
escapeXml
(
blogSubtitle
));
...
...
@@ -158,7 +156,7 @@ public class FeedProcessor {
authorName
=
articleQueryService
.
getAuthor
(
articles
.
getJSONObject
(
0
)).
getString
(
User
.
USER_NAME
);
}
final
boolean
isFullContent
=
"fullContent"
.
equals
(
preference
.
getString
(
Preference
.
FEED_OUTPUT_MODE
));
final
boolean
isFullContent
=
"fullContent"
.
equals
(
preference
.
getString
(
Option
.
ID_C_
FEED_OUTPUT_MODE
));
for
(
int
i
=
0
;
i
<
articles
.
length
();
i
++)
{
final
JSONObject
article
=
articles
.
getJSONObject
(
i
);
...
...
@@ -218,7 +216,7 @@ public class FeedProcessor {
* @param context the specified context
* @throws IOException io exception
*/
@RequestProcessing
(
value
=
{
"/tag-articles-feed.do"
},
method
=
{
HTTPRequestMethod
.
GET
,
HTTPRequestMethod
.
HEAD
})
@RequestProcessing
(
value
=
{
"/tag-articles-feed.do"
},
method
=
{
HTTPRequestMethod
.
GET
,
HTTPRequestMethod
.
HEAD
})
public
void
tagArticlesAtom
(
final
HTTPRequestContext
context
)
throws
IOException
{
final
AtomRenderer
renderer
=
new
AtomRenderer
();
...
...
@@ -256,9 +254,9 @@ public class FeedProcessor {
return
;
}
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogSubtitle
=
preference
.
getString
(
Preference
.
BLOG_SUBTITLE
)
+
", "
+
tagTitle
;
final
int
outputCnt
=
preference
.
getInt
(
Preference
.
FEED_OUTPUT_CNT
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
final
String
blogSubtitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_SUBTITLE
)
+
", "
+
tagTitle
;
final
int
outputCnt
=
preference
.
getInt
(
Option
.
ID_C_
FEED_OUTPUT_CNT
);
feed
.
setTitle
(
StringEscapeUtils
.
escapeXml
(
blogTitle
));
feed
.
setSubtitle
(
StringEscapeUtils
.
escapeXml
(
blogSubtitle
));
...
...
@@ -295,7 +293,7 @@ public class FeedProcessor {
authorName
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
)).
getString
(
User
.
USER_NAME
);
}
final
boolean
isFullContent
=
"fullContent"
.
equals
(
preference
.
getString
(
Preference
.
FEED_OUTPUT_MODE
));
final
boolean
isFullContent
=
"fullContent"
.
equals
(
preference
.
getString
(
Option
.
ID_C_
FEED_OUTPUT_MODE
));
for
(
int
i
=
0
;
i
<
articles
.
size
();
i
++)
{
final
JSONObject
article
=
articles
.
get
(
i
);
...
...
@@ -352,7 +350,7 @@ public class FeedProcessor {
*
* @param context the specified context
*/
@RequestProcessing
(
value
=
{
"/blog-articles-rss.do"
},
method
=
{
HTTPRequestMethod
.
GET
,
HTTPRequestMethod
.
HEAD
})
@RequestProcessing
(
value
=
{
"/blog-articles-rss.do"
},
method
=
{
HTTPRequestMethod
.
GET
,
HTTPRequestMethod
.
HEAD
})
public
void
blogArticlesRSS
(
final
HTTPRequestContext
context
)
{
final
HttpServletResponse
response
=
context
.
getResponse
();
final
RssRenderer
renderer
=
new
RssRenderer
();
...
...
@@ -369,16 +367,16 @@ public class FeedProcessor {
return
;
}
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogSubtitle
=
preference
.
getString
(
Preference
.
BLOG_SUBTITLE
);
final
int
outputCnt
=
preference
.
getInt
(
Preference
.
FEED_OUTPUT_CNT
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
final
String
blogSubtitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_SUBTITLE
);
final
int
outputCnt
=
preference
.
getInt
(
Option
.
ID_C_
FEED_OUTPUT_CNT
);
channel
.
setTitle
(
StringEscapeUtils
.
escapeXml
(
blogTitle
));
channel
.
setLastBuildDate
(
new
Date
());
channel
.
setLink
(
Latkes
.
getServePath
());
channel
.
setAtomLink
(
Latkes
.
getServePath
()
+
"/blog-articles-rss.do"
);
channel
.
setGenerator
(
"Solo, ver "
+
SoloServletListener
.
VERSION
);
final
String
localeString
=
preference
.
getString
(
Preference
.
LOCALE_STRING
);
final
String
localeString
=
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
);
final
String
country
=
Locales
.
getCountry
(
localeString
).
toLowerCase
();
final
String
language
=
Locales
.
getLanguage
(
localeString
).
toLowerCase
();
...
...
@@ -402,7 +400,7 @@ public class FeedProcessor {
authorName
=
articleQueryService
.
getAuthor
(
articles
.
getJSONObject
(
0
)).
getString
(
User
.
USER_NAME
);
}
final
boolean
isFullContent
=
"fullContent"
.
equals
(
preference
.
getString
(
Preference
.
FEED_OUTPUT_MODE
));
final
boolean
isFullContent
=
"fullContent"
.
equals
(
preference
.
getString
(
Option
.
ID_C_
FEED_OUTPUT_MODE
));
for
(
int
i
=
0
;
i
<
articles
.
length
();
i
++)
{
final
JSONObject
article
=
articles
.
getJSONObject
(
i
);
...
...
@@ -464,7 +462,7 @@ public class FeedProcessor {
* @param context the specified context
* @throws IOException io exception
*/
@RequestProcessing
(
value
=
{
"/tag-articles-rss.do"
},
method
=
{
HTTPRequestMethod
.
GET
,
HTTPRequestMethod
.
HEAD
})
@RequestProcessing
(
value
=
{
"/tag-articles-rss.do"
},
method
=
{
HTTPRequestMethod
.
GET
,
HTTPRequestMethod
.
HEAD
})
public
void
tagArticlesRSS
(
final
HTTPRequestContext
context
)
throws
IOException
{
final
HttpServletResponse
response
=
context
.
getResponse
();
final
HttpServletRequest
request
=
context
.
getRequest
();
...
...
@@ -502,16 +500,16 @@ public class FeedProcessor {
return
;
}
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogSubtitle
=
preference
.
getString
(
Preference
.
BLOG_SUBTITLE
)
+
", "
+
tagTitle
;
final
int
outputCnt
=
preference
.
getInt
(
Preference
.
FEED_OUTPUT_CNT
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
final
String
blogSubtitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_SUBTITLE
)
+
", "
+
tagTitle
;
final
int
outputCnt
=
preference
.
getInt
(
Option
.
ID_C_
FEED_OUTPUT_CNT
);
channel
.
setTitle
(
StringEscapeUtils
.
escapeXml
(
blogTitle
));
channel
.
setLastBuildDate
(
new
Date
());
channel
.
setLink
(
Latkes
.
getServePath
());
channel
.
setAtomLink
(
Latkes
.
getServePath
()
+
"/tag-articles-rss.do"
);
channel
.
setGenerator
(
"Solo, ver "
+
SoloServletListener
.
VERSION
);
final
String
localeString
=
preference
.
getString
(
Preference
.
LOCALE_STRING
);
final
String
localeString
=
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
);
final
String
country
=
Locales
.
getCountry
(
localeString
).
toLowerCase
();
final
String
language
=
Locales
.
getLanguage
(
localeString
).
toLowerCase
();
...
...
@@ -546,7 +544,7 @@ public class FeedProcessor {
authorName
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
)).
getString
(
User
.
USER_NAME
);
}
final
boolean
isFullContent
=
"fullContent"
.
equals
(
preference
.
getString
(
Preference
.
FEED_OUTPUT_MODE
));
final
boolean
isFullContent
=
"fullContent"
.
equals
(
preference
.
getString
(
Option
.
ID_C_
FEED_OUTPUT_MODE
));
for
(
int
i
=
0
;
i
<
articles
.
size
();
i
++)
{
final
JSONObject
article
=
articles
.
get
(
i
);
...
...
src/main/java/org/b3log/solo/processor/IndexProcessor.java
View file @
c9e1e51e
...
...
@@ -40,7 +40,7 @@ import org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.processor.renderer.ConsoleRenderer
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.PreferenceQueryService
;
...
...
@@ -53,7 +53,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 1.1.2.
5, Jun 13
, 2015
* @version 1.1.2.
6, Nov 20
, 2015
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -110,7 +110,7 @@ public class IndexProcessor {
final
int
currentPageNum
=
getCurrentPageNum
(
requestURI
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
filler
.
fillIndexArticles
(
request
,
dataModel
,
currentPageNum
,
preference
);
...
...
src/main/java/org/b3log/solo/processor/LoginProcessor.java
View file @
c9e1e51e
...
...
@@ -43,7 +43,6 @@ import org.b3log.latke.util.Strings;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.processor.renderer.ConsoleRenderer
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.repository.OptionRepository
;
...
...
@@ -62,13 +61,13 @@ import java.util.Map;
/**
* Login/logout processor.
*
<p/>
*
* <p>Initializes administrator</p>.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @author <a href="mailto:dongxu.wang@acm.org">Dongxu Wang</a>
* @version 1.1.1.
6, Oct 26, 2013
* @version 1.1.1.
7, Nov 20, 2015
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -401,7 +400,7 @@ public class LoginProcessor {
ServiceException
,
IOException
,
RepositoryException
{
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
String
token
=
new
Randoms
().
nextStringWithMD5
();
final
String
adminEmail
=
preference
.
getString
(
Preference
.
ADMIN_EMAIL
);
final
String
adminEmail
=
preference
.
getString
(
Option
.
ID_C_
ADMIN_EMAIL
);
final
String
mailSubject
=
langPropsService
.
get
(
"resetPwdMailSubject"
);
final
String
mailBody
=
langPropsService
.
get
(
"resetPwdMailBody"
)
+
" "
+
Latkes
.
getServePath
()
+
"/forgot?token="
+
token
+
"&login="
+
userEmail
;
...
...
@@ -458,7 +457,7 @@ public class LoginProcessor {
dataModel
.
put
(
Common
.
YEAR
,
String
.
valueOf
(
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
)));
dataModel
.
put
(
Common
.
VERSION
,
SoloServletListener
.
VERSION
);
dataModel
.
put
(
Common
.
STATIC_RESOURCE_VERSION
,
Latkes
.
getStaticResourceVersion
());
dataModel
.
put
(
Preference
.
BLOG_TITLE
,
preference
.
getString
(
Preference
.
BLOG_TITLE
));
dataModel
.
put
(
Option
.
ID_C_BLOG_TITLE
,
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
));
final
String
token
=
request
.
getParameter
(
"token"
);
final
String
email
=
request
.
getParameter
(
"login"
);
...
...
src/main/java/org/b3log/solo/processor/PageProcessor.java
View file @
c9e1e51e
...
...
@@ -35,8 +35,8 @@ import org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer;
import
org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer
;
import
org.b3log.latke.util.Stopwatchs
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.CommentQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
...
...
@@ -50,7 +50,7 @@ import org.json.JSONObject;
* Page processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
4, Nov 17, 2013
* @version 1.1.0.
5, Nov 20, 2015
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -116,7 +116,7 @@ public class PageProcessor {
return
;
}
Skins
.
fillLangs
(
preference
.
getString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
final
Map
<
String
,
String
>
langs
=
langPropsService
.
getAll
(
Latkes
.
getLocale
());
...
...
@@ -130,7 +130,7 @@ public class PageProcessor {
final
String
pageId
=
page
.
getString
(
Keys
.
OBJECT_ID
);
page
.
put
(
Common
.
COMMENTABLE
,
preference
.
getBoolean
(
Preference
.
COMMENTABLE
)
&&
page
.
getBoolean
(
Page
.
PAGE_COMMENTABLE
));
page
.
put
(
Common
.
COMMENTABLE
,
preference
.
getBoolean
(
Option
.
ID_C_
COMMENTABLE
)
&&
page
.
getBoolean
(
Page
.
PAGE_COMMENTABLE
));
page
.
put
(
Common
.
PERMALINK
,
page
.
getString
(
Page
.
PAGE_PERMALINK
));
dataModel
.
put
(
Page
.
PAGE
,
page
);
final
List
<
JSONObject
>
comments
=
commentQueryService
.
getComments
(
pageId
);
...
...
src/main/java/org/b3log/solo/processor/RepairProcessor.java
View file @
c9e1e51e
...
...
@@ -68,7 +68,7 @@ import org.json.JSONObject;
* See AuthFilter filter configurations in web.xml for authentication.</p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.1
0, Nov 8
, 2015
* @version 1.2.0.1
1, Nov 20
, 2015
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -247,19 +247,19 @@ public class RepairProcessor {
try
{
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
String
originalSigns
=
preference
.
getString
(
Preference
.
SIGNS
);
final
String
originalSigns
=
preference
.
getString
(
Option
.
ID_C_
SIGNS
);
preference
.
put
(
Preference
.
SIGNS
,
Preference
.
Default
.
DEFAULT_SIGNS
);
preference
.
put
(
Option
.
ID_C_
SIGNS
,
Preference
.
Default
.
DEFAULT_SIGNS
);
preferenceMgmtService
.
updatePreference
(
preference
);
// Sends the sample signs to developer
final
Message
msg
=
new
MailService
.
Message
();
msg
.
setFrom
(
preference
.
getString
(
Preference
.
ADMIN_EMAIL
));
msg
.
setFrom
(
preference
.
getString
(
Option
.
ID_C_
ADMIN_EMAIL
));
msg
.
addRecipient
(
"DL88250@gmail.com"
);
msg
.
setSubject
(
"Restore signs"
);
msg
.
setHtmlBody
(
originalSigns
+
"<p>Admin email: "
+
preference
.
getString
(
Preference
.
ADMIN_EMAIL
)
+
"</p>"
);
msg
.
setHtmlBody
(
originalSigns
+
"<p>Admin email: "
+
preference
.
getString
(
Option
.
ID_C_
ADMIN_EMAIL
)
+
"</p>"
);
MAIL_SVC
.
send
(
msg
);
renderer
.
setContent
(
"Restores signs succeeded."
);
...
...
src/main/java/org/b3log/solo/processor/TagProcessor.java
View file @
c9e1e51e
...
...
@@ -42,7 +42,7 @@ import org.b3log.latke.util.Requests;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.ArticleQueryService
;
...
...
@@ -59,7 +59,7 @@ import org.json.JSONObject;
* Tag processor.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.
3, Nov 17, 2013
* @version 1.1.1.
4, Nov 20, 2015
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -160,10 +160,10 @@ public class TagProcessor {
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
List
<
JSONObject
>
articles
=
articleQueryService
.
getArticlesByTag
(
tagId
,
currentPageNum
,
pageSize
);
...
...
src/main/java/org/b3log/solo/processor/UserTemplateProcessor.java
View file @
c9e1e51e
...
...
@@ -35,7 +35,7 @@ import org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer;
import
org.b3log.latke.servlet.renderer.freemarker.FreeMarkerRenderer
;
import
org.b3log.latke.util.Locales
;
import
org.b3log.latke.util.freemarker.Templates
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.processor.util.Filler
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.StatisticMgmtService
;
...
...
@@ -55,7 +55,7 @@ import org.json.JSONObject;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
4, Nov 17, 2013
* @version 1.0.0.
5, Nov 20, 2015
* @since 0.4.5
*/
@RequestProcessor
...
...
@@ -135,7 +135,7 @@ public class UserTemplateProcessor {
filler
.
fillBlogHeader
(
request
,
response
,
dataModel
,
preference
);
filler
.
fillUserTemplate
(
request
,
template
,
dataModel
,
preference
);
filler
.
fillBlogFooter
(
request
,
dataModel
,
preference
);
Skins
.
fillLangs
(
preference
.
optString
(
Preference
.
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_
LOCALE_STRING
),
(
String
)
request
.
getAttribute
(
Keys
.
TEMAPLTE_DIR_NAME
),
dataModel
);
statisticMgmtService
.
incBlogViewCount
(
request
,
response
);
}
catch
(
final
Exception
e
)
{
...
...
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
View file @
c9e1e51e
...
...
@@ -44,7 +44,6 @@ import org.b3log.latke.util.Strings;
import
org.b3log.solo.SoloServletListener
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.model.Skin
;
import
org.b3log.solo.model.UserExt
;
import
org.b3log.solo.processor.renderer.ConsoleRenderer
;
...
...
@@ -59,7 +58,7 @@ import org.json.JSONObject;
* Admin console render processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.1.
7, Sep 28
, 2015
* @version 1.2.1.
8, Nov 20
, 2015
* @since 0.4.1
*/
@RequestProcessor
...
...
@@ -169,16 +168,16 @@ public class AdminConsole {
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
dataModel
.
put
(
Preference
.
LOCALE_STRING
,
preference
.
getString
(
Preference
.
LOCALE_STRING
));
dataModel
.
put
(
Preference
.
BLOG_TITLE
,
preference
.
getString
(
Preference
.
BLOG_TITLE
));
dataModel
.
put
(
Preference
.
BLOG_SUBTITLE
,
preference
.
getString
(
Preference
.
BLOG_SUBTITLE
));
dataModel
.
put
(
Option
.
ID_C_LOCALE_STRING
,
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
));
dataModel
.
put
(
Option
.
ID_C_BLOG_TITLE
,
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
));
dataModel
.
put
(
Option
.
ID_C_BLOG_SUBTITLE
,
preference
.
getString
(
Option
.
ID_C_
BLOG_SUBTITLE
));
dataModel
.
put
(
Common
.
VERSION
,
SoloServletListener
.
VERSION
);
dataModel
.
put
(
Common
.
STATIC_RESOURCE_VERSION
,
Latkes
.
getStaticResourceVersion
());
dataModel
.
put
(
Common
.
YEAR
,
String
.
valueOf
(
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
)));
dataModel
.
put
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
,
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
));
dataModel
.
put
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
,
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
));
dataModel
.
put
(
Preference
.
LOCALE_STRING
,
preference
.
getString
(
Preference
.
LOCALE_STRING
));
dataModel
.
put
(
Preference
.
EDITOR_TYPE
,
preference
.
getString
(
Preference
.
EDITOR_TYPE
));
dataModel
.
put
(
Option
.
ID_C_ARTICLE_LIST_DISPLAY_COUNT
,
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
));
dataModel
.
put
(
Option
.
ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE
,
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
));
dataModel
.
put
(
Option
.
ID_C_LOCALE_STRING
,
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
));
dataModel
.
put
(
Option
.
ID_C_EDITOR_TYPE
,
preference
.
getString
(
Option
.
ID_C_
EDITOR_TYPE
));
dataModel
.
put
(
Skin
.
SKIN_DIR_NAME
,
preference
.
getString
(
Skin
.
SKIN_DIR_NAME
));
Keys
.
fillRuntime
(
dataModel
);
...
...
@@ -227,7 +226,7 @@ public class AdminConsole {
Keys
.
fillRuntime
(
dataModel
);
dataModel
.
put
(
Preference
.
LOCALE_STRING
,
locale
.
toString
());
dataModel
.
put
(
Option
.
ID_C_
LOCALE_STRING
,
locale
.
toString
());
fireFreeMarkerActionEvent
(
templateName
,
dataModel
);
}
...
...
@@ -253,7 +252,7 @@ public class AdminConsole {
final
Map
<
String
,
Object
>
dataModel
=
renderer
.
getDataModel
();
dataModel
.
putAll
(
langs
);
dataModel
.
put
(
Preference
.
LOCALE_STRING
,
locale
.
toString
());
dataModel
.
put
(
Option
.
ID_C_
LOCALE_STRING
,
locale
.
toString
());
JSONObject
preference
=
null
;
...
...
@@ -270,7 +269,7 @@ public class AdminConsole {
final
String
id
=
availableIDs
[
i
];
String
option
;
if
(
id
.
equals
(
preference
.
optString
(
Preference
.
TIME_ZONE_ID
)))
{
if
(
id
.
equals
(
preference
.
optString
(
Option
.
ID_C_
TIME_ZONE_ID
)))
{
option
=
"<option value=\""
+
id
+
"\" selected=\"true\">"
+
id
+
"</option>"
;
}
else
{
option
=
"<option value=\""
+
id
+
"\">"
+
id
+
"</option>"
;
...
...
src/main/java/org/b3log/solo/processor/console/PreferenceConsole.java
View file @
c9e1e51e
...
...
@@ -46,7 +46,7 @@ import org.json.JSONObject;
* Preference console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.
7
, Nov 20, 2015
* @version 1.2.0.
8
, Nov 20, 2015
* @since 0.4.0
*/
@RequestProcessor
...
...
@@ -140,7 +140,7 @@ public class PreferenceConsole {
renderer
.
setJSONObject
(
ret
);
ret
.
put
(
Preference
.
REPLY_NOTIFICATION_TEMPLATE
,
replyNotificationTemplate
);
ret
.
put
(
"replyNotificationTemplate"
,
replyNotificationTemplate
);
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
...
...
@@ -185,7 +185,7 @@ public class PreferenceConsole {
try
{
final
JSONObject
requestJSONObject
=
Requests
.
parseRequestJSONObject
(
request
,
response
);
final
JSONObject
replyNotificationTemplate
=
requestJSONObject
.
getJSONObject
(
Preference
.
REPLY_NOTIFICATION_TEMPLATE
);
final
JSONObject
replyNotificationTemplate
=
requestJSONObject
.
getJSONObject
(
"replyNotificationTemplate"
);
preferenceMgmtService
.
updateReplyNotificationTemplate
(
replyNotificationTemplate
);
...
...
@@ -244,7 +244,7 @@ public class PreferenceConsole {
final
JSONArray
signs
=
new
JSONArray
();
final
JSONArray
allSigns
=
// includes the empty sign(id=0)
new
JSONArray
(
preference
.
getString
(
Preference
.
SIGNS
));
new
JSONArray
(
preference
.
getString
(
Option
.
ID_C_
SIGNS
));
for
(
int
i
=
1
;
i
<
allSigns
.
length
();
i
++)
{
// excludes the empty sign
signs
.
put
(
allSigns
.
getJSONObject
(
i
));
...
...
@@ -596,7 +596,7 @@ public class PreferenceConsole {
errMsgBuilder
.
append
(
" - "
);
String
input
=
preference
.
optString
(
Preference
.
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
);
String
input
=
preference
.
optString
(
Option
.
ID_C_
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"externalRelevantArticlesDisplayCntLabel"
)).
append
(
"] "
).
append
(
...
...
@@ -605,7 +605,7 @@ public class PreferenceConsole {
return
true
;
}
input
=
preference
.
optString
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
);
input
=
preference
.
optString
(
Option
.
ID_C_
RELEVANT_ARTICLES_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"relevantArticlesDisplayCntLabel"
)).
append
(
"] "
).
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
...
...
@@ -613,7 +613,7 @@ public class PreferenceConsole {
return
true
;
}
input
=
preference
.
optString
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
);
input
=
preference
.
optString
(
Option
.
ID_C_
RANDOM_ARTICLES_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"randomArticlesDisplayCntLabel"
)).
append
(
"] "
).
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
...
...
@@ -621,7 +621,7 @@ public class PreferenceConsole {
return
true
;
}
input
=
preference
.
optString
(
Preference
.
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
input
=
preference
.
optString
(
Option
.
ID_C_
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"indexMostCommentArticleDisplayCntLabel"
)).
append
(
"] "
).
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
...
...
@@ -629,7 +629,7 @@ public class PreferenceConsole {
return
true
;
}
input
=
preference
.
optString
(
Preference
.
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
input
=
preference
.
optString
(
Option
.
ID_C_
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"indexMostViewArticleDisplayCntLabel"
)).
append
(
"] "
).
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
...
...
@@ -637,7 +637,7 @@ public class PreferenceConsole {
return
true
;
}
input
=
preference
.
optString
(
Preference
.
RECENT_COMMENT_DISPLAY_CNT
);
input
=
preference
.
optString
(
Option
.
ID_C_
RECENT_COMMENT_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"indexRecentCommentDisplayCntLabel"
)).
append
(
"] "
).
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
...
...
@@ -645,7 +645,7 @@ public class PreferenceConsole {
return
true
;
}
input
=
preference
.
optString
(
Preference
.
MOST_USED_TAG_DISPLAY_CNT
);
input
=
preference
.
optString
(
Option
.
ID_C_
MOST_USED_TAG_DISPLAY_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"indexTagDisplayCntLabel"
)).
append
(
"] "
).
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
...
...
@@ -653,7 +653,7 @@ public class PreferenceConsole {
return
true
;
}
input
=
preference
.
optString
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
input
=
preference
.
optString
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"pageSizeLabel"
)).
append
(
"] "
).
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
...
...
@@ -661,7 +661,7 @@ public class PreferenceConsole {
return
true
;
}
input
=
preference
.
optString
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
input
=
preference
.
optString
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"windowSizeLabel"
)).
append
(
"] "
).
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
...
...
@@ -669,7 +669,7 @@ public class PreferenceConsole {
return
true
;
}
input
=
preference
.
optString
(
Preference
.
FEED_OUTPUT_CNT
);
input
=
preference
.
optString
(
Option
.
ID_C_
FEED_OUTPUT_CNT
);
if
(!
isNonNegativeInteger
(
input
))
{
errMsgBuilder
.
append
(
langPropsService
.
get
(
"feedOutputCntLabel"
)).
append
(
"] "
).
append
(
langPropsService
.
get
(
"nonNegativeIntegerOnlyLabel"
));
...
...
src/main/java/org/b3log/solo/processor/util/Filler.java
View file @
c9e1e51e
...
...
@@ -71,7 +71,7 @@ import org.json.JSONObject;
* Filler utilities.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.11.1
1, Nov 7
, 2015
* @version 1.5.11.1
2, Nov 20
, 2015
* @since 0.3.1
*/
@Service
...
...
@@ -203,8 +203,8 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Index Articles"
);
try
{
final
int
pageSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
int
pageSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
windowSize
=
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
JSONObject
statistic
=
statisticQueryService
.
getStatistic
();
final
int
publishedArticleCnt
=
statistic
.
getInt
(
Statistic
.
STATISTIC_PUBLISHED_ARTICLE_COUNT
);
...
...
@@ -219,7 +219,7 @@ public class Filler {
if
(
null
==
template
)
{
LOGGER
.
debug
(
"The skin dose not contain [index.ftl] template"
);
}
else
{
// See https://github.com/b3log/solo/issues/179 for more details
}
else
// See https://github.com/b3log/solo/issues/179 for more details
if
(
Templates
.
hasExpression
(
template
,
"<#list articles1 as article>"
))
{
isArticles1
=
true
;
query
.
addSort
(
Article
.
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
);
...
...
@@ -227,13 +227,12 @@ public class Filler {
LOGGER
.
trace
(
"Query ${articles1} in index.ftl"
);
}
else
{
// <#list articles as article>
query
.
addSort
(
Article
.
ARTICLE_PUT_TOP
,
SortDirection
.
DESCENDING
);
if
(
preference
.
getBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
if
(
preference
.
getBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
))
{
query
.
addSort
(
Article
.
ARTICLE_UPDATE_DATE
,
SortDirection
.
DESCENDING
);
}
else
{
query
.
addSort
(
Article
.
ARTICLE_CREATE_DATE
,
SortDirection
.
DESCENDING
);
}
}
}
query
.
index
(
Article
.
ARTICLE_PERMALINK
);
...
...
@@ -254,13 +253,11 @@ public class Filler {
if
(
hasMultipleUsers
)
{
setArticlesExProperties
(
request
,
articles
,
preference
);
}
else
{
if
(!
articles
.
isEmpty
())
{
}
else
if
(!
articles
.
isEmpty
())
{
final
JSONObject
author
=
articleQueryService
.
getAuthor
(
articles
.
get
(
0
));
setArticlesExProperties
(
request
,
articles
,
author
,
preference
);
}
}
if
(!
isArticles1
)
{
dataModel
.
put
(
Article
.
ARTICLES
,
articles
);
...
...
@@ -347,7 +344,7 @@ public class Filler {
try
{
LOGGER
.
debug
(
"Filling most used tags...."
);
final
int
mostUsedTagDisplayCnt
=
preference
.
getInt
(
Preference
.
MOST_USED_TAG_DISPLAY_CNT
);
final
int
mostUsedTagDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
MOST_USED_TAG_DISPLAY_CNT
);
final
List
<
JSONObject
>
tags
=
tagRepository
.
getMostUsedTags
(
mostUsedTagDisplayCnt
);
...
...
@@ -406,7 +403,7 @@ public class Filler {
}
}
final
String
localeString
=
preference
.
getString
(
Preference
.
LOCALE_STRING
);
final
String
localeString
=
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
);
final
String
language
=
Locales
.
getLanguage
(
localeString
);
for
(
final
JSONObject
archiveDate
:
archiveDates2
)
{
...
...
@@ -449,7 +446,7 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Most View Articles"
);
try
{
LOGGER
.
debug
(
"Filling the most view count articles...."
);
final
int
mostCommentArticleDisplayCnt
=
preference
.
getInt
(
Preference
.
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
final
int
mostCommentArticleDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
final
List
<
JSONObject
>
mostViewCountArticles
=
articleRepository
.
getMostViewCountArticles
(
mostCommentArticleDisplayCnt
);
dataModel
.
put
(
Common
.
MOST_VIEW_COUNT_ARTICLES
,
mostViewCountArticles
);
...
...
@@ -474,7 +471,7 @@ public class Filler {
try
{
LOGGER
.
debug
(
"Filling most comment articles...."
);
final
int
mostCommentArticleDisplayCnt
=
preference
.
getInt
(
Preference
.
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
final
int
mostCommentArticleDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
final
List
<
JSONObject
>
mostCommentArticles
=
articleRepository
.
getMostCommentArticles
(
mostCommentArticleDisplayCnt
);
dataModel
.
put
(
Common
.
MOST_COMMENT_ARTICLES
,
mostCommentArticles
);
...
...
@@ -497,7 +494,7 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Recent Articles"
);
try
{
final
int
recentArticleDisplayCnt
=
preference
.
getInt
(
Preference
.
RECENT_ARTICLE_DISPLAY_CNT
);
final
int
recentArticleDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RECENT_ARTICLE_DISPLAY_CNT
);
final
List
<
JSONObject
>
recentArticles
=
articleRepository
.
getRecentArticles
(
recentArticleDisplayCnt
);
...
...
@@ -525,7 +522,7 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Recent Comments"
);
try
{
LOGGER
.
debug
(
"Filling recent comments...."
);
final
int
recentCommentDisplayCnt
=
preference
.
getInt
(
Preference
.
RECENT_COMMENT_DISPLAY_CNT
);
final
int
recentCommentDisplayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RECENT_COMMENT_DISPLAY_CNT
);
final
List
<
JSONObject
>
recentComments
=
commentRepository
.
getRecentComments
(
recentCommentDisplayCnt
);
...
...
@@ -565,9 +562,9 @@ public class Filler {
Stopwatchs
.
start
(
"Fill Footer"
);
try
{
LOGGER
.
debug
(
"Filling footer...."
);
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
dataModel
.
put
(
Preference
.
BLOG_TITLE
,
blogTitle
);
dataModel
.
put
(
Option
.
ID_C_
BLOG_TITLE
,
blogTitle
);
dataModel
.
put
(
"blogHost"
,
Latkes
.
getServerHost
()
+
":"
+
Latkes
.
getServerPort
());
dataModel
.
put
(
Common
.
VERSION
,
SoloServletListener
.
VERSION
);
...
...
@@ -645,32 +642,32 @@ public class Filler {
dataModel
.
put
(
Common
.
TOP_BAR
,
topBarHTML
);
dataModel
.
put
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
,
preference
.
getInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
));
dataModel
.
put
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
,
preference
.
getInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
));
dataModel
.
put
(
Preference
.
LOCALE_STRING
,
preference
.
getString
(
Preference
.
LOCALE_STRING
));
dataModel
.
put
(
Preference
.
BLOG_TITLE
,
preference
.
getString
(
Preference
.
BLOG_TITLE
));
dataModel
.
put
(
Preference
.
BLOG_SUBTITLE
,
preference
.
getString
(
Preference
.
BLOG_SUBTITLE
));
dataModel
.
put
(
Preference
.
HTML_HEAD
,
preference
.
getString
(
Preference
.
HTML_HEAD
));
dataModel
.
put
(
Option
.
ID_C_ARTICLE_LIST_DISPLAY_COUNT
,
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
));
dataModel
.
put
(
Option
.
ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE
,
preference
.
getInt
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
));
dataModel
.
put
(
Option
.
ID_C_LOCALE_STRING
,
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
));
dataModel
.
put
(
Option
.
ID_C_BLOG_TITLE
,
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
));
dataModel
.
put
(
Option
.
ID_C_BLOG_SUBTITLE
,
preference
.
getString
(
Option
.
ID_C_
BLOG_SUBTITLE
));
dataModel
.
put
(
Option
.
ID_C_HTML_HEAD
,
preference
.
getString
(
Option
.
ID_C_
HTML_HEAD
));
String
metaKeywords
=
preference
.
getString
(
Preference
.
META_KEYWORDS
);
String
metaKeywords
=
preference
.
getString
(
Option
.
ID_C_
META_KEYWORDS
);
if
(
Strings
.
isEmptyOrNull
(
metaKeywords
))
{
metaKeywords
=
""
;
}
dataModel
.
put
(
Preference
.
META_KEYWORDS
,
metaKeywords
);
dataModel
.
put
(
Option
.
ID_C_
META_KEYWORDS
,
metaKeywords
);
String
metaDescription
=
preference
.
getString
(
Preference
.
META_DESCRIPTION
);
String
metaDescription
=
preference
.
getString
(
Option
.
ID_C_
META_DESCRIPTION
);
if
(
Strings
.
isEmptyOrNull
(
metaDescription
))
{
metaDescription
=
""
;
}
dataModel
.
put
(
Preference
.
META_DESCRIPTION
,
metaDescription
);
dataModel
.
put
(
Option
.
ID_C_
META_DESCRIPTION
,
metaDescription
);
dataModel
.
put
(
Common
.
YEAR
,
String
.
valueOf
(
Calendar
.
getInstance
().
get
(
Calendar
.
YEAR
)));
dataModel
.
put
(
Common
.
IS_LOGGED_IN
,
null
!=
userQueryService
.
getCurrentUser
(
request
));
dataModel
.
put
(
Common
.
FAVICON_API
,
SoloServletListener
.
FAVICON_API
);
final
String
noticeBoard
=
preference
.
getString
(
Preference
.
NOTICE_BOARD
);
final
String
noticeBoard
=
preference
.
getString
(
Option
.
ID_C_
NOTICE_BOARD
);
dataModel
.
put
(
Preference
.
NOTICE_BOARD
,
noticeBoard
);
dataModel
.
put
(
Option
.
ID_C_
NOTICE_BOARD
,
noticeBoard
);
final
Query
query
=
new
Query
().
setPageCount
(
1
);
final
JSONObject
result
=
userRepository
.
get
(
query
);
...
...
@@ -831,9 +828,9 @@ public class Filler {
fillSide
(
request
,
dataModel
,
preference
);
}
final
String
noticeBoard
=
preference
.
getString
(
Preference
.
NOTICE_BOARD
);
final
String
noticeBoard
=
preference
.
getString
(
Option
.
ID_C_
NOTICE_BOARD
);
dataModel
.
put
(
Preference
.
NOTICE_BOARD
,
noticeBoard
);
dataModel
.
put
(
Option
.
ID_C_
NOTICE_BOARD
,
noticeBoard
);
}
catch
(
final
JSONException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Fills user template failed"
,
e
);
throw
new
ServiceException
(
e
);
...
...
@@ -934,7 +931,7 @@ public class Filler {
article
.
put
(
Common
.
AUTHOR_THUMBNAIL_URL
,
thumbnailURL
);
}
if
(
preference
.
getBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
if
(
preference
.
getBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
))
{
article
.
put
(
Common
.
HAS_UPDATED
,
articleQueryService
.
hasUpdated
(
article
));
}
else
{
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
...
...
@@ -996,7 +993,7 @@ public class Filler {
article
.
put
(
Common
.
AUTHOR_THUMBNAIL_URL
,
thumbnailURL
);
}
if
(
preference
.
getBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
))
{
if
(
preference
.
getBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
))
{
article
.
put
(
Common
.
HAS_UPDATED
,
articleQueryService
.
hasUpdated
(
article
));
}
else
{
article
.
put
(
Common
.
HAS_UPDATED
,
false
);
...
...
@@ -1103,7 +1100,7 @@ public class Filler {
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
""
);
}
final
String
articleListStyle
=
preference
.
optString
(
Preference
.
ARTICLE_LIST_STYLE
);
final
String
articleListStyle
=
preference
.
optString
(
Option
.
ID_C_
ARTICLE_LIST_STYLE
);
if
(
"titleOnly"
.
equals
(
articleListStyle
))
{
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
""
);
...
...
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
c9e1e51e
...
...
@@ -39,8 +39,14 @@ import org.b3log.latke.util.CollectionUtils;
import
org.b3log.latke.util.Ids
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.model.*
;
import
org.b3log.solo.model.ArchiveDate
;
import
org.b3log.solo.model.Article
;
import
static
org
.
b3log
.
solo
.
model
.
Article
.*;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.model.UserExt
;
import
org.b3log.solo.repository.ArchiveDateArticleRepository
;
import
org.b3log.solo.repository.ArchiveDateRepository
;
import
org.b3log.solo.repository.ArticleRepository
;
...
...
@@ -58,7 +64,7 @@ import org.json.JSONObject;
* Article management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.2.
6, Apr 16
, 2015
* @version 1.2.2.
7, Nov 20
, 2015
* @since 0.3.5
*/
@Service
...
...
@@ -325,7 +331,7 @@ public class ArticleMgmtService {
// Set editor type
if
(!
article
.
has
(
Article
.
ARTICLE_EDITOR_TYPE
))
{
article
.
put
(
Article
.
ARTICLE_EDITOR_TYPE
,
preference
.
optString
(
Preference
.
EDITOR_TYPE
));
article
.
put
(
Article
.
ARTICLE_EDITOR_TYPE
,
preference
.
optString
(
Option
.
ID_C_
EDITOR_TYPE
));
}
final
boolean
publishNewArticle
=
!
oldArticle
.
getBoolean
(
ARTICLE_IS_PUBLISHED
)
&&
article
.
getBoolean
(
ARTICLE_IS_PUBLISHED
);
...
...
@@ -526,7 +532,7 @@ public class ArticleMgmtService {
userRepository
.
update
(
author
.
optString
(
Keys
.
OBJECT_ID
),
author
);
// Step 14: Set editor type
if
(!
article
.
has
(
Article
.
ARTICLE_EDITOR_TYPE
))
{
article
.
put
(
Article
.
ARTICLE_EDITOR_TYPE
,
preference
.
optString
(
Preference
.
EDITOR_TYPE
));
article
.
put
(
Article
.
ARTICLE_EDITOR_TYPE
,
preference
.
optString
(
Option
.
ID_C_
EDITOR_TYPE
));
}
// Step 15: Add article
articleRepository
.
add
(
article
);
...
...
src/main/java/org/b3log/solo/service/ArticleQueryService.java
View file @
c9e1e51e
...
...
@@ -15,7 +15,6 @@
*/
package
org
.
b3log
.
solo
.
service
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
...
...
@@ -44,7 +43,7 @@ import org.b3log.latke.util.Strings;
import
org.b3log.solo.model.Article
;
import
static
org
.
b3log
.
solo
.
model
.
Article
.*;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.
Preference
;
import
org.b3log.solo.model.
Option
;
import
org.b3log.solo.model.Sign
;
import
org.b3log.solo.model.Tag
;
import
org.b3log.solo.repository.ArchiveDateArticleRepository
;
...
...
@@ -58,13 +57,12 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONObject
;
/**
* Article query service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://blog.sweelia.com">ArmstrongCN</a>
* @version 1.1.2.
3, Jun 13
, 2015
* @version 1.1.2.
4, Nov 20
, 2015
* @since 0.3.5
*/
@Service
...
...
@@ -134,8 +132,7 @@ public class ArticleQueryService {
*
* @param articleId the given article id
* @param request the specified request
* @return {@code true} if the current user can access the article,
* {@code false} otherwise
* @return {@code true} if the current user can access the article, {@code false} otherwise
* @throws Exception exception
*/
public
boolean
canAccessArticle
(
final
String
articleId
,
final
HttpServletRequest
request
)
throws
Exception
{
...
...
@@ -234,14 +231,13 @@ public class ArticleQueryService {
* Gets the specified article's author.
*
* <p>
* The specified article has a property
* {@value Article#ARTICLE_AUTHOR_EMAIL}, this method will use this property
* to get a user from users.
* The specified article has a property {@value Article#ARTICLE_AUTHOR_EMAIL}, this method will use this property to
* get a user from users.
* </p>
*
* <p>
* If can't find the specified article's author (i.e. the author has been
*
removed by administrator), returns
administrator.
* If can't find the specified article's author (i.e. the author has been
removed by administrator), returns
* administrator.
* </p>
*
* @param article the specified article
...
...
@@ -282,7 +278,7 @@ public class ArticleQueryService {
* @throws JSONException json exception
*/
public
JSONObject
getSign
(
final
String
signId
,
final
JSONObject
preference
)
throws
JSONException
,
RepositoryException
{
final
JSONArray
signs
=
new
JSONArray
(
preference
.
getString
(
Preference
.
SIGNS
));
final
JSONArray
signs
=
new
JSONArray
(
preference
.
getString
(
Option
.
ID_C_
SIGNS
));
JSONObject
defaultSign
=
null
;
...
...
@@ -354,8 +350,7 @@ public class ArticleQueryService {
* Gets the recent articles with the specified fetch size.
*
* @param fetchSize the specified fetch size
* @return a list of json object, its size less or equal to the specified
* fetch size
* @return a list of json object, its size less or equal to the specified fetch size
* @throws ServiceException service exception
*/
public
List
<
JSONObject
>
getRecentArticles
(
final
int
fetchSize
)
throws
ServiceException
{
...
...
@@ -376,8 +371,7 @@ public class ArticleQueryService {
* </p>
*
* @param articleId the specified article id
* @return for example,
* <pre>
* @return for example, <pre>
* {
* "article": {
* "oId": "",
...
...
@@ -432,7 +426,7 @@ public class ArticleQueryService {
// Signs
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
article
.
put
(
Sign
.
SIGNS
,
new
JSONArray
(
preference
.
getString
(
Preference
.
SIGNS
)));
article
.
put
(
Sign
.
SIGNS
,
new
JSONArray
(
preference
.
getString
(
Option
.
ID_C_
SIGNS
)));
// Remove unused properties
article
.
remove
(
ARTICLE_AUTHOR_EMAIL
);
...
...
@@ -453,20 +447,18 @@ public class ArticleQueryService {
}
/**
* 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>
* If the property "articleIsPublished" of the specified request json object is {@code true}, the returned articles
all are published,
* {@code false} otherwise.
* If the property "articleIsPublished" of the specified request json object is {@code true}, the returned articles
*
all are published,
{@code false} otherwise.
* </p>
*
* <p>
* Specified the "excludes" for results properties exclusion.
* </p>
*
* @param requestJSONObject the specified request json object, for example,
* <pre>
* @param requestJSONObject the specified request json object, for example, <pre>
* {
* "paginationCurrentPageNum": 1,
* "paginationPageSize": 20,
...
...
@@ -476,8 +468,7 @@ public class ArticleQueryService {
* }, see {@link Pagination} for more details
* </pre>
*
* @return for example,
* <pre>
* @return for example, <pre>
* {
* "pagination": {
* "paginationPageCount": 100,
...
...
@@ -697,8 +688,7 @@ public class ArticleQueryService {
* </p>
*
* @param fetchSize the specified fetch size
* @return a list of json objects, its size less or equal to the specified
* fetch size
* @return a list of json objects, its size less or equal to the specified fetch size
* @throws ServiceException service exception
*/
public
List
<
JSONObject
>
getArticlesRandomly
(
final
int
fetchSize
)
throws
ServiceException
{
...
...
@@ -729,7 +719,7 @@ public class ArticleQueryService {
public
List
<
JSONObject
>
getRelevantArticles
(
final
JSONObject
article
,
final
JSONObject
preference
)
throws
ServiceException
{
try
{
final
int
displayCnt
=
preference
.
getInt
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
);
final
int
displayCnt
=
preference
.
getInt
(
Option
.
ID_C_
RELEVANT_ARTICLES_DISPLAY_CNT
);
final
String
[]
tagTitles
=
article
.
getString
(
Article
.
ARTICLE_TAGS_REF
).
split
(
","
);
final
int
maxTagCnt
=
displayCnt
>
tagTitles
.
length
?
tagTitles
.
length
:
displayCnt
;
final
String
articleId
=
article
.
getString
(
Keys
.
OBJECT_ID
);
...
...
@@ -819,15 +809,13 @@ public class ArticleQueryService {
* </p>
*
* @param articleId the specified article id
* @return the previous article,
* <pre>
* @return the previous article, <pre>
* {
* "articleTitle": "",
* "articlePermalink": "",
* "articleAbstract": ""
* }
* </pre>
* returns {@code null} if not found
* </pre> returns {@code null} if not found
*
* @throws ServiceException service exception
*/
...
...
@@ -848,15 +836,13 @@ public class ArticleQueryService {
* </p>
*
* @param articleId the specified article id
* @return the previous article,
* <pre>
* @return the previous article, <pre>
* {
* "articleTitle": "",
* "articlePermalink": "",
* "articleAbstract": ""
* }
* </pre>
* returns {@code null} if not found
* </pre> returns {@code null} if not found
*
* @throws ServiceException service exception
*/
...
...
src/main/java/org/b3log/solo/service/CommentMgmtService.java
View file @
c9e1e51e
...
...
@@ -54,7 +54,7 @@ import org.json.JSONObject;
* Comment management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
7, Nov 5
, 2015
* @version 1.1.0.
8, Nov 20
, 2015
* @since 0.3.5
*/
@Service
...
...
@@ -180,7 +180,7 @@ public class CommentMgmtService {
final
String
commentId
=
comment
.
getString
(
Keys
.
OBJECT_ID
);
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
).
replaceAll
(
SoloServletListener
.
ENTER_ESC
,
"<br/>"
);
final
String
adminEmail
=
preference
.
getString
(
Preference
.
ADMIN_EMAIL
);
final
String
adminEmail
=
preference
.
getString
(
Option
.
ID_C_
ADMIN_EMAIL
);
if
(
adminEmail
.
equalsIgnoreCase
(
commentEmail
))
{
LOGGER
.
log
(
Level
.
DEBUG
,
"Do not send comment notification mail to admin itself[{0}]"
,
adminEmail
);
...
...
@@ -204,7 +204,7 @@ public class CommentMgmtService {
}
}
final
String
blogTitle
=
preference
.
getString
(
Preference
.
BLOG_TITLE
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
);
boolean
isArticle
=
true
;
String
title
=
articleOrPage
.
optString
(
Article
.
ARTICLE_TITLE
);
...
...
@@ -281,7 +281,7 @@ public class CommentMgmtService {
ret
.
put
(
Keys
.
STATUS_CODE
,
false
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
if
(
null
==
preference
||
!
preference
.
optBoolean
(
Preference
.
COMMENTABLE
))
{
if
(
null
==
preference
||
!
preference
.
optBoolean
(
Option
.
ID_C_
COMMENTABLE
))
{
ret
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"notAllowCommentLabel"
));
return
ret
;
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
c9e1e51e
...
...
@@ -540,7 +540,7 @@ public class InitService {
final
JSONObject
replyNotificationTemplate
=
new
JSONObject
(
Preference
.
Default
.
DEFAULT_REPLY_NOTIFICATION_TEMPLATE
);
replyNotificationTemplate
.
put
(
Keys
.
OBJECT_ID
,
Preference
.
REPLY_NOTIFICATION_TEMPLATE
);
replyNotificationTemplate
.
put
(
Keys
.
OBJECT_ID
,
"replyNotificationTemplate"
);
final
JSONObject
subjectOpt
=
new
JSONObject
();
subjectOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_REPLY_NOTI_TPL_SUBJECT
);
...
...
src/main/java/org/b3log/solo/service/PageMgmtService.java
View file @
c9e1e51e
...
...
@@ -28,8 +28,8 @@ import org.b3log.latke.service.annotation.Service;
import
org.b3log.latke.util.Ids
;
import
org.b3log.latke.util.Strings
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.model.Preference
;
import
org.b3log.solo.repository.CommentRepository
;
import
org.b3log.solo.repository.PageRepository
;
import
org.b3log.solo.util.Comments
;
...
...
@@ -40,7 +40,7 @@ import org.json.JSONObject;
* Page management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
7, May 3
0, 2015
* @version 1.1.0.
8, Nov 2
0, 2015
* @since 0.4.0
*/
@Service
...
...
@@ -169,7 +169,7 @@ public class PageMgmtService {
// Set editor type
if
(!
newPage
.
has
(
Page
.
PAGE_EDITOR_TYPE
))
{
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
newPage
.
put
(
Page
.
PAGE_EDITOR_TYPE
,
preference
.
optString
(
Preference
.
EDITOR_TYPE
));
newPage
.
put
(
Page
.
PAGE_EDITOR_TYPE
,
preference
.
optString
(
Option
.
ID_C_
EDITOR_TYPE
));
}
pageRepository
.
update
(
pageId
,
newPage
);
...
...
@@ -278,7 +278,7 @@ public class PageMgmtService {
// Set editor type
if
(!
page
.
has
(
Page
.
PAGE_EDITOR_TYPE
))
{
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
page
.
put
(
Page
.
PAGE_EDITOR_TYPE
,
preference
.
optString
(
Preference
.
EDITOR_TYPE
));
page
.
put
(
Page
.
PAGE_EDITOR_TYPE
,
preference
.
optString
(
Option
.
ID_C_
EDITOR_TYPE
));
}
final
String
ret
=
pageRepository
.
add
(
page
);
...
...
src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
View file @
c9e1e51e
...
...
@@ -38,7 +38,6 @@ import org.b3log.solo.model.Preference;
import
org.b3log.solo.model.Skin
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
static
org
.
b3log
.
solo
.
model
.
Preference
.*;
import
static
org
.
b3log
.
solo
.
model
.
Skin
.
SKINS
;
import
static
org
.
b3log
.
solo
.
model
.
Skin
.
SKIN_DIR_NAME
;
import
static
org
.
b3log
.
solo
.
model
.
Skin
.
SKIN_NAME
;
...
...
@@ -50,7 +49,7 @@ import static org.b3log.solo.util.Skins.setDirectoryForTemplateLoading;
* Preference management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.1.
9
, Nov 20, 2015
* @version 1.3.1.
10
, Nov 20, 2015
* @since 0.4.0
*/
@Service
...
...
@@ -148,7 +147,7 @@ public class PreferenceMgmtService {
setDirectoryForTemplateLoading
(
preference
.
getString
(
SKIN_DIR_NAME
));
final
String
localeString
=
preference
.
getString
(
Preference
.
LOCALE_STRING
);
final
String
localeString
=
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
);
if
(
"zh_CN"
.
equals
(
localeString
))
{
TimeZones
.
setTimeZone
(
"Asia/Shanghai"
);
...
...
@@ -229,19 +228,19 @@ public class PreferenceMgmtService {
preference
.
put
(
Skin
.
SKINS
,
skinArray
.
toString
());
final
String
timeZoneId
=
preference
.
getString
(
TIME_ZONE_ID
);
final
String
timeZoneId
=
preference
.
getString
(
Option
.
ID_C_
TIME_ZONE_ID
);
TimeZones
.
setTimeZone
(
timeZoneId
);
preference
.
put
(
Preference
.
SIGNS
,
preference
.
get
(
Preference
.
SIGNS
).
toString
());
preference
.
put
(
Option
.
ID_C_SIGNS
,
preference
.
get
(
Option
.
ID_C_
SIGNS
).
toString
());
final
JSONObject
oldPreference
=
preferenceQueryService
.
getPreference
();
final
String
adminEmail
=
oldPreference
.
getString
(
ADMIN_EMAIL
);
preference
.
put
(
ADMIN_EMAIL
,
adminEmail
);
final
String
adminEmail
=
oldPreference
.
getString
(
Option
.
ID_C_
ADMIN_EMAIL
);
preference
.
put
(
Option
.
ID_C_
ADMIN_EMAIL
,
adminEmail
);
final
String
version
=
oldPreference
.
optString
(
VERSION
);
preference
.
put
(
VERSION
,
version
);
final
String
version
=
oldPreference
.
optString
(
Option
.
ID_C_
VERSION
);
preference
.
put
(
Option
.
ID_C_
VERSION
,
version
);
final
String
localeString
=
preference
.
getString
(
Preference
.
LOCALE_STRING
);
final
String
localeString
=
preference
.
getString
(
Option
.
ID_C_
LOCALE_STRING
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Current locale[string={0}]"
,
localeString
);
Latkes
.
setLocale
(
new
Locale
(
Locales
.
getLanguage
(
localeString
),
Locales
.
getCountry
(
localeString
)));
...
...
src/main/java/org/b3log/solo/service/UpgradeService.java
View file @
c9e1e51e
...
...
@@ -44,7 +44,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="mailto:dongxu.wang@acm.org">Dongxu Wang</a>
* @version 1.1.0.
1
, Nov 20, 2015
* @version 1.1.0.
2
, Nov 20, 2015
* @since 1.2.0
*/
@Service
...
...
@@ -126,7 +126,7 @@ public class UpgradeService {
return
;
}
final
String
currentVer
=
preference
.
getString
(
Preference
.
VERSION
);
final
String
currentVer
=
preference
.
getString
(
Option
.
ID_C_
VERSION
);
if
(
SoloServletListener
.
VERSION
.
equals
(
currentVer
))
{
return
;
...
...
@@ -182,182 +182,182 @@ public class UpgradeService {
// Upgrades preference model
final
JSONObject
preference
=
preferenceRepository
.
get
(
Preference
.
PREFERENCE
);
final
String
adminEmail
=
preference
.
optString
(
Preference
.
ADMIN_EMAIL
);
final
String
adminEmail
=
preference
.
optString
(
Option
.
ID_C_
ADMIN_EMAIL
);
final
JSONObject
adminEmailOpt
=
new
JSONObject
();
adminEmailOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ADMIN_EMAIL
);
adminEmailOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
adminEmailOpt
.
put
(
Option
.
OPTION_VALUE
,
adminEmail
);
optionRepository
.
add
(
adminEmailOpt
);
final
boolean
allowVisitDraftViaPermalink
=
preference
.
optBoolean
(
Preference
.
ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
final
boolean
allowVisitDraftViaPermalink
=
preference
.
optBoolean
(
Option
.
ID_C_
ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
final
JSONObject
allowVisitDraftViaPermalinkOpt
=
new
JSONObject
();
allowVisitDraftViaPermalinkOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK
);
allowVisitDraftViaPermalinkOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
allowVisitDraftViaPermalinkOpt
.
put
(
Option
.
OPTION_VALUE
,
Boolean
.
toString
(
allowVisitDraftViaPermalink
));
optionRepository
.
add
(
allowVisitDraftViaPermalinkOpt
);
final
boolean
commentable
=
preference
.
optBoolean
(
Preference
.
COMMENTABLE
);
final
boolean
commentable
=
preference
.
optBoolean
(
Option
.
ID_C_
COMMENTABLE
);
final
JSONObject
commentableOpt
=
new
JSONObject
();
commentableOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_COMMENTABLE
);
commentableOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
commentableOpt
.
put
(
Option
.
OPTION_VALUE
,
Boolean
.
toString
(
commentable
));
optionRepository
.
add
(
commentableOpt
);
final
String
feedOutputMode
=
preference
.
optString
(
Preference
.
FEED_OUTPUT_MODE
);
final
String
feedOutputMode
=
preference
.
optString
(
Option
.
ID_C_
FEED_OUTPUT_MODE
);
final
JSONObject
feedOutputModeOpt
=
new
JSONObject
();
feedOutputModeOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_FEED_OUTPUT_MODE
);
feedOutputModeOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
feedOutputModeOpt
.
put
(
Option
.
OPTION_VALUE
,
feedOutputMode
);
optionRepository
.
add
(
feedOutputModeOpt
);
final
int
feedOutputCnt
=
preference
.
optInt
(
Preference
.
FEED_OUTPUT_CNT
);
final
int
feedOutputCnt
=
preference
.
optInt
(
Option
.
ID_C_
FEED_OUTPUT_CNT
);
final
JSONObject
feedOutputCntOpt
=
new
JSONObject
();
feedOutputCntOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_FEED_OUTPUT_CNT
);
feedOutputCntOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
feedOutputCntOpt
.
put
(
Option
.
OPTION_VALUE
,
feedOutputCnt
);
optionRepository
.
add
(
feedOutputCntOpt
);
final
int
articleListDisplayCount
=
preference
.
optInt
(
Preference
.
ARTICLE_LIST_DISPLAY_COUNT
);
final
int
articleListDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
ARTICLE_LIST_DISPLAY_COUNT
);
final
JSONObject
articleListDisplayCountOpt
=
new
JSONObject
();
articleListDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ARTICLE_LIST_DISPLAY_COUNT
);
articleListDisplayCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
articleListDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
articleListDisplayCount
);
optionRepository
.
add
(
articleListDisplayCountOpt
);
final
int
relevantArticlesDisplayCount
=
preference
.
optInt
(
Preference
.
RELEVANT_ARTICLES_DISPLAY_CNT
);
final
int
relevantArticlesDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
RELEVANT_ARTICLES_DISPLAY_CNT
);
final
JSONObject
relevantArticlesDisplayCountOpt
=
new
JSONObject
();
relevantArticlesDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_RELEVANT_ARTICLES_DISPLAY_CNT
);
relevantArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
relevantArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
relevantArticlesDisplayCount
);
optionRepository
.
add
(
relevantArticlesDisplayCountOpt
);
final
int
articleListPaginationWindowSize
=
preference
.
optInt
(
Preference
.
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
int
articleListPaginationWindowSize
=
preference
.
optInt
(
Option
.
ID_C_
ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
final
JSONObject
articleListPaginationWindowSizeOpt
=
new
JSONObject
();
articleListPaginationWindowSizeOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE
);
articleListPaginationWindowSizeOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
articleListPaginationWindowSizeOpt
.
put
(
Option
.
OPTION_VALUE
,
articleListPaginationWindowSize
);
optionRepository
.
add
(
articleListPaginationWindowSizeOpt
);
final
String
articleListStyle
=
preference
.
optString
(
Preference
.
ARTICLE_LIST_STYLE
);
final
String
articleListStyle
=
preference
.
optString
(
Option
.
ID_C_
ARTICLE_LIST_STYLE
);
final
JSONObject
articleListStyleOpt
=
new
JSONObject
();
articleListStyleOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ARTICLE_LIST_STYLE
);
articleListStyleOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
articleListStyleOpt
.
put
(
Option
.
OPTION_VALUE
,
articleListStyle
);
optionRepository
.
add
(
articleListStyleOpt
);
final
String
blogSubtitle
=
preference
.
optString
(
Preference
.
BLOG_SUBTITLE
);
final
String
blogSubtitle
=
preference
.
optString
(
Option
.
ID_C_
BLOG_SUBTITLE
);
final
JSONObject
blogSubtitleOpt
=
new
JSONObject
();
blogSubtitleOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BLOG_SUBTITLE
);
blogSubtitleOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
blogSubtitleOpt
.
put
(
Option
.
OPTION_VALUE
,
blogSubtitle
);
optionRepository
.
add
(
blogSubtitleOpt
);
final
String
blogTitle
=
preference
.
optString
(
Preference
.
BLOG_TITLE
);
final
String
blogTitle
=
preference
.
optString
(
Option
.
ID_C_
BLOG_TITLE
);
final
JSONObject
blogTitleOpt
=
new
JSONObject
();
blogTitleOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_BLOG_TITLE
);
blogTitleOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
blogTitleOpt
.
put
(
Option
.
OPTION_VALUE
,
blogTitle
);
optionRepository
.
add
(
blogTitleOpt
);
final
boolean
enableArticleUpdateHint
=
preference
.
optBoolean
(
Preference
.
ENABLE_ARTICLE_UPDATE_HINT
);
final
boolean
enableArticleUpdateHint
=
preference
.
optBoolean
(
Option
.
ID_C_
ENABLE_ARTICLE_UPDATE_HINT
);
final
JSONObject
enableArticleUpdateHintOpt
=
new
JSONObject
();
enableArticleUpdateHintOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_ENABLE_ARTICLE_UPDATE_HINT
);
enableArticleUpdateHintOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
enableArticleUpdateHintOpt
.
put
(
Option
.
OPTION_VALUE
,
Boolean
.
toString
(
enableArticleUpdateHint
));
optionRepository
.
add
(
enableArticleUpdateHintOpt
);
final
int
externalRelevantArticlesDisplayCount
=
preference
.
optInt
(
Preference
.
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
);
final
int
externalRelevantArticlesDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
);
final
JSONObject
externalRelevantArticlesDisplayCountOpt
=
new
JSONObject
();
externalRelevantArticlesDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT
);
externalRelevantArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
externalRelevantArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
externalRelevantArticlesDisplayCount
);
optionRepository
.
add
(
externalRelevantArticlesDisplayCountOpt
);
final
String
htmlHead
=
preference
.
optString
(
Preference
.
HTML_HEAD
);
final
String
htmlHead
=
preference
.
optString
(
Option
.
ID_C_
HTML_HEAD
);
final
JSONObject
htmlHeadOpt
=
new
JSONObject
();
htmlHeadOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_HTML_HEAD
);
htmlHeadOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
htmlHeadOpt
.
put
(
Option
.
OPTION_VALUE
,
htmlHead
);
optionRepository
.
add
(
htmlHeadOpt
);
final
String
keyOfSolo
=
preference
.
optString
(
Preference
.
KEY_OF_SOLO
);
final
String
keyOfSolo
=
preference
.
optString
(
Option
.
ID_C_
KEY_OF_SOLO
);
final
JSONObject
keyOfSoloOpt
=
new
JSONObject
();
keyOfSoloOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_KEY_OF_SOLO
);
keyOfSoloOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
keyOfSoloOpt
.
put
(
Option
.
OPTION_VALUE
,
keyOfSolo
);
optionRepository
.
add
(
keyOfSoloOpt
);
final
String
localeString
=
preference
.
optString
(
Preference
.
LOCALE_STRING
);
final
String
localeString
=
preference
.
optString
(
Option
.
ID_C_
LOCALE_STRING
);
final
JSONObject
localeStringOpt
=
new
JSONObject
();
localeStringOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_LOCALE_STRING
);
localeStringOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
localeStringOpt
.
put
(
Option
.
OPTION_VALUE
,
localeString
);
optionRepository
.
add
(
localeStringOpt
);
final
String
metaDescription
=
preference
.
optString
(
Preference
.
META_DESCRIPTION
);
final
String
metaDescription
=
preference
.
optString
(
Option
.
ID_C_
META_DESCRIPTION
);
final
JSONObject
metaDescriptionOpt
=
new
JSONObject
();
metaDescriptionOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_META_DESCRIPTION
);
metaDescriptionOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
metaDescriptionOpt
.
put
(
Option
.
OPTION_VALUE
,
metaDescription
);
optionRepository
.
add
(
metaDescriptionOpt
);
final
String
metaKeywords
=
preference
.
optString
(
Preference
.
META_KEYWORDS
);
final
String
metaKeywords
=
preference
.
optString
(
Option
.
ID_C_
META_KEYWORDS
);
final
JSONObject
metaKeywordsOpt
=
new
JSONObject
();
metaKeywordsOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_META_KEYWORDS
);
metaKeywordsOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
metaKeywordsOpt
.
put
(
Option
.
OPTION_VALUE
,
metaKeywords
);
optionRepository
.
add
(
metaKeywordsOpt
);
final
int
mostCommentArticleDisplayCount
=
preference
.
optInt
(
Preference
.
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
final
int
mostCommentArticleDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
final
JSONObject
mostCommentArticleDisplayCountOpt
=
new
JSONObject
();
mostCommentArticleDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT
);
mostCommentArticleDisplayCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
mostCommentArticleDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
mostCommentArticleDisplayCount
);
optionRepository
.
add
(
mostCommentArticleDisplayCountOpt
);
final
int
mostUsedTagDisplayCount
=
preference
.
optInt
(
Preference
.
MOST_USED_TAG_DISPLAY_CNT
);
final
int
mostUsedTagDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
MOST_USED_TAG_DISPLAY_CNT
);
final
JSONObject
mostUsedTagDisplayCountOpt
=
new
JSONObject
();
mostUsedTagDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_MOST_USED_TAG_DISPLAY_CNT
);
mostUsedTagDisplayCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
mostUsedTagDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
mostUsedTagDisplayCount
);
optionRepository
.
add
(
mostUsedTagDisplayCountOpt
);
final
int
mostViewArticleDisplayCount
=
preference
.
optInt
(
Preference
.
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
final
int
mostViewArticleDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
MOST_VIEW_ARTICLE_DISPLAY_CNT
);
final
JSONObject
mostViewArticleDisplayCountOpt
=
new
JSONObject
();
mostViewArticleDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT
);
mostViewArticleDisplayCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
mostViewArticleDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
mostViewArticleDisplayCount
);
optionRepository
.
add
(
mostViewArticleDisplayCountOpt
);
final
String
noticeBoard
=
preference
.
optString
(
Preference
.
NOTICE_BOARD
);
final
String
noticeBoard
=
preference
.
optString
(
Option
.
ID_C_
NOTICE_BOARD
);
final
JSONObject
noticeBoardOpt
=
new
JSONObject
();
noticeBoardOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_NOTICE_BOARD
);
noticeBoardOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
noticeBoardOpt
.
put
(
Option
.
OPTION_VALUE
,
noticeBoard
);
optionRepository
.
add
(
noticeBoardOpt
);
final
int
randomArticlesDisplayCount
=
preference
.
optInt
(
Preference
.
RANDOM_ARTICLES_DISPLAY_CNT
);
final
int
randomArticlesDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
RANDOM_ARTICLES_DISPLAY_CNT
);
final
JSONObject
randomArticlesDisplayCountOpt
=
new
JSONObject
();
randomArticlesDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_RANDOM_ARTICLES_DISPLAY_CNT
);
randomArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
randomArticlesDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
randomArticlesDisplayCount
);
optionRepository
.
add
(
randomArticlesDisplayCountOpt
);
final
int
recentCommentDisplayCount
=
preference
.
optInt
(
Preference
.
RECENT_COMMENT_DISPLAY_CNT
);
final
int
recentCommentDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
RECENT_COMMENT_DISPLAY_CNT
);
final
JSONObject
recentCommentDisplayCountOpt
=
new
JSONObject
();
recentCommentDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_RECENT_COMMENT_DISPLAY_CNT
);
recentCommentDisplayCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
recentCommentDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
recentCommentDisplayCount
);
optionRepository
.
add
(
recentCommentDisplayCountOpt
);
final
int
recentArticleDisplayCount
=
preference
.
optInt
(
Preference
.
RECENT_ARTICLE_DISPLAY_CNT
);
final
int
recentArticleDisplayCount
=
preference
.
optInt
(
Option
.
ID_C_
RECENT_ARTICLE_DISPLAY_CNT
);
final
JSONObject
recentArticleDisplayCountOpt
=
new
JSONObject
();
recentArticleDisplayCountOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_RECENT_ARTICLE_DISPLAY_CNT
);
recentArticleDisplayCountOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
recentArticleDisplayCountOpt
.
put
(
Option
.
OPTION_VALUE
,
recentArticleDisplayCount
);
optionRepository
.
add
(
recentArticleDisplayCountOpt
);
final
String
signs
=
preference
.
optString
(
Preference
.
SIGNS
);
final
String
signs
=
preference
.
optString
(
Option
.
ID_C_
SIGNS
);
final
JSONObject
signsOpt
=
new
JSONObject
();
signsOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_SIGNS
);
signsOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
...
...
@@ -385,14 +385,14 @@ public class UpgradeService {
skinsOpt
.
put
(
Option
.
OPTION_VALUE
,
skins
);
optionRepository
.
add
(
skinsOpt
);
final
String
timeZoneId
=
preference
.
optString
(
Preference
.
TIME_ZONE_ID
);
final
String
timeZoneId
=
preference
.
optString
(
Option
.
ID_C_
TIME_ZONE_ID
);
final
JSONObject
timeZoneIdOpt
=
new
JSONObject
();
timeZoneIdOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_TIME_ZONE_ID
);
timeZoneIdOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
timeZoneIdOpt
.
put
(
Option
.
OPTION_VALUE
,
timeZoneId
);
optionRepository
.
add
(
timeZoneIdOpt
);
final
String
editorType
=
preference
.
optString
(
Preference
.
EDITOR_TYPE
);
final
String
editorType
=
preference
.
optString
(
Option
.
ID_C_
EDITOR_TYPE
);
final
JSONObject
editorTypeOpt
=
new
JSONObject
();
editorTypeOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_EDITOR_TYPE
);
editorTypeOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
...
...
@@ -405,7 +405,7 @@ public class UpgradeService {
footerContentOpt
.
put
(
Option
.
OPTION_VALUE
,
Preference
.
Default
.
DEFAULT_FOOTER_CONTENT
);
optionRepository
.
add
(
footerContentOpt
);
final
JSONObject
replyNotificationTemplate
=
preferenceRepository
.
get
(
Preference
.
REPLY_NOTIFICATION_TEMPLATE
);
final
JSONObject
replyNotificationTemplate
=
preferenceRepository
.
get
(
"replyNotificationTemplate"
);
final
String
body
=
replyNotificationTemplate
.
optString
(
"body"
);
final
JSONObject
bodyOpt
=
new
JSONObject
();
...
...
@@ -433,7 +433,7 @@ public class UpgradeService {
allowRegisterOpt
.
put
(
Option
.
OPTION_VALUE
,
Preference
.
Default
.
DEFAULT_ALLOW_REGISTER
);
optionRepository
.
add
(
allowRegisterOpt
);
preference
.
put
(
Preference
.
VERSION
,
TO_VER
);
preference
.
put
(
Option
.
ID_C_
VERSION
,
TO_VER
);
preferenceRepository
.
update
(
Preference
.
PREFERENCE
,
preference
);
transaction
.
commit
();
...
...
@@ -535,7 +535,7 @@ public class UpgradeService {
* @throws IOException IOException
*/
private
void
notifyUserByEmail
()
throws
ServiceException
,
JSONException
,
IOException
{
final
String
adminEmail
=
preferenceQueryService
.
getPreference
().
getString
(
Preference
.
ADMIN_EMAIL
);
final
String
adminEmail
=
preferenceQueryService
.
getPreference
().
getString
(
Option
.
ID_C_
ADMIN_EMAIL
);
final
MailService
.
Message
message
=
new
MailService
.
Message
();
message
.
setFrom
(
adminEmail
);
...
...
src/test/java/org/b3log/solo/service/PreferenceMgmtServiceTestCase.java
View file @
c9e1e51e
...
...
@@ -17,6 +17,7 @@ package org.b3log.solo.service;
import
org.b3log.latke.model.User
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Preference
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
...
...
@@ -26,7 +27,7 @@ import org.testng.annotations.Test;
* {@link PreferenceMgmtService} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
1, Sep 11, 2012
* @version 1.0.0.
2, Nov 20, 2015
*/
@Test
(
suiteName
=
"service"
)
public
class
PreferenceMgmtServiceTestCase
extends
AbstractTestCase
{
...
...
@@ -62,14 +63,14 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
final
PreferenceQueryService
preferenceQueryService
=
getPreferenceQueryService
();
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
Assert
.
assertEquals
(
preference
.
getString
(
Preference
.
BLOG_TITLE
),
Assert
.
assertEquals
(
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
),
Preference
.
Default
.
DEFAULT_BLOG_TITLE
);
preference
.
put
(
Preference
.
BLOG_TITLE
,
"updated blog title"
);
preference
.
put
(
Option
.
ID_C_
BLOG_TITLE
,
"updated blog title"
);
preferenceMgmtService
.
updatePreference
(
preference
);
preference
=
preferenceQueryService
.
getPreference
();
Assert
.
assertEquals
(
preference
.
getString
(
Preference
.
BLOG_TITLE
),
"updated blog title"
);
Assert
.
assertEquals
(
preference
.
getString
(
Option
.
ID_C_
BLOG_TITLE
),
"updated blog title"
);
}
/**
...
...
@@ -79,23 +80,16 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
updateReplyNotificationTemplate
()
throws
Exception
{
final
PreferenceMgmtService
preferenceMgmtService
=
getPreferenceMgmtService
();
final
PreferenceQueryService
preferenceQueryService
=
getPreferenceQueryService
();
JSONObject
replyNotificationTemplate
=
preferenceQueryService
.
getReplyNotificationTemplate
();
final
PreferenceMgmtService
preferenceMgmtService
=
getPreferenceMgmtService
();
final
PreferenceQueryService
preferenceQueryService
=
getPreferenceQueryService
();
JSONObject
replyNotificationTemplate
=
preferenceQueryService
.
getReplyNotificationTemplate
();
Assert
.
assertEquals
(
replyNotificationTemplate
.
toString
(),
Preference
.
Default
.
DEFAULT_REPLY_NOTIFICATION_TEMPLATE
);
Assert
.
assertEquals
(
replyNotificationTemplate
.
toString
(),
Preference
.
Default
.
DEFAULT_REPLY_NOTIFICATION_TEMPLATE
);
replyNotificationTemplate
.
put
(
"subject"
,
"updated subject"
);
preferenceMgmtService
.
updateReplyNotificationTemplate
(
replyNotificationTemplate
);
preferenceMgmtService
.
updateReplyNotificationTemplate
(
replyNotificationTemplate
);
replyNotificationTemplate
=
preferenceQueryService
.
getReplyNotificationTemplate
();
Assert
.
assertEquals
(
replyNotificationTemplate
.
getString
(
"subject"
),
"updated subject"
);
replyNotificationTemplate
=
preferenceQueryService
.
getReplyNotificationTemplate
();
Assert
.
assertEquals
(
replyNotificationTemplate
.
getString
(
"subject"
),
"updated subject"
);
}
}
src/test/java/org/b3log/solo/service/PreferenceQueryServiceTestCase.java
View file @
c9e1e51e
...
...
@@ -17,6 +17,7 @@ package org.b3log.solo.service;
import
org.b3log.latke.model.User
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Preference
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
...
...
@@ -26,7 +27,7 @@ import org.testng.annotations.Test;
* {@link PreferenceQueryService} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
1, Sep 11, 2012
* @version 1.0.0.
2, Nov 20, 2015
*/
@Test
(
suiteName
=
"service"
)
public
class
PreferenceQueryServiceTestCase
extends
AbstractTestCase
{
...
...
@@ -58,12 +59,11 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
getPreference
()
throws
Exception
{
final
PreferenceQueryService
preferenceQueryService
=
getPreferenceQueryService
();
final
PreferenceQueryService
preferenceQueryService
=
getPreferenceQueryService
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
Assert
.
assertEquals
(
preference
.
getString
(
Preference
.
BLOG_TITLE
),
Preference
.
Default
.
DEFAULT_BLOG_TITLE
);
Assert
.
assertEquals
(
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
),
Preference
.
Default
.
DEFAULT_BLOG_TITLE
);
}
/**
...
...
@@ -73,12 +73,11 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
*/
@Test
(
dependsOnMethods
=
"init"
)
public
void
getReplyNotificationTemplate
()
throws
Exception
{
final
PreferenceQueryService
preferenceQueryService
=
getPreferenceQueryService
();
final
JSONObject
replyNotificationTemplate
=
preferenceQueryService
.
getReplyNotificationTemplate
();
final
PreferenceQueryService
preferenceQueryService
=
getPreferenceQueryService
();
final
JSONObject
replyNotificationTemplate
=
preferenceQueryService
.
getReplyNotificationTemplate
();
Assert
.
assertEquals
(
replyNotificationTemplate
.
toString
(),
Preference
.
Default
.
DEFAULT_REPLY_NOTIFICATION_TEMPLATE
);
Assert
.
assertEquals
(
replyNotificationTemplate
.
toString
(),
Preference
.
Default
.
DEFAULT_REPLY_NOTIFICATION_TEMPLATE
);
}
}
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