com.blade.mvc.http.Request.attribute()

Here are the examples of the java api com.blade.mvc.http.Request.attribute() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

31 Examples 7

19 Source : InstallController.java
with MIT License
from tfssweb

/**
 * 安装页
 *
 * @return
 */
@Route(value = "/", method = HttpMethod.GET)
public String index(Request request) {
    boolean existInstall = Files.exists(Paths.get(AttachController.CLreplacedPATH + "install.lock"));
    int allow_reinstall = TaleConst.OPTIONS.getInt("allow_install", 0);
    if (allow_reinstall == 1) {
        request.attribute("is_install", false);
    } else {
        request.attribute("is_install", existInstall);
    }
    return "install";
}

19 Source : BaseController.java
with MIT License
from tfssweb

public BaseController keywords(Request request, String keywords) {
    request.attribute("keywords", keywords);
    return this;
}

19 Source : BaseController.java
with MIT License
from tfssweb

public BaseController replacedle(Request request, String replacedle) {
    request.attribute("replacedle", replacedle);
    return this;
}

19 Source : IndexController.java
with MIT License
from biezhi

/**
 * 打赏首页
 *
 * @param orderParam
 * @param request
 * @return
 */
@GetRoute("/")
public String index(@Param OrderParam orderParam, Request request) {
    Page<Order> orderPage = makeMoneyService.findOrders(orderParam);
    request.attribute("orderPage", orderPage);
    Map<String, String> options = makeMoneyService.findOptions();
    request.attribute("options", options);
    return "themes/" + THEME_NAME + "/index.html";
}

18 Source : BaseWebHook.java
with MIT License
from tfssweb

private boolean isRedirect(Request request, Response response) {
    Users user = TaleUtils.getLoginUser();
    String uri = request.uri();
    if (null == user) {
        Integer uid = TaleUtils.getCookieUid(request);
        if (null != uid) {
            user = new Users().find(uid);
            request.session().attribute(TaleConst.LOGIN_SESSION_KEY, user);
        }
    }
    if (uri.startsWith(TaleConst.ADMIN_URI) && !uri.startsWith(TaleConst.LOGIN_URI)) {
        if (null == user) {
            response.redirect(TaleConst.LOGIN_URI);
            return false;
        }
        request.attribute(TaleConst.PLUGINS_MENU_NAME, TaleConst.PLUGIN_MENUS);
    }
    return true;
}

18 Source : CategoryController.java
with MIT License
from tfssweb

/**
 * 分类列表页
 *
 * @since 1.3.1
 */
@GetRoute(value = { "categories", "categories.html" })
public String categories(Request request) {
    Map<String, List<Contents>> mapping = metreplacedervice.getMetaMapping(Types.CATEGORY);
    Set<String> categories = mapping.keySet();
    request.attribute("categories", categories);
    request.attribute("mapping", mapping);
    return this.render("categories");
}

18 Source : CategoryController.java
with MIT License
from tfssweb

/**
 * 标签列表页面
 * <p>
 * 渲染所有的标签和文章映射
 *
 * @since 1.3.1
 */
@GetRoute(value = { "tags", "tags.html" })
public String tags(Request request) {
    Map<String, List<Contents>> mapping = metreplacedervice.getMetaMapping(Types.TAG);
    Set<String> tags = mapping.keySet();
    request.attribute("tags", tags);
    request.attribute("mapping", mapping);
    return this.render("tags");
}

17 Source : IndexController.java
with MIT License
from tfssweb

/**
 * 首页分页
 *
 * @param request
 * @param page
 * @param limit
 * @return
 */
@GetRoute(value = { "page/:page", "page/:page.html" })
public String index(Request request, @PathParam int page, @Param(defaultValue = "12") int limit) {
    page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
    if (page > 1) {
        this.replacedle(request, "第" + page + "页");
    }
    request.attribute("page_num", page);
    request.attribute("limit", limit);
    request.attribute("is_home", true);
    request.attribute("page_prefix", "/page");
    return this.render("index");
}

17 Source : TemplateController.java
with MIT License
from tfssweb

