Commit b805e436 authored by Liang Ding's avatar Liang Ding

🎨 #12690

parent 2f347ac1
......@@ -385,8 +385,6 @@ public final class SoloServletListener extends AbstractServletListener {
DispatcherServlet.post("/console/plugin/updateSetting", pluginConsole::updateSetting);
final PreferenceConsole preferenceConsole = beanManager.getReference(PreferenceConsole.class);
DispatcherServlet.get("/console/reply/notification/template", preferenceConsole::getReplyNotificationTemplate);
DispatcherServlet.put("/console/reply/notification/template", preferenceConsole::updateReplyNotificationTemplate);
DispatcherServlet.get("/console/signs/", preferenceConsole::getSigns);
DispatcherServlet.get("/console/preference/", preferenceConsole::getPreference);
DispatcherServlet.put("/console/preference/", preferenceConsole::updatePreference);
......
......@@ -222,16 +222,6 @@ public final class Option {
*/
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.
*/
......@@ -421,16 +411,6 @@ public final class Option {
*/
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.
*/
......@@ -454,13 +434,6 @@ public final class Option {
// 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();
}
/**
......
......@@ -87,82 +87,6 @@ public class PreferenceConsole {
@Inject
private LangPropsService langPropsService;
/**
* Gets reply template.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "replyNotificationTemplate": {
* "subject": "",
* "body": ""
* }
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
public void getReplyNotificationTemplate(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
try {
final JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
ret.put("replyNotificationTemplate", replyNotificationTemplate);
ret.put(Keys.STATUS_CODE, true);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel"));
}
}
/**
* Updates reply template.
* <p>
* <p>
* Request json:
* <pre>
* {
* "replyNotificationTemplate": {
* "subject": "",
* "body": ""
* }
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
public void updateReplyNotificationTemplate(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
try {
final JSONObject requestJSONObject = context.requestJSON();
final JSONObject replyNotificationTemplate = requestJSONObject.getJSONObject("replyNotificationTemplate");
preferenceMgmtService.updateReplyNotificationTemplate(replyNotificationTemplate);
final JSONObject ret = new JSONObject();
ret.put(Keys.STATUS_CODE, true);
ret.put(Keys.MSG, langPropsService.get("updateSuccLabel"));
renderer.setJSONObject(ret);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("updateFailLabel"));
}
}
/**
* Gets signs.
* <p>
......
......@@ -400,9 +400,6 @@ public class CommentMgmtService {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
JSONObject originalComment = null;
comment.put(Comment.COMMENT_NAME, commentName);
comment.put(Comment.COMMENT_URL, commentURL);
comment.put(Comment.COMMENT_CONTENT, commentContent);
......@@ -425,6 +422,7 @@ public class CommentMgmtService {
ret.put(Comment.COMMENT_CONTENT, cmtContent);
ret.put(Comment.COMMENT_URL, commentURL);
JSONObject originalComment;
if (StringUtils.isNotBlank(originalCommentId)) {
originalComment = commentRepository.get(originalCommentId);
if (null != originalComment) {
......
......@@ -226,7 +226,6 @@ public class InitService {
try {
initStatistic();
initPreference(requestJSONObject);
initReplyNotificationTemplate();
initAdmin(requestJSONObject);
initLink();
helloWorld();
......@@ -466,32 +465,6 @@ public class InitService {
LOGGER.info("Initialized statistic");
}
/**
* Initializes reply notification template.
*
* @throws Exception exception
*/
private void initReplyNotificationTemplate() throws Exception {
LOGGER.debug("Initializing reply notification template");
final JSONObject replyNotificationTemplate = new JSONObject(DefaultPreference.DEFAULT_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);
subjectOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
subjectOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("subject"));
optionRepository.add(subjectOpt);
final JSONObject bodyOpt = new JSONObject();
bodyOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_BODY);
bodyOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
bodyOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("body"));
optionRepository.add(bodyOpt);
LOGGER.info("Initialized reply notification template");
}
/**
* Initializes preference.
*
......
......@@ -140,35 +140,6 @@ public class PreferenceMgmtService {
Stopwatchs.end();
}
/**
* Updates the reply notification template with the specified reply notification template.
*
* @param replyNotificationTemplate the specified reply notification template
* @throws ServiceException service exception
*/
public void updateReplyNotificationTemplate(final JSONObject replyNotificationTemplate) throws ServiceException {
final Transaction transaction = optionRepository.beginTransaction();
try {
final JSONObject bodyOpt = optionRepository.get(Option.ID_C_REPLY_NOTI_TPL_BODY);
bodyOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("body"));
optionRepository.update(Option.ID_C_REPLY_NOTI_TPL_BODY, bodyOpt);
final JSONObject subjectOpt = optionRepository.get(Option.ID_C_REPLY_NOTI_TPL_SUBJECT);
subjectOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("subject"));
optionRepository.update(Option.ID_C_REPLY_NOTI_TPL_SUBJECT, subjectOpt);
transaction.commit();
} catch (final Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
LOGGER.log(Level.ERROR, "Updates reply notification failed", e);
throw new ServiceException(e);
}
}
/**
* Updates the preference with the specified preference.
*
......
......@@ -20,7 +20,6 @@ package org.b3log.solo.service;
import org.b3log.latke.ioc.Inject;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service;
import org.b3log.solo.model.Option;
import org.b3log.solo.repository.OptionRepository;
......@@ -53,27 +52,6 @@ public class PreferenceQueryService {
@Inject
private OptionQueryService optionQueryService;
/**
* Gets the reply notification template.
*
* @return reply notification template, returns {@code null} if not found
* @throws ServiceException service exception
*/
public JSONObject getReplyNotificationTemplate() throws ServiceException {
try {
final JSONObject ret = new JSONObject();
final JSONObject preference = getPreference();
ret.put("subject", preference.optString(Option.ID_C_REPLY_NOTI_TPL_SUBJECT));
ret.put("body", preference.optString(Option.ID_C_REPLY_NOTI_TPL_BODY));
return ret;
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Updates reply notification template failed", e);
throw new ServiceException(e);
}
}
/**
* Gets the user preference.
*
......
......@@ -73,6 +73,8 @@ public final class V310_320 {
connection.close();
optionRepository.remove("adminEmail");
optionRepository.remove("replyNotiTplBody");
optionRepository.remove("replyNotiTplSubject");
final Transaction transaction = optionRepository.beginTransaction();
final JSONObject versionOpt = optionRepository.get(Option.ID_C_VERSION);
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, 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/>.
*/
Util.htmlDecode=function(t){var e=document.createElement("div");return e.innerHTML=decodeURIComponent(t),e.innerText},Util.proessURL=function(t){return/^\w+:\/\//.test(t)||(t="http://"+t),t};var Admin=function(){this.register={},this.tools=["#page-list","#file-list","#link-list","#preference","#user-list","#plugin-list","#others","#category-list"],this.adTools=["link-list","preference","file-list","page-list","user-list","plugin-list","others","category-list"]};$.extend(Admin.prototype,{logout:function(){window.location.href=latkeConfig.servePath+"/logout"},toggleMenu:function(){"-240px"===$("#tabs").css("left")?($("#tabs").css("left",0),$(".tabs__bg").show()):($("#tabs").css("left","-240px"),$(".tabs__bg").hide())},clearTip:function(){$("#tipMsg").text(""),$("#loadMsg").text("")},setHashByPage:function(t){var e=window.location.hash.split("/");/^\d*$/.test(e[e.length-1])?e[e.length-1]=t:e.push(t),window.location.hash=e.join("/")},selectTab:function(t){window.location.hash="#"+t},analyseHash:function(){for(var t=window.location.hash,e=t.substr(1,t.length-1).split("/"),i={page:1,hashList:[]},a=0;a<e.length;a++)a===e.length-1&&/^\d+$/.test(e[a])?i.page=e[a]:i.hashList.push(e[a]);return i},setCurByHash:function(){$(window).scrollTop(0),$("#tipMsg").text("");var t=admin.analyseHash(),e=t.hashList[1],i=t.hashList[2];if(1===t.hashList.length&&(e=t.hashList[0]),""!==e){"article"!==e?admin.article.clearDraftTimer():"article"===e&&(admin.article.autoSaveDraftTimer=setInterval(function(){admin.article._autoSaveToDraft()},admin.article.AUTOSAVETIME));try{if("article"!==e&&admin.article.isConfirm&&""!==admin.editors.articleEditor.getContent().replace(/\s/g,"")&&admin.article.content!==admin.editors.articleEditor.getContent()&&!confirm(Label.editorLeaveLabel))return void(window.location.hash="#article/article");if("article"===e&&admin.article.isConfirm&&""!==admin.editors.articleEditor.getContent().replace(/\s/g,"")&&admin.article.content!==admin.editors.articleEditor.getContent())return}catch(t){var a=$("#articleContent");if(0<a.length){if("article"!==e&&admin.article.isConfirm&&""!==a.val().replace(/\s/g,"")&&admin.article.content!==a.val()&&!confirm(Label.editorLeaveLabel))return void(window.location.hash="#article/article");if("article"===e&&admin.article.isConfirm&&""!==a.val().replace(/\s/g,"")&&admin.article.content!==a.val())return}}"article"!==e&&admin.editors.articleEditor.setContent&&admin.article.clear(),admin.article.isConfirm=!0,$("#tabs").tabs("setCurrent",e),$("#loadMsg").text(Label.loadingLabel),1===$("#tabsPanel_"+e).length?""===$("#tabsPanel_"+e).html().replace(/\s/g,"")?$("#tabsPanel_"+e).load("admin-"+e+".do",function(){"article"===e&&admin.article.status.id?admin.register[e].init.call(admin.register[e].obj,admin.article.getAndSet):admin.register[e].init.call(admin.register[e].obj,t.page),i&&$("#tab"+e.substring(0,1).toUpperCase()+e.substring(1)).tabs("setCurrent",i),admin.plugin.setCurByHash(t)}):("article"===e&&admin.article.status.id&&admin.article.getAndSet(),admin.register[e]&&admin.register[e].refresh&&admin.register[e].refresh.call(admin.register[e].obj,t.page),i&&$("#tab"+e.substring(0,1).toUpperCase()+e.substring(1)).tabs("setCurrent",i),admin.plugin.setCurByHash(t)):($("#tipMsg").text("Error: No tab! "+Label.reportIssueLabel),$("#loadMsg").text(""))}},init:function(){Util.killIE(),$("#loadMsg").text(Label.loadingLabel),$("#tabs").tabs(),setInterval(function(){""!==$("#tipMsg").text()&&setTimeout(function(){$("#tipMsg").text("")},7e3)},6e3),$("#loadMsg").text("")},collapseNav:function(t){$(t).next().slideToggle("normal",function(){"none"!==this.style.display?($(t).find(".icon-chevron-down")[0].className="icon-chevron-up fn__right",$(t).addClass("tab-current")):($(t).find(".icon-chevron-up")[0].className="icon-chevron-down fn__right",$(t).removeClass("tab-current")),$("#tabs > ul").height("auto"),$("#tabs > ul").height($("#tabs > ul").height()+80)})},inited:function(){if("adminRole"!==Label.userRole)for(var t=0;t<this.adTools.length;t++)$("#tabs").tabs("remove",this.adTools[t]);else for(var e=0;e<this.tools.length;e++)if("#"+window.location.hash.split("/")[1]===this.tools[e]){$("#tabToolsTitle").click();break}this.setCurByHash()}});var admin=new Admin;
admin.editors={};var SoloEditor=function(e){this.conf=e,this.init()};$.extend(SoloEditor.prototype,{init:function(){this.editor=new Vditor(this.conf.id,{cache:!0,hint:{emojiPath:latkeConfig.staticServePath+"/js/lib/emojify.js-1.1.0/images/basic"},preview:{delay:500,show:this.conf.previewShow,url:latkeConfig.servePath+"/console/markdown/2html",parse:function(e){"none"!==e.style.display&&(Util.parseMarkdown("content-reset"),Label.markedAvailable||(hljs.initHighlighting.called=!1,hljs.initHighlighting()))}},upload:{max:10485760,url:Label.uploadURL,token:Label.uploadToken,filename:function(e){return e.replace(/\?|\\|\/|:|\||<|>|\*|\[|\]|\s+/g,"-")}},height:this.conf.height,counter:102400,resize:{enable:this.conf.resize},lang:Label.localeString,classes:{preview:"content-reset"}}),"function"==typeof this.conf.fun&&this.conf.fun()},getContent:function(){return this.editor.getValue()},setContent:function(e){this.editor.setValue(e)},remove:function(){document.getElementById(this.editor.vditor.id).outerHTML=""}}),admin.editors.articleEditor={},admin.editors.abstractEditor={},admin.editors.pageEditor={};
var TablePaginate=function(a){this.id=a,this.currentPage=1};$.extend(TablePaginate.prototype,{buildTable:function(a,t){var e={colModel:a,noDataTip:Label.noDataLabel};t||(e.expendRow={index:"expendRow"}),$("#"+this.id+"Table").table(e)},initPagination:function(){var a=this.id;$("#"+a+"Pagination").paginate({bind:function(a,t){t?$("#tipMsg").text(t):admin.setHashByPage(a)},currentPage:1,errorMessage:Label.inputErrorLabel,nextPageText:">",previousPageText:"<",goText:Label.gotoLabel,type:"custom",custom:[1],pageCount:1})},initCommentsDialog:function(){var a=this;$("#"+this.id+"Comments").dialog({modal:!0,hideFooter:!0,close:function(){return admin[a.id+"List"].getList(a.currentPage),!0}})},updateTablePagination:function(a,t,e){if((t=parseInt(t))>e.paginationPageCount&&1<t)return $("#tipMsg").text(Label.pageLabel+t+Label.notFoundLabel),void $("#loadMsg").text("");$("#"+this.id+"Table").table("update",{data:[{groupName:"all",groupData:a}]}),0===e.paginationPageCount&&(e.paginationPageCount=1),$("#"+this.id+"Pagination").paginate("update",{pageCount:e.paginationPageCount,currentPage:t,custom:e.paginationPageNums}),this.currentPage=t}});
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, 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/>.
*/
var Util={isArticlePage:function(e){var t=!0;return-1<e.indexOf(latkeConfig.servePath+"/tags/")&&(t=!1),-1<e.indexOf(latkeConfig.servePath+"/tags.html")&&(t=!1),-1<e.indexOf(latkeConfig.servePath+"/category/")&&(t=!1),-1<e.indexOf(latkeConfig.servePath+"/archives.html")&&(t=!1),-1<e.indexOf(latkeConfig.servePath+"/archives/")&&(t=!1),-1<e.indexOf(latkeConfig.servePath+"/links.html")&&(t=!1),e===latkeConfig.servePath&&(t=!1),/^[0-9]*$/.test(e.replace(latkeConfig.servePath+"/",""))&&(t=!1),t},initPjax:function(e){1===$("#pjax").length&&($.pjax({selector:"a",container:"#pjax",show:"",cache:!1,storage:!0,titleSuffix:"",filter:function(e){return e===latkeConfig.servePath+"/rss.xml"||-1<e.indexOf(latkeConfig.servePath+"/admin-index.do")||!(-1<e.indexOf(latkeConfig.servePath))},callback:function(){e&&e()}}),NProgress.configure({showSpinner:!1}),$("#pjax").bind("pjax.start",function(){NProgress.start()}),$("#pjax").bind("pjax.end",function(){window.scroll(window.scrollX,0),NProgress.done()}))},parseMarkdown:function(){var e=!1,t=!1,i="content-reset";if($("."+i).each(function(){$(this).find("p").each(function(){(2<$(this).text().split("$").length||1<$(this).text().split("\\(").length&&1<$(this).text().split("\\)").length)&&(e=!0)}),0<$(this).find("code.lang-flow, code.language-flow").length&&(t=!0)}),e){var n=function(){MathJax.Hub.Config({tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"]],processEscapes:!0,processEnvironments:!0,skipTags:["pre","code","script"]},asciimath2jax:{delimiters:[["$","$"]]}}),MathJax.Hub.Typeset()};"undefined"!=typeof MathJax?n():$.ajax({method:"GET",url:"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML",dataType:"script",cache:!0}).done(function(){n()})}if(t){var o=function(){$("."+i+" code.lang-flow, ."+i+" code.language-flow").each(function(e){var t=$(this),i="symFlow"+(new Date).getTime()+e;t.hide();var n=flowchart.parse($.trim(t.text()));t.parent().after('<div style="text-align: center" id="'+i+'"></div>'),n.drawSVG(i),t.parent().remove(),$("#"+i).find("svg").height("auto").width("auto")})};"undefined"!=typeof flowchart?o():$.ajax({method:"GET",url:latkeConfig.staticServePath+"/js/lib/flowchart/flowchart.min.js",dataType:"script",cache:!0}).done(function(){o()})}},killIE:function(e){var t=navigator.userAgent.split("MSIE")[1];t&&(e||(e=7),parseFloat(t.split(";"))<=e&&function(){if(""===Cookie.readCookie("showKill"))try{var t="<div style='display: block; height: 100%; width: 100%; position: fixed; background-color: rgb(0, 0, 0); opacity: 0.6;filter: alpha(opacity=60); top: 0px;z-index:110'></div><iframe style='left:"+($(window).width()-781)/2+"px;z-index:120;top: "+($(window).height()-680)/2+"px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='"+latkeConfig.servePath+"/kill-browser'></iframe>";$("body").append(t)}catch(e){t="<div style='display: block; height: 100%; width: 100%; position: fixed; background-color: rgb(0, 0, 0); opacity: 0.6;filter: alpha(opacity=60); top: 0px;z-index:110'></div><iframe style='left:10px;z-index:120;top: 0px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='"+latkeConfig.servePath+"/kill-browser'></iframe>",document.body.innerHTML=document.body.innerHTML+t}}())},replaceEmString:function(e){var t=e.split("[em");if(1===t.length)return e;e=t[0];for(var i=1;i<t.length;i++){var n=t[i].substr(0,2);e+="<img width='20' src='"+latkeConfig.staticServePath+"/images/emotions/em"+n+".png' alt='"+Label["em"+n+"Label"]+"' title='"+Label["em"+n+"Label"]+"'/> "+t[i].substr(3)}return e},switchMobile:function(e){Cookie.createCookie("btouch_switch_toggle",e,365),setTimeout(function(){location.reload()},1250)},setTopBar:function(){var e=$("#top");if(1===e.length){var t=$("#showTop");t.click(function(){e.slideDown(),t.hide()}),$("#hideTop").click(function(){e.slideUp(),t.show()})}},goTop:function(){$("html, body").animate({scrollTop:0},800)},goBottom:function(e){e||(e=0),$("html, body").animate({scrollTop:$(document).height()-$(window).height()-e},800)},init:function(){Util.killIE(),Util.setTopBar(),Util.parseMarkdown(),Util.initSW()},initSW:function(){navigator.serviceWorker&&navigator.serviceWorker.register("/sw.js",{scope:"/"})},replaceSideEm:function(e){for(var t=0;t<e.length;t++){var i=$(e[t]);i.html(Util.replaceEmString(i.html()))}},buildTags:function(e){e=e||"tags";for(var t=["tags1","tags2","tags3","tags4","tags5"],i=$("#"+e+" b").get(),n=parseInt($("#"+e+" b").last().text()),o=Math.ceil(n/t.length),a=0;a<i.length;a++)for(var r=parseInt(i[a].innerHTML),s=0;s<t.length;s++)if(s*o<r&&r<=(s+1)*o){i[a].parentNode.className=t[s];break}$("#"+e).html($("#"+e+" li").get().sort(function(e,t){var i=$(e).find("span").text().toLowerCase(),n=$(t).find("span").text().toLowerCase();return i.localeCompare(n)}))},toDate:function(e,t){var i=new Date(e),n={"M+":i.getMonth()+1,"d+":i.getDate(),"H+":i.getHours(),"m+":i.getMinutes(),"s+":i.getSeconds(),"q+":Math.floor((i.getMonth()+3)/3),S:i.getMilliseconds()};for(var o in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(i.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+o+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?n[o]:("00"+n[o]).substr((""+n[o]).length)));return t}};if(!Cookie)var Cookie={readCookie:function(e){for(var t=e+"=",i=document.cookie.split(";"),n=0;n<i.length;n++){for(var o=i[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(t))return decodeURIComponent(o.substring(t.length,o.length))}return""},eraseCookie:function(e){this.createCookie(e,"",-1)},createCookie:function(e,t,i){var n="";if(i){var o=new Date;o.setTime(o.getTime()+24*i*60*60*1e3),n="; expires="+o.toGMTString()}document.cookie=e+"="+encodeURIComponent(t)+n+"; path=/"}};
\ No newline at end of file
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, 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/>.
*/
var Page=function(e){this.currentCommentId="",this.tips=e};$.extend(Page.prototype,{replaceCommentsEm:function(e){for(var t=$(e),o=0;o<t.length;o++){var i=t[o].innerHTML;t[o].innerHTML=Util.replaceEmString(i)}},parseLanguage:function(e){var t=!1;$(".content-reset pre").each(function(){t=!0}),t&&(document.createStyleSheet?document.createStyleSheet(latkeConfig.staticServePath+"/js/lib/highlight-9.13.1/styles/"+(e&&e.theme||"github")+".css"):$("head").append($("<link rel='stylesheet' href='"+latkeConfig.staticServePath+"/js/lib/highlight-9.13.1/styles/"+(e&&e.theme||"github")+".css'>")),Label.markedAvailable||$.ajax({url:latkeConfig.staticServePath+"/js/lib/highlight-9.13.1/highlight.pack.js",dataType:"script",cache:!0,success:function(){hljs.initHighlighting.called=!1,hljs.initHighlighting()}}))},load:function(e){var t=this;t.parseLanguage(e),$("#comment").click(function(){t.toggleEditor()}).attr("readonly","readonly"),$("#soloEditorCancel").click(function(){t.toggleEditor()}),$("#soloEditorAdd").click(function(){t.submitComment()})},toggleEditor:function(e,t){var o=this;"undefined"==typeof Vditor&&$.ajax({method:"GET",url:latkeConfig.staticServePath+"/js/lib/vditor-0.2.5/index.min.js",dataType:"script",cache:!0,async:!1,success:function(){window.vditor=new Vditor("soloEditorComment",{placeholder:o.tips.commentContentCannotEmptyLabel,height:180,hint:{emojiPath:latkeConfig.staticServePath+"/js/lib/emojify.js-1.1.0/images/basic"},esc:function(){$("#soloEditorCancel").click()},ctrlEnter:function(){$("#soloEditorAdd").click()},preview:{delay:500,show:!1,url:latkeConfig.servePath+"/console/markdown/2html",parse:function(e){"none"!==e.style.display&&(Util.parseMarkdown("content-reset"),Label.markedAvailable||(hljs.initHighlighting.called=!1,hljs.initHighlighting()))}},counter:500,resize:{enable:!0,position:"top",after:function(){$("body").css("padding-bottom",$("#soloEditor").outerHeight())}},lang:o.tips.langLabel,toolbar:["emoji","headings","bold","italic","strike","|","line","quote","|","list","ordered-list","check","|","code","inline-code","|","undo","redo","|","link","table","|","preview","fullscreen","info","help"],classes:{preview:"content__reset"}}),vditor.focus()}});var i=$("#soloEditor");0!==i.length?"0px"===$("body").css("padding-bottom")||e?($("#soloEditorError").text(""),i.css({bottom:"0",opacity:1}),$("body").css("padding-bottom","238px"),this.currentCommentId=e,$("#soloEditorReplyTarget").text(t?"@"+t:""),"undefined"!=typeof vditor&&vditor.focus()):(i.css({bottom:"-300px",opacity:0}),$("body").css("padding-bottom",0)):location.href=latkeConfig.servePath+"/start"},loadRandomArticles:function(s){var c=this.tips.randomArticles1Label;$.ajax({url:latkeConfig.servePath+"/articles/random",type:"POST",success:function(e,t){var o=e.randomArticles;if(o&&0!==o.length){for(var i="",n=0;n<o.length;n++){var l=o[n],a=l.articleTitle;i+="<li><a rel='nofollow' title='"+a+"' href='"+latkeConfig.servePath+l.articlePermalink+"'>"+a+"</a></li>"}var r=(s||"<h4>"+c+"</h4>")+"<ul>"+i+"</ul>";$("#randomArticles").append(r)}else $("#randomArticles").remove()}})},loadRelevantArticles:function(e,s){$.ajax({url:latkeConfig.servePath+"/article/id/"+e+"/relevant/articles",type:"GET",success:function(e,t){var o=e.relevantArticles;if(o&&0!==o.length){for(var i="",n=0;n<o.length;n++){var l=o[n],a=l.articleTitle;i+="<li><a rel='nofollow' title='"+a+"' href='"+latkeConfig.servePath+l.articlePermalink+"'>"+a+"</a></li>"}var r=s+"<ul>"+i+"</ul>";$("#relevantArticles").append(r)}else $("#relevantArticles").remove()},error:function(){$("#relevantArticles").remove()}})},loadExternalRelevantArticles:function(e,s){var c=this.tips;try{$.ajax({url:"https://rhythm.b3log.org/get-articles-by-tags.do?tags="+e+"&blogHost="+c.blogHost+"&paginationPageSize="+c.externalRelevantArticlesDisplayCount,type:"GET",cache:!0,dataType:"jsonp",error:function(){$("#externalRelevantArticles").remove()},success:function(e,t){var o=e.articles;if(o&&0!==o.length){for(var i="",n=0;n<o.length;n++){var l=o[n],a=l.articleTitle;i+="<li><a rel='nofollow' title='"+a+"' target='_blank' href='"+l.articlePermalink+"'>"+a+"</a></li>"}var r=(s||"<h4>"+c.externalRelevantArticles1Label+"</h4>")+"<ul>"+i+"</ul>";$("#externalRelevantArticles").append(r)}else $("#externalRelevantArticles").remove()}})}catch(e){}},submitComment:function(){var t=this,e=this.tips,o="article";if(void 0===e.externalRelevantArticlesDisplayCount&&(o="page"),1<vditor.getValue().length&&vditor.getValue().length<500){$("#soloEditorAdd").attr("disabled","disabled");var i={oId:e.oId,commentContent:vditor.getValue()};this.currentCommentId&&(i.commentOriginalCommentId=this.currentCommentId),$.ajax({type:"POST",url:latkeConfig.servePath+"/"+o+"/comments",cache:!1,contentType:"application/json",data:JSON.stringify(i),success:function(e){$("#soloEditorAdd").removeAttr("disabled"),e.sc?(t.toggleEditor(),vditor.setValue(""),t.addCommentAjax(Util.replaceEmString(e.cmtTpl))):$("#soloEditorError").html(e.msg)}})}else $("#soloEditorError").text(t.tips.commentContentCannotEmptyLabel)},addReplyForm:function(e,t){this.currentCommentId=e,this.toggleEditor(e,t)},hideComment:function(e){$("#commentRef"+e).hide()},showComment:function(e,t,o,i){var n=parseInt($(e).position().top);if(i&&(n=parseInt($(e).parents(i).position().top)),0<$("#commentRef"+t).length)$("#commentRef"+t).show().css("top",n+o+"px");else{var l=$("#"+t).clone();l.addClass("comment-body-ref").attr("id","commentRef"+t),l.find("#replyForm").remove(),$("#comments").append(l),$("#commentRef"+t).css("top",n+o+"px")}},addCommentAjax:function(e){0<$("#comments").children().length?$($("#comments").children()[0]).before(e):$("#comments").html(e),window.location.hash="#comments"}});
\ No newline at end of file
......@@ -49,51 +49,6 @@ public class PreferenceConsoleTestCase extends AbstractTestCase {
super.init();
}
/**
* getReplyNotificationTemplate.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void getReplyNotificationTemplate() throws Exception {
final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/console/reply/notification/template");
mockAdminLogin(request);
final MockHttpServletResponse response = mockResponse();
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "sc\":true"));
}
/**
* updateReplyNotificationTemplate.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "getReplyNotificationTemplate")
public void updateReplyNotificationTemplate() throws Exception {
final JSONObject p = getPreferenceQueryService().getReplyNotificationTemplate();
final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/console/reply/notification/template");
request.setMethod("PUT");
final JSONObject requestJSON = new JSONObject();
requestJSON.put("replyNotificationTemplate", p);
final BufferedReader reader = new BufferedReader(new StringReader(requestJSON.toString()));
request.setReader(reader);
mockAdminLogin(request);
final MockHttpServletResponse response = mockResponse();
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "sc\":true"));
}
/**
* getSigns.
*
......
......@@ -51,7 +51,6 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
final JSONObject another = new JSONObject();
another.put(User.USER_NAME, "test1");
another.put(User.USER_EMAIL, "test1@gmail.com");
another.put(User.USER_URL, "https://b3log.org");
another.put(User.USER_ROLE, Role.DEFAULT_ROLE);
another.put(UserExt.USER_AVATAR, "");
......@@ -66,7 +65,6 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
JSONObject admin = new JSONObject();
admin.put(User.USER_NAME, "test");
admin.put(User.USER_EMAIL, "test@gmail.com");
admin.put(User.USER_URL, "https://b3log.org");
admin.put(User.USER_ROLE, Role.ADMIN_ROLE);
admin.put(UserExt.USER_AVATAR, "");
......@@ -87,7 +85,7 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
final JSONArray users = result.getJSONArray(Keys.RESULTS);
Assert.assertEquals(users.length(), 1);
Assert.assertEquals(users.getJSONObject(0).getString(User.USER_EMAIL), "test1@gmail.com");
Assert.assertEquals(users.getJSONObject(0).getString(User.USER_NAME), "test1");
final JSONObject notFound = userRepository.getByUserName("not.found");
Assert.assertNull(notFound);
......
......@@ -61,24 +61,4 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
preference = preferenceQueryService.getPreference();
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "updated blog title");
}
/**
* Update Reply Notification Template.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void updateReplyNotificationTemplate() throws Exception {
final PreferenceMgmtService preferenceMgmtService = getPreferenceMgmtService();
final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.toString(), Option.DefaultPreference.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
replyNotificationTemplate.put("subject", "updated subject");
preferenceMgmtService.updateReplyNotificationTemplate(replyNotificationTemplate);
replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.getString("subject"), "updated subject");
}
}
......@@ -54,17 +54,4 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "Solo 的个人博客");
}
/**
* Get Reply Notification Template.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void getReplyNotificationTemplate() throws Exception {
final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
final JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.toString(), Option.DefaultPreference.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
}
}
......@@ -48,7 +48,6 @@ public class UserMgmtServiceTestCase extends AbstractTestCase {
final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "user1name");
requestJSONObject.put(User.USER_EMAIL, "test1@gmail.com");
final String id = userMgmtService.addUser(requestJSONObject);
Assert.assertNotNull(id);
......@@ -65,7 +64,6 @@ public class UserMgmtServiceTestCase extends AbstractTestCase {
JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "user2name");
requestJSONObject.put(User.USER_EMAIL, "test2@gmail.com");
requestJSONObject.put(User.USER_ROLE, Role.ADMIN_ROLE);
final String id = userMgmtService.addUser(requestJSONObject);
......@@ -91,7 +89,6 @@ public class UserMgmtServiceTestCase extends AbstractTestCase {
final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "user1 name");
requestJSONObject.put(User.USER_EMAIL, "test1@gmail.com");
try {
final String id = userMgmtService.addUser(requestJSONObject);
......@@ -110,8 +107,7 @@ public class UserMgmtServiceTestCase extends AbstractTestCase {
final UserMgmtService userMgmtService = getUserMgmtService();
final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "username");
requestJSONObject.put(User.USER_EMAIL, "<script></script>");
requestJSONObject.put(User.USER_NAME, "<script></script>");
final String id = userMgmtService.addUser(requestJSONObject);
}
......
......@@ -47,7 +47,6 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "user1name");
requestJSONObject.put(User.USER_EMAIL, "test1@gmail.com");
final String id = userMgmtService.addUser(requestJSONObject);
Assert.assertNotNull(id);
......
#
# Solo - A small and beautiful blogging system written in Java.
# Copyright (c) 2010-2019, 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/>.
#
#
# Description: Solo logging configurations for test.
# Version: 1.0.0.0, Mar 3, 2019
# Author: <a href="http://88250.b3log.org">Liang Ding</a>
#
log4j.rootLogger=INFO,stdout
log4j.logger.org.b3log.solo=INFO
log4j.logger.org.b3log.latke=WARN
log4j.logger.org.b3log.latke.util.freemarker.Templates=ERROR
log4j.logger.org.b3log.latke.repository.jdbc.util=WARN
log4j.logger.org.eclipse.jetty=WARN
log4j.logger.freemarker=WARN
log4j.logger.com.mchange=WARN
log4j.logger.com.alibaba=WARN
# Print only messages of level ERROR or above in the package noModule.
log4j.logger.noModule=ERROR
# Console appender
log4j.appender.stdout.Encoding=UTF-8
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%-5p]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n
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