Ejemplo n.º 1
0
 public NutMap _topic(Topic topic, Map<Integer, UserProfile> authors, String mdrender) {
   yvrService.fillTopic(topic, authors);
   NutMap tp = new NutMap();
   tp.put("id", topic.getId());
   tp.put("author_id", "" + topic.getAuthor().getUserId());
   tp.put("tab", topic.getType().toString());
   tp.put(
       "content",
       "false".equals(mdrender)
           ? topic.getContent()
           : Markdowns.toHtml(topic.getContent(), urlbase));
   tp.put("title", StringEscapeUtils.unescapeHtml(topic.getTitle()));
   if (topic.getLastComment() != null)
     tp.put("last_reply_at", _time(topic.getLastComment().getCreateTime()));
   tp.put("good", topic.isGood());
   tp.put("top", topic.isTop());
   tp.put("reply_count", topic.getReplyCount());
   tp.put("visit_count", topic.getVisitCount());
   tp.put("create_at", _time(topic.getCreateTime()));
   UserProfile profile = topic.getAuthor();
   if (profile != null) {
     profile.setScore(yvrService.getUserScore(topic.getUserId()));
   }
   tp.put("author", _author(profile));
   return tp;
 }
Ejemplo n.º 2
0
  /** 全文输出 */
  @At
  @Ok("raw:xml")
  public String rss() throws IOException, FeedException {
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("rss_2.0");
    String urlbase = conf.get("website.urlbase", "https://nutz.cn");
    feed.setLink(urlbase);
    feed.setTitle(conf.get("website.title", "Nutz社区"));
    feed.setDescription(conf.get("website.description", "一个有爱的社区"));

    feed.setAuthor(conf.get("website.author", "wendal"));
    feed.setEncoding("UTF-8");
    feed.setLanguage("zh-cn");

    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    SyndEntry entry;
    SyndContent description;
    List<Topic> list =
        dao.query(Topic.class, Cnd.orderBy().desc("createTime"), dao.createPager(1, 10));
    for (Topic topic : list) {
      dao.fetchLinks(topic, "author");
      entry = new SyndEntryImpl();
      entry.setTitle(topic.getTitle());
      entry.setLink(urlbase + "/yvr/t/" + topic.getId());
      entry.setPublishedDate(topic.getCreateTime());
      description = new SyndContentImpl();
      description.setType("text/html");
      description.setValue(Markdowns.toHtml(topic.getContent(), urlbase));
      entry.setDescription(description);
      entry.setAuthor(topic.getAuthor().getLoginname());
      entries.add(entry);
    }

    feed.setEntries(entries);
    if (list.size() > 0) {
      feed.setPublishedDate(list.get(0).getCreateTime());
    }

    SyndFeedOutput output = new SyndFeedOutput();
    return output.outputString(feed, true);
  }