Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
🦄 add search page and is_slug function
Browse files Browse the repository at this point in the history
  • Loading branch information
hellokaton committed Mar 15, 2017
1 parent da7fd30 commit 742a62b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<sqlite.version>3.15.1</sqlite.version>
<druid.version>1.0.24</druid.version>
<blade.version>1.7.2-alpha</blade.version>
<blade-jdbc.version>0.1.5</blade-jdbc.version>
<blade-jdbc.version>0.1.6-alpha</blade-jdbc.version>
<blade-tpl.verion>0.0.9</blade-tpl.verion>
<blade-embed-jetty.version>0.1.3</blade-embed-jetty.version>
</properties>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/tale/controller/IndexController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/tale/ext/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 742a62b

Please sign in to comment.