Commit d5af438b authored by Liang Ding's avatar Liang Ding

💚 修复单元测试

parent 6cb882f4
/*
* 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/>.
*/
package org.b3log.solo.util;
import jodd.http.HttpRequest;
......
This diff is collapsed.
/**
* 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/>.
*/
body,dd,div,dl,h1,h2,h3,h4,h5,h6,html,img,li,ol,p,ul{padding:0;margin:0}.clear,.fn-clear:after{clear:both}.form th,.nowrap{white-space:nowrap}.goBottomIcon,.goTopIcon{position:fixed;right:20px}#tags,#tags li{list-style:none}body{background-color:#FFF;color:#000;font-family:elvetica,Arial,sans-serif,'\5fae\8f6f\96c5\9ed1';font-size:small}img{border:none;vertical-align:middle}h1{font-size:160%}h2{font-size:140%}h3{font-size:120%}h4{font-size:110%}textarea{overflow:auto}.button,button{background:url(../images/icon.png) center bottom;border:1px solid;border-color:#CCC #BBB #A0A0A0;border-radius:4px;height:28px;margin:0;padding:0 6px;vertical-align:top}.button:hover,button:hover{border-color:#BBB}.padding12{padding:12px}.paddingBottom12{padding-bottom:12px!important}.paddingTop12{padding-top:12px!important}.margin12{margin:12px}.marginTop12{margin-top:12px!important}.marginBottom12{margin-bottom:12px!important}.marginLeft12{margin-left:12px!important}.marginLeft6{margin-left:6px!important}.marginRight12{margin-right:12px!important}.f-bold{font-weight:700!important}.left{float:left}.right{float:right}.clear{background-color:transparent;border:0;display:block;font-size:0;height:0;line-height:0;overflow:hidden}.fn-clear:after,.fn-clear:before{display:table;content:""}.fn__flex{display:flex}.fn__flex1{flex:1;min-width:1px}.fn__flex-inline{display:inline-flex!important;align-items:center}.none{display:none}.pointer{cursor:pointer}.no-underline{text-decoration:none!important}#tags a,.logo{text-decoration:none}.red{color:red}.contentBody{margin-bottom:12px;padding:3px 12px}.form th{text-align:right}.form input[type=text],.form input[type=password],.form textarea{border-color:silver #D9D9D9 #D9D9D9;border-right:1px solid #D9D9D9;border-style:solid;border-width:1px;font-family:Helvetica,Arial,sans-serif;font-size:12px;outline:0;width:99%;padding:0 3px}.form input{height:24px}.form input[type=checkbox]{border:0;vertical-align:sub;height:20px}.form input.normalInput{width:auto}.form input[type=checkbox]:focus{border:0;box-shadow:0 0 0}.form input:focus,.form textarea:focus{box-shadow:0 1px 2px rgba(0,0,0,.3) inset}.form textarea{padding:3px;overflow:auto;resize:vertical}.logo{padding:0 5px;text-shadow:0 0 1px #EEE}.article-body h1,.article-body h2{padding-bottom:.3em;border-bottom:1px solid #eee}.aboutIcon,.adminIcon,.articlesIcon,.browserIcon,.cacheIcon,.calendarIcon,.commentIcon,.deleteIcon,.draftsIcon,.falseIcon,.fileIcon,.goBottomIcon,.goTopIcon,.homeIcon,.linkIcon,.loginIcon,.logoutIcon,.notPutTopIcon,.othersIcon,.pageIcon,.postIcon,.preferenceIcon,.putTopIcon,.trueIcon,.updateIcon,.usersIcon{background-image:url(../images/icon.png);cursor:pointer;height:16px;width:16px}.adminIcon,.homeIcon,.loginIcon,.logoutIcon{margin-top:3px}.pageIcon{background-position:-144px 0}.postIcon{background-position:-16px 0}.linkIcon{background-position:-32px 0}.preferenceIcon{background-position:-48px 0}.articlesIcon{background-position:-64px 0}.trueIcon{background-position:-80px 0;cursor:auto}.falseIcon{background-position:-96px 0;cursor:auto}.fileIcon{background-position:-112px 0}.deleteIcon{background-position:0 -16px}.updateIcon{background-position:-16px -16px}.commentIcon{background-position:-32px -16px}.homeIcon{background-position:-64px -16px}.adminIcon{background-position:-80px -16px}.logoutIcon{background-position:-96px -16px}.loginIcon{background-position:-112px -16px}.browserIcon{background-position:-128px -16px}.calendarIcon{background-position:-144px -16px}.putTopIcon{background-position:-16px -32px;float:left}.notPutTopIcon{background-position:-32px -32px;float:left}.othersIcon{background-position:-48px -32px}.cacheIcon,.draftsIcon{background-position:-96px -32px}.usersIcon{background-position:-112px -32px}.goTopIcon{background-position:-64px -32px;top:45%}.goBottomIcon{background-position:-80px -32px;bottom:40%}.article-body{word-wrap:break-word;overflow:auto;line-height:1.65;font-size:16px;word-break:break-word}.article-body ol,.article-body ul{padding-left:2em;margin-top:0;margin-bottom:16px}.article-body li{margin-top:.25em}.article-body img{cursor:zoom-in}.article-body img.emoji{cursor:auto;max-width:18px}#captcha,#captchaReply,#emotions span{cursor:pointer}.article-body h1,.article-body h2,.article-body h3,.article-body h4,.article-body h5,.article-body h6{margin-top:24px;margin-bottom:16px;font-weight:600;line-height:1.25}.article-body h1{font-size:1.7em}.article-body h2{font-size:1.5em}.article-body h3{font-size:1.25em}.article-body h4{font-size:1em}.article-body h5{font-size:.875em}.article-body h6{font-size:.85em}.article-body hr{height:.15em;padding:0;margin:24px 0;background-color:#e7e7e7;border:0}.article-body p{margin-top:0;margin-bottom:16px}.article-body blockquote{padding:0 1em;color:#777;border-left:.25em solid #ddd;margin-bottom:16px}.article-body blockquote p{margin:0}.article-body ins>iframe{border:0}.article-body iframe{border:1px solid rgba(0,0,0,.38)}.article-body table{width:100%;border:1px solid #dedede;margin:15px auto;border-collapse:collapse;empty-cells:show}.article-body thead{text-align:center}.article-body td,.article-body th{height:35px;border:1px solid #dedede;padding:0 10px}.article-body th{font-weight:700;text-align:center!important;background:rgba(158,188,226,.2)}.article-body tbody tr:nth-child(2n){background:rgba(158,188,226,.12)}.article-body tr:hover{background:#efefef}.article-body code{padding:.2em .4em;margin:0;font-size:85%;background-color:rgba(252,41,41,.12);border-radius:3px;word-break:break-word}.article-body pre{position:relative}.article-body pre textarea{position:absolute;top:-100000px}.article-body pre>code{padding:.5em;background-color:rgba(0,0,0,.04);background-size:20px 20px;border-radius:5px;display:block}.article-body kbd{display:inline-block;padding:3px 5px;font:11px Consolas,"Liberation Mono",Menlo,Courier,monospace;line-height:10px;color:#555;vertical-align:middle;background-color:#fcfcfc;border:1px solid rgba(0,0,0,.38);border-bottom-color:#bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb}.article-body .task-list-item,.article-body__task{list-style:none;margin-left:-1em}.em00,.em01,.em02,.em03,.em04,.em05,.em06,.em07,.em08,.em09,.em10,.em11,.em12,.em13,.em14{background-image:url(../images/emotions/emotions.png);background-size:120px;float:left;height:24px;margin-right:5px;width:24px}.em01{background-position:-24px 0}.em02{background-position:-48px 0}.em03{background-position:-72px 0}.em04{background-position:-96px 0}.em05{background-position:0 -24px}.em06{background-position:-24px -24px}.em07{background-position:-48px -24px}.em08{background-position:-72px -24px}.em09{background-position:-96px -24px}.em10{background-position:0 -48px}.em11{background-position:-24px -48px}.em12{background-position:-48px -48px}.em13{background-position:-72px -48px}.em14{background-position:-96px -48px}#tags li{float:left;height:38px}#tags a:hover{text-shadow:0 0 2px #555}#tags a{border-radius:3px;box-shadow:1px 1px 3px #555;float:left;margin:3px 6px;padding:3px 12px}#tags .tags1{font-size:12px;font-weight:400}#tags .tags2{font-size:14px;font-weight:400}#tags .tags3{font-size:16px;font-weight:400}#tags .tags4{font-size:18px;font-weight:700}#tags .tags5{font-size:20px;font-weight:700}
\ 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/>.
*/
.error,button{font-weight:700}.wrap,body,html{min-height:100vh}.content,.logo{align-self:center}.content-reset img,.img-error{max-width:100%}body,html{margin:0;padding:0}body{background-color:#fff;color:#3b3e43;font-family:\5fae\8f6f\96c5\9ed1;font-size:small}button{background-size:110% 110%;border:1px solid rgba(27,31,35,.2);font-size:13px;text-shadow:0 1px 0 rgba(255,255,255,.9);white-space:nowrap;background-color:#eff3f6;background-image:linear-gradient(-180deg,#fafbfc,#eff3f6 90%);color:#24292e;border-radius:3px;box-shadow:0 1px 3px rgba(0,0,0,.075);outline:0;padding:7px 15px;margin-top:10px;cursor:pointer}button:hover{background-color:#e6ebf1;background-image:linear-gradient(-180deg,#f0f3f6,#e6ebf1 90%);background-position:-.5em;border-color:rgba(27,31,35,.35)}a{color:#4285f4;text-decoration:none}h2{background-color:#F3F1E5;border-radius:4px 4px 0 0;font-size:16px;margin:0;padding:10px 20px}input[type=password],input[type=text]{border:1px solid #d1d5da;background-color:#FAFAFA;border-radius:3px;box-shadow:inset 0 1px 2px rgba(27,31,35,.075);padding:7px 8px;width:100%;line-height:17px;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;outline:0;margin-top:10px}input[type=password]:focus,input[type=text]:focus{background-color:#FFF;box-shadow:inset 0 1px 2px rgba(27,31,35,.075),0 0 0 .2em #dbedff;border:1px solid #4285f4}.error{color:#d23f31}.wrap{border-top:5px solid #E6E5D9;background-color:#F3F1E5;display:flex;flex-direction:column;box-sizing:border-box}.content-wrap{flex:1;display:flex}.content{background-color:#fff;margin:0 auto;width:760px;display:flex}.main{border-left:1px solid #E6E5D9;font-size:15px;padding:20px;flex:1}.logo{width:217px;text-align:center}.logo img{height:128px;width:128px}.footerWrapper{background-color:#FFF;border-top:1px solid #E6E5D9;padding:12px 0;text-align:center}.a-error{text-align:right}#github,.content-reset thead{text-align:center}.img-error{margin:20px auto;padding:0;display:block}.content-reset h1,.content-reset h2{padding-bottom:.3em;border-bottom:1px solid #eee}.kill img{position:absolute;right:40px;top:200px}.kill ul{margin-bottom:50px}.kill p{margin:12px 20px}.kill span{margin-left:20px}#github{position:relative}#github.github--loading:after{content:"Loading...";position:absolute;height:100%;width:100%;top:0;left:0;z-index:7;background-color:rgba(255,255,255,.6);font-size:22px;text-align:center;padding-top:135px;color:#000;text-shadow:0 1px 2px rgba(0,0,0,.2);box-sizing:border-box}#github .github__icon{height:300px;width:400px;background-image:url(../images/github.png);margin:0 auto;background-size:contain;cursor:pointer}#github .github__icon:hover{background-image:url(../images/github.gif)}#github img{display:none}#github span{cursor:pointer;font-size:12px;color:#999}.content-reset{word-wrap:break-word;overflow:auto;line-height:1.65;font-size:16px;word-break:break-word}.content-reset ol,.content-reset ul{padding-left:2em;margin-top:0;margin-bottom:16px}.content-reset li{margin-top:.25em}.content-reset img.emoji{max-width:18px}.content-reset h1,.content-reset h2,.content-reset h3,.content-reset h4,.content-reset h5,.content-reset h6{margin-top:24px;margin-bottom:16px;font-weight:600;line-height:1.25}.content-reset h1{font-size:1.7em}.content-reset h2{font-size:1.5em}.content-reset h3{font-size:1.25em}.content-reset h4{font-size:1em}.content-reset h5{font-size:.875em}.content-reset h6{font-size:.85em}.content-reset hr{height:.15em;padding:0;margin:24px 0;background-color:#e7e7e7;border:0}.content-reset p{margin-top:0;margin-bottom:16px}.content-reset blockquote{padding:0 1em;color:#777;border-left:.25em solid #ddd;margin-bottom:16px}.content-reset blockquote p{margin:0}.content-reset ins>iframe{border:0}.content-reset iframe{border:1px solid rgba(0,0,0,.38)}.content-reset table{width:100%;border:1px solid #dedede;margin:15px auto;border-collapse:collapse;empty-cells:show}.content-reset td,.content-reset th{height:35px;border:1px solid #dedede;padding:0 10px}.content-reset th{font-weight:700;text-align:center!important;background:rgba(158,188,226,.2)}.content-reset tbody tr:nth-child(2n){background:rgba(158,188,226,.12)}.content-reset tr:hover{background:#efefef}.content-reset code{padding:.2em .4em;margin:0;font-size:85%;background-color:rgba(252,41,41,.12);border-radius:3px;word-break:break-word}.content-reset pre{position:relative}.content-reset pre textarea{position:absolute;top:-100000px}.content-reset pre>code{padding:.5em;background-color:rgba(0,0,0,.04);background-size:20px 20px;border-radius:5px;display:block}.content-reset kbd{display:inline-block;padding:3px 5px;font:11px Consolas,"Liberation Mono",Menlo,Courier,monospace;line-height:10px;color:#555;vertical-align:middle;background-color:#fcfcfc;border:1px solid rgba(0,0,0,.38);border-bottom-color:#bbb;border-radius:3px;box-shadow:inset 0 -1px 0 #bbb}.content-reset .task-list-item,.content-reset__task{list-style:none;margin-left:-1em}.search{border-top:5px solid #e6e5d9;background-color:#f3f1e5;padding:20px 0 20px 84px;min-height:480px;flex:1}.search__body{display:flex;flex-direction:column}.search__header{margin:20px;display:flex}.search__header a{line-height:44px}.search__input{flex:1}.search__input input{margin:0 10px 0 20px;width:523px;height:44px;line-height:44px}.search__input button{height:44px;margin:0}.search__articles{width:600px}.search__articles header h1{margin:0}.search__articles header h1>a{font-size:18px;text-decoration:none;font-weight:400}.search__articles .meta{font-size:14px;color:#999}.search__articles footer{margin-bottom:30px}.search__articles footer a{text-decoration:none;font-size:13px}.search__articles footer a:hover,.search__articles header h1>a:hover,.search__pagination a:hover{text-decoration:underline}.search__pagination a{color:#4285f4;text-decoration:none}.search__pagination a,.search__pagination span{margin-right:5px}@media (max-width:780px){.content,.main{width:auto}.main,.search__input{float:none}.wrap{padding:40px 0}.logo,.search__header img,.search__header>.fn-right{display:none}.main{border:0}#init,.search,input{width:100%;box-sizing:border-box}input{display:block}.a-403,.a-404,.a-500{margin:0 20px 0 0}#init{padding:0 20px;left:0}.search__input input{margin:0}.search__input button{position:absolute;right:20px;height:32px;line-height:16px}.search{padding:20px;min-height:auto}.search__articles{width:auto}}
\ 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 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?goto="+latkeConfig.servePath},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 right",$(t).addClass("tab-current")):($(t).find(".icon-chevron-up")[0].className="icon-chevron-down 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(t){this.conf=t,this.init()};$.extend(SoloEditor.prototype,{init:function(){this.editor=new Vditor(this.conf.id,{cache:!0,preview:{delay:500,show:!1,url:latkeConfig.servePath+"/console/markdown/2html",parse:function(t){"none"!==t.style.display&&(Util.parseMarkdown("content-reset"),Label.markedAvailable||(hljs.initHighlighting.called=!1,hljs.initHighlighting()))}},upload:{max:10485760,url:"https://hacpai.com/upload/editor"},height:this.conf.height,counter:102400,resize:{enable:!1},lang:Label.localeString,classes:{preview:"content-reset"}}),"function"==typeof this.conf.fun&&this.conf.fun()},getContent:function(){return this.editor.getValue()},setContent:function(t){this.editor.setValue(t)},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={htmlDecode:function(e){var t=document.createElement("div");return t.innerHTML=decodeURIComponent(e),t.innerText},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(e){var t=!1,i=!1;e=e||"article-body";if($("."+e).each(function(){if($(this).find("p").each(function(){if(2<$(this).text().split("$").length||1<$(this).text().split("\\(").length&&1<$(this).text().split("\\)").length)return!(t=!0)}),0<$(this).find("code.lang-flow, code.language-flow").length)return!(i=!0)}),t){var n=function(){MathJax.Hub.Config({tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"]],processEscapes:!0,processEnvironments:!0,skipTags:["pre","code","script"]}}),MathJax.Hub.Typeset()};"undefined"!=typeof MathJax?n():$.ajax({method:"GET",url:"https://cdn.staticfile.org/MathJax/MathJax-2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&_=1473258780393",dataType:"script",cache:!0}).done(function(){n()})}if(i){var o=function(){$("."+e+" code.lang-flow, ."+e+" 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()})}},isLoggedIn:function(){return!!(1===$("#admin").length&&$("#admin").data("login")||"true"===latkeConfig.isLoggedIn)},getUserName:function(){return 1===$("#adminName").length?$("#adminName").text():latkeConfig.userName},error:function(){$("#tipMsg").text("Error: "+arguments[0]+" File: "+arguments[1]+"\nLine: "+arguments[2]+" please report this issue on https://github.com/b3log/solo/issues/new"),$("#loadMsg").text("")},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},proessURL:function(e){return/^\w+:\/\//.test(e)||(e="http://"+e),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);var t=$("body").height()>$(document).height()?$("body").height():$(document).height();window.scrollTo(0,t-$(window).height()-e)},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},getWinHeight:function(){return window.innerHeight?window.innerHeight:"CSS1Compat"===document.compatMode?window.document.documentElement.clientHeight:window.document.body.clientHeight}};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
This diff is collapsed.
......@@ -123,7 +123,7 @@ public abstract class AbstractTestCase {
final InitService initService = getInitService();
final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_EMAIL, "test@gmail.com");
requestJSONObject.put(User.USER_NAME, "Admin");
requestJSONObject.put(User.USER_NAME, "Solo");
requestJSONObject.put(UserExt.USER_B3_KEY, "pass");
initService.init(requestJSONObject);
final UserQueryService userQueryService = getUserQueryService();
......
......@@ -182,7 +182,7 @@ public class ArticleProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "Admin 的个人博客</title>"));
Assert.assertTrue(StringUtils.contains(content, "Solo 的个人博客</title>"));
}
/**
......@@ -202,7 +202,7 @@ public class ArticleProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "Admin 的个人博客</title>"));
Assert.assertTrue(StringUtils.contains(content, "Solo 的个人博客</title>"));
}
/**
......@@ -223,7 +223,7 @@ public class ArticleProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "<title>Admin 的个人博客 - 访问密码</title>"));
Assert.assertTrue(StringUtils.contains(content, "<title>Solo 的个人博客 - 访问密码</title>"));
}
/**
......
......@@ -82,6 +82,6 @@ public class CategoryProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "<title>分类1 - Admin 的个人博客</title>"));
Assert.assertTrue(StringUtils.contains(content, "<title>分类1 - Solo 的个人博客</title>"));
}
}
......@@ -55,6 +55,6 @@ public class ErrorProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "<title>Admin 的个人博客 - 403 Forbidden!</title>"));
Assert.assertTrue(StringUtils.contains(content, "<title>Solo 的个人博客 - 403 Forbidden!</title>"));
}
}
......@@ -73,7 +73,7 @@ public class IndexProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "<title>Admin 的个人博客</title>"));
Assert.assertTrue(StringUtils.contains(content, "<title>Solo 的个人博客</title>"));
}
/**
......@@ -87,7 +87,7 @@ public class IndexProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "<title>Admin 的个人博客 - 403 Forbidden!</title>"));
Assert.assertTrue(StringUtils.contains(content, "<title>Solo 的个人博客 - 403 Forbidden!</title>"));
}
/**
......
......@@ -67,7 +67,7 @@ public class PageProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "page1 title - Admin 的个人博客"));
Assert.assertTrue(StringUtils.contains(content, "page1 title - Solo 的个人博客"));
}
private JSONObject addPage() throws Exception {
......
......@@ -71,6 +71,6 @@ public class SearchProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "Admin 的个人博客搜索"));
Assert.assertTrue(StringUtils.contains(content, "Solo 的个人博客搜索"));
}
}
......@@ -58,6 +58,6 @@ public class TagProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "<title>Solo - Admin 的个人博客</title>"));
Assert.assertTrue(StringUtils.contains(content, "<title>Solo - Solo 的个人博客</title>"));
}
}
......@@ -58,6 +58,6 @@ public class UserTemplateProcessorTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "<title>友情链接 - Admin 的个人博客</title>"));
Assert.assertTrue(StringUtils.contains(content, "<title>友情链接 - Solo 的个人博客</title>"));
}
}
......@@ -59,7 +59,7 @@ public class AdminConsoleTestCase extends AbstractTestCase {
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "后台管理 - Admin 的个人博客"));
Assert.assertTrue(StringUtils.contains(content, "后台管理 - Solo 的个人博客"));
}
/**
......
......@@ -35,7 +35,7 @@ import java.io.StringReader;
* {@link UserConsole} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Dec 11, 2018
* @version 1.0.0.1, Feb 8, 2019
* @since 2.9.8
*/
@Test(suiteName = "processor")
......@@ -51,39 +51,14 @@ public class UserConsoleTestCase extends AbstractTestCase {
super.init();
}
/**
* addUser.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void addUser() throws Exception {
final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/console/user/");
request.setMethod("POST");
final JSONObject requestJSON = new JSONObject();
requestJSON.put(User.USER_NAME, "D");
requestJSON.put(User.USER_EMAIL, "d@b3log.org");
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"));
}
/**
* updateUser.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "addUser")
@Test(dependsOnMethods = "init")
public void updateUser() throws Exception {
final JSONObject u = getUserRepository().getList(new Query()).get(1);
final JSONObject u = getUserRepository().getFirst(new Query());
final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/console/user/");
......@@ -107,7 +82,7 @@ public class UserConsoleTestCase extends AbstractTestCase {
*/
@Test(dependsOnMethods = "updateUser")
public void getUser() throws Exception {
final JSONObject u = getUserRepository().getList(new Query()).get(1);
final JSONObject u = getUserRepository().getFirst(new Query());
final String userId = u.optString(Keys.OBJECT_ID);
final MockHttpServletRequest request = mockRequest();
......@@ -148,7 +123,7 @@ public class UserConsoleTestCase extends AbstractTestCase {
*/
@Test(dependsOnMethods = "getUsers")
public void changeUserRole() throws Exception {
final JSONObject u = getUserRepository().getList(new Query()).get(1);
final JSONObject u = getUserRepository().getFirst(new Query());
final String userId = u.optString(Keys.OBJECT_ID);
final MockHttpServletRequest request = mockRequest();
......@@ -170,7 +145,7 @@ public class UserConsoleTestCase extends AbstractTestCase {
*/
@Test(dependsOnMethods = "changeUserRole")
public void removeUser() throws Exception {
final JSONObject u = getUserRepository().getList(new Query()).get(1);
final JSONObject u = getUserRepository().getFirst(new Query());
final String userId = u.optString(Keys.OBJECT_ID);
final MockHttpServletRequest request = mockRequest();
......
......@@ -35,7 +35,7 @@ import org.testng.annotations.Test;
* {@link UserRepository} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.2, Oct 17, 2015
* @version 1.1.0.3, Feb 8, 2019
*/
@Test(suiteName = "repository")
public final class UserRepositoryImplTestCase extends AbstractTestCase {
......@@ -55,6 +55,8 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
another.put(User.USER_URL, "https://b3log.org");
another.put(User.USER_ROLE, Role.DEFAULT_ROLE);
another.put(UserExt.USER_AVATAR, "");
another.put(UserExt.USER_GITHUB_ID, "");
another.put(UserExt.USER_B3_KEY, "");
Transaction transaction = userRepository.beginTransaction();
userRepository.add(another);
......@@ -68,6 +70,8 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
admin.put(User.USER_URL, "https://b3log.org");
admin.put(User.USER_ROLE, Role.ADMIN_ROLE);
admin.put(UserExt.USER_AVATAR, "");
admin.put(UserExt.USER_GITHUB_ID, "");
admin.put(UserExt.USER_B3_KEY, "");
transaction = userRepository.beginTransaction();
userRepository.add(admin);
......
......@@ -53,7 +53,7 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
JSONObject preference = preferenceQueryService.getPreference();
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "Admin 的个人博客");
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "Solo 的个人博客");
preference.put(Option.ID_C_BLOG_TITLE, "updated blog title");
preferenceMgmtService.updatePreference(preference);
......
......@@ -52,7 +52,7 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
final JSONObject preference = preferenceQueryService.getPreference();
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "Admin 的个人博客");
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "Solo 的个人博客");
}
/**
......
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