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

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

Fixes #1546: Publish news as a rss feed

Added possibility to disable the RSS feed by commenting out the servlet definition in web.xml.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1<%-- $Id: news.jsp 5479 2010-11-08 07:33:46Z 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="net.sf.basedb.clients.web.servlet.RssNewsFeed"
44  import="java.util.Date"
45%>
46<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
47<%
48final SessionControl sc = Base.getSessionControl(pageContext, true);
49final String ID = sc.getId();
50final DbControl dc = sc.newDbControl();
51final String root = request.getContextPath()+"/";
52ItemResultList<News> news = null;
53String broadcastTitle = (String)application.getAttribute("broadcast.title");
54String broadcastMessage = (String)application.getAttribute("broadcast.message");
55boolean denyLogin = Boolean.TRUE.equals(application.getAttribute("broadcast.deny-login"));
56
57try
58{
59  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
60  %>
61  <base:page type="default" title="">
62  <base:head styles="login.css">
63  </base:head>
64  <base:body>
65   
66    <table border=0 cellspacing=5 cellpadding=0 width="80%" align="center">
67    <tr><td><base:icon image="goback.gif" /><a href="<%=root%>/main.jsp?ID=<%=ID%>">Back to login</a></td></tr>
68    <tr>
69    <td>
70      <h3>News and announcements
71      <%
72      if (RssNewsFeed.isEnabled()) 
73      {
74        %><a href="news.rss" 
75          title="Subscribe to news from this BASE server"
76          ><base:icon image="rss.png" /></a>
77        <%
78      }
79      %>
80      </h3>
81      <div id="news" class="news">
82      <%
83      if (broadcastTitle != null)
84      {
85        %>
86        <div class="item"><base:icon image="warning.gif" />
87          <a name="broadcast"></a>
88          <span class="date"><%=dateFormatter.format(new Date())%></span>
89          <span class="headline"><%=HTML.encodeTags(broadcastTitle)%><%=denyLogin ? " (login disabled)" : "" %></span><br>
90          <span class="text"><%=HTML.niceFormat(broadcastMessage)%></span>
91        </div>
92        <% 
93      }
94      ItemQuery<News> query = News.getQuery();
95      query.order(Orders.desc(Hql.property("newsDate")));
96      query.order(Orders.desc(Hql.property("id")));
97      query.setCacheResult(true);
98      news = query.list(dc);
99      for (News n : news)
100      {
101        %>
102        <div class="item">
103          <a name="<%=n.getId() + "-" + n.getVersion()%>"></a>
104          <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>
105          <span class="headline"><%=HTML.encodeTags(n.getName())%></span><br>
106          <span class="text"><%=Values.getString(n.getDescription())%></span>
107        </div>
108        <%
109      }
110      %>
111      </div>
112    </td>
113    </tr>
114    <tr><td><base:icon image="goback.gif" /><a href="<%=root%>/main.jsp?ID=<%=ID%>">Back to login</a></td></tr>
115    </table>
116  </base:body>
117  </base:page>
118  <%
119}
120finally
121{
122  if (dc != null) dc.close();
123}
124%>
125
Note: See TracBrowser for help on using the repository browser.