use of com.tale.model.entity.Contents in project tale by otale.
the class IndexController method index.
/**
* 仪表盘
*/
@GetRoute(value = { "/", "index" })
public String index(Request request) {
List<Comments> comments = siteService.recentComments(5);
List<Contents> contents = siteService.getContens(Types.RECENT_ARTICLE, 5);
Statistics statistics = siteService.getStatistics();
request.attribute("comments", comments);
request.attribute("articles", contents);
request.attribute("statistics", statistics);
return "admin/index";
}
use of com.tale.model.entity.Contents in project tale by otale.
the class Theme method comments.
/**
* 获取当前文章/页面的评论
*
* @param limit
* @return
*/
public static Page<Comment> comments(int limit) {
Contents contents = current_article();
if (null == contents) {
return new Page<>();
}
InterpretContext ctx = InterpretContext.current();
Object value = ctx.getValueStack().getValue("cp");
int page = 1;
if (null != value) {
page = (int) value;
}
Page<Comment> comments = siteService.getComments(contents.getCid(), page, limit);
return comments;
}
use of com.tale.model.entity.Contents in project tale by otale.
the class Theme method show_tags.
/**
* 显示标签
*
* @param split 每个标签之间的分隔符
* @return
*/
public static String show_tags(String split) throws UnsupportedEncodingException {
Contents contents = current_article();
if (StringKit.isNotBlank(contents.getTags())) {
String[] arr = contents.getTags().split(",");
StringBuffer sbuf = new StringBuffer();
for (String c : arr) {
sbuf.append(split).append("<a href=\"/tag/" + URLEncoder.encode(c, "UTF-8") + "\">" + c + "</a>");
}
return split.length() > 0 ? sbuf.substring(split.length() - 1) : sbuf.toString();
}
return "";
}
use of com.tale.model.entity.Contents in project tale by otale.
the class Theme method articles.
/**
* 分页
*
* @param limit
* @return
*/
public static Page<Contents> articles(int limit) {
Request request = WebContext.request();
Integer page = request.attribute("page_num");
page = null == page ? request.queryInt("page", 1) : page;
page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
Page<Contents> articles = select().from(Contents.class).where(Contents::getType, Types.ARTICLE).and("status", Types.PUBLISH).order(Contents::getCreated, OrderBy.DESC).page(page, limit);
request.attribute("articles", articles);
if (page > 1) {
WebContext.request().attribute("title", "第" + page + "页");
}
request.attribute("is_home", true);
request.attribute("page_prefix", "/page");
return articles;
}
use of com.tale.model.entity.Contents in project tale by otale.
the class Theme method current_article.
/**
* 获取当前上下文的文章对象
*
* @return
*/
private static Contents current_article() {
InterpretContext ctx = InterpretContext.current();
Object value = ctx.getValueStack().getValue("article");
if (null != value) {
return (Contents) value;
}
return null;
}
Aggregations