Commit 0f1aa2a6 authored by Liang Ding's avatar Liang Ding

🎨 #12764

parent 549af2ea
......@@ -24,7 +24,7 @@ import org.json.JSONObject;
* This class defines all comment model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.1, Mar 3, 2019
* @version 1.2.0.2, Apr 19, 2019
* @since 0.3.1
*/
public final class Comment {
......@@ -89,11 +89,6 @@ public final class Comment {
*/
public static final String COMMENT_ORIGINAL_COMMENT_NAME = "commentOriginalCommentName";
/**
* Key of comment on type.
*/
public static final String COMMENT_ON_TYPE = "commentOnType";
/**
* Key of comment on id.
*/
......
......@@ -21,7 +21,7 @@ package org.b3log.solo.model;
* This class defines all page model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.2, Apr 18, 2019
* @version 1.2.0.0, Apr 19, 2019
* @since 0.3.1
*/
public final class Page {
......@@ -51,42 +51,16 @@ public final class Page {
*/
public static final String PAGE_ORDER = "pageOrder";
/**
* Key of comment count.
*/
public static final String PAGE_COMMENT_COUNT = "pageCommentCount";
/**
* Key of permalink.
*/
public static final String PAGE_PERMALINK = "pagePermalink";
/**
* Key of comments.
*/
public static final String PAGE_COMMENTS_REF = "pageComments";
/**
* Key of comment-able.
*/
public static final String PAGE_COMMENTABLE = "pageCommentable";
/**
* Key of page type.
* <p>
* Available values:
* <ul>
* <li>link</li>
* No contents (pageContent), if users clicked, just jump to the given address specified by the permalink.
* <li>page</li>
* A normal customized page.
* </ul>
* </p>
* <p>
* "page" 类型已经废除 https://github.com/b3log/solo/issues/12764
*/
public static final String PAGE_TYPE = "pageType";
/**
* Key of open target.
* <p>
......
......@@ -345,7 +345,6 @@ public class B3Receiver {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
comment.put(Comment.COMMENT_ON_ID, articleId);
comment.put(Comment.COMMENT_ON_TYPE, Article.ARTICLE);
final String commentSharpURL = Comment.getCommentSharpURLForArticle(article, commentId);
comment.put(Comment.COMMENT_SHARP_URL, commentSharpURL);
commentRepository.add(comment);
......
......@@ -18,6 +18,7 @@
package org.b3log.solo.processor.console;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.Inject;
......@@ -42,7 +43,7 @@ import org.json.JSONObject;
* Plugin console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.10, Mar 29, 2019
* @version 1.0.0.11, Apr 19, 2019
* @since 0.4.0
*/
@RequestProcessor
......@@ -353,8 +354,8 @@ public class PageConsole {
for (int i = 0; i < pages.length(); i++) {
final JSONObject page = pages.getJSONObject(i);
if ("page".equals(page.optString(Page.PAGE_TYPE))) {
final String permalink = page.optString(Page.PAGE_PERMALINK);
if (StringUtils.startsWith(permalink, "/")) {
page.put(Page.PAGE_PERMALINK, Latkes.getServePath() + permalink);
}
......
......@@ -24,7 +24,6 @@ import org.b3log.latke.logging.Logger;
import org.b3log.latke.repository.*;
import org.b3log.latke.repository.annotation.Repository;
import org.b3log.solo.cache.CommentCache;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment;
import org.json.JSONObject;
......@@ -165,16 +164,11 @@ public class CommentRepository extends AbstractRepository {
while (iterator.hasNext()) {
final JSONObject comment = iterator.next();
final String commentOnType = comment.optString(Comment.COMMENT_ON_TYPE);
if (Article.ARTICLE.equals(commentOnType)) {
final String articleId = comment.optString(Comment.COMMENT_ON_ID);
if (!articleRepository.isPublished(articleId)) {
iterator.remove();
}
}
}
LOGGER.debug("Removed unpublished articles' comments....");
}
......
......@@ -273,13 +273,11 @@ public class ArticleMgmtService {
JSONObject page = pageRepository.getByPermalink(permalink);
if (null == page) {
page = new JSONObject();
page.put(Page.PAGE_COMMENT_COUNT, 0);
final int maxOrder = pageRepository.getMaxOrder();
page.put(Page.PAGE_ORDER, maxOrder + 1);
page.put(Page.PAGE_TITLE, "我的开源");
page.put(Page.PAGE_OPEN_TARGET, "_self");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "link");
page.put(Page.PAGE_PERMALINK, permalink);
page.put(Page.PAGE_ICON, "images/github-icon.png");
page.put(Page.PAGE_CONTENT, content);
......
......@@ -48,7 +48,7 @@ import java.util.Date;
* Comment management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.0.0, Apr 18, 2019
* @version 1.4.0.1, Apr 19, 2019
* @since 0.3.5
*/
@Service
......@@ -311,7 +311,6 @@ public class CommentMgmtService {
setCommentThumbnailURL(comment);
ret.put(Comment.COMMENT_THUMBNAIL_URL, comment.getString(Comment.COMMENT_THUMBNAIL_URL));
comment.put(Comment.COMMENT_ON_ID, articleId);
comment.put(Comment.COMMENT_ON_TYPE, Article.ARTICLE);
final String commentId = Ids.genTimeMillisId();
comment.put(Keys.OBJECT_ID, commentId);
ret.put(Keys.OBJECT_ID, commentId);
......
......@@ -33,7 +33,6 @@ import org.b3log.latke.util.Paginator;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Common;
import org.b3log.solo.model.Page;
import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.PageRepository;
......@@ -52,7 +51,7 @@ import java.util.List;
* Comment query service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.2.6, Mar 17, 2019
* @version 1.3.2.6, Apr 19, 2019
* @since 0.3.5
*/
@Service
......@@ -114,12 +113,6 @@ public class CommentQueryService {
}
final String onId = comment.optString(Comment.COMMENT_ON_ID);
final String onType = comment.optString(Comment.COMMENT_ON_TYPE);
if (Page.PAGE.equals(onType)) {
return false; // Only admin can access page comment
}
final JSONObject article = articleRepository.get(onId);
if (null == article) {
return false;
......@@ -174,21 +167,10 @@ public class CommentQueryService {
final JSONObject comment = comments.getJSONObject(i);
String title;
final String onType = comment.getString(Comment.COMMENT_ON_TYPE);
final String onId = comment.getString(Comment.COMMENT_ON_ID);
if (Article.ARTICLE.equals(onType)) {
final JSONObject article = articleRepository.get(onId);
title = article.getString(Article.ARTICLE_TITLE);
comment.put(Common.TYPE, Common.ARTICLE_COMMENT_TYPE);
} else { // It's a comment of page
final JSONObject page = pageRepository.get(onId);
title = page.getString(Page.PAGE_TITLE);
comment.put(Common.TYPE, Common.PAGE_COMMENT_TYPE);
}
comment.put(Common.COMMENT_TITLE, title);
String commentContent = comment.optString(Comment.COMMENT_CONTENT);
......
......@@ -864,9 +864,8 @@ public class DataModelService {
LOGGER.debug("Filling page navigations....");
final List<JSONObject> pages = pageRepository.getPages();
for (final JSONObject page : pages) {
if ("page".equals(page.optString(Page.PAGE_TYPE))) {
final String permalink = page.optString(Page.PAGE_PERMALINK);
if (StringUtils.startsWith(permalink, "/")) {
page.put(Page.PAGE_PERMALINK, Latkes.getServePath() + permalink);
}
}
......
......@@ -40,8 +40,6 @@ import org.b3log.solo.model.*;
import org.b3log.solo.model.Option.DefaultPreference;
import org.b3log.solo.repository.*;
import org.b3log.solo.util.Images;
import org.b3log.solo.util.Skins;
import org.b3log.solo.util.Solos;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -49,7 +47,6 @@ import org.json.JSONObject;
import java.sql.Connection;
import java.text.ParseException;
import java.util.List;
import java.util.Set;
/**
* Solo initialization service.
......@@ -290,7 +287,6 @@ public class InitService {
comment.put(Comment.COMMENT_THUMBNAIL_URL, "https://img.hacpai.com/avatar/1353745196354_1535379434567.png?imageView2/1/w/64/h/64/q/100");
comment.put(Comment.COMMENT_CREATED, now);
comment.put(Comment.COMMENT_ON_ID, articleId);
comment.put(Comment.COMMENT_ON_TYPE, Article.ARTICLE);
final String commentId = Ids.genTimeMillisId();
comment.put(Keys.OBJECT_ID, commentId);
final String commentSharpURL = Comment.getCommentSharpURLForArticle(article, commentId);
......
......@@ -19,6 +19,7 @@ package org.b3log.solo.service;
import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.Inject;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
......@@ -27,7 +28,6 @@ import org.b3log.latke.repository.Transaction;
import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service;
import org.b3log.latke.util.Ids;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Page;
import org.b3log.solo.repository.CommentRepository;
......@@ -42,7 +42,7 @@ import java.util.List;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @version 1.1.0.17, Apr 18, 2019
* @version 1.1.0.18, Apr 19, 2019
* @since 0.4.0
*/
@Service
......@@ -120,7 +120,6 @@ public class PageMgmtService {
* "pageCommentCount": int,
* "pagePermalink": "",
* "pageCommentable": boolean,
* "pageType": "",
* "pageOpenTarget": "",
* "pageIcon": "" // optional
* }
......@@ -135,16 +134,14 @@ public class PageMgmtService {
final JSONObject oldPage = pageRepository.get(pageId);
final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page));
newPage.put(Page.PAGE_ORDER, oldPage.getInt(Page.PAGE_ORDER));
newPage.put(Page.PAGE_COMMENT_COUNT, oldPage.getInt(Page.PAGE_COMMENT_COUNT));
String permalink = page.optString(Page.PAGE_PERMALINK).trim();
final String oldPermalink = oldPage.getString(Page.PAGE_PERMALINK);
if (!oldPermalink.equals(permalink)) {
if (StringUtils.isBlank(permalink)) {
permalink = "/pages/" + pageId + ".html";
permalink = Latkes.getServePath();
}
if (Page.PAGE.equals(page.getString(Page.PAGE_TYPE))) {
if (!permalink.startsWith("/")) {
permalink = "/" + permalink;
}
......@@ -165,7 +162,6 @@ public class PageMgmtService {
throw new ServiceException(langPropsService.get("duplicatedPermalinkLabel"));
}
}
}
newPage.put(Page.PAGE_PERMALINK, permalink.replaceAll(" ", "-"));
......@@ -223,7 +219,6 @@ public class PageMgmtService {
* "pageContent": "",
* "pageOpenTarget": "",
* "pageCommentable": boolean,
* "pageType": "",
* "pagePermalink": "", // optional
* "pageIcon": "" // optional
* }
......@@ -236,16 +231,14 @@ public class PageMgmtService {
try {
final JSONObject page = requestJSONObject.getJSONObject(Page.PAGE);
page.put(Page.PAGE_COMMENT_COUNT, 0);
final int maxOrder = pageRepository.getMaxOrder();
page.put(Page.PAGE_ORDER, maxOrder + 1);
String permalink = page.optString(Page.PAGE_PERMALINK);
if (StringUtils.isBlank(permalink)) {
permalink = "/pages/" + Ids.genTimeMillisId() + ".html";
permalink = Latkes.getServePath();
}
if (Page.PAGE.equals(page.getString(Page.PAGE_TYPE))) {
if (!permalink.startsWith("/")) {
permalink = "/" + permalink;
}
......@@ -265,7 +258,6 @@ public class PageMgmtService {
throw new ServiceException(langPropsService.get("duplicatedPermalinkLabel"));
}
}
page.put(Page.PAGE_PERMALINK, permalink.replaceAll(" ", "-"));
......
......@@ -35,7 +35,7 @@ import java.util.regex.Pattern;
* Permalink query service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.6, Feb 7, 2019
* @version 1.0.0.7, Apr 19, 2019
* @since 0.6.1
*/
@Service
......@@ -83,19 +83,6 @@ public class PermalinkQueryService {
return matcher.matches();
}
/**
* Checks whether the specified page permalink matches the system generated format pattern ("/pages/${pageId}.html").
*
* @param permalink the specified permalink
* @return {@code true} if matches, returns {@code false} otherwise
*/
public static boolean matchDefaultPagePermalinkFormat(final String permalink) {
final Pattern pattern = Pattern.compile("/pages/\\d+\\.html");
final Matcher matcher = pattern.matcher(permalink);
return matcher.matches();
}
/**
* Checks whether the specified permalink is a {@link #invalidArticlePermalinkFormat(java.lang.String) invalid article
* permalink format} and {@link #invalidPagePermalinkFormat(java.lang.String) invalid page permalink format}.
......@@ -136,10 +123,6 @@ public class PermalinkQueryService {
return true;
}
if (matchDefaultPagePermalinkFormat(permalink)) {
return false;
}
return invalidUserDefinedPermalinkFormat(permalink);
}
......
......@@ -18,6 +18,7 @@
package org.b3log.solo.upgrade;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.BeanManager;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
......@@ -25,6 +26,7 @@ import org.b3log.latke.repository.FilterOperator;
import org.b3log.latke.repository.PropertyFilter;
import org.b3log.latke.repository.Query;
import org.b3log.latke.repository.Transaction;
import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.solo.model.*;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.OptionRepository;
......@@ -33,6 +35,8 @@ import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.service.ArticleMgmtService;
import org.json.JSONObject;
import java.sql.Connection;
import java.sql.Statement;
import java.util.List;
/**
......@@ -86,6 +90,14 @@ public final class V350_360 {
* 去掉自定义页面 https://github.com/b3log/solo/issues/12764
*/
private static void convertPagesToArticles() throws Exception {
final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix") + "_";
final Connection connection = Connections.getConnection();
final Statement statement = connection.createStatement();
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "page` DROP COLUMN `pageType`");
statement.close();
connection.commit();
connection.close();
final BeanManager beanManager = BeanManager.getInstance();
final PageRepository pageRepository = beanManager.getReference(PageRepository.class);
final CommentRepository commentRepository = beanManager.getReference(CommentRepository.class);
......@@ -94,11 +106,11 @@ public final class V350_360 {
final JSONObject admin = userRepository.getAdmin();
final List<JSONObject> pages = pageRepository.getList(new Query().
setFilter(new PropertyFilter(Page.PAGE_TYPE, FilterOperator.EQUAL, Page.PAGE)));
setFilter(new PropertyFilter("pageType", FilterOperator.EQUAL, Page.PAGE)));
for (final JSONObject page : pages) {
final String title = page.optString(Page.PAGE_TITLE);
final String content = page.optString(Page.PAGE_CONTENT);
final int commentCnt = page.optInt(Page.PAGE_COMMENT_COUNT);
final int commentCnt = page.optInt("pageCommentCount");
final String permalink = page.optString(Page.PAGE_PERMALINK);
final boolean commentable = page.optBoolean(Page.PAGE_COMMENTABLE);
......@@ -126,11 +138,9 @@ public final class V350_360 {
final Transaction transaction = pageRepository.beginTransaction();
for (final JSONObject comment : comments) {
comment.put(Comment.COMMENT_ON_ID, articleId);
comment.put(Comment.COMMENT_ON_TYPE, Article.ARTICLE);
final String commentId = comment.optString(Keys.OBJECT_ID);
commentRepository.update(commentId, comment);
}
page.put(Page.PAGE_TYPE, "link");
pageRepository.update(pageId, page);
transaction.commit();
......
{
"description": "Description of repository structures, for generation of the relational database table and persistence validation.",
"version": "3.2.1.6, Mar 4, 2019",
"version": "3.2.1.7, Apr 19, 2019",
"authors": [
"Liang Ding"
],
......@@ -229,11 +229,6 @@
"type": "String",
"length": 19
},
{
"name": "pageCommentCount",
"description": "页面评论计数",
"type": "int"
},
{
"name": "pageContent",
"description": "页面内容",
......@@ -262,12 +257,6 @@
"description": "页面是否可以评论",
"type": "boolean"
},
{
"name": "pageType",
"description": "页面类型,自定义导航:link,普通页面:page",
"type": "String",
"length": 10
},
{
"name": "pageOpenTarget",
"description": "页面打开方式",
......
......@@ -51,6 +51,5 @@
</div>
<div class="fn__clear"></div>
</div>
<div id="pageComments" class="fn__none"></div>
<div class="fn__clear"></div>
${plugins}
......@@ -80,12 +80,7 @@ admin.commentList = {
commentsData = []
for (var i = 0; i < comments.length; i++) {
var type = 'Article'
if (comments[i].type === 'pageComment') {
type = 'Page'
}
commentsData[i] = {}
commentsData[i].content = '<div class="vditor-reset">' +
Util.replaceEmString(comments[i].commentContent) +
'</div><span class=\'table-tag\'> on &nbsp;&nbsp;</span><a href=\'' +
......
......@@ -40,7 +40,7 @@ import java.io.StringReader;
* {@link CommentProcessorTestCase} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.5, Feb 10, 2019
* @version 1.0.0.6, Apr 19, 2019
* @since 1.7.0
*/
@Test(suiteName = "processor")
......@@ -98,7 +98,6 @@ public class CommentProcessorTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
return pageMgmtService.addPage(requestJSONObject);
......
......@@ -36,7 +36,7 @@ import java.io.StringReader;
* {@link PageConsole} 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, Apr 19, 2019
* @since 2.9.8
*/
@Test(suiteName = "processor")
......@@ -69,7 +69,6 @@ public class PageConsoleTestCase extends AbstractTestCase {
page.put(Page.PAGE_CONTENT, "");
page.put(Page.PAGE_PERMALINK, "https://hacpai.com");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "link");
page.put(Page.PAGE_OPEN_TARGET, "");
page.put(Page.PAGE_ICON, "");
final BufferedReader reader = new BufferedReader(new StringReader(requestJSON.toString()));
......
......@@ -31,7 +31,7 @@ import java.util.List;
* {@link ArticleRepository} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.2, Sep 16, 2018
* @version 1.0.0.3, Apr 19, 2019
*/
@Test(suiteName = "repository")
public class CommentRepositoryImplTestCase extends AbstractTestCase {
......@@ -51,7 +51,6 @@ public class CommentRepositoryImplTestCase extends AbstractTestCase {
comment.put(Comment.COMMENT_CREATED, new Date().getTime());
comment.put(Comment.COMMENT_NAME, "comment1 name");
comment.put(Comment.COMMENT_ON_ID, "comment1 on id");
comment.put(Comment.COMMENT_ON_TYPE, "comment1 on type");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
comment.put(Comment.COMMENT_SHARP_URL, "comment1 sharp url");
......
......@@ -31,7 +31,7 @@ import java.util.List;
* {@link PageRepository} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.3, Sep 22, 2017
* @version 1.0.0.4, Apr 19, 2019
*/
@Test(suiteName = "repository")
public class PageRepositoryImplTestCase extends AbstractTestCase {
......@@ -48,14 +48,11 @@ public class PageRepositoryImplTestCase extends AbstractTestCase {
Assert.assertEquals(pageRepository.getMaxOrder(), -1);
final JSONObject page = new JSONObject();
page.put(Page.PAGE_COMMENT_COUNT, 0);
page.put(Page.PAGE_CONTENT, "page1 content");
page.put(Page.PAGE_ORDER, 0);
page.put(Page.PAGE_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
page.put(Page.PAGE_ICON, "");
......@@ -94,14 +91,11 @@ public class PageRepositoryImplTestCase extends AbstractTestCase {
final PageRepository pageRepository = getPageRepository();
final JSONObject page = new JSONObject();
page.put(Page.PAGE_COMMENT_COUNT, 0);
page.put(Page.PAGE_CONTENT, "page2 content");
page.put(Page.PAGE_ORDER, 1);
page.put(Page.PAGE_PERMALINK, "page2 permalink");
page.put(Page.PAGE_TITLE, "page2 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
page.put(Page.PAGE_ICON, "");
......@@ -123,14 +117,11 @@ public class PageRepositoryImplTestCase extends AbstractTestCase {
final PageRepository pageRepository = getPageRepository();
final JSONObject page = new JSONObject();
page.put(Page.PAGE_COMMENT_COUNT, 0);
page.put(Page.PAGE_CONTENT, "page3 content");
page.put(Page.PAGE_ORDER, 2);
page.put(Page.PAGE_PERMALINK, "page3 permalink");
page.put(Page.PAGE_TITLE, "page3 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
page.put(Page.PAGE_ICON, "");
......
......@@ -105,7 +105,6 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject);
......
......@@ -27,7 +27,7 @@ import org.testng.annotations.Test;
* {@link PageMgmtService} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.2, Sep 11, 2012
* @version 1.0.0.3, Apr 19, 2019
*/
@Test(suiteName = "service")
public class PageMgmtServiceTestCase extends AbstractTestCase {
......@@ -59,7 +59,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject);
......@@ -84,7 +83,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page2 permalink");
page.put(Page.PAGE_TITLE, "page2 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject);
......@@ -119,7 +117,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page3 permalink");
page.put(Page.PAGE_TITLE, "page3 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject);
......@@ -156,7 +153,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page4 permalink");
page.put(Page.PAGE_TITLE, "page4 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject);
......
......@@ -28,7 +28,7 @@ import org.testng.annotations.Test;
* {@link PageQueryService} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.2, Sep 11, 2012
* @version 1.0.0.3, Apr 19, 2019
*/
@Test(suiteName = "service")
public class PageQueryServiceTestCase extends AbstractTestCase {
......@@ -60,7 +60,6 @@ public class PageQueryServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject);
......
......@@ -24,52 +24,22 @@ import org.testng.annotations.Test;
* {@link org.b3log.solo.service.PermalinkQueryService} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Jun 21, 2013
* @version 1.0.0.1, Apr 19, 2019
* @since 0.6.1
*/
public final class PermalinkQueryServiceTestCase {
/**
* Test method for {@linkplain Permalinks#matchDefaultArticlePermalinkFormat(java.lang.String)}.
* Test method for {@linkplain PermalinkQueryService#matchDefaultArticlePermalinkFormat(java.lang.String)}.
*/
@Test
public void matchDefaultArticlePermalinkFormat() {
Assert.assertTrue(
PermalinkQueryService.matchDefaultArticlePermalinkFormat(
"/articles/1986/08/25/1234567890.html"));
Assert.assertFalse(
PermalinkQueryService.matchDefaultArticlePermalinkFormat(
"/articles/1986/0/25/1234567890.html"));
Assert.assertFalse(
PermalinkQueryService.matchDefaultArticlePermalinkFormat(
"/articles/1.html"));
Assert.assertFalse(
PermalinkQueryService.matchDefaultArticlePermalinkFormat(
"/articles/1986/08/25/a.html"));
Assert.assertFalse(
PermalinkQueryService.matchDefaultArticlePermalinkFormat(
"/articles/1986/aa/25/1234567890.html"));
Assert.assertFalse(
PermalinkQueryService.matchDefaultArticlePermalinkFormat(
"/1986/aa/25/1234567890.html"));
Assert.assertFalse(
PermalinkQueryService.matchDefaultArticlePermalinkFormat(
"/articles/1986/08/25/1234567890html"));
}
/**
* Test method for {@linkplain Permalinks#matchDefaultPagePermalinkFormat(java.lang.String)}.
*/
@Test
public void matchDefaultPagePermalinkFormat() {
Assert.assertTrue(PermalinkQueryService.matchDefaultPagePermalinkFormat(
"/pages/1234567890.html"));
Assert.assertFalse(PermalinkQueryService.matchDefaultPagePermalinkFormat(
"/pages.html"));
Assert.assertFalse(PermalinkQueryService.matchDefaultPagePermalinkFormat(
"/1234567890.html"));
Assert.assertFalse(PermalinkQueryService.matchDefaultPagePermalinkFormat(
"/pages/a1234567890.html"));
Assert.assertTrue(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/08/25/1234567890.html"));
Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/0/25/1234567890.html"));
Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1.html"));
Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/08/25/a.html"));
Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/aa/25/1234567890.html"));
Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/1986/aa/25/1234567890.html"));
Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/08/25/1234567890html"));
}
}
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