/** * Render the title from the given Channel to the given StringBuffer, * using standard Radeox filtering tags. * @param feed the RSS Channel we retrieved via the Feed URL * @param buf the StringBuffer we're using to prepare the output */ private void renderTitleDefault(SyndFeed feed, StringBuffer buf) { buf.append("__"); if (feed.getLink() != null) buf.append("{link:"); buf.append(feed.getTitle()); if (feed.getLink() != null) { buf.append("|") .append(feed.getLink()) .append("}"); } buf.append("__\n\n"); }
protected WireFeed createRealFeed(String type,SyndFeed syndFeed) { Channel channel = new Channel(type); channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules())); channel.setEncoding(syndFeed.getEncoding()); channel.setTitle(syndFeed.getTitle()); if (syndFeed.getLink() != null) { channel.setLink(syndFeed.getLink()); } else if (syndFeed.getLinks().size() > 0) { channel.setLink(((SyndLink)syndFeed.getLinks().get(0)).getHref()); } channel.setDescription(syndFeed.getDescription()); SyndImage sImage = syndFeed.getImage(); if (sImage!=null) { channel.setImage(createRSSImage(sImage)); } List sEntries = syndFeed.getEntries(); if (sEntries!=null) { channel.setItems(createRSSItems(sEntries)); } if (((List)syndFeed.getForeignMarkup()).size() > 0) { channel.setForeignMarkup(syndFeed.getForeignMarkup()); } return channel; }
protected WireFeed createRealFeed(String type,SyndFeed syndFeed) { Channel channel = new Channel(type); channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules())); channel.setEncoding(syndFeed.getEncoding()); channel.setTitle(syndFeed.getTitle()); if (syndFeed.getLink() != null) { channel.setLink(syndFeed.getLink()); } else if (syndFeed.getLinks().size() > 0) { channel.setLink(((SyndLink)syndFeed.getLinks().get(0)).getHref()); } channel.setDescription(syndFeed.getDescription()); SyndImage sImage = syndFeed.getImage(); if (sImage!=null) { channel.setImage(createRSSImage(sImage)); } List sEntries = syndFeed.getEntries(); if (sEntries!=null) { channel.setItems(createRSSItems(sEntries)); } if (((List)syndFeed.getForeignMarkup()).size() > 0) { channel.setForeignMarkup(syndFeed.getForeignMarkup()); } return channel; }
HttpClientFeedFetcher feedFetcher = new HttpClientFeedFetcher(); try { SyndFeed feed = feedFetcher.retrieveFeed(new URL("http://habrahabr.ru/rss/")); System.out.println(feed.getLink()); } catch (IllegalArgumentException | IOException | FeedException | FetcherException e) { e.printStackTrace(); }
protected WireFeed createRealFeed(String type,SyndFeed syndFeed) { Channel channel = new Channel(type); channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules())); channel.setEncoding(syndFeed.getEncoding()); channel.setTitle(syndFeed.getTitle()); if (syndFeed.getLink() != null) { channel.setLink(syndFeed.getLink()); } else if (syndFeed.getLinks().size() > 0) { channel.setLink(((SyndLink)syndFeed.getLinks().get(0)).getHref()); } channel.setDescription(syndFeed.getDescription()); SyndImage sImage = syndFeed.getImage(); if (sImage!=null) { channel.setImage(createRSSImage(sImage)); } List sEntries = syndFeed.getEntries(); if (sEntries!=null) { channel.setItems(createRSSItems(sEntries)); } if (((List)syndFeed.getForeignMarkup()).size() > 0) { channel.setForeignMarkup(syndFeed.getForeignMarkup()); } return channel; }
/** * Render the title from the given Channel to the given StringBuffer, * using CSS styled 'div' tags. In this case, the title will be enclosed * in a <div> with the class <code>rss.channel.title</code>. If * the channel includes a link, the title will be rendered as a link to * that URL, and the <a> tag will also be of class * <code>rss.channel.title</code> * @param feed the RSS Channel we retrieved via the Feed URL * @param buf the StringBuffer we're using to prepare the output * TODO Figure out how to stop Radeox from filtering the URLs */ private void renderTitleCSS(SyndFeed feed, StringBuffer buf) { buf.append(NEWLINE).append("<div class='rsschanneltitle'>"); if (feed.getLink() != null) { buf.append("<a class='rsschanneltitle' href=\"") .append(Encoder.escape(feed.getLink())) .append("\">"); } buf.append(feed.getTitle()); if (feed.getLink() != null) buf.append("</a>"); buf.append(NEWLINE).append("</div>"); }
protected WireFeed createRealFeed(String type,SyndFeed syndFeed) { Channel channel = new Channel(type); channel.setModules(ModuleUtils.cloneModules(syndFeed.getModules())); channel.setEncoding(syndFeed.getEncoding()); channel.setTitle(syndFeed.getTitle()); if (syndFeed.getLink() != null) { channel.setLink(syndFeed.getLink()); } else if (syndFeed.getLinks().size() > 0) { channel.setLink(((SyndLink)syndFeed.getLinks().get(0)).getHref()); } channel.setDescription(syndFeed.getDescription()); SyndImage sImage = syndFeed.getImage(); if (sImage!=null) { channel.setImage(createRSSImage(sImage)); } List sEntries = syndFeed.getEntries(); if (sEntries!=null) { channel.setItems(createRSSItems(sEntries)); } if (((List)syndFeed.getForeignMarkup()).size() > 0) { channel.setForeignMarkup(syndFeed.getForeignMarkup()); } return channel; }
/** * If a parameter was passed with the name "img" and the literal value "true", * render the image from the channel (if it has one.) This requires the use * of named parameters. * @param feed the RSS Channel we retrieved via the Feed URL * @param writer the output writer * @param paramObj our parameter helper object * @throws java.io.IOException from calls to <code>writer.write()</code> */ private void renderImage(SyndFeed feed, Writer writer, RSSMacroParameters paramObj) throws java.io.IOException { if (feed.getImage() == null) return; if (!(paramObj.isImg())) return; SyndImage rssImage = feed.getImage(); StringBuffer buf = new StringBuffer(NEWLINE + "{image:"); buf.append("img=").append(rssImage.getUrl()); buf.append("|link=").append(feed.getLink()); buf.append("|align=").append(paramObj.getAlign()); if (rssImage.getDescription() != null) { buf.append("|alt=").append(rssImage.getDescription()); } buf.append("}"); Logger.debug("*** RSS image: " + buf); writer.write(buf.toString()); }
private Map<Channel, List<Document>> buildChannelMap(long userId) { List<Source> sources; if (userId == PUB_USER_KEY) { sources = articleDao.getPublicSources(); } else if (articleDao.hasSubscriptions(userId)) { sources = articleDao.getSources(userId); } else { return Collections.emptyMap(); } List<RufusFeed> requests = sources.parallelStream().map(RufusFeed::generate).collect(Collectors.toList()); Map<Channel, List<Document>> ret = new HashMap<>(); requests.stream().filter(r -> r.getFeed() != null).forEach(r -> { Pair<SyndFeed, List<SyndEntry>> synd = feedPair(r); ret.put(Channel.of( synd.getKey().getTitle(), synd.getKey().getLanguage(), synd.getKey().getLink(), r.getSource()), extractDocuments(synd)); }); return ret; }
protected WireFeed createRealFeed(String type,SyndFeed syndFeed) { Channel channel = (Channel) super.createRealFeed(type,syndFeed); if (syndFeed.getUri() != null) { channel.setUri(syndFeed.getUri()); } else { // if URI is not set use the value for link channel.setUri(syndFeed.getLink()); } return channel; }
protected WireFeed createRealFeed(String type,SyndFeed syndFeed) { Channel channel = (Channel) super.createRealFeed(type,syndFeed); if (syndFeed.getUri() != null) { channel.setUri(syndFeed.getUri()); } else { // if URI is not set use the value for link channel.setUri(syndFeed.getLink()); } return channel; }
@Override protected WireFeed createRealFeed(String type,SyndFeed syndFeed) { Channel channel = (Channel) super.createRealFeed(type,syndFeed); if (syndFeed.getUri() != null) { channel.setUri(syndFeed.getUri()); } else { // if URI is not set use the value for link channel.setUri(syndFeed.getLink()); } return channel; }
@Override protected WireFeed createRealFeed(String type,SyndFeed syndFeed) { Channel channel = (Channel) super.createRealFeed(type,syndFeed); if (syndFeed.getUri() != null) { channel.setUri(syndFeed.getUri()); } else { // if URI is not set use the value for link channel.setUri(syndFeed.getLink()); } return channel; }