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

🎨 #12764

parent 549af2ea
...@@ -24,7 +24,7 @@ import org.json.JSONObject; ...@@ -24,7 +24,7 @@ import org.json.JSONObject;
* This class defines all comment model relevant keys. * This class defines all comment model relevant keys.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.1
*/ */
public final class Comment { public final class Comment {
...@@ -89,11 +89,6 @@ public final class Comment { ...@@ -89,11 +89,6 @@ public final class Comment {
*/ */
public static final String COMMENT_ORIGINAL_COMMENT_NAME = "commentOriginalCommentName"; 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. * Key of comment on id.
*/ */
......
...@@ -21,7 +21,7 @@ package org.b3log.solo.model; ...@@ -21,7 +21,7 @@ package org.b3log.solo.model;
* This class defines all page model relevant keys. * This class defines all page model relevant keys.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.1
*/ */
public final class Page { public final class Page {
...@@ -51,42 +51,16 @@ public final class Page { ...@@ -51,42 +51,16 @@ public final class Page {
*/ */
public static final String PAGE_ORDER = "pageOrder"; public static final String PAGE_ORDER = "pageOrder";
/**
* Key of comment count.
*/
public static final String PAGE_COMMENT_COUNT = "pageCommentCount";
/** /**
* Key of permalink. * Key of permalink.
*/ */
public static final String PAGE_PERMALINK = "pagePermalink"; public static final String PAGE_PERMALINK = "pagePermalink";
/**
* Key of comments.
*/
public static final String PAGE_COMMENTS_REF = "pageComments";
/** /**
* Key of comment-able. * Key of comment-able.
*/ */
public static final String PAGE_COMMENTABLE = "pageCommentable"; 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. * Key of open target.
* <p> * <p>
......
...@@ -345,7 +345,6 @@ public class B3Receiver { ...@@ -345,7 +345,6 @@ public class B3Receiver {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, ""); comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, ""); comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
comment.put(Comment.COMMENT_ON_ID, articleId); comment.put(Comment.COMMENT_ON_ID, articleId);
comment.put(Comment.COMMENT_ON_TYPE, Article.ARTICLE);
final String commentSharpURL = Comment.getCommentSharpURLForArticle(article, commentId); final String commentSharpURL = Comment.getCommentSharpURLForArticle(article, commentId);
comment.put(Comment.COMMENT_SHARP_URL, commentSharpURL); comment.put(Comment.COMMENT_SHARP_URL, commentSharpURL);
commentRepository.add(comment); commentRepository.add(comment);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package org.b3log.solo.processor.console; package org.b3log.solo.processor.console;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes; import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.Inject; import org.b3log.latke.ioc.Inject;
...@@ -42,7 +43,7 @@ import org.json.JSONObject; ...@@ -42,7 +43,7 @@ import org.json.JSONObject;
* Plugin console request processing. * Plugin console request processing.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.4.0
*/ */
@RequestProcessor @RequestProcessor
...@@ -353,8 +354,8 @@ public class PageConsole { ...@@ -353,8 +354,8 @@ public class PageConsole {
for (int i = 0; i < pages.length(); i++) { for (int i = 0; i < pages.length(); i++) {
final JSONObject page = pages.getJSONObject(i); final JSONObject page = pages.getJSONObject(i);
if ("page".equals(page.optString(Page.PAGE_TYPE))) { final String permalink = page.optString(Page.PAGE_PERMALINK);
final String permalink = page.optString(Page.PAGE_PERMALINK); if (StringUtils.startsWith(permalink, "/")) {
page.put(Page.PAGE_PERMALINK, Latkes.getServePath() + permalink); page.put(Page.PAGE_PERMALINK, Latkes.getServePath() + permalink);
} }
......
...@@ -24,7 +24,6 @@ import org.b3log.latke.logging.Logger; ...@@ -24,7 +24,6 @@ import org.b3log.latke.logging.Logger;
import org.b3log.latke.repository.*; import org.b3log.latke.repository.*;
import org.b3log.latke.repository.annotation.Repository; import org.b3log.latke.repository.annotation.Repository;
import org.b3log.solo.cache.CommentCache; import org.b3log.solo.cache.CommentCache;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment; import org.b3log.solo.model.Comment;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -165,14 +164,9 @@ public class CommentRepository extends AbstractRepository { ...@@ -165,14 +164,9 @@ public class CommentRepository extends AbstractRepository {
while (iterator.hasNext()) { while (iterator.hasNext()) {
final JSONObject comment = iterator.next(); final JSONObject comment = iterator.next();
final String commentOnType = comment.optString(Comment.COMMENT_ON_TYPE); final String articleId = comment.optString(Comment.COMMENT_ON_ID);
if (!articleRepository.isPublished(articleId)) {
if (Article.ARTICLE.equals(commentOnType)) { iterator.remove();
final String articleId = comment.optString(Comment.COMMENT_ON_ID);
if (!articleRepository.isPublished(articleId)) {
iterator.remove();
}
} }
} }
......
...@@ -273,13 +273,11 @@ public class ArticleMgmtService { ...@@ -273,13 +273,11 @@ public class ArticleMgmtService {
JSONObject page = pageRepository.getByPermalink(permalink); JSONObject page = pageRepository.getByPermalink(permalink);
if (null == page) { if (null == page) {
page = new JSONObject(); page = new JSONObject();
page.put(Page.PAGE_COMMENT_COUNT, 0);
final int maxOrder = pageRepository.getMaxOrder(); final int maxOrder = pageRepository.getMaxOrder();
page.put(Page.PAGE_ORDER, maxOrder + 1); page.put(Page.PAGE_ORDER, maxOrder + 1);
page.put(Page.PAGE_TITLE, "我的开源"); page.put(Page.PAGE_TITLE, "我的开源");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "link");
page.put(Page.PAGE_PERMALINK, permalink); page.put(Page.PAGE_PERMALINK, permalink);
page.put(Page.PAGE_ICON, "images/github-icon.png"); page.put(Page.PAGE_ICON, "images/github-icon.png");
page.put(Page.PAGE_CONTENT, content); page.put(Page.PAGE_CONTENT, content);
......
...@@ -48,7 +48,7 @@ import java.util.Date; ...@@ -48,7 +48,7 @@ import java.util.Date;
* Comment management service. * Comment management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.5
*/ */
@Service @Service
...@@ -311,7 +311,6 @@ public class CommentMgmtService { ...@@ -311,7 +311,6 @@ public class CommentMgmtService {
setCommentThumbnailURL(comment); setCommentThumbnailURL(comment);
ret.put(Comment.COMMENT_THUMBNAIL_URL, comment.getString(Comment.COMMENT_THUMBNAIL_URL)); ret.put(Comment.COMMENT_THUMBNAIL_URL, comment.getString(Comment.COMMENT_THUMBNAIL_URL));
comment.put(Comment.COMMENT_ON_ID, articleId); comment.put(Comment.COMMENT_ON_ID, articleId);
comment.put(Comment.COMMENT_ON_TYPE, Article.ARTICLE);
final String commentId = Ids.genTimeMillisId(); final String commentId = Ids.genTimeMillisId();
comment.put(Keys.OBJECT_ID, commentId); comment.put(Keys.OBJECT_ID, commentId);
ret.put(Keys.OBJECT_ID, commentId); ret.put(Keys.OBJECT_ID, commentId);
......
...@@ -33,7 +33,6 @@ import org.b3log.latke.util.Paginator; ...@@ -33,7 +33,6 @@ import org.b3log.latke.util.Paginator;
import org.b3log.solo.model.Article; import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment; import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Common; import org.b3log.solo.model.Common;
import org.b3log.solo.model.Page;
import org.b3log.solo.repository.ArticleRepository; import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.CommentRepository; import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.PageRepository; import org.b3log.solo.repository.PageRepository;
...@@ -52,7 +51,7 @@ import java.util.List; ...@@ -52,7 +51,7 @@ import java.util.List;
* Comment query service. * Comment query service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.3.5
*/ */
@Service @Service
...@@ -114,12 +113,6 @@ public class CommentQueryService { ...@@ -114,12 +113,6 @@ public class CommentQueryService {
} }
final String onId = comment.optString(Comment.COMMENT_ON_ID); 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); final JSONObject article = articleRepository.get(onId);
if (null == article) { if (null == article) {
return false; return false;
...@@ -174,21 +167,10 @@ public class CommentQueryService { ...@@ -174,21 +167,10 @@ public class CommentQueryService {
final JSONObject comment = comments.getJSONObject(i); final JSONObject comment = comments.getJSONObject(i);
String title; String title;
final String onType = comment.getString(Comment.COMMENT_ON_TYPE);
final String onId = comment.getString(Comment.COMMENT_ON_ID); final String onId = comment.getString(Comment.COMMENT_ON_ID);
final JSONObject article = articleRepository.get(onId);
if (Article.ARTICLE.equals(onType)) { title = article.getString(Article.ARTICLE_TITLE);
final JSONObject article = articleRepository.get(onId); comment.put(Common.TYPE, Common.ARTICLE_COMMENT_TYPE);
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); comment.put(Common.COMMENT_TITLE, title);
String commentContent = comment.optString(Comment.COMMENT_CONTENT); String commentContent = comment.optString(Comment.COMMENT_CONTENT);
......
...@@ -864,9 +864,8 @@ public class DataModelService { ...@@ -864,9 +864,8 @@ public class DataModelService {
LOGGER.debug("Filling page navigations...."); LOGGER.debug("Filling page navigations....");
final List<JSONObject> pages = pageRepository.getPages(); final List<JSONObject> pages = pageRepository.getPages();
for (final JSONObject page : pages) { for (final JSONObject page : pages) {
if ("page".equals(page.optString(Page.PAGE_TYPE))) { final String permalink = page.optString(Page.PAGE_PERMALINK);
final String permalink = page.optString(Page.PAGE_PERMALINK); if (StringUtils.startsWith(permalink, "/")) {
page.put(Page.PAGE_PERMALINK, Latkes.getServePath() + permalink); page.put(Page.PAGE_PERMALINK, Latkes.getServePath() + permalink);
} }
} }
......
...@@ -40,8 +40,6 @@ import org.b3log.solo.model.*; ...@@ -40,8 +40,6 @@ import org.b3log.solo.model.*;
import org.b3log.solo.model.Option.DefaultPreference; import org.b3log.solo.model.Option.DefaultPreference;
import org.b3log.solo.repository.*; import org.b3log.solo.repository.*;
import org.b3log.solo.util.Images; 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.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -49,7 +47,6 @@ import org.json.JSONObject; ...@@ -49,7 +47,6 @@ import org.json.JSONObject;
import java.sql.Connection; import java.sql.Connection;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* Solo initialization service. * Solo initialization service.
...@@ -290,7 +287,6 @@ public class InitService { ...@@ -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_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_CREATED, now);
comment.put(Comment.COMMENT_ON_ID, articleId); comment.put(Comment.COMMENT_ON_ID, articleId);
comment.put(Comment.COMMENT_ON_TYPE, Article.ARTICLE);
final String commentId = Ids.genTimeMillisId(); final String commentId = Ids.genTimeMillisId();
comment.put(Keys.OBJECT_ID, commentId); comment.put(Keys.OBJECT_ID, commentId);
final String commentSharpURL = Comment.getCommentSharpURLForArticle(article, commentId); final String commentSharpURL = Comment.getCommentSharpURLForArticle(article, commentId);
......
...@@ -19,6 +19,7 @@ package org.b3log.solo.service; ...@@ -19,6 +19,7 @@ package org.b3log.solo.service;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.Inject; import org.b3log.latke.ioc.Inject;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger; import org.b3log.latke.logging.Logger;
...@@ -27,7 +28,6 @@ import org.b3log.latke.repository.Transaction; ...@@ -27,7 +28,6 @@ import org.b3log.latke.repository.Transaction;
import org.b3log.latke.service.LangPropsService; import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.service.ServiceException; import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service; import org.b3log.latke.service.annotation.Service;
import org.b3log.latke.util.Ids;
import org.b3log.solo.model.Comment; import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Page; import org.b3log.solo.model.Page;
import org.b3log.solo.repository.CommentRepository; import org.b3log.solo.repository.CommentRepository;
...@@ -42,7 +42,7 @@ import java.util.List; ...@@ -42,7 +42,7 @@ import java.util.List;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</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 * @since 0.4.0
*/ */
@Service @Service
...@@ -120,7 +120,6 @@ public class PageMgmtService { ...@@ -120,7 +120,6 @@ public class PageMgmtService {
* "pageCommentCount": int, * "pageCommentCount": int,
* "pagePermalink": "", * "pagePermalink": "",
* "pageCommentable": boolean, * "pageCommentable": boolean,
* "pageType": "",
* "pageOpenTarget": "", * "pageOpenTarget": "",
* "pageIcon": "" // optional * "pageIcon": "" // optional
* } * }
...@@ -135,35 +134,32 @@ public class PageMgmtService { ...@@ -135,35 +134,32 @@ public class PageMgmtService {
final JSONObject oldPage = pageRepository.get(pageId); final JSONObject oldPage = pageRepository.get(pageId);
final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page)); final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page));
newPage.put(Page.PAGE_ORDER, oldPage.getInt(Page.PAGE_ORDER)); 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(); String permalink = page.optString(Page.PAGE_PERMALINK).trim();
final String oldPermalink = oldPage.getString(Page.PAGE_PERMALINK); final String oldPermalink = oldPage.getString(Page.PAGE_PERMALINK);
if (!oldPermalink.equals(permalink)) { if (!oldPermalink.equals(permalink)) {
if (StringUtils.isBlank(permalink)) { if (StringUtils.isBlank(permalink)) {
permalink = "/pages/" + pageId + ".html"; permalink = Latkes.getServePath();
} }
if (Page.PAGE.equals(page.getString(Page.PAGE_TYPE))) { if (!permalink.startsWith("/")) {
if (!permalink.startsWith("/")) { permalink = "/" + permalink;
permalink = "/" + permalink; }
}
if (PermalinkQueryService.invalidPagePermalinkFormat(permalink)) {
if (transaction.isActive()) {
transaction.rollback();
}
throw new ServiceException(langPropsService.get("invalidPermalinkFormatLabel")); if (PermalinkQueryService.invalidPagePermalinkFormat(permalink)) {
if (transaction.isActive()) {
transaction.rollback();
} }
if (!oldPermalink.equals(permalink) && permalinkQueryService.exist(permalink)) { throw new ServiceException(langPropsService.get("invalidPermalinkFormatLabel"));
if (transaction.isActive()) { }
transaction.rollback();
}
throw new ServiceException(langPropsService.get("duplicatedPermalinkLabel")); if (!oldPermalink.equals(permalink) && permalinkQueryService.exist(permalink)) {
if (transaction.isActive()) {
transaction.rollback();
} }
throw new ServiceException(langPropsService.get("duplicatedPermalinkLabel"));
} }
} }
...@@ -223,7 +219,6 @@ public class PageMgmtService { ...@@ -223,7 +219,6 @@ public class PageMgmtService {
* "pageContent": "", * "pageContent": "",
* "pageOpenTarget": "", * "pageOpenTarget": "",
* "pageCommentable": boolean, * "pageCommentable": boolean,
* "pageType": "",
* "pagePermalink": "", // optional * "pagePermalink": "", // optional
* "pageIcon": "" // optional * "pageIcon": "" // optional
* } * }
...@@ -236,35 +231,32 @@ public class PageMgmtService { ...@@ -236,35 +231,32 @@ public class PageMgmtService {
try { try {
final JSONObject page = requestJSONObject.getJSONObject(Page.PAGE); final JSONObject page = requestJSONObject.getJSONObject(Page.PAGE);
page.put(Page.PAGE_COMMENT_COUNT, 0);
final int maxOrder = pageRepository.getMaxOrder(); final int maxOrder = pageRepository.getMaxOrder();
page.put(Page.PAGE_ORDER, maxOrder + 1); page.put(Page.PAGE_ORDER, maxOrder + 1);
String permalink = page.optString(Page.PAGE_PERMALINK); String permalink = page.optString(Page.PAGE_PERMALINK);
if (StringUtils.isBlank(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("/")) {
if (!permalink.startsWith("/")) { permalink = "/" + permalink;
permalink = "/" + permalink; }
}
if (PermalinkQueryService.invalidPagePermalinkFormat(permalink)) {
if (transaction.isActive()) {
transaction.rollback();
}
throw new ServiceException(langPropsService.get("invalidPermalinkFormatLabel")); if (PermalinkQueryService.invalidPagePermalinkFormat(permalink)) {
if (transaction.isActive()) {
transaction.rollback();
} }
if (permalinkQueryService.exist(permalink)) { throw new ServiceException(langPropsService.get("invalidPermalinkFormatLabel"));
if (transaction.isActive()) { }
transaction.rollback();
}
throw new ServiceException(langPropsService.get("duplicatedPermalinkLabel")); if (permalinkQueryService.exist(permalink)) {
if (transaction.isActive()) {
transaction.rollback();
} }
throw new ServiceException(langPropsService.get("duplicatedPermalinkLabel"));
} }
page.put(Page.PAGE_PERMALINK, permalink.replaceAll(" ", "-")); page.put(Page.PAGE_PERMALINK, permalink.replaceAll(" ", "-"));
......
...@@ -35,7 +35,7 @@ import java.util.regex.Pattern; ...@@ -35,7 +35,7 @@ import java.util.regex.Pattern;
* Permalink query service. * Permalink query service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.6.1
*/ */
@Service @Service
...@@ -83,19 +83,6 @@ public class PermalinkQueryService { ...@@ -83,19 +83,6 @@ public class PermalinkQueryService {
return matcher.matches(); 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 * 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}. * permalink format} and {@link #invalidPagePermalinkFormat(java.lang.String) invalid page permalink format}.
...@@ -136,10 +123,6 @@ public class PermalinkQueryService { ...@@ -136,10 +123,6 @@ public class PermalinkQueryService {
return true; return true;
} }
if (matchDefaultPagePermalinkFormat(permalink)) {
return false;
}
return invalidUserDefinedPermalinkFormat(permalink); return invalidUserDefinedPermalinkFormat(permalink);
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package org.b3log.solo.upgrade; package org.b3log.solo.upgrade;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.BeanManager; import org.b3log.latke.ioc.BeanManager;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger; import org.b3log.latke.logging.Logger;
...@@ -25,6 +26,7 @@ import org.b3log.latke.repository.FilterOperator; ...@@ -25,6 +26,7 @@ import org.b3log.latke.repository.FilterOperator;
import org.b3log.latke.repository.PropertyFilter; import org.b3log.latke.repository.PropertyFilter;
import org.b3log.latke.repository.Query; import org.b3log.latke.repository.Query;
import org.b3log.latke.repository.Transaction; import org.b3log.latke.repository.Transaction;
import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.solo.model.*; import org.b3log.solo.model.*;
import org.b3log.solo.repository.CommentRepository; import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.OptionRepository; import org.b3log.solo.repository.OptionRepository;
...@@ -33,6 +35,8 @@ import org.b3log.solo.repository.UserRepository; ...@@ -33,6 +35,8 @@ import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.service.ArticleMgmtService; import org.b3log.solo.service.ArticleMgmtService;
import org.json.JSONObject; import org.json.JSONObject;
import java.sql.Connection;
import java.sql.Statement;
import java.util.List; import java.util.List;
/** /**
...@@ -86,6 +90,14 @@ public final class V350_360 { ...@@ -86,6 +90,14 @@ public final class V350_360 {
* 去掉自定义页面 https://github.com/b3log/solo/issues/12764 * 去掉自定义页面 https://github.com/b3log/solo/issues/12764
*/ */
private static void convertPagesToArticles() throws Exception { 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 BeanManager beanManager = BeanManager.getInstance();
final PageRepository pageRepository = beanManager.getReference(PageRepository.class); final PageRepository pageRepository = beanManager.getReference(PageRepository.class);
final CommentRepository commentRepository = beanManager.getReference(CommentRepository.class); final CommentRepository commentRepository = beanManager.getReference(CommentRepository.class);
...@@ -94,11 +106,11 @@ public final class V350_360 { ...@@ -94,11 +106,11 @@ public final class V350_360 {
final JSONObject admin = userRepository.getAdmin(); final JSONObject admin = userRepository.getAdmin();
final List<JSONObject> pages = pageRepository.getList(new Query(). 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) { for (final JSONObject page : pages) {
final String title = page.optString(Page.PAGE_TITLE); final String title = page.optString(Page.PAGE_TITLE);
final String content = page.optString(Page.PAGE_CONTENT); 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 String permalink = page.optString(Page.PAGE_PERMALINK);
final boolean commentable = page.optBoolean(Page.PAGE_COMMENTABLE); final boolean commentable = page.optBoolean(Page.PAGE_COMMENTABLE);
...@@ -126,11 +138,9 @@ public final class V350_360 { ...@@ -126,11 +138,9 @@ public final class V350_360 {
final Transaction transaction = pageRepository.beginTransaction(); final Transaction transaction = pageRepository.beginTransaction();
for (final JSONObject comment : comments) { for (final JSONObject comment : comments) {
comment.put(Comment.COMMENT_ON_ID, articleId); comment.put(Comment.COMMENT_ON_ID, articleId);
comment.put(Comment.COMMENT_ON_TYPE, Article.ARTICLE);
final String commentId = comment.optString(Keys.OBJECT_ID); final String commentId = comment.optString(Keys.OBJECT_ID);
commentRepository.update(commentId, comment); commentRepository.update(commentId, comment);
} }
page.put(Page.PAGE_TYPE, "link");
pageRepository.update(pageId, page); pageRepository.update(pageId, page);
transaction.commit(); transaction.commit();
......
{ {
"description": "Description of repository structures, for generation of the relational database table and persistence validation.", "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": [ "authors": [
"Liang Ding" "Liang Ding"
], ],
...@@ -229,11 +229,6 @@ ...@@ -229,11 +229,6 @@
"type": "String", "type": "String",
"length": 19 "length": 19
}, },
{
"name": "pageCommentCount",
"description": "页面评论计数",
"type": "int"
},
{ {
"name": "pageContent", "name": "pageContent",
"description": "页面内容", "description": "页面内容",
...@@ -262,12 +257,6 @@ ...@@ -262,12 +257,6 @@
"description": "页面是否可以评论", "description": "页面是否可以评论",
"type": "boolean" "type": "boolean"
}, },
{
"name": "pageType",
"description": "页面类型,自定义导航:link,普通页面:page",
"type": "String",
"length": 10
},
{ {
"name": "pageOpenTarget", "name": "pageOpenTarget",
"description": "页面打开方式", "description": "页面打开方式",
......
...@@ -51,6 +51,5 @@ ...@@ -51,6 +51,5 @@
</div> </div>
<div class="fn__clear"></div> <div class="fn__clear"></div>
</div> </div>
<div id="pageComments" class="fn__none"></div>
<div class="fn__clear"></div> <div class="fn__clear"></div>
${plugins} ${plugins}
...@@ -80,12 +80,7 @@ admin.commentList = { ...@@ -80,12 +80,7 @@ admin.commentList = {
commentsData = [] commentsData = []
for (var i = 0; i < comments.length; i++) { for (var i = 0; i < comments.length; i++) {
var type = 'Article' var type = 'Article'
if (comments[i].type === 'pageComment') {
type = 'Page'
}
commentsData[i] = {} commentsData[i] = {}
commentsData[i].content = '<div class="vditor-reset">' + commentsData[i].content = '<div class="vditor-reset">' +
Util.replaceEmString(comments[i].commentContent) + Util.replaceEmString(comments[i].commentContent) +
'</div><span class=\'table-tag\'> on &nbsp;&nbsp;</span><a href=\'' + '</div><span class=\'table-tag\'> on &nbsp;&nbsp;</span><a href=\'' +
......
...@@ -40,7 +40,7 @@ import java.io.StringReader; ...@@ -40,7 +40,7 @@ import java.io.StringReader;
* {@link CommentProcessorTestCase} test case. * {@link CommentProcessorTestCase} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 1.7.0
*/ */
@Test(suiteName = "processor") @Test(suiteName = "processor")
...@@ -98,7 +98,6 @@ public class CommentProcessorTestCase extends AbstractTestCase { ...@@ -98,7 +98,6 @@ public class CommentProcessorTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page1 permalink"); page.put(Page.PAGE_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title"); page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
return pageMgmtService.addPage(requestJSONObject); return pageMgmtService.addPage(requestJSONObject);
......
...@@ -36,7 +36,7 @@ import java.io.StringReader; ...@@ -36,7 +36,7 @@ import java.io.StringReader;
* {@link PageConsole} test case. * {@link PageConsole} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 2.9.8
*/ */
@Test(suiteName = "processor") @Test(suiteName = "processor")
...@@ -69,7 +69,6 @@ public class PageConsoleTestCase extends AbstractTestCase { ...@@ -69,7 +69,6 @@ public class PageConsoleTestCase extends AbstractTestCase {
page.put(Page.PAGE_CONTENT, ""); page.put(Page.PAGE_CONTENT, "");
page.put(Page.PAGE_PERMALINK, "https://hacpai.com"); page.put(Page.PAGE_PERMALINK, "https://hacpai.com");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "link");
page.put(Page.PAGE_OPEN_TARGET, ""); page.put(Page.PAGE_OPEN_TARGET, "");
page.put(Page.PAGE_ICON, ""); page.put(Page.PAGE_ICON, "");
final BufferedReader reader = new BufferedReader(new StringReader(requestJSON.toString())); final BufferedReader reader = new BufferedReader(new StringReader(requestJSON.toString()));
......
...@@ -31,7 +31,7 @@ import java.util.List; ...@@ -31,7 +31,7 @@ import java.util.List;
* {@link ArticleRepository} test case. * {@link ArticleRepository} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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") @Test(suiteName = "repository")
public class CommentRepositoryImplTestCase extends AbstractTestCase { public class CommentRepositoryImplTestCase extends AbstractTestCase {
...@@ -51,7 +51,6 @@ 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_CREATED, new Date().getTime());
comment.put(Comment.COMMENT_NAME, "comment1 name"); comment.put(Comment.COMMENT_NAME, "comment1 name");
comment.put(Comment.COMMENT_ON_ID, "comment1 on id"); 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_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, ""); comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
comment.put(Comment.COMMENT_SHARP_URL, "comment1 sharp url"); comment.put(Comment.COMMENT_SHARP_URL, "comment1 sharp url");
......
...@@ -31,7 +31,7 @@ import java.util.List; ...@@ -31,7 +31,7 @@ import java.util.List;
* {@link PageRepository} test case. * {@link PageRepository} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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") @Test(suiteName = "repository")
public class PageRepositoryImplTestCase extends AbstractTestCase { public class PageRepositoryImplTestCase extends AbstractTestCase {
...@@ -48,14 +48,11 @@ public class PageRepositoryImplTestCase extends AbstractTestCase { ...@@ -48,14 +48,11 @@ public class PageRepositoryImplTestCase extends AbstractTestCase {
Assert.assertEquals(pageRepository.getMaxOrder(), -1); Assert.assertEquals(pageRepository.getMaxOrder(), -1);
final JSONObject page = new JSONObject(); final JSONObject page = new JSONObject();
page.put(Page.PAGE_COMMENT_COUNT, 0);
page.put(Page.PAGE_CONTENT, "page1 content"); page.put(Page.PAGE_CONTENT, "page1 content");
page.put(Page.PAGE_ORDER, 0); page.put(Page.PAGE_ORDER, 0);
page.put(Page.PAGE_PERMALINK, "page1 permalink"); page.put(Page.PAGE_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title"); page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
page.put(Page.PAGE_ICON, ""); page.put(Page.PAGE_ICON, "");
...@@ -94,14 +91,11 @@ public class PageRepositoryImplTestCase extends AbstractTestCase { ...@@ -94,14 +91,11 @@ public class PageRepositoryImplTestCase extends AbstractTestCase {
final PageRepository pageRepository = getPageRepository(); final PageRepository pageRepository = getPageRepository();
final JSONObject page = new JSONObject(); final JSONObject page = new JSONObject();
page.put(Page.PAGE_COMMENT_COUNT, 0);
page.put(Page.PAGE_CONTENT, "page2 content"); page.put(Page.PAGE_CONTENT, "page2 content");
page.put(Page.PAGE_ORDER, 1); page.put(Page.PAGE_ORDER, 1);
page.put(Page.PAGE_PERMALINK, "page2 permalink"); page.put(Page.PAGE_PERMALINK, "page2 permalink");
page.put(Page.PAGE_TITLE, "page2 title"); page.put(Page.PAGE_TITLE, "page2 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
page.put(Page.PAGE_ICON, ""); page.put(Page.PAGE_ICON, "");
...@@ -123,14 +117,11 @@ public class PageRepositoryImplTestCase extends AbstractTestCase { ...@@ -123,14 +117,11 @@ public class PageRepositoryImplTestCase extends AbstractTestCase {
final PageRepository pageRepository = getPageRepository(); final PageRepository pageRepository = getPageRepository();
final JSONObject page = new JSONObject(); final JSONObject page = new JSONObject();
page.put(Page.PAGE_COMMENT_COUNT, 0);
page.put(Page.PAGE_CONTENT, "page3 content"); page.put(Page.PAGE_CONTENT, "page3 content");
page.put(Page.PAGE_ORDER, 2); page.put(Page.PAGE_ORDER, 2);
page.put(Page.PAGE_PERMALINK, "page3 permalink"); page.put(Page.PAGE_PERMALINK, "page3 permalink");
page.put(Page.PAGE_TITLE, "page3 title"); page.put(Page.PAGE_TITLE, "page3 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
page.put(Page.PAGE_ICON, ""); page.put(Page.PAGE_ICON, "");
......
...@@ -105,7 +105,6 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase { ...@@ -105,7 +105,6 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page1 permalink"); page.put(Page.PAGE_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title"); page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject); final String pageId = pageMgmtService.addPage(requestJSONObject);
......
...@@ -27,7 +27,7 @@ import org.testng.annotations.Test; ...@@ -27,7 +27,7 @@ import org.testng.annotations.Test;
* {@link PageMgmtService} test case. * {@link PageMgmtService} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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") @Test(suiteName = "service")
public class PageMgmtServiceTestCase extends AbstractTestCase { public class PageMgmtServiceTestCase extends AbstractTestCase {
...@@ -59,7 +59,6 @@ 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_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title"); page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject); final String pageId = pageMgmtService.addPage(requestJSONObject);
...@@ -84,7 +83,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase { ...@@ -84,7 +83,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page2 permalink"); page.put(Page.PAGE_PERMALINK, "page2 permalink");
page.put(Page.PAGE_TITLE, "page2 title"); page.put(Page.PAGE_TITLE, "page2 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject); final String pageId = pageMgmtService.addPage(requestJSONObject);
...@@ -119,7 +117,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase { ...@@ -119,7 +117,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page3 permalink"); page.put(Page.PAGE_PERMALINK, "page3 permalink");
page.put(Page.PAGE_TITLE, "page3 title"); page.put(Page.PAGE_TITLE, "page3 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject); final String pageId = pageMgmtService.addPage(requestJSONObject);
...@@ -156,7 +153,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase { ...@@ -156,7 +153,6 @@ public class PageMgmtServiceTestCase extends AbstractTestCase {
page.put(Page.PAGE_PERMALINK, "page4 permalink"); page.put(Page.PAGE_PERMALINK, "page4 permalink");
page.put(Page.PAGE_TITLE, "page4 title"); page.put(Page.PAGE_TITLE, "page4 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject); final String pageId = pageMgmtService.addPage(requestJSONObject);
......
...@@ -28,7 +28,7 @@ import org.testng.annotations.Test; ...@@ -28,7 +28,7 @@ import org.testng.annotations.Test;
* {@link PageQueryService} test case. * {@link PageQueryService} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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") @Test(suiteName = "service")
public class PageQueryServiceTestCase extends AbstractTestCase { public class PageQueryServiceTestCase extends AbstractTestCase {
...@@ -60,7 +60,6 @@ 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_PERMALINK, "page1 permalink");
page.put(Page.PAGE_TITLE, "page1 title"); page.put(Page.PAGE_TITLE, "page1 title");
page.put(Page.PAGE_COMMENTABLE, true); page.put(Page.PAGE_COMMENTABLE, true);
page.put(Page.PAGE_TYPE, "page");
page.put(Page.PAGE_OPEN_TARGET, "_self"); page.put(Page.PAGE_OPEN_TARGET, "_self");
final String pageId = pageMgmtService.addPage(requestJSONObject); final String pageId = pageMgmtService.addPage(requestJSONObject);
......
...@@ -24,52 +24,22 @@ import org.testng.annotations.Test; ...@@ -24,52 +24,22 @@ import org.testng.annotations.Test;
* {@link org.b3log.solo.service.PermalinkQueryService} test case. * {@link org.b3log.solo.service.PermalinkQueryService} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 0.6.1
*/ */
public final class PermalinkQueryServiceTestCase { public final class PermalinkQueryServiceTestCase {
/** /**
* Test method for {@linkplain Permalinks#matchDefaultArticlePermalinkFormat(java.lang.String)}. * Test method for {@linkplain PermalinkQueryService#matchDefaultArticlePermalinkFormat(java.lang.String)}.
*/ */
@Test @Test
public void matchDefaultArticlePermalinkFormat() { public void matchDefaultArticlePermalinkFormat() {
Assert.assertTrue( Assert.assertTrue(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/08/25/1234567890.html"));
PermalinkQueryService.matchDefaultArticlePermalinkFormat( Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/0/25/1234567890.html"));
"/articles/1986/08/25/1234567890.html")); Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1.html"));
Assert.assertFalse( Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/08/25/a.html"));
PermalinkQueryService.matchDefaultArticlePermalinkFormat( Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/aa/25/1234567890.html"));
"/articles/1986/0/25/1234567890.html")); Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/1986/aa/25/1234567890.html"));
Assert.assertFalse( Assert.assertFalse(PermalinkQueryService.matchDefaultArticlePermalinkFormat("/articles/1986/08/25/1234567890html"));
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"));
} }
} }
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