Commit a3610ca0 authored by vcjmhg's avatar vcjmhg

Merge branch 'dev' of https://github.com/88250/solo into dev

parents d653f16e 425ec935
This diff is collapsed.
......@@ -42,7 +42,7 @@
"css-loader": "^3.4.2",
"extract-loader": "^3.1.0",
"file-loader": "^5.0.2",
"node-sass": "^4.13.1",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"postcss-loader": "^3.0.0",
"sass-loader": "^8.0.2",
......@@ -51,10 +51,10 @@
"webpack-cli": "^3.3.10"
},
"dependencies": {
"jquery": "^3.4.1",
"jquery": "^3.5.0",
"nprogress": "^0.2.0",
"uvstat": "^1.0.7",
"vcmt": "^1.1.10",
"vditor": "^3.1.20"
"vcmt": "^1.2.1",
"vditor": "^3.2.6"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
Description: Solo POM.
Version: 3.18.3.92, Apr 29, 2020
Version: 3.18.3.94, May 10, 2020
Author: <a href="http://88250.b3log.org">Liang Ding</a>
Author: <a href="http://www.annpeter.cn">Ann Peter</a>
Author: <a href="http://vanessa.b3log.org">Vanessa</a>
......@@ -73,7 +73,7 @@
</scm>
<properties>
<org.b3log.latke.version>3.3.4</org.b3log.latke.version>
<org.b3log.latke.version>3.4.0</org.b3log.latke.version>
<jsoup.version>1.12.1</jsoup.version>
<flexmark.version>0.50.40</flexmark.version>
......
......@@ -17,7 +17,7 @@ else
docker rm solo
docker run --detach --name solo --network=host \
--env RUNTIME_DB="MYSQL" \
--env JDBC_USERNAME="root" \
--env JDBC_USERNAME="root" \
--env JDBC_PASSWORD="123456" \
--env JDBC_DRIVER="com.mysql.cj.jdbc.Driver" \
--env JDBC_URL="jdbc:mysql://127.0.0.1:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC" \
......
......@@ -85,7 +85,7 @@ public final class Server extends BaseServer {
public static class TailStringWriter extends StringWriter {
private AtomicInteger count = new AtomicInteger();
private final AtomicInteger count = new AtomicInteger();
@Override
public void flush() {
......@@ -153,13 +153,11 @@ public final class Server extends BaseServer {
commandLine = commandLineParser.parse(options, args);
} catch (final ParseException e) {
helpFormatter.printHelp(cmdSyntax, header, options, footer, true);
return;
}
if (commandLine.hasOption("h")) {
helpFormatter.printHelp(cmdSyntax, header, options, footer, true);
return;
}
......
......@@ -73,19 +73,16 @@ public class B3ArticleSender extends AbstractEventListener<JSONObject> {
final String title = originalArticle.getString(Article.ARTICLE_TITLE);
if (Article.ARTICLE_STATUS_C_PUBLISHED != originalArticle.optInt(Article.ARTICLE_STATUS)) {
LOGGER.log(Level.INFO, "Ignored push a draft [title={}] to Rhy", title);
return;
}
if (StringUtils.isNotBlank(originalArticle.optString(Article.ARTICLE_VIEW_PWD))) {
LOGGER.log(Level.INFO, "Article [title={}] is a password article, ignored push to Rhy", title);
return;
}
if (!originalArticle.optBoolean(Common.POST_TO_COMMUNITY)) {
LOGGER.log(Level.INFO, "Article [title={}] push flag [postToCommunity] is [false], ignored push to Rhy", title);
return;
}
......
......@@ -153,7 +153,7 @@ public final class Entry {
/**
* Categories.
*/
private Set<Category> categories = new HashSet<Category>();
private final Set<Category> categories = new HashSet<Category>();
/**
* Gets the URI.
......
......@@ -157,7 +157,7 @@ public final class Feed {
/**
* Entries.
*/
private List<Entry> entries = new ArrayList<>();
private final List<Entry> entries = new ArrayList<>();
/**
* Gets the id.
......
......@@ -153,7 +153,7 @@ public final class Channel {
/**
* Items.
*/
private List<Item> items = new ArrayList<>();
private final List<Item> items = new ArrayList<>();
/**
* Gets the atom link.
......
......@@ -71,7 +71,7 @@ public final class Item {
/**
* Categories.
*/
private Set<Category> categories = new HashSet<>();
private final Set<Category> categories = new HashSet<>();
/**
* Start guid element.
......
......@@ -49,7 +49,7 @@ public final class Sitemap {
/**
* URLs.
*/
private List<URL> urls = new ArrayList<>();
private final List<URL> urls = new ArrayList<>();
/**
* Adds the specified url.
......
......@@ -41,7 +41,7 @@ import java.util.Map;
*/
public class ToCPlugin extends NotInteractivePlugin {
private ToCEventHandler handler = new ToCEventHandler();
private final ToCEventHandler handler = new ToCEventHandler();
@Override
public void changeStatus() {
......
......@@ -143,14 +143,12 @@ public class ArticleProcessor {
final String markdownText = context.requestJSON().optString("markdownText");
if (StringUtils.isBlank(markdownText)) {
result.put(Common.DATA, "");
return;
}
if (!Solos.isLoggedIn(context)) {
result.put(Keys.CODE, -1);
result.put(Keys.MSG, langPropsService.get("getFailLabel"));
return;
}
......@@ -173,14 +171,12 @@ public class ArticleProcessor {
final String articleId = context.param("articleId");
if (StringUtils.isBlank(articleId)) {
context.sendError(404);
return;
}
final JSONObject article = articleQueryService.getArticleById(articleId);
if (null == article) {
context.sendError(404);
return;
}
......@@ -238,7 +234,6 @@ public class ArticleProcessor {
}
context.sendRedirect(Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK));
return;
}
......@@ -266,7 +261,6 @@ public class ArticleProcessor {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
renderer.setJSONObject(jsonObject);
return;
}
......@@ -299,7 +293,6 @@ public class ArticleProcessor {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
renderer.setJSONObject(jsonObject);
return;
}
......@@ -308,14 +301,12 @@ public class ArticleProcessor {
final String articleId = context.pathVar("id");
if (StringUtils.isBlank(articleId)) {
context.sendError(404);
return;
}
final JSONObject article = articleQueryService.getArticleById(articleId);
if (null == article) {
context.sendError(404);
return;
}
......@@ -524,7 +515,6 @@ public class ArticleProcessor {
final JSONObject authorRet = userQueryService.getUser(authorId);
if (null == authorRet) {
context.sendError(404);
return;
}
......@@ -568,7 +558,6 @@ public class ArticleProcessor {
final JSONObject preference = optionQueryService.getPreference();
if (null == preference) {
context.sendError(404);
return;
}
......@@ -578,14 +567,12 @@ public class ArticleProcessor {
final JSONObject result = userQueryService.getUser(authorId);
if (null == result) {
context.sendError(404);
return;
}
final JSONObject articlesResult = articleQueryService.getArticlesByAuthorId(authorId, currentPageNum, pageSize);
if (null == articlesResult) {
context.sendError(404);
return;
}
......@@ -601,7 +588,7 @@ public class ArticleProcessor {
dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
dataModelService.fillUsite(dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMPLATE_DIR_NAME), dataModel);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
......@@ -626,7 +613,6 @@ public class ArticleProcessor {
if (null == result) {
LOGGER.log(Level.DEBUG, "Can not find articles for the specified archive date[string={}]", archiveDateString);
context.sendError(404);
return;
}
......@@ -642,14 +628,13 @@ public class ArticleProcessor {
final List<JSONObject> articles = articleQueryService.getArticlesByArchiveDate(archiveDateId, currentPageNum, pageSize);
if (articles.isEmpty()) {
context.sendError(404);
return;
}
dataModelService.setArticlesExProperties(context, articles, preference);
final Map<String, Object> dataModel = renderer.getDataModel();
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMPLATE_DIR_NAME), dataModel);
prepareShowArchiveArticles(preference, dataModel, articles, currentPageNum, pageCount, archiveDateString, archiveDate);
final Response response = context.getResponse();
dataModelService.fillCommon(context, dataModel, preference);
......@@ -671,7 +656,6 @@ public class ArticleProcessor {
final JSONObject article = (JSONObject) context.attr(Article.ARTICLE);
if (null == article) {
context.sendError(404);
return;
}
......@@ -713,7 +697,7 @@ public class ArticleProcessor {
dataModelService.fillCommon(context, dataModel, preference);
dataModelService.fillFaviconURL(dataModel, preference);
dataModelService.fillUsite(dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMPLATE_DIR_NAME), dataModel);
// Fire [Before Render Article] event
final JSONObject eventData = new JSONObject();
......
......@@ -139,7 +139,6 @@ public class B3Receiver {
final String msg = "Not found client";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return;
}
......@@ -151,7 +150,6 @@ public class B3Receiver {
final String msg = "Not found user [" + articleAuthorName + "]";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return;
}
......@@ -162,7 +160,6 @@ public class B3Receiver {
final String msg = "Wrong key";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return;
}
......@@ -172,7 +169,6 @@ public class B3Receiver {
final String msg = "Not found article";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return;
}
......@@ -197,7 +193,6 @@ public class B3Receiver {
final JSONObject addRequest = new JSONObject().put(Article.ARTICLE, article);
articleMgmtService.addArticle(addRequest);
LOGGER.log(Level.INFO, "Added an article [" + title + "] via Sym");
return;
}
......
......@@ -36,7 +36,6 @@ public class BeforeRequestHandler implements Handler {
context.setHeader("Retry-After", "600");
context.sendString("Too Many Requests");
context.abort();
return;
}
......
......@@ -106,7 +106,6 @@ public class CategoryProcessor {
final JSONObject category = categoryQueryService.getByURI(categoryURI);
if (null == category) {
context.sendError(404);
return;
}
......@@ -155,7 +154,6 @@ public class CategoryProcessor {
final JSONObject category = categoryQueryService.getByURI(categoryURI);
if (null == category) {
context.sendError(404);
return;
}
......@@ -171,11 +169,10 @@ public class CategoryProcessor {
final int pageCount = result.optJSONObject(Pagination.PAGINATION).optInt(Pagination.PAGINATION_PAGE_COUNT);
if (0 == pageCount) {
context.sendError(404);
return;
}
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMPLATE_DIR_NAME), dataModel);
dataModelService.setArticlesExProperties(context, articles, preference);
final List<Integer> pageNums = (List) result.optJSONObject(Pagination.PAGINATION).opt(Pagination.PAGINATION_PAGE_NUMS);
......
......@@ -136,7 +136,6 @@ public class CommentProcessor {
if (!Solos.isLoggedIn(context)) {
jsonObject.put(Keys.STATUS_CODE, false);
jsonObject.put(Keys.MSG, "Need login");
return;
}
......@@ -152,7 +151,7 @@ public class CommentProcessor {
// 添加评论优化 https://github.com/b3log/solo/issues/12246
try {
final String skinDirName = (String) context.attr(Keys.TEMAPLTE_DIR_NAME);
final String skinDirName = (String) context.attr(Keys.TEMPLATE_DIR_NAME);
final Template template = Skins.getSkinTemplate(context, "common-comment.ftl");
final JSONObject preference = optionQueryService.getPreference();
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), skinDirName, dataModel);
......
......@@ -167,7 +167,6 @@ public class FeedProcessor {
final JSONObject preference = optionQueryService.getPreference();
if (null == preference) {
context.sendError(404);
return;
}
......
......@@ -72,7 +72,6 @@ public class FetchUploadProcessor {
final String msg = "Gets upload token failed";
LOGGER.log(Level.ERROR, msg);
result.put(Keys.MSG, msg);
return;
}
......@@ -93,7 +92,6 @@ public class FetchUploadProcessor {
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Fetch file [url=" + originalURL + "] failed", e);
result.put(Keys.MSG, "Fetch file [url=" + originalURL + "] failed");
return;
}
......@@ -124,7 +122,6 @@ public class FetchUploadProcessor {
final String msg = "Upload file to community OSS [url=" + originalURL + "] failed";
LOGGER.log(Level.ERROR, msg, e);
result.put(Keys.MSG, msg);
return;
}
......
......@@ -96,7 +96,7 @@ public class IndexProcessor {
final int currentPageNum = Paginator.getPage(request);
final JSONObject preference = optionQueryService.getPreference();
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMPLATE_DIR_NAME), dataModel);
dataModelService.fillIndexArticles(context, dataModel, currentPageNum, preference);
dataModelService.fillCommon(context, dataModel, preference);
......@@ -126,7 +126,6 @@ public class IndexProcessor {
public void showStart(final RequestContext context) {
if (initService.isInited() && null != Solos.getCurrentUser(context)) {
context.sendRedirect(Latkes.getServePath());
return;
}
......
......@@ -50,7 +50,6 @@ public class InitCheckHandler implements Handler {
// 禁止直接获取 robots.txt https://github.com/b3log/solo/issues/12543
if (requestURI.startsWith("/robots.txt") && !isSpiderBot) {
context.sendError(403);
return;
}
......@@ -58,14 +57,12 @@ public class InitCheckHandler implements Handler {
final InitService initService = beanManager.getReference(InitService.class);
if (initService.isInited()) {
context.handle();
return;
}
if (StringUtils.startsWith(requestURI, Latkes.getContextPath() + "/login/")) {
// Do initialization
context.handle();
return;
}
......
......@@ -124,7 +124,6 @@ public class OAuthProcessor {
final String referer = STATES.get(state);
if (null == referer) {
context.sendError(400);
return;
}
STATES.remove(state);
......@@ -158,7 +157,6 @@ public class OAuthProcessor {
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Registers via oauth failed", e);
context.sendError(500);
return;
}
} else {
......@@ -169,7 +167,6 @@ public class OAuthProcessor {
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Updates user GitHub id failed", e);
context.sendError(500);
return;
}
}
......@@ -182,7 +179,6 @@ public class OAuthProcessor {
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Updates user name failed", e);
context.sendError(500);
return;
}
}
......@@ -191,7 +187,6 @@ public class OAuthProcessor {
if (null == user) {
LOGGER.log(Level.WARN, "Can't get user by name [" + userName + "]");
context.sendError(404);
return;
}
......
......@@ -59,7 +59,6 @@ public class PermalinkHandler implements Handler {
final InitService initService = beanManager.getReference(InitService.class);
if (!initService.isInited()) {
context.handle();
return;
}
......@@ -69,7 +68,6 @@ public class PermalinkHandler implements Handler {
if (PermalinkQueryService.invalidPermalinkFormat(permalink)) {
LOGGER.log(Level.DEBUG, "Skip permalink handling request [URI={}]", permalink);
context.handle();
return;
}
......@@ -78,13 +76,11 @@ public class PermalinkHandler implements Handler {
if (null == article) {
LOGGER.log(Level.DEBUG, "Not found article with permalink [{}]", permalink);
context.handle();
return;
}
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Processes article permalink handler failed", e);
context.sendError(404);
return;
}
......@@ -92,11 +88,9 @@ public class PermalinkHandler implements Handler {
if (Solos.needViewPwd(context, article)) {
try {
context.sendRedirect(Latkes.getServePath() + "/console/article-pwd?articleId=" + article.optString(Keys.OBJECT_ID));
return;
} catch (final Exception e) {
context.sendError(404);
return;
}
}
......@@ -106,7 +100,6 @@ public class PermalinkHandler implements Handler {
final boolean allowVisitDraftViaPermalink = preference.getBoolean(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK);
if (Article.ARTICLE_STATUS_C_PUBLISHED != article.optInt(Article.ARTICLE_STATUS) && !allowVisitDraftViaPermalink) {
context.sendError(404);
return;
}
......
......@@ -86,7 +86,7 @@ public class SkinHandler implements Handler {
}
}
}
request.setAttribute(Keys.TEMAPLTE_DIR_NAME, skin);
request.setAttribute(Keys.TEMPLATE_DIR_NAME, skin);
}
private static void fillBotAttrs(final Request request) {
......
......@@ -36,7 +36,6 @@ public class StaticMidware {
final String html = Statics.get(context);
if (null == html) {
context.handle();
return;
}
......
......@@ -101,7 +101,6 @@ public class TagProcessor {
final JSONObject result = tagQueryService.getTagByTitle(tagTitle);
if (null == result) {
context.sendError(404);
return;
}
......@@ -109,14 +108,13 @@ public class TagProcessor {
final String tagId = tag.getString(Keys.OBJECT_ID);
final JSONObject preference = optionQueryService.getPreference();
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMPLATE_DIR_NAME), dataModel);
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 tagArticleResult = articleQueryService.getArticlesByTag(tagId, currentPageNum, pageSize);
if (null == tagArticleResult) {
context.sendError(404);
return;
}
......
......@@ -93,7 +93,6 @@ public class UserTemplateProcessor {
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Renders CHANGE_LOGS failed", e);
}
return;
}
......@@ -107,7 +106,6 @@ public class UserTemplateProcessor {
final Template template = Skins.getSkinTemplate(context, templateName);
if (null == template) {
context.sendError(404);
return;
}
......@@ -119,7 +117,7 @@ public class UserTemplateProcessor {
dataModelService.fillFaviconURL(dataModel, preference);
dataModelService.fillUsite(dataModel);
dataModelService.fillUserTemplate(context, template, dataModel, preference);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMAPLTE_DIR_NAME), dataModel);
Skins.fillLangs(preference.optString(Option.ID_C_LOCALE_STRING), (String) context.attr(Keys.TEMPLATE_DIR_NAME), dataModel);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
......
......@@ -230,7 +230,6 @@ public class AdminConsole {
if (!Solos.isAdminLoggedIn(context)) {
context.sendError(401);
return;
}
......@@ -243,7 +242,6 @@ public class AdminConsole {
final byte[] zipData = exportService.exportSQL();
if (null == zipData) {
context.sendError(500);
return;
}
......@@ -263,7 +261,6 @@ public class AdminConsole {
final Response response = context.getResponse();
if (!Solos.isAdminLoggedIn(context)) {
context.sendError(401);
return;
}
......@@ -297,7 +294,6 @@ public class AdminConsole {
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Export failed", e);
context.renderJSON().renderMsg("Export failed, please check log");
return;
}
}
......@@ -311,7 +307,6 @@ public class AdminConsole {
final Response response = context.getResponse();
if (!Solos.isAdminLoggedIn(context)) {
context.sendError(401);
return;
}
......@@ -363,7 +358,6 @@ public class AdminConsole {
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Export failed", e);
context.renderJSON().renderMsg("Export failed, please check log");
return;
}
}
......
......@@ -180,7 +180,6 @@ public class ArticleConsole {
renderer.setJSONObject(ret);
ret.put(Keys.STATUS_CODE, false);
ret.put(Keys.MSG, langPropsService.get("forbiddenLabel"));
return;
}
......@@ -298,7 +297,6 @@ public class ArticleConsole {
if (!articleQueryService.canAccessArticle(articleId, currentUser)) {
ret.put(Keys.STATUS_CODE, false);
ret.put(Keys.MSG, langPropsService.get("forbiddenLabel"));
return;
}
......@@ -342,7 +340,6 @@ public class ArticleConsole {
if (!articleQueryService.canAccessArticle(articleId, currentUser)) {
ret.put(Keys.STATUS_CODE, false);
ret.put(Keys.MSG, langPropsService.get("forbiddenLabel"));
return;
}
......@@ -382,7 +379,6 @@ public class ArticleConsole {
if (!Solos.isAdminLoggedIn(context)) {
ret.put(Keys.MSG, langPropsService.get("forbiddenLabel"));
ret.put(Keys.STATUS_CODE, false);
return;
}
......@@ -423,7 +419,6 @@ public class ArticleConsole {
if (!Solos.isAdminLoggedIn(context)) {
ret.put(Keys.MSG, langPropsService.get("forbiddenLabel"));
ret.put(Keys.STATUS_CODE, false);
return;
}
......@@ -490,7 +485,6 @@ public class ArticleConsole {
if (!articleQueryService.canAccessArticle(articleId, currentUser)) {
ret.put(Keys.MSG, langPropsService.get("forbiddenLabel"));
ret.put(Keys.STATUS_CODE, false);
return;
}
......
......@@ -156,7 +156,6 @@ public class CategoryConsole {
final JSONObject result = categoryQueryService.getCategory(categoryId);
if (null == result) {
renderer.setJSONObject(new JSONObject().put(Keys.STATUS_CODE, false));
return;
}
......@@ -273,7 +272,6 @@ public class CategoryConsole {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, addArticleWithTagFirstLabel);
return;
}
......@@ -292,7 +290,6 @@ public class CategoryConsole {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("duplicatedCategoryLabel"));
return;
}
......@@ -301,7 +298,6 @@ public class CategoryConsole {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("categoryURIMustBeASCIILabel"));
return;
}
......@@ -310,14 +306,12 @@ public class CategoryConsole {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("duplicatedCategoryURILabel"));
return;
}
if (255 <= StringUtils.length(uri)) {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("categoryURITooLongLabel"));
return;
}
......@@ -409,7 +403,6 @@ public class CategoryConsole {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, addArticleWithTagFirstLabel);
return;
}
......@@ -427,7 +420,6 @@ public class CategoryConsole {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("duplicatedCategoryLabel"));
return;
}
......@@ -436,7 +428,6 @@ public class CategoryConsole {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("categoryURIMustBeASCIILabel"));
return;
}
mayExist = categoryQueryService.getByURI(uri);
......@@ -444,14 +435,12 @@ public class CategoryConsole {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("duplicatedCategoryURILabel"));
return;
}
if (255 <= StringUtils.length(uri)) {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("categoryURITooLongLabel"));
return;
}
......
......@@ -88,7 +88,6 @@ public class CommentConsole {
if (!commentQueryService.canAccessComment(commentId, currentUser)) {
ret.put(Keys.STATUS_CODE, false);
ret.put(Keys.MSG, langPropsService.get("forbiddenLabel"));
return;
}
......
......@@ -29,7 +29,6 @@ public class ConsoleAdminAuthMidware {
if (!Solos.isAdminLoggedIn(context)) {
context.sendError(401);
context.abort();
return;
}
......
......@@ -33,7 +33,6 @@ public class ConsoleAuthMidware {
if (null == currentUser) {
context.sendError(401);
context.abort();
return;
}
......
......@@ -323,7 +323,6 @@ public class LinkConsole {
final JSONObject result = linkQueryService.getLink(linkId);
if (null == result) {
renderer.setJSONObject(new JSONObject().put(Keys.STATUS_CODE, false));
return;
}
......
......@@ -283,7 +283,6 @@ public class PageConsole {
final JSONObject result = pageQueryService.getPage(pageId);
if (null == result) {
renderer.setJSONObject(new JSONObject().put(Keys.STATUS_CODE, false));
return;
}
......
......@@ -181,7 +181,6 @@ public class PreferenceConsole {
final JSONObject preference = optionQueryService.getPreference();
if (null == preference) {
renderer.setJSONObject(new JSONObject().put(Keys.STATUS_CODE, false));
return;
}
......
......@@ -93,7 +93,6 @@ public class SkinConsole {
final JSONObject skin = optionQueryService.getSkin();
if (null == skin) {
renderer.setJSONObject(new JSONObject().put(Keys.STATUS_CODE, false));
return;
}
......@@ -104,7 +103,6 @@ public class SkinConsole {
final String name = Latkes.getSkinName(dirName);
if (null == name) {
LOGGER.log(Level.WARN, "The directory [{}] does not contain any skin, ignored it", dirName);
continue;
}
......
......@@ -83,14 +83,12 @@ public class StaticSiteConsole {
if (!Strings.isURL(url)) {
context.renderJSON(-1);
context.renderMsg("Invalid site URL");
return;
}
if (Latkes.isInJar()) {
context.renderJSON(-1);
context.renderMsg("Do not support this feature while running in Jar");
return;
}
......
......@@ -229,7 +229,6 @@ public class UserConsole {
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel"));
return;
}
......
......@@ -219,7 +219,6 @@ public class ArticleMgmtService {
optionMgmtService.addOrUpdateOption(githubReposOpt);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Updates github repos option failed", e);
return;
}
......
......@@ -83,7 +83,6 @@ public class CategoryMgmtService {
}
LOGGER.log(Level.WARN, "Cant not find the target category of source category [order={}]", srcCategoryOrder);
return;
}
......
......@@ -171,7 +171,6 @@ public class CommentQueryService {
final String commentId = comment.optString(Keys.OBJECT_ID);
commentRepository.remove(commentId);
transaction.commit();
continue;
}
......
......@@ -629,7 +629,7 @@ public class DataModelService {
dataModel.put(User.USERS, userList);
final JSONObject admin = userRepository.getAdmin();
dataModel.put(Common.ADMIN_USER, admin);
final String skinDirName = (String) context.attr(Keys.TEMAPLTE_DIR_NAME);
final String skinDirName = (String) context.attr(Keys.TEMPLATE_DIR_NAME);
dataModel.put(Option.ID_C_SKIN_DIR_NAME, skinDirName);
Keys.fillRuntime(dataModel);
fillPageNavigations(dataModel);
......
......@@ -456,11 +456,9 @@ public class ExportService {
if (StringUtils.isNotBlank(article.optString(Article.ARTICLE_VIEW_PWD))) {
passwords.add(one);
continue;
} else if (Article.ARTICLE_STATUS_C_PUBLISHED == article.optInt(Article.ARTICLE_STATUS)) {
posts.add(one);
continue;
} else {
drafts.add(one);
......
......@@ -98,7 +98,6 @@ public class UpgradeService {
V380_390.perform();
case "3.9.0":
V390_400.perform();
break;
default:
LOGGER.log(Level.ERROR, "Please upgrade to v3.0.0 first");
......
......@@ -131,7 +131,6 @@ public class UserMgmtService {
usite = result.optJSONObject(Common.DATA);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Gets usite failed", e);
return;
}
......@@ -146,7 +145,6 @@ public class UserMgmtService {
optionMgmtService.addOrUpdateOption(usiteOpt);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Updates usite option failed", e);
return;
}
}
......
......@@ -29,7 +29,7 @@ import java.util.concurrent.ThreadLocalRandom;
* Image utilities.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.0, Apr 30, 2020
* @version 1.2.0.1, May 15, 2020
* @since 2.7.0
*/
public final class Images {
......@@ -42,7 +42,7 @@ public final class Images {
/**
* Community file service URL.
*/
public static String COMMUNITY_FILE_URL = "https://img.hacpai.com";
public static String COMMUNITY_FILE_URL = "https://b3logfile.com";
/**
* Checks whether the specified URL has uploaded.
......@@ -51,7 +51,7 @@ public final class Images {
* @return {@code true} if it has uploaded, returns {@code false} otherwise
*/
public static boolean uploaded(final String url) {
return StringUtils.startsWith(url, COMMUNITY_FILE_URL);
return StringUtils.startsWith(url, COMMUNITY_FILE_URL) || StringUtils.startsWith(url, "https://img.hacpai.com");
}
/**
......@@ -67,7 +67,7 @@ public final class Images {
for (final Element img : imgs) {
String imgSrc = img.attr("src");
if (!StringUtils.startsWith(imgSrc, COMMUNITY_FILE_URL) ||
if (!uploaded(imgSrc) ||
StringUtils.contains(imgSrc, ".gif") || StringUtils.containsIgnoreCase(imgSrc, "imageView") ||
StringUtils.containsIgnoreCase(imgSrc, "data:")) {
continue;
......@@ -105,11 +105,9 @@ public final class Images {
final long max = System.currentTimeMillis();
final long delta = max - min;
final long time = ThreadLocalRandom.current().nextLong(0, delta) + min;
return COMMUNITY_FILE_URL + "/bing/" + DateFormatUtils.format(time, "yyyyMMdd") + ".jpg";
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Generates random image URL failed", e);
return COMMUNITY_FILE_URL + "/bing/20171104.jpg";
}
}
......@@ -122,7 +120,6 @@ public final class Images {
*/
public static List<String> randomImages(final int n) {
final List<String> ret = new ArrayList<>();
int i = 0;
while (i < n * 5) {
final String url = randImage();
......
......@@ -249,7 +249,6 @@ public final class Markdowns {
for (final Thread thread : threads) {
if (thread.getId() == threadId[0]) {
thread.stop();
break;
}
}
......
......@@ -111,7 +111,7 @@ public final class Skins {
* @return template, returns {@code null} if not found
*/
public static Template getSkinTemplate(final RequestContext context, final String templateName) {
String templateDirName = (String) context.attr(Keys.TEMAPLTE_DIR_NAME);
String templateDirName = (String) context.attr(Keys.TEMPLATE_DIR_NAME);
if (StringUtils.isBlank(templateDirName)) {
templateDirName = Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME;
}
......
......@@ -18,7 +18,8 @@ import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.b3log.latke.http.RequestContext;
import org.b3log.solo.model.Option;
import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Strings;
import org.b3log.solo.processor.SkinRenderer;
import java.io.ByteArrayInputStream;
......@@ -38,7 +39,7 @@ import java.util.zip.GZIPOutputStream;
* Static utilities. 页面静态化 https://github.com/88250/solo/issues/107
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Apr 14, 2020
* @version 1.0.0.1, May 10, 2020
* @since 4.1.0
*/
public final class Statics {
......@@ -46,12 +47,12 @@ public final class Statics {
/**
* Logger.
*/
private static Logger LOGGER = LogManager.getLogger(Statics.class);
private static final Logger LOGGER = LogManager.getLogger(Statics.class);
/**
* Generated page expire time.
*/
private static long EXPIRED = TimeUnit.HOURS.toMillis(6);
private static final long EXPIRED = TimeUnit.HOURS.toMillis(6);
private static File DIR;
......@@ -81,6 +82,12 @@ public final class Statics {
return null;
}
final String remoteAddr = Requests.getRemoteAddr(context.getRequest());
if (Strings.isIPv4(remoteAddr)) {
// 直接用 IP 访问不走缓存
return null;
}
final String key = key(context);
if (null == key) {
return null;
......
This diff is collapsed.
......@@ -416,6 +416,7 @@ admin.article = {
// editor
admin.editors.articleEditor = new SoloEditor({
outline: true,
id: 'articleContent',
height: 500,
fun: fun,
......
......@@ -57,6 +57,7 @@ $.extend(SoloEditor.prototype, {
})
const options = {
outline: this.conf.outline || false,
mode: Label.editorMode,
typewriterMode: this.conf.typewriterMode,
cache: {
......@@ -105,6 +106,51 @@ $.extend(SoloEditor.prototype, {
toolbarConfig: {
pin: true,
},
toolbar:[
"emoji",
"headings",
"bold",
"link",
"|",
"list",
"ordered-list",
"check",
"outdent",
"indent",
"|",
"quote",
"code",
"insert-before",
"insert-after",
"|",
"upload",
"record",
"table",
"|",
"undo",
"redo",
"|",
"fullscreen",
"edit-mode",
{
name: "more",
toolbar: [
"italic",
"strike",
"line",
"inline-code",
"both",
"code-theme",
"content-theme",
"export",
"outline",
"preview",
"format",
"devtools",
"info",
"help",
],
}],
after: () => {
if (typeof this.conf.fun === 'function') {
this.conf.fun()
......@@ -118,8 +164,6 @@ $.extend(SoloEditor.prototype, {
'link',
'upload',
'edit-mode',
'code-theme',
'content-theme',
{
name: 'more',
toolbar: [
......
......@@ -108,6 +108,7 @@ admin.themeList = {
cache: false,
data: JSON.stringify(requestJSONObject),
success: function (result, textStatus) {
sessionStorage.removeItem('skin')
$('#tipMsg').text(result.msg)
if (!result.sc) {
$('#loadMsg').text('')
......
......@@ -23,7 +23,7 @@ window.Vcomment = Vcomment
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.2.1.0, Apr 30, 2020
* @version 2.3.1.0, May 15, 2020
*/
/**
......@@ -109,11 +109,7 @@ window.Util = {
return true
},
callback: function () {
try {
// TODO vditor@3.1.21 移除 try cache
Util.parseMarkdown()
} catch (e) {
}
Util.parseMarkdown()
if (typeof Util.uvstat === 'undefined') {
Util.uvstat = new Uvstat()
}
......@@ -310,7 +306,7 @@ window.Util = {
loadVditor: function (cb) {
$.ajax({
method: 'GET',
url: 'https://cdn.jsdelivr.net/npm/vditor@3.1.20/dist/index.min.js',
url: 'https://cdn.jsdelivr.net/npm/vditor@3.2.6/dist/index.min.js',
dataType: 'script',
cache: true,
success: () => {
......@@ -321,9 +317,35 @@ window.Util = {
},
})
},
skinPreview: () => {
if (location.pathname === '/admin-index.do') {
return
}
const skinParam = location.search.split('skin=')
let skin = ''
let urlHasSkin = false
if (skinParam.length === 2) {
skin = skinParam[1].split('=')[0]
urlHasSkin = true
}
if (skin) {
sessionStorage.setItem('skin', skin)
} else {
skin = sessionStorage.getItem('skin')
}
if (!skin) {
return
}
if (!urlHasSkin) {
location.search = location.search
? location.search + '&skin=' + skin
: '?skin=' + skin
}
},
};
(() => {
Util.skinPreview()
if (typeof Vditor === 'undefined') {
Util.loadVditor()
}
......
This diff is collapsed.
......@@ -180,8 +180,6 @@ $.extend(Page.prototype, {
'emoji',
'link',
'edit-mode',
'code-theme',
'content-theme',
{
name: 'more',
toolbar: [
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ html {
body {
margin: 0;
font-family:"Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", "Microsoft Yahei", sans-serif ;
font-family:"Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif ;
font-size: 14px;
background-color: #fff;
-webkit-font-smoothing: antialiased;
......@@ -123,7 +123,7 @@ textarea {
margin: 0;
font-size: 100%;
vertical-align: middle;
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
outline: none;
}
......@@ -172,4 +172,4 @@ svg {
blockquote {
margin: 0;
}
\ No newline at end of file
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -425,7 +425,7 @@ a {
box-sizing: border-box;
font-size: 14px;
outline: none;
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
}
button {
......
......@@ -55,7 +55,7 @@ html {
}
body {
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", "Microsoft Yahei", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", "EmojiSymbols";
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", "Android Emoji", "EmojiSymbols";
font-size: 12px;
background-color: #292929;
margin: 0;
......
This diff is collapsed.
This diff is collapsed.
......@@ -53,7 +53,7 @@ html {
body {
height: 100%;
max-height: 100%;
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
letter-spacing: 0.01rem;
font-size: 100%;
line-height: 1.75em;
......@@ -89,7 +89,7 @@ h4, h5, h6 {
-o-font-feature-settings: 'dlig' 1, 'liga' 1, 'lnum' 1, 'kern' 1;
color: #666;
line-height: 1.15em;
font-family: "Open Sans", "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
font-family: "Open Sans", "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
text-rendering: geometricPrecision;
}
......@@ -194,7 +194,7 @@ mark {
code, tt {
padding: 1px 3px;
font-family: Inconsolata, monospace, "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
font-family: Inconsolata, monospace, "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
font-size: 0.85em;
white-space: pre-wrap;
border: #E3EDF3 1px solid;
......@@ -352,7 +352,7 @@ pre code, pre tt {
box-sizing: border-box;
font-size: 14px;
outline: none;
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", Tahoma, "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
font-family: "Helvetica Neue", "Luxi Sans", "DejaVu Sans", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
}
.form textarea {
......
......@@ -136,7 +136,7 @@ public abstract class AbstractTestCase {
cookieJSONObject.put(Keys.TOKEN, "pass:" + random);
final String cookieValue = Crypts.encryptByAES(cookieJSONObject.toString(), Solos.COOKIE_SECRET);
request.addCookie(Solos.COOKIE_NAME, cookieValue);
request.setAttribute(Keys.TEMAPLTE_DIR_NAME, Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
request.setAttribute(Keys.TEMPLATE_DIR_NAME, Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
}
/**
......
......@@ -161,7 +161,7 @@ public class ArticleProcessorTestCase extends AbstractTestCase {
final MockRequest request = mockRequest();
request.setRequestURI("/archives/" + DateFormatUtils.format(System.currentTimeMillis(), "yyyy/MM"));
request.setParameter("p", "1");
request.setAttribute(Keys.TEMAPLTE_DIR_NAME, Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
request.setAttribute(Keys.TEMPLATE_DIR_NAME, Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
final MockResponse response = mockResponse();
mockDispatcher(request, response);
......@@ -181,7 +181,7 @@ public class ArticleProcessorTestCase extends AbstractTestCase {
final MockRequest request = mockRequest();
request.setRequestURI("/article");
request.setAttribute(Article.ARTICLE, article);
request.setAttribute(Keys.TEMAPLTE_DIR_NAME, Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
request.setAttribute(Keys.TEMPLATE_DIR_NAME, Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
final MockResponse response = mockResponse();
mockDispatcher(request, response);
......@@ -202,7 +202,7 @@ public class ArticleProcessorTestCase extends AbstractTestCase {
final MockRequest request = mockRequest();
request.setRequestURI("/console/article-pwd");
request.setParameter("articleId", articleId);
request.setAttribute(Keys.TEMAPLTE_DIR_NAME, Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
request.setAttribute(Keys.TEMPLATE_DIR_NAME, Option.DefaultPreference.DEFAULT_SKIN_DIR_NAME);
final MockResponse response = mockResponse();
mockDispatcher(request, response);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment