Ejemplo n.º 1
0
 @Override
 public String renderComments(BlogEntry entry, List<Comment> comments) {
   VelocityContext commentsContext = new VelocityContext();
   commentsContext.put("entryURL", entry.getPermalink().substring(2));
   commentsContext.put("commentList", comments);
   StringWriter writer = new StringWriter();
   Template template = loadTemplate("comments.vm");
   template.merge(commentsContext, writer);
   return Util.replaceJournalLinks(writer.toString(), journal);
 }
Ejemplo n.º 2
0
  @Override
  public String renderBlogEntry(BlogEntry entry) {
    VelocityContext entryContext = new VelocityContext();
    entryContext.put("entry", entry);
    BlogEntry prev = reader.getPreviousEntry(entry.getItemid());
    String prevURL = "";
    if (null != prev) {
      prevURL = prev.getPermalink().substring(2);
    }
    entryContext.put("prevURL", prevURL);

    BlogEntry next = reader.getNextEntry(entry.getItemid());
    String nextURL = "";
    if (null != next) {
      nextURL = next.getPermalink().substring(2);
    }
    entryContext.put("nextURL", nextURL);
    Template template = loadTemplate("blog_entry.vm");
    StringWriter writer = new StringWriter();
    template.merge(entryContext, writer);
    return Util.replaceJournalLinks(writer.toString(), journal);
  }
Ejemplo n.º 3
0
  public String renderIndex() {
    StringBuilder result = new StringBuilder();
    result.append(
        "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n"
            + "        \"http://www.w3.org/TR/html4/loose.dtd\">\n"
            + "<html>");
    result.append("<span class=\"index_header\">JOURNAL: ").append(journal).append("</span>");
    while (reader.hasNext()) {
      BlogEntry entry = reader.next();
      result
          .append("<br>")
          .append("<span class=\"index_item\">")
          .append("<a href=\"")
          .append(entry.getPermalink().substring(2))
          .append("\">")
          .append(entry.getSubject())
          .append("</a>")
          .append("</span>");
    }
    result.append("</body>\n").append("</html>");

    return result.toString();
  }