forked from b3log/solo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOption.java
More file actions
536 lines (441 loc) · 14.6 KB
/
Option.java
File metadata and controls
536 lines (441 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
/*
* Solo - A beautiful, simple, stable, fast Java blogging system.
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.model;
import org.b3log.latke.Keys;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
/**
* This class defines option model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.0.6, May 29, 2018
* @since 0.6.0
*/
public final class Option {
/**
* Option.
*/
public static final String OPTION = "option";
/**
* Options.
*/
public static final String OPTIONS = "options";
/**
* Key of option value.
*/
public static final String OPTION_VALUE = "optionValue";
/**
* Key of option category.
*/
public static final String OPTION_CATEGORY = "optionCategory";
// oId constants
/**
* Key of broadcast chance expiration time.
*/
public static final String ID_C_BROADCAST_CHANCE_EXPIRATION_TIME = "broadcastChanceExpirationTime";
/**
* Key of Qiniu access key.
*/
public static final String ID_C_QINIU_ACCESS_KEY = "qiniuAccessKey";
/**
* Key of Qiniu secret key.
*/
public static final String ID_C_QINIU_SECRET_KEY = "qiniuSecretKey";
/**
* Key of Qiniu domain.
*/
public static final String ID_C_QINIU_DOMAIN = "qiniuDomain";
/**
* Key of Qiniu bucket.
*/
public static final String ID_C_QINIU_BUCKET = "qiniuBucket";
/**
* Key of blog title.
*/
public static final String ID_C_BLOG_TITLE = "blogTitle";
/**
* Key of blog subtitle.
*/
public static final String ID_C_BLOG_SUBTITLE = "blogSubtitle";
/**
* Key of relevant articles display count.
*/
public static final String ID_C_RELEVANT_ARTICLES_DISPLAY_CNT = "relevantArticlesDisplayCount";
/**
* Key of random articles display count.
*/
public static final String ID_C_RANDOM_ARTICLES_DISPLAY_CNT = "randomArticlesDisplayCount";
/**
* Key of external relevant articles display count.
*/
public static final String ID_C_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_CNT = "externalRelevantArticlesDisplayCount";
/**
* Key of recent article display count.
*/
public static final String ID_C_RECENT_ARTICLE_DISPLAY_CNT = "recentArticleDisplayCount";
/**
* Key of recent comment display count.
*/
public static final String ID_C_RECENT_COMMENT_DISPLAY_CNT = "recentCommentDisplayCount";
/**
* Key of most used tag display count.
*/
public static final String ID_C_MOST_USED_TAG_DISPLAY_CNT = "mostUsedTagDisplayCount";
/**
* Key of most comment article display count.
*/
public static final String ID_C_MOST_COMMENT_ARTICLE_DISPLAY_CNT = "mostCommentArticleDisplayCount";
/**
* Key of most view article display count.
*/
public static final String ID_C_MOST_VIEW_ARTICLE_DISPLAY_CNT = "mostViewArticleDisplayCount";
/**
* Key of article list display count.
*/
public static final String ID_C_ARTICLE_LIST_DISPLAY_COUNT = "articleListDisplayCount";
/**
* Key of article list pagination window size.
*/
public static final String ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE = "articleListPaginationWindowSize";
/**
* Key of administrator's email.
*/
public static final String ID_C_ADMIN_EMAIL = "adminEmail";
/**
* Key of locale string.
*/
public static final String ID_C_LOCALE_STRING = "localeString";
/**
* Key of time zone id.
*/
public static final String ID_C_TIME_ZONE_ID = "timeZoneId";
/**
* Key of notice board.
*/
public static final String ID_C_NOTICE_BOARD = "noticeBoard";
/**
* Key of HTML head.
*/
public static final String ID_C_HTML_HEAD = "htmlHead";
/**
* Key of meta keywords.
*/
public static final String ID_C_META_KEYWORDS = "metaKeywords";
/**
* Key of meta description.
*/
public static final String ID_C_META_DESCRIPTION = "metaDescription";
/**
* Key of article update hint flag.
*/
public static final String ID_C_ENABLE_ARTICLE_UPDATE_HINT = "enableArticleUpdateHint";
/**
* Key of signs.
*/
public static final String ID_C_SIGNS = "signs";
/**
* Key of key of Solo.
*/
public static final String ID_C_KEY_OF_SOLO = "keyOfSolo";
/**
* Key of allow visit draft via permalink.
*/
public static final String ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK = "allowVisitDraftViaPermalink";
/**
* Key of allow register.
*/
public static final String ID_C_ALLOW_REGISTER = "allowRegister";
/**
* Key of version.
*/
public static final String ID_C_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 ID_C_ARTICLE_LIST_STYLE = "articleListStyle";
/**
* Key of article/page comment-able.
*/
public static final String ID_C_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 ID_C_FEED_OUTPUT_MODE = "feedOutputMode";
/**
* Key of feed (Atom/RSS) output entry count.
*/
public static final String ID_C_FEED_OUTPUT_CNT = "feedOutputCnt";
/**
* Key of editor type.
* <p>
* Optional values:
* <ul>
* <li>"tinyMCE"</li>
* <li>"CodeMirror-Markdown"</li>
* <li>"KindEditor"</li>
* </ul>
* </p>
*/
public static final String ID_C_EDITOR_TYPE = "editorType";
/**
* Key of skins.
*/
public static final String ID_C_SKINS = "skins";
/**
* Key of skin dir name.
*/
public static final String ID_C_SKIN_DIR_NAME = "skinDirName";
/**
* Key of skin name.
*/
public static final String ID_C_SKIN_NAME = "skinName";
/**
* Key of reply notification template body.
*/
public static final String ID_C_REPLY_NOTI_TPL_BODY = "replyNotiTplBody";
/**
* Key of reply notification template subject.
*/
public static final String ID_C_REPLY_NOTI_TPL_SUBJECT = "replyNotiTplSubject";
/**
* Key of footer content.
*/
public static final String ID_C_FOOTER_CONTENT = "footerContent";
/**
* Key of statistic blog view count.
*/
public static final String ID_C_STATISTIC_BLOG_VIEW_COUNT = "statisticBlogViewCount";
/**
* Key of statistic blog comment count.
*/
public static final String ID_C_STATISTIC_BLOG_COMMENT_COUNT = "statisticBlogCommentCount";
/**
* Key of statistic blog comment(published article) count.
*/
public static final String ID_C_STATISTIC_PUBLISHED_BLOG_COMMENT_COUNT = "statisticPublishedBlogCommentCount";
/**
* Key of statistic blog article count.
*/
public static final String ID_C_STATISTIC_BLOG_ARTICLE_COUNT = "statisticBlogArticleCount";
/**
* Key of statistic blog published article count.
*/
public static final String ID_C_STATISTIC_PUBLISHED_ARTICLE_COUNT = "statisticPublishedBlogArticleCount";
// Category constants
/**
* Broadcast.
*/
public static final String CATEGORY_C_BROADCAST = "broadcast";
/**
* Qiniu.
*/
public static final String CATEGORY_C_QINIU = "qiniu";
/**
* Preference.
*/
public static final String CATEGORY_C_PREFERENCE = "preference";
/**
* Statistic.
*/
public static final String CATEGORY_C_STATISTIC = "statistic";
/**
* Private constructor.
*/
private Option() {
}
/**
* Default preference.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.1.0.9, Nov 23, 2015
* @since 0.3.1
*/
public static final class DefaultPreference {
/**
* Default recent article display count.
*/
public static final int DEFAULT_RECENT_ARTICLE_DISPLAY_COUNT = 10;
/**
* Default recent comment display count.
*/
public static final int DEFAULT_RECENT_COMMENT_DISPLAY_COUNT = 10;
/**
* Default most used tag display count.
*/
public static final int DEFAULT_MOST_USED_TAG_DISPLAY_COUNT = 20;
/**
* Default article list display count.
*/
public static final int DEFAULT_ARTICLE_LIST_DISPLAY_COUNT = 20;
/**
* Default article list pagination window size.
*/
public static final int DEFAULT_ARTICLE_LIST_PAGINATION_WINDOW_SIZE = 15;
/**
* Default most comment article display count.
*/
public static final int DEFAULT_MOST_COMMENT_ARTICLE_DISPLAY_COUNT = 5;
/**
* Default blog subtitle.
*/
public static final String DEFAULT_BLOG_SUBTITLE = "记录精彩的程序人生";
/**
* Default skin directory name.
*/
public static final String DEFAULT_SKIN_DIR_NAME = "Medium";
/**
* Default language.
*/
public static final String DEFAULT_LANGUAGE = "zh_CN";
/**
* Default time zone.
*
* @see java.util.TimeZone#getAvailableIDs()
*/
public static final String DEFAULT_TIME_ZONE = "Asia/Shanghai";
/**
* Default enable article update hint.
*/
public static final String DEFAULT_ENABLE_ARTICLE_UPDATE_HINT = "true";
/**
* Default notice board.
*/
public static final String DEFAULT_NOTICE_BOARD = "Open Source, Open Mind, <br/>Open Sight, Open Future!";
/**
* Default meta keywords..
*/
public static final String DEFAULT_META_KEYWORDS = "Solo,Java,博客,开源";
/**
* Default meta description..
*/
public static final String DEFAULT_META_DESCRIPTION = "A beautiful, simple, stable, fast Java blogging system. 一款漂亮、简约、稳定、极速的 Java 博客系统。";
/**
* Default HTML head to append.
*/
public static final String DEFAULT_HTML_HEAD = "";
/**
* Default footer content.
*/
public static final String DEFAULT_FOOTER_CONTENT = "";
/**
* Default relevant articles display count.
*/
public static final int DEFAULT_RELEVANT_ARTICLES_DISPLAY_COUNT = 5;
/**
* Default random articles display count.
*/
public static final int DEFAULT_RANDOM_ARTICLES_DISPLAY_COUNT = 5;
/**
* Default external relevant articles display count.
*/
public static final int DEFAULT_EXTERNAL_RELEVANT_ARTICLES_DISPLAY_COUNT = 5;
/**
* Most view articles display count.
*/
public static final int DEFAULT_MOST_VIEW_ARTICLES_DISPLAY_COUNT = 5;
/**
* Default signs.
*/
public static final String DEFAULT_SIGNS;
/**
* Default allow visit draft via permalink.
*/
public static final String DEFAULT_ALLOW_VISIT_DRAFT_VIA_PERMALINK = "false";
/**
* Default allow register.
*/
public static final String DEFAULT_ALLOW_REGISTER = "false";
/**
* Default allow comment article/page.
*/
public static final String DEFAULT_COMMENTABLE = "true";
/**
* Default article list display style.
*/
public static final String DEFAULT_ARTICLE_LIST_STYLE = "titleAndAbstract";
/**
* Default key of solo.
*/
public static final String DEFAULT_KEY_OF_SOLO = "Your key";
/**
* Default reply notification template.
*/
public static final String DEFAULT_REPLY_NOTIFICATION_TEMPLATE;
/**
* Default feed output mode.
*/
public static final String DEFAULT_FEED_OUTPUT_MODE = "abstract";
/**
* Default feed output entry count.
*/
public static final int DEFAULT_FEED_OUTPUT_CNT = 10;
/**
* Default editor type.
*/
public static final String DEFAULT_EDITOR_TYPE = "CodeMirror-Markdown";
/**
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(DefaultPreference.class);
static {
final JSONArray signs = new JSONArray();
final int signLength = 4;
try {
for (int i = 0; i < signLength; i++) {
final JSONObject sign = new JSONObject();
sign.put(Keys.OBJECT_ID, i);
signs.put(sign);
sign.put(Sign.SIGN_HTML, "");
}
// Sign(id=0) is the 'empty' sign, used for article user needn't a sign
DEFAULT_SIGNS = signs.toString();
final JSONObject replyNotificationTemplate = new JSONObject();
replyNotificationTemplate.put("subject", "${blogTitle}: New reply of your comment");
replyNotificationTemplate.put("body",
"Your comment on post[<a href='${postLink}'>" + "${postTitle}</a>] received an reply: <p>${replier}"
+ ": <span><a href='${replyURL}'>${replyContent}</a></span></p>");
DEFAULT_REPLY_NOTIFICATION_TEMPLATE = replyNotificationTemplate.toString();
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Creates sign error!", e);
throw new IllegalStateException(e);
}
}
/**
* Private default constructor.
*/
private DefaultPreference() {
}
}
}