@Route(value = "", method = HttpMethod.GET)
public String index(Request request) {
    String themePath = Const.CLreplacedPATH + File.separatorChar + "templates" + File.separatorChar + "themes" + File.separatorChar + Commons.site_theme();
    try {
        List<String> files = Files.list(Paths.get(themePath)).map(path -> path.getFileName().toString()).filter(path -> path.endsWith(".html")).collect(Collectors.toList());
        List<String> partial = Files.list(Paths.get(themePath + File.separatorChar + "partial")).map(path -> path.getFileName().toString()).filter(path -> path.endsWith(".html")).map(fileName -> "partial/" + fileName).collect(Collectors.toList());
        List<String> statics = Files.list(Paths.get(themePath + File.separatorChar + "static")).map(path -> path.getFileName().toString()).filter(path -> path.endsWith(".js") || path.endsWith(".css")).map(fileName -> "static/" + fileName).collect(Collectors.toList());
        files.addAll(partial);
        files.addAll(statics);
        request.attribute("tpls", files);
    } catch (IOException e) {
        log.error("找不到模板路径");
    }
    return "admin/tpl_list";
}

17 Source : PageController.java
with MIT License
from tfssweb

@Route(value = "new", method = HttpMethod.GET)
public String newPage(Request request) {
    request.attribute(Types.ATTACH_URL, Commons.site_option(Types.ATTACH_URL, Commons.site_url()));
    return "admin/page_edit";
}

17 Source : CommentController.java
with MIT License
from tfssweb

@GetRoute(value = "")
public String index(@Param(defaultValue = "1") int page, @Param(defaultValue = "15") int limit, Request request) {
    Users users = this.user();
    Page<Comments> commentPage = new Comments().where("author_id", "<>", users.getUid()).page(page, limit);
    request.attribute("comments", commentPage);
    return "admin/comment_list";
}

17 Source : CategoryController.java
with MIT License
from tfssweb

@Route(value = "", method = HttpMethod.GET)
public String index(Request request) {
    List<Metas> categories = siteService.getMetas(Types.RECENT_META, Types.CATEGORY, TaleConst.MAX_POSTS);
    List<Metas> tags = siteService.getMetas(Types.RECENT_META, Types.TAG, TaleConst.MAX_POSTS);
    request.attribute("categories", categories);
    request.attribute("tags", tags);
    return "admin/category";
}

17 Source : AdminController.java
with MIT License
from biezhi

@GetRoute("template/:theme")
public String template(@PathParam String theme, Request request) throws IOException {
    File themeDir = new File(Utils.CLreplacedPATH + "templates/themes/" + theme);
    File[] files = themeDir.listFiles(pathname -> pathname.getName().endsWith(".html"));
    List<Template> list = new ArrayList<>();
    for (File file : Objects.requireNonNull(files)) {
        list.add(new Template(file.getName(), IOKit.readToString(file.toPath())));
    }
    request.attribute("files", list);
    request.attribute("theme", theme);
    return "admin/template.html";
}

16 Source : CategoryController.java
with MIT License
from tfssweb

/**
 * 某个分类详情页分页
 */
@GetRoute(value = { "category/:keyword/:page", "category/:keyword/:page.html" })
public String categories(Request request, @PathParam String keyword, @PathParam int page, @Param(defaultValue = "12") int limit) {
    page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
    Metas metaDto = metreplacedervice.getMeta(Types.CATEGORY, keyword);
    if (null == metaDto) {
        return this.render_404();
    }
    Page<Contents> contentsPage = contentsService.getArticles(metaDto.getMid(), page, limit);
    request.attribute("articles", contentsPage);
    request.attribute("meta", metaDto);
    request.attribute("type", "分类");
    request.attribute("keyword", keyword);
    request.attribute("is_category", true);
    request.attribute("page_prefix", "/category/" + keyword);
    return this.render("page-category");
}

16 Source : CategoryController.java
with MIT License
from tfssweb

/**
 * 标签下文章分页
 */
@GetRoute(value = { "tag/:name/:page", "tag/:name/:page.html" })
public String tags(Request request, @PathParam String name, @PathParam int page, @Param(defaultValue = "12") int limit) {
    page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
    Metas metaDto = metreplacedervice.getMeta(Types.TAG, name);
    if (null == metaDto) {
        return this.render_404();
    }
    Page<Contents> contentsPage = contentsService.getArticles(metaDto.getMid(), page, limit);
    request.attribute("articles", contentsPage);
    request.attribute("meta", metaDto);
    request.attribute("type", "标签");
    request.attribute("keyword", name);
    request.attribute("is_tag", true);
    request.attribute("page_prefix", "/tag/" + name);
    return this.render("page-category");
}

16 Source : ThemeController.java
with MIT License
from tfssweb

/**
 * 主题设置页面
 *
 * @param request
 * @return
 */
