diff --git a/src/main/java/org/jivesoftware/site/FeedManager.java b/src/main/java/org/jivesoftware/site/FeedManager.java index e71ba6bb..2f9a4b99 100644 --- a/src/main/java/org/jivesoftware/site/FeedManager.java +++ b/src/main/java/org/jivesoftware/site/FeedManager.java @@ -12,9 +12,8 @@ import java.net.URL; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * FeedManager @@ -46,7 +45,7 @@ public List getBlogFeedEntries(String baseUrl, String feedUrl) { try { SyndFeed feed = feedFetcher.retrieveFeed(new URL(baseUrl + "/" + feedUrl )); if (null != feed) { - return (List)feed.getEntries(); + return (List)feed.getEntries().stream().filter(Objects::nonNull).collect(Collectors.toList()); } } catch (Exception e) { Log.warn("Problem getting Community Blog RSS feed '{}'.", baseUrl + "/" + feedUrl, e); @@ -55,15 +54,35 @@ public List getBlogFeedEntries(String baseUrl, String feedUrl) { } public List getItems( String baseUrl, String feedUrl, int max ) + { + return getTaggedItems(baseUrl, feedUrl, null, max); + } + + public List getTaggedItems( String baseUrl, String feedUrl, String tag, int max ) { final List result = new ArrayList<>( max ); final List entries = getBlogFeedEntries( baseUrl, feedUrl ); - for ( int i=0; i < entries.size() && i < max; i++ ) - { - result.add( new FeedItem( getJSON( entries.get( i ).getLink() ) ) ); + for (final SyndEntry entry : entries) { + if (entry == null) { + continue; + } + final JSONObject json = getJSON(entry.getLink()); + if (json == null) { + continue; + } + final FeedItem item = new FeedItem(json); + if (tag != null) { + if (Arrays.stream(item.getTags()).anyMatch(t -> t.equalsIgnoreCase(tag))) { + result.add(item); + } + } else { + result.add(item); + } + if (result.size() >= max) { + break; + } } - return result; } diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index b5b88060..f5dfb514 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,10 +1,8 @@ -<%@ page import="org.jivesoftware.site.Versions" %> -<%@ page import="org.jivesoftware.webservices.RestClient" %> -<%@ page import="org.jivesoftware.site.FeedManager" %> - +<%@ page import="org.jivesoftware.site.Versions"%> +<%@ page import="org.jivesoftware.webservices.RestClient"%> +<%@ page import="org.jivesoftware.site.FeedManager"%> <%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> <%@ taglib uri="http://igniterealtime.org/website/tags" prefix="ir" %> <% String baseUrl = config.getServletContext().getInitParameter("discourse_baseurl"); @@ -17,7 +15,6 @@ request.setAttribute( "feedManager", FeedManager.getInstance() ); request.setAttribute( "restClient", new RestClient() ); %> - a real time collaboration community site @@ -119,35 +116,13 @@ <%-- Show blog feed --%> - - <%--<% try { %>--%> - <%--<%--%> - <%--RestClient client = new RestClient();--%> - <%--String blogSearchUrl = restBaseUrl + "/search/places?filter=search(Ignite,Realtime,Blog)&filter=type(blog)";--%> - <%--JSONObject result = client.get(blogSearchUrl);--%> - <%--JSONArray results = result.getJSONArray("list");--%> - <%--JSONObject blog = (JSONObject)results.get(0);--%> - <%--String contentsUrl = blog.getJSONObject("resources").getJSONObject("contents").getString("ref");--%> - - <%--String blogRestUrl = contentsUrl + "?count=5";--%> - <%--result = client.get(blogRestUrl);--%> - <%--JSONArray posts = result.getJSONArray("list");--%> - <%--request.setAttribute("posts", posts);--%> - <%--%>--%> - <%----%> - <%--<% } catch (Exception e) { %>--%> - <%----%> - <%--<% } %>--%> - <%----%> - - diff --git a/src/main/webapp/projects/asterisk/index.jsp b/src/main/webapp/projects/asterisk/index.jsp index 834f4e71..6792bdf2 100644 --- a/src/main/webapp/projects/asterisk/index.jsp +++ b/src/main/webapp/projects/asterisk/index.jsp @@ -1,8 +1,20 @@ <%@ page import="org.jivesoftware.site.Versions"%> - +<%@ page import="org.jivesoftware.webservices.RestClient"%> +<%@ page import="org.jivesoftware.site.FeedManager"%> <%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> +<%@ taglib uri="http://igniterealtime.org/website/tags" prefix="ir" %> +<% + String baseUrl = config.getServletContext().getInitParameter("discourse_baseurl"); + if ( baseUrl == null || baseUrl.isEmpty() ) + { + baseUrl = "https://discourse.igniterealtime.org/"; + } + + request.setAttribute( "baseUrl", baseUrl ); + request.setAttribute( "feedManager", FeedManager.getInstance() ); + request.setAttribute( "restClient", new RestClient() ); +%> Asterisk-IM @@ -88,8 +100,26 @@ fully supported in the Spark IM client. Read more about - - + + +
+ +
+ + Latest Blog Entries + +
+ + + <%-- Show blog feed --%> + + + + + +
+ + diff --git a/src/main/webapp/projects/botz/index.jsp b/src/main/webapp/projects/botz/index.jsp index 2729c9af..717fb2e1 100644 --- a/src/main/webapp/projects/botz/index.jsp +++ b/src/main/webapp/projects/botz/index.jsp @@ -1,8 +1,20 @@ <%@ page import="org.jivesoftware.site.Versions"%> - +<%@ page import="org.jivesoftware.webservices.RestClient"%> +<%@ page import="org.jivesoftware.site.FeedManager"%> <%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> +<%@ taglib uri="http://igniterealtime.org/website/tags" prefix="ir" %> +<% + String baseUrl = config.getServletContext().getInitParameter("discourse_baseurl"); + if ( baseUrl == null || baseUrl.isEmpty() ) + { + baseUrl = "https://discourse.igniterealtime.org/"; + } + + request.setAttribute( "baseUrl", baseUrl ); + request.setAttribute( "feedManager", FeedManager.getInstance() ); + request.setAttribute( "restClient", new RestClient() ); +%> Botz @@ -74,8 +86,26 @@ - - + + +
+ +
+ + Latest Blog Entries + +
+ + + <%-- Show blog feed --%> + + + + + +
+ + diff --git a/src/main/webapp/projects/openfire/index.jsp b/src/main/webapp/projects/openfire/index.jsp index 5a89ce21..6cbe9919 100644 --- a/src/main/webapp/projects/openfire/index.jsp +++ b/src/main/webapp/projects/openfire/index.jsp @@ -1,9 +1,20 @@ <%@ page import="org.jivesoftware.site.Versions"%> - +<%@ page import="org.jivesoftware.webservices.RestClient"%> +<%@ page import="org.jivesoftware.site.FeedManager"%> <%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> -<%@ taglib tagdir="/WEB-INF/tags" prefix="i" %> +<%@ taglib uri="http://igniterealtime.org/website/tags" prefix="ir" %> +<% + String baseUrl = config.getServletContext().getInitParameter("discourse_baseurl"); + if ( baseUrl == null || baseUrl.isEmpty() ) + { + baseUrl = "https://discourse.igniterealtime.org/"; + } + + request.setAttribute( "baseUrl", baseUrl ); + request.setAttribute( "feedManager", FeedManager.getInstance() ); + request.setAttribute( "restClient", new RestClient() ); +%> Openfire Server @@ -91,8 +102,25 @@ - - + + +
+ +
+ + Latest Blog Entries + +
+ + + <%-- Show blog feed --%> + + + + + +
+ diff --git a/src/main/webapp/projects/pade/index.jsp b/src/main/webapp/projects/pade/index.jsp index 8648ad7e..9eba107f 100644 --- a/src/main/webapp/projects/pade/index.jsp +++ b/src/main/webapp/projects/pade/index.jsp @@ -1,8 +1,20 @@ <%@ page import="org.jivesoftware.site.Versions"%> - +<%@ page import="org.jivesoftware.webservices.RestClient"%> +<%@ page import="org.jivesoftware.site.FeedManager"%> <%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> +<%@ taglib uri="http://igniterealtime.org/website/tags" prefix="ir" %> +<% + String baseUrl = config.getServletContext().getInitParameter("discourse_baseurl"); + if ( baseUrl == null || baseUrl.isEmpty() ) + { + baseUrl = "https://discourse.igniterealtime.org/"; + } + + request.setAttribute( "baseUrl", baseUrl ); + request.setAttribute( "feedManager", FeedManager.getInstance() ); + request.setAttribute( "restClient", new RestClient() ); +%> Pade @@ -92,8 +104,26 @@ - - + + +
+ +
+ + Latest Blog Entries + +
+ + + <%-- Show blog feed --%> + + + + + +
+ + diff --git a/src/main/webapp/projects/smack/index.jsp b/src/main/webapp/projects/smack/index.jsp index 3c57494e..dd118f11 100644 --- a/src/main/webapp/projects/smack/index.jsp +++ b/src/main/webapp/projects/smack/index.jsp @@ -1,8 +1,20 @@ <%@ page import="org.jivesoftware.site.Versions"%> - +<%@ page import="org.jivesoftware.webservices.RestClient"%> +<%@ page import="org.jivesoftware.site.FeedManager"%> <%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> +<%@ taglib uri="http://igniterealtime.org/website/tags" prefix="ir" %> +<% + String baseUrl = config.getServletContext().getInitParameter("discourse_baseurl"); + if ( baseUrl == null || baseUrl.isEmpty() ) + { + baseUrl = "https://discourse.igniterealtime.org/"; + } + + request.setAttribute( "baseUrl", baseUrl ); + request.setAttribute( "feedManager", FeedManager.getInstance() ); + request.setAttribute( "restClient", new RestClient() ); +%> Smack API @@ -91,6 +103,25 @@ + +
+ +
+ + Latest Blog Entries + +
+ + + <%-- Show blog feed --%> + + + + + +
+ + diff --git a/src/main/webapp/projects/spark/index.jsp b/src/main/webapp/projects/spark/index.jsp index c800264f..4d1e4e79 100644 --- a/src/main/webapp/projects/spark/index.jsp +++ b/src/main/webapp/projects/spark/index.jsp @@ -1,8 +1,20 @@ <%@ page import="org.jivesoftware.site.Versions"%> - +<%@ page import="org.jivesoftware.webservices.RestClient"%> +<%@ page import="org.jivesoftware.site.FeedManager"%> <%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> +<%@ taglib uri="http://igniterealtime.org/website/tags" prefix="ir" %> +<% + String baseUrl = config.getServletContext().getInitParameter("discourse_baseurl"); + if ( baseUrl == null || baseUrl.isEmpty() ) + { + baseUrl = "https://discourse.igniterealtime.org/"; + } + + request.setAttribute( "baseUrl", baseUrl ); + request.setAttribute( "feedManager", FeedManager.getInstance() ); + request.setAttribute( "restClient", new RestClient() ); +%> Spark IM Client @@ -91,8 +103,26 @@ - - + + +
+ +
+ + Latest Blog Entries + +
+ + + <%-- Show blog feed --%> + + + + + +
+ + diff --git a/src/main/webapp/projects/tinder/index.jsp b/src/main/webapp/projects/tinder/index.jsp index 8f49789f..abd7f35e 100644 --- a/src/main/webapp/projects/tinder/index.jsp +++ b/src/main/webapp/projects/tinder/index.jsp @@ -1,8 +1,20 @@ <%@ page import="org.jivesoftware.site.Versions"%> - +<%@ page import="org.jivesoftware.webservices.RestClient"%> +<%@ page import="org.jivesoftware.site.FeedManager"%> <%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> +<%@ taglib uri="http://igniterealtime.org/website/tags" prefix="ir" %> +<% + String baseUrl = config.getServletContext().getInitParameter("discourse_baseurl"); + if ( baseUrl == null || baseUrl.isEmpty() ) + { + baseUrl = "https://discourse.igniterealtime.org/"; + } + + request.setAttribute( "baseUrl", baseUrl ); + request.setAttribute( "feedManager", FeedManager.getInstance() ); + request.setAttribute( "restClient", new RestClient() ); +%> Tinder API @@ -89,8 +101,26 @@ - - + + +
+ +
+ + Latest Blog Entries + +
+ + + <%-- Show blog feed --%> + + + + + +
+ + diff --git a/src/main/webapp/projects/whack/index.jsp b/src/main/webapp/projects/whack/index.jsp index a5725939..3eea21c9 100644 --- a/src/main/webapp/projects/whack/index.jsp +++ b/src/main/webapp/projects/whack/index.jsp @@ -1,8 +1,20 @@ -<%@ page import="org.jivesoftware.site.Versions" %> - +<%@ page import="org.jivesoftware.site.Versions"%> +<%@ page import="org.jivesoftware.webservices.RestClient"%> +<%@ page import="org.jivesoftware.site.FeedManager"%> <%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> +<%@ taglib uri="http://igniterealtime.org/website/tags" prefix="ir" %> +<% + String baseUrl = config.getServletContext().getInitParameter("discourse_baseurl"); + if ( baseUrl == null || baseUrl.isEmpty() ) + { + baseUrl = "https://discourse.igniterealtime.org/"; + } + + request.setAttribute( "baseUrl", baseUrl ); + request.setAttribute( "feedManager", FeedManager.getInstance() ); + request.setAttribute( "restClient", new RestClient() ); +%> Whack API @@ -86,8 +98,26 @@ - - + + +
+ +
+ + Latest Blog Entries + +
+ + + <%-- Show blog feed --%> + + + + + +
+ +