Package com.freewebsys.blog.pojo

Examples of com.freewebsys.blog.pojo.Post


    log.info("saveComment:" + comment);
    try {
      if (comment.getPostId() != null) {
        baseDao.save(comment);

        Post post = (Post) baseDao.findById(Post.class,
            comment.getPostId());
        // 所有评论数据.
        List<Comment> commentList = findAllCommentByPostId(post.getId());
        // 循环展示页面.
        String url = post.getUrl();
        url = url.substring(0, url.lastIndexOf("/") + 1);
        // 生成评论文件夹路径。
        String filePath = FreemakerTemplateEngine.WEBAPP_PATH + url
            + "article_" + post.getId() + "/";
        // 如果文件夹不存在,创建.
        File fileDir = new File(filePath);
        if (!fileDir.exists()) {
          fileDir.mkdirs();
        }
View Full Code Here


  @Transactional
  public void deletePostById(Long id, HttpServletRequest request)
      throws Exception {
    log.info("deletePostById:" + id);
    try {
      Post post = (Post) baseDao.findById(Post.class, id);
      baseDao.delete(post);

      // 重新生成静态页面.
      CommonTemplateService.genHtmlByTemplate(request);
    } catch (Exception e) {
View Full Code Here

      postTypeMap.put(postType.getId(), new ArrayList<Post>());
    }

    // 找到分类数据.
    for (int i = 0; i < postList.size(); i++) {
      Post post = postList.get(i);
      if (post.getPostTypeId() != null) {
        // 将分类增加到map里面.
        postTypeMap.get(post.getPostTypeId()).add(post);
      }
      // 生成每一个文章页面.
      Map<String, Object> postMap = new HashMap<String, Object>();
      // 文章分类数据
      postMap.put("postTypeList", postTypeList);
View Full Code Here

    // 循环.
    for (int i = 0; i < postList.size(); i++) {
      // 增加首页分页.
      int loopPage = (int) Math.floor(i / pageSize);
      System.out.println("loopPage:" + loopPage);
      Post post = postList.get(i);
      postListTmp[loopPage].add(post);
      // 增加每一个文章的生成.
      String prevUrl = null;
      String nextUrl = null;
      if (i != 0) {
        // 前一个url.
        Post postTemp = postList.get(i - 1);
        prevUrl = postTemp.getUrl();
      }
      if (i != (postList.size() - 1)) {
        // 后一个url.
        Post postTemp = postList.get(i + 1);
        nextUrl = postTemp.getUrl();
      }
      // 增加类型分页参数.
      if (StringUtils.isNotBlank(path) && StringUtils.isNotBlank(prevUrl)) {
        prevUrl += "?type=" + path;
      }
View Full Code Here

          .getTemplateByName("/theme/default/article.ftl");

      String postHtml = FreemakerTemplateEngine.writeTemp(articleTemp,
          root);
      // System.out.println(FreemakerTemplateEngine.WEBAPP_PATH);
      Post post = (Post) root.get("post");
      if (post != null && post.getUrl() != null) {
        String fileName = post.getUrl().substring(
            post.getUrl().lastIndexOf("/") + 1);
        // 生成文件的决定路径.
        String filePath = FreemakerTemplateEngine.WEBAPP_PATH
            + post.getUrl().substring(0,
                post.getUrl().lastIndexOf("/") + 1);
        File file = new File(filePath);
        if (!file.exists()) {
          file.mkdirs();
        }
        // 生成首页index.html文件.
View Full Code Here

      String hql = " from Post post where post.status = 1 order by post.createDate desc ";
      List<Post> postList = baseDao.findByMaxResults(limit, hql);
      IteratorStatus.StatusState state = new IteratorStatus.StatusState();

      for (int i = 0; i < postList.size(); i++) {
        Post post = postList.get(i);
        if (i == (postList.size() - 1)) {// 设置最后一页.
          state.setLast(true);
        }
        // 设置变量
        env.setVariable("status",
            DEFAULT_WRAPPER.wrap(new IteratorStatus(state)));
        env.setVariable("post", DEFAULT_WRAPPER.wrap(post));
        body.render(env.getOut());
        // 迭代器往后.
        state.next();

        String prevUrl = null;
        String nextUrl = null;
        if (i != 0) {
          // 前一个url.
          Post postTemp = postList.get(i - 1);
          prevUrl = postTemp.getUrl();
        }
        if (i != (postList.size() - 1)) {
          // 后一个url.
          Post postTemp = postList.get(i + 1);
          nextUrl = postTemp.getUrl();
        }
        Map<String, Object> rootPost = new HashMap<String, Object>();
        rootPost.put("prevUrl", prevUrl);
        rootPost.put("nextUrl", nextUrl);
        // 使用自定义模板postList
View Full Code Here

  public String addPost(HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "id", required = false) Long id,
      ModelMap model) throws Exception {
    if (id != null) {
      Post post = postService.findPostById(id);
      model.addAttribute("postAttribute", post);
    } else {
      model.addAttribute("postAttribute", new Post());
    }
    // 查询全部.
    List<PostType> postTypeList = postTypeService.findAllPostType();
    model.addAttribute("postTypeList", postTypeList);
    return "/admin/post/postForm";
View Full Code Here

TOP

Related Classes of com.freewebsys.blog.pojo.Post

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.