@GetRoute(value = "setting")
public String setting(Request request) {
    String currentTheme = Commons.site_theme();
    String key = "theme_" + currentTheme + "_options";
    String option = optionsService.getOption(key);
    Map<String, Object> map = new HashMap<>();
    try {
        if (StringKit.isNotBlank(option)) {
            map = JsonKit.toAson(option);
        }
        request.attribute("theme_options", map);
    } catch (Exception e) {
        log.error("解析主题设置出现异常", e);
    }
    request.attribute("theme_options", map);
    return this.render("setting");
}

16 Source : PageController.java
with MIT License
from tfssweb

@Route(value = "/:cid", method = HttpMethod.GET)
public String editPage(@PathParam String cid, Request request) {
    Optional<Contents> contents = contentsService.getContents(cid);
    if (!contents.isPresent()) {
        return render_404();
    }
    request.attribute("contents", contents.get());
    request.attribute(Types.ATTACH_URL, Commons.site_option(Types.ATTACH_URL, Commons.site_url()));
    return "admin/page_edit";
}

16 Source : PageController.java
with MIT License
from tfssweb

@Route(value = "", method = HttpMethod.GET)
public String index(Request request) {
    Page<Contents> contentsPage = new Contents().where("type", Types.PAGE).page(1, TaleConst.MAX_POSTS, "created desc");
    request.attribute("articles", contentsPage);
    return "admin/page_list";
}

16 Source : ArticleController.java
with MIT License
from tfssweb

/**
 * 文章管理首页
 *
 * @param page
 * @param limit
 * @param request
 * @return
 */
@GetRoute(value = "")
public String index(@Param(defaultValue = "1") int page, @Param(defaultValue = "15") int limit, Request request) {
    Page<Contents> articles = new Contents().where("type", Types.ARTICLE).page(page, limit, "created desc");
    request.attribute("articles", articles);
    return "admin/article_list";
}

16 Source : AdminController.java
with MIT License
from biezhi

@GetRoute("orders")
public String orders(OrderParam orderParam, Request request) {
    Page<Order> orders = makeMoneyService.findOrders(orderParam);
    request.attribute("orderPage", orders);
    return "admin/orders.html";
}

15 Source : IndexController.java
with MIT License
from tfssweb

/**
 * 归档页
 *
 * @return
 */
@GetRoute(value = { "archives", "archives.html" })
public String archives(Request request) {
    List<Archive> archives = siteService.getArchives();
    request.attribute("archives", archives);
    request.attribute("is_archive", true);
    return this.render("archives");
}

15 Source : IndexController.java
with MIT License
from tfssweb

/**
 * 系统设置
 */
@Route(value = "setting", method = HttpMethod.GET)
public String setting(Request request) {
    Map<String, String> options = optionsService.getOptions();
    request.attribute("options", options);
    return "admin/setting";
}

15 Source : ArticleController.java
with MIT License
from tfssweb

/**
 * 文章发布页面
 *
 * @param request
 * @return
 */
@GetRoute(value = "publish")
public String newArticle(Request request) {
    List<Metas> categories = metreplacedervice.getMetas(Types.CATEGORY);
    request.attribute("categories", categories);
    request.attribute(Types.ATTACH_URL, Commons.site_option(Types.ATTACH_URL, Commons.site_url()));
    return "admin/article_edit";
}

14 Source : Theme.java
with MIT License
from tfssweb

/**
 * 分页
 *
 * @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 = new Contents().where("type", Types.ARTICLE).and("status", Types.PUBLISH).page(page, limit, "created desc");
    request.attribute("articles", articles);
    if (page > 1) {
        WebContext.request().attribute("replacedle", "第" + page + "页");
    }
    request.attribute("is_home", true);
    request.attribute("page_prefix", "/page");
    return articles;
}

14 Source : IndexController.java
with MIT License
from tfssweb

@GetRoute(value = { "search/:keyword/:page", "search/:keyword/:page.html" })
public String search(Request request, @PathParam String keyword, @PathParam int page, @Param(defaultValue = "12") int limit) {
    page = page < 0 || page > TaleConst.MAX_PAGE ? 1 : page;
    Page<Contents> articles = new Contents().where("type", Types.ARTICLE).and("status", Types.PUBLISH).like("replacedle", "%" + keyword + "%").page(page, limit, "created desc");
    request.attribute("articles", articles);
    request.attribute("type", "搜索");
    request.attribute("keyword", keyword);
    request.attribute("page_prefix", "/search/" + keyword);
    return this.render("page-category");
}

14 Source : ThemeController.java
with MIT License
from tfssweb

@GetRoute(value = "")
public String index(Request request) {
    // 读取主题
    String themesDir = AttachController.CLreplacedPATH + "templates/themes";
    File[] themesFile = new File(themesDir).listFiles();
    List<ThemeDto> themes = new ArrayList<>(themesFile.length);
    for (File f : themesFile) {
        if (f.isDirectory()) {
            ThemeDto themeDto = new ThemeDto(f.getName());
            if (Files.exists(Paths.get(f.getPath() + "/setting.html"))) {
                themeDto.setHreplacedetting(true);
            }
            themes.add(themeDto);
            try {
                Blade.me().addStatics("/templates/themes/" + f.getName() + "/screenshot.png");
            } catch (Exception e) {
            }
        }
    }
    request.attribute("current_theme", Commons.site_theme());
    request.attribute("themes", themes);
    return "admin/themes";
}

14 Source : AttachController.java
with MIT License
from tfssweb

/**
 * 附件页面
 *
 * @param request
 * @param page
 * @param limit
 * @return
 */
