source: trunk/www/info/news.jsp @ 5478

Last change on this file since 5478 was 5478, checked in by Nicklas Nordborg, 12 years ago

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.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1<%-- $Id: news.jsp 5478 2010-11-05 10:38:08Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Gregory Vincic
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  This page lists all news in case they are too many to be shown
24  on the fron page.
25
26  @author Nicklas
27  @version 2.0
28--%>
29<%@ page pageEncoding="UTF-8" session="false"
30  import="net.sf.basedb.core.SessionControl"
31  import="net.sf.basedb.core.DbControl"
32  import="net.sf.basedb.core.News"
33  import="net.sf.basedb.core.ItemQuery"
34  import="net.sf.basedb.core.ItemResultList"
35  import="net.sf.basedb.core.query.Orders"
36  import="net.sf.basedb.core.query.Hql"
37  import="net.sf.basedb.core.query.Expressions"
38  import="net.sf.basedb.clients.web.Base"
39  import="net.sf.basedb.clients.web.util.HTML"
40  import="net.sf.basedb.util.Values"
41  import="net.sf.basedb.util.formatter.Formatter"
42  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
43  import="java.util.Date"
44%>
45<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
46<%
47final SessionControl sc = Base.getSessionControl(pageContext, true);
48final String ID = sc.getId();
49final DbControl dc = sc.newDbControl();
50final String root = request.getContextPath()+"/";
51ItemResultList<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
56try
57{
58  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
59  %>
60  <base:page type="default" title="">
61  <base:head styles="login.css">
62  </base:head>
63  <base:body>
64   
65    <table border=0 cellspacing=5 cellpadding=0 width="80%" align="center">
66    <tr><td><base:icon image="goback.gif" /><a href="<%=root%>/main.jsp?ID=<%=ID%>">Back to login</a></td></tr>
67    <tr>
68    <td>
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>
72      <div id="news" class="news">
73      <%
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      }
85      ItemQuery<News> query = News.getQuery();
86      query.order(Orders.desc(Hql.property("newsDate")));
87      query.order(Orders.desc(Hql.property("id")));
88      query.setCacheResult(true);
89      news = query.list(dc);
90      for (News n : news)
91      {
92        %>
93        <div class="item">
94          <a name="<%=n.getId() + "-" + n.getVersion()%>"></a>
95          <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>
96          <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br>
97          <span class="text"><%=Values.getString(n.getDescription())%></span>
98        </div>
99        <%
100      }
101      %>
102      </div>
103    </td>
104    </tr>
105    <tr><td><base:icon image="goback.gif" /><a href="<%=root%>/main.jsp?ID=<%=ID%>">Back to login</a></td></tr>
106    </table>
107  </base:body>
108  </base:page>
109  <%
110}
111finally
112{
113  if (dc != null) dc.close();
114}
115%>
116
Note: See TracBrowser for help on using the repository browser.