Changeset 5478


Ignore:
Timestamp:
Nov 5, 2010, 11:38:08 AM (12 years ago)
Author:
Nicklas Nordborg
Message:

References #1545: Publish news as a rss feed

Added servlet RssNewsFeed to serve rss document. It will cache the current news so it should not be too heavy even if clients update often.

The feed includes all public news and the broadcast message that the admin can set in the Administrate -> Broadcast message dialog.

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/config/dist/web.xml

    r5395 r5478  
    181181  </servlet-mapping>
    182182
     183  <!-- The News feed servlet  -->
     184  <servlet>
     185    <servlet-name>news-feed</servlet-name>
     186    <servlet-class>
     187      net.sf.basedb.clients.web.servlet.RssNewsFeed
     188    </servlet-class>
     189  </servlet>
     190  <servlet-mapping>
     191    <servlet-name>news-feed</servlet-name>
     192    <url-pattern>/info/news.rss</url-pattern>
     193  </servlet-mapping>
    183194
    184195  <!-- Axis2 servlets for web services -->
  • trunk/www/admin/news/index.jsp

    r5426 r5478  
    4343  import="net.sf.basedb.util.formatter.Formatter"
    4444  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     45  import="net.sf.basedb.clients.web.servlet.RssNewsFeed"
    4546  import="java.util.Date"
    4647  import="java.util.Set"
     
    151152    dc.commit();
    152153    cc.removeObject("item");
     154    RssNewsFeed.reset();
    153155  }
    154156  else if ("DeleteItem".equals(cmd))
     
    159161    RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true);
    160162    dc.commit();
     163    RssNewsFeed.reset();
    161164    redirect = viewPage;
    162165  }
     
    169172    int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true);
    170173    dc.commit();
     174    RssNewsFeed.reset();
    171175    if (numTotal != numRemoved)
    172176    {
     
    182186    RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false);
    183187    dc.commit();
     188    RssNewsFeed.reset();
    184189    redirect = viewPage;
    185190  }
     
    192197    int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false);
    193198    dc.commit();
     199    RssNewsFeed.reset();
    194200    if (numTotal != numRemoved)
    195201    {
  • trunk/www/admin/server/submit_server.jsp

    r5426 r5478  
    3535  import="net.sf.basedb.clients.web.util.HTML"
    3636  import="net.sf.basedb.util.Values"
     37  import="net.sf.basedb.clients.web.servlet.RssNewsFeed"
    3738%>
    3839<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     
    123124      message = "Message is now disabled";
    124125    }
     126    RssNewsFeed.reset();
    125127  }
    126128  else
  • trunk/www/include/styles/main.css

    r5426 r5478  
    7171  border-bottom: 0px;
    7272}
     73
     74h3 * { vertical-align: bottom; }
    7375
    7476h4 {
  • trunk/www/info/news.jsp

    r5426 r5478  
    5050final String root = request.getContextPath()+"/";
    5151ItemResultList<News> news = null;
     52String broadcastTitle = (String)application.getAttribute("broadcast.title");
     53String broadcastMessage = (String)application.getAttribute("broadcast.message");
     54boolean denyLogin = Boolean.TRUE.equals(application.getAttribute("broadcast.deny-login"));
     55
    5256try
    5357{
     
    6367    <tr>
    6468    <td>
    65       <h3>News and announcements</h3>
     69      <h3>News and announcements <a href="news.rss"
     70        title="Subscribe to news from this BASE server"
     71        ><base:icon image="rss.png" /></a></h3>
    6672      <div id="news" class="news">
    6773      <%
     74      if (broadcastTitle != null)
     75      {
     76        %>
     77        <div class="item"><base:icon image="warning.gif" />
     78          <a name="broadcast"></a>
     79          <span class="date"><%=dateFormatter.format(new Date())%></span>
     80          <span class="headline"><%=HTML.encodeTags(broadcastTitle)%><%=denyLogin ? " (login disabled)" : "" %></span><br>
     81          <span class="text"><%=HTML.niceFormat(broadcastMessage)%></span>
     82        </div>
     83        <%
     84      }
    6885      ItemQuery<News> query = News.getQuery();
    6986      query.order(Orders.desc(Hql.property("newsDate")));
     
    7592        %>
    7693        <div class="item">
     94          <a name="<%=n.getId() + "-" + n.getVersion()%>"></a>
    7795          <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>
    7896          <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br>
     
    85103    </td>
    86104    </tr>
    87     <tr><td><base:icon image="left_arrow.gif" /><a href="<%=root%>/main.jsp?ID=<%=ID%>">Back to login</a></td></tr>
     105    <tr><td><base:icon image="goback.gif" /><a href="<%=root%>/main.jsp?ID=<%=ID%>">Back to login</a></td></tr>
    88106    </table>
    89107  </base:body>
  • trunk/www/main.jsp

    r5426 r5478  
    242242      %>
    243243     
    244       <h3>News and announcements</h3>
     244      <h3>News and announcements <a href="info/news.rss"
     245        title="Subscribe to news from this BASE server"
     246        ><base:icon image="rss.png" /></a>
     247      </h3>
    245248      <div id="news" class="news">
    246249      <%
     
    276279      {
    277280        %>
    278         <base:icon image="bullet.gif" /><a href="info/news.jsp"><%=news.getTotalCount()-10%> more</a>
     281        <base:icon image="bullet.gif" /><a href="info/news.jsp"
     282          title="Show older news..."><%=news.getTotalCount()-10%> more</a>
    279283        <%
    280284      }
  • trunk/www/my_base/index.jsp

    r5474 r5478  
    329329  <td width="50%">
    330330 
    331   <h3 class="light docked"><base:icon image="news.gif" />&nbsp;News and announcements (<%=news.size()%>)</h3>
     331  <h3 class="light docked"><base:icon image="news.gif" />&nbsp;News and announcements (<%=news.size()%>) <a href="../info/news.rss"
     332        title="Subscribe to news from this BASE server"
     333        ><base:icon image="rss.png" /></a></h3>
    332334    <div id="news" class="news welcomesection" style="height: 400px; overflow: auto;">
    333335    <%
Note: See TracChangeset for help on using the changeset viewer.