Search in sources :

Example 1 with InterpretContext

use of jetbrick.template.runtime.InterpretContext in project tale by otale.

the class Theme method meta_description.

/**
     * 获取header description
     * @return
     */
public static String meta_description() {
    InterpretContext ctx = InterpretContext.current();
    Object value = ctx.getValueStack().getValue("description");
    if (null != value) {
        return value.toString();
    }
    return Commons.site_option("site_description");
}
Also used : InterpretContext(jetbrick.template.runtime.InterpretContext)

Example 2 with InterpretContext

use of jetbrick.template.runtime.InterpretContext in project tale by otale.

the class Theme method comments.

/**
     * 获取当前文章/页面的评论
     * @param limit
     * @return
     */
public static Paginator<Comment> comments(int limit) {
    Contents contents = current_article();
    if (null == contents) {
        return new Paginator<>(0, limit);
    }
    InterpretContext ctx = InterpretContext.current();
    Object value = ctx.getValueStack().getValue("cp");
    int page = 1;
    if (null != value) {
        page = (int) value;
    }
    return siteService.getComments(contents.getCid(), page, limit);
}
Also used : Contents(com.tale.model.Contents) InterpretContext(jetbrick.template.runtime.InterpretContext) Paginator(com.blade.jdbc.model.Paginator)

Example 3 with InterpretContext

use of jetbrick.template.runtime.InterpretContext 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;
}
Also used : Contents(com.tale.model.Contents) InterpretContext(jetbrick.template.runtime.InterpretContext)

Example 4 with InterpretContext

use of jetbrick.template.runtime.InterpretContext in project tale by otale.

the class Theme method meta_keywords.

/**
     * 获取header keywords
     * @return
     */
public static String meta_keywords() {
    InterpretContext ctx = InterpretContext.current();
    Object value = ctx.getValueStack().getValue("keywords");
    if (null != value) {
        return value.toString();
    }
    return Commons.site_option("site_keywords");
}
Also used : InterpretContext(jetbrick.template.runtime.InterpretContext)

Example 5 with InterpretContext

use of jetbrick.template.runtime.InterpretContext in project tale by otale.

the class Theme method head_title.

/**
     * header title
     * @return
     */
public static String head_title() {
    InterpretContext ctx = InterpretContext.current();
    Object value = ctx.getValueStack().getValue("title");
    String p = "首页";
    if (null != value) {
        p = value.toString();
    }
    return p + " - " + Commons.site_option("site_title", "Tale 博客");
}
Also used : InterpretContext(jetbrick.template.runtime.InterpretContext)

Aggregations

InterpretContext (jetbrick.template.runtime.InterpretContext)5 Contents (com.tale.model.Contents)2 Paginator (com.blade.jdbc.model.Paginator)1