Skip to content

Commit

Permalink
Merge pull request otale#165 from intersimone999/dev
Browse files Browse the repository at this point in the history
🦄 renamed inconsistent identifiers
  • Loading branch information
hellokaton authored Mar 22, 2017
2 parents 207cb7f + 33a53c8 commit 9b4bd0f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/main/java/com/tale/controller/IndexController.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public String index(Request request, @QueryParam(value = "limit", defaultValue =
* 自定义页面
*/
@Route(values = {"/:pagename", "/:pagename.html"}, method = HttpMethod.GET)
public String page(@PathParam String pagename, Request request) {
Contents contents = contentsService.getContents(pagename);
public String page(@PathParam String cid, Request request) {
Contents contents = contentsService.getContents(cid);
if (null == contents) {
return this.render_404();
}
Expand All @@ -89,18 +89,18 @@ public String page(@PathParam String pagename, Request request) {
* 首页分页
*
* @param request
* @param pageIndex
* @param page
* @param limit
* @return
*/
@Route(values = {"page/:pageIndex", "page/:pageIndex.html"}, method = HttpMethod.GET)
public String index(Request request, @PathParam int pageIndex, @QueryParam(value = "limit", defaultValue = "12") int limit) {
pageIndex = pageIndex < 0 || pageIndex > TaleConst.MAX_PAGE ? 1 : pageIndex;
Take take = new Take(Contents.class).eq("type", Types.ARTICLE).eq("status", Types.PUBLISH).page(pageIndex, limit, "created desc");
public String index(Request request, @PathParam int page, @QueryParam(value = "limit", defaultValue = "12") int limit) {
page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
Take take = new Take(Contents.class).eq("type", Types.ARTICLE).eq("status", Types.PUBLISH).page(page, limit, "created desc");
Paginator<Contents> articles = contentsService.getArticles(take);
request.attribute("articles", articles);
if (pageIndex > 1) {
this.title(request, "第" + pageIndex + "页");
if (page > 1) {
this.title(request, "第" + page + "页");
}
request.attribute("is_home", true);
request.attribute("page_prefix", "/page");
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/tale/controller/InstallController.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public RestResponse doInstall(@QueryParam String site_title, @QueryParam String
return RestResponse.fail("邮箱格式不正确");
}

Users users = new Users();
users.setUsername(admin_user);
users.setPassword(admin_pwd);
users.setEmail(admin_email);
Users temp = new Users();
temp.setUsername(admin_user);
temp.setPassword(admin_pwd);
temp.setEmail(admin_email);

siteService.initSite(users);
siteService.initSite(temp);

if (site_url.endsWith("/")) {
site_url = site_url.substring(0, site_url.length() - 1);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/tale/init/WebContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public void init(BConfig bConfig, ServletContext sec) {
macros.add(macroName);
}
}
StringBuffer macroBuf = new StringBuffer();
macros.forEach(s -> macroBuf.append(',').append(s));
templateEngine.addConfig("jetx.import.macros", macroBuf.substring(1));
StringBuffer sbuf = new StringBuffer();
macros.forEach(s -> sbuf.append(',').append(s));
templateEngine.addConfig("jetx.import.macros", sbuf.substring(1));

GlobalResolver resolver = templateEngine.getGlobalResolver();
resolver.registerFunctions(Commons.class);
Expand Down Expand Up @@ -109,4 +109,4 @@ public void register(Ioc ioc) {
Commons.setSiteService(ioc.getBean(SiteService.class));
}

}
}
6 changes: 3 additions & 3 deletions src/main/java/com/tale/utils/TaleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ public static void download(Response response, String filePath) throws Exception
OutputStream out = response.outputStream();
FileInputStream in = new FileInputStream(file);
byte[] buffer = new byte[1024];
int length;
while ((length = in.read(buffer)) > 0) {
out.write(buffer, 0, length);
int len;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
}
in.close();
out.flush();
Expand Down

0 comments on commit 9b4bd0f

Please sign in to comment.