@Route(value = "", method = HttpMethod.GET)
public String index(Request request, @Param(defaultValue = "1") int page, @Param(defaultValue = "12") int limit) {
    Attach attach = new Attach();
    Page<Attach> attachPage = attach.page(page, limit);
    request.attribute("attachs", attachPage);
    request.attribute(Types.ATTACH_URL, Commons.site_option(Types.ATTACH_URL, Commons.site_url()));
    request.attribute("max_file_size", TaleConst.MAX_FILE_SIZE / 1024);
    return "admin/attach";
}

14 Source : ArticleController.java
with MIT License
from tfssweb

/**
 * 文章编辑页面
 *
 * @param cid
 * @param request
 * @return
 */
@GetRoute(value = "/:cid")
public String editArticle(@PathParam String cid, Request request) {
    Optional<Contents> contents = contentsService.getContents(cid);
    if (!contents.isPresent()) {
        return render_404();
    }
    request.attribute("contents", contents.get());
    List<Metas> categories = metreplacedervice.getMetas(Types.CATEGORY);
    request.attribute("categories", categories);
    request.attribute("active", "article");
    request.attribute(Types.ATTACH_URL, Commons.site_option(Types.ATTACH_URL, Commons.site_url()));
    return "admin/article_edit";
}

13 Source : IndexController.java
with MIT License
from tfssweb

/**
 * 仪表盘
 */
@Route(value = { "/", "index" }, method = HttpMethod.GET)
public String index(Request request) {
    List<Comments> comments = siteService.recentComments(5);
    List<Contents> contents = siteService.getContens(Types.RECENT_ARTICLE, 5);
    Statistics statistics = siteService.getStatistics();
    // 取最新的20条日志
    Page<Logs> logsPage = new Logs().page(1, 20, "id desc");
    List<Logs> logs = logsPage.getRows();
    request.attribute("comments", comments);
    request.attribute("articles", contents);
    request.attribute("statistics", statistics);
    request.attribute("logs", logs);
    return "admin/index";
}

10 Source : IndexController.java
with MIT License
from tfssweb

/**
 * 文章页
 */
@CsrfToken(newToken = true)
@GetRoute(value = { "article/:cid", "article/:cid.html" })
public String post(Request request, @PathParam String cid) {
    Optional<Contents> contentsOptional = contentsService.getContents(cid);
    if (!contentsOptional.isPresent()) {
        return this.render_404();
    }
    Contents contents = contentsOptional.get();
    if (Types.DRAFT.equals(contents.getStatus())) {
        return this.render_404();
    }
    request.attribute("article", contents);
    request.attribute("is_post", true);
    if (contents.getAllowComment()) {
        int cp = request.queryInt("cp", 1);
        request.attribute("cp", cp);
    }
    Contents temp = new Contents();
    temp.setHits(contents.getHits() + 1);
    temp.update(contents.getCid());
    return this.render("post");
}

8 Source : IndexController.java
with MIT License
from tfssweb

/**
 * 自定义页面
 */
@CsrfToken(newToken = true)
@GetRoute(value = { "/:cid", "/:cid.html" })
public String page(@PathParam String cid, Request request) {
    Optional<Contents> contentsOptional = contentsService.getContents(cid);
    if (!contentsOptional.isPresent()) {
        return this.render_404();
    }
    Contents contents = contentsOptional.get();
    if (contents.getAllowComment()) {
        int cp = request.queryInt("cp", 1);
        request.attribute("cp", cp);
    }
    request.attribute("article", contents);
    Contents temp = new Contents();
    temp.setHits(contents.getHits() + 1);
    temp.update(contents.getCid());
    if (Types.ARTICLE.equals(contents.getType())) {
        return this.render("post");
    }
    if (Types.PAGE.equals(contents.getType())) {
        return this.render("page");
    }
    return this.render_404();
}