From 742a62b38be8ec94a3eb0795bdc8e8f7ac88a5a2 Mon Sep 17 00:00:00 2001 From: biezhi Date: Wed, 15 Mar 2017 20:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=84=20add=20search=20page=20and=20is?= =?UTF-8?q?=5Fslug=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../java/com/tale/controller/IndexController.java | 6 ++++++ src/main/java/com/tale/ext/Theme.java | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0527d215..52a21bee 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ 3.15.1 1.0.24 1.7.2-alpha - 0.1.5 + 0.1.6-alpha 0.0.9 0.1.3 diff --git a/src/main/java/com/tale/controller/IndexController.java b/src/main/java/com/tale/controller/IndexController.java index c90d69d0..d0e98ce0 100644 --- a/src/main/java/com/tale/controller/IndexController.java +++ b/src/main/java/com/tale/controller/IndexController.java @@ -222,6 +222,12 @@ public String search(Request request, @PathParam String keyword, @QueryParam(val return this.search(request, keyword, 1, limit); } + @Route(values = {"search", "search.html"}) + public String search(Request request, @QueryParam(value = "limit", defaultValue = "12") int limit) { + String keyword = request.query("s"); + return this.search(request, keyword, 1, limit); + } + @Route(values = {"search/:keyword/:page", "search/:keyword/:page.html"}, method = HttpMethod.GET) public String search(Request request, @PathParam String keyword, @PathParam int page, @QueryParam(value = "limit", defaultValue = "12") int limit) { diff --git a/src/main/java/com/tale/ext/Theme.java b/src/main/java/com/tale/ext/Theme.java index 028bf787..671d9e0e 100644 --- a/src/main/java/com/tale/ext/Theme.java +++ b/src/main/java/com/tale/ext/Theme.java @@ -570,4 +570,17 @@ public static String comments_num(String noComment, String value){ public static String theme_option(String key){ return TaleConst.OPTIONS.get("theme_option_" + key); } + + /** + * 返回是否是某个页面 + * @param pageName + * @return + */ + public static boolean is_slug(String pageName){ + Contents contents = current_article(); + if(null != contents && Types.PAGE.equals(contents.getType()) && contents.getSlug().equals(pageName)){ + return true; + } + return false; + } }