Changeset 7394


Ignore:
Timestamp:
Jun 9, 2017, 2:23:58 PM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2085: Sticky news

Various places where news are displyed have been updated to sort the news with the "sticky" flag set first. The sticky news item are displayed with a different background color and a "paperclip" icon.

The login page has also been modified to show all sticky news even if there are more than 10 items which was the limit before.

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/servlet/RssNewsFeed.java

    r7158 r7394  
    174174
    175175      ItemQuery<News> query = News.getQuery();
     176      query.order(Orders.desc(Hql.property("sticky")));
    176177      query.order(Orders.desc(Hql.property("newsDate")));
    177178      query.order(Orders.desc(Hql.property("id")));
  • trunk/www/include/styles/login.css

    r6632 r7394  
    9595.news .item
    9696{
    97   margin-top: 2px;
     97  padding: 0.25em;
    9898  border-bottom-width: 1px;
    9999  border-bottom-style: dotted;
    100   padding-bottom: 2px;
     100}
     101
     102.news .item.sticky
     103{
     104  background-image: url('../../images/paperclip.png');
     105  background-repeat: no-repeat;
     106  background-position: 2px 0.5em;
     107  padding-left: 24px;
    101108}
    102109
     
    140147{
    141148  border-width: 0 1px 1px 1px;
    142   padding: 2px;
    143149}
    144150
  • trunk/www/info/news.jsp

    r6177 r7394  
    8484      {
    8585        %>
    86         <div class="item">
     86        <div class="item note sticky">
    8787          <div class="headline">
    88             <base:icon image="warning.png" />
    8988            <a name="broadcast"></a>
    9089            <span class="date"><%=dateFormatter.format(new Date())%></span>
     
    9695      }
    9796      ItemQuery<News> query = News.getQuery();
     97      query.order(Orders.desc(Hql.property("sticky")));
    9898      query.order(Orders.desc(Hql.property("newsDate")));
    9999      query.order(Orders.desc(Hql.property("id")));
     
    103103      {
    104104        %>
    105         <div class="item">
     105        <div class="item <%=n.isSticky() ? "note sticky" : ""%>">
    106106          <div class="headline">
    107107            <a name="<%=n.getId() + "-" + n.getVersion()%>"></a>
  • trunk/www/main.jsp

    r7114 r7394  
    3737  import="net.sf.basedb.core.News"
    3838  import="net.sf.basedb.core.ItemQuery"
    39   import="net.sf.basedb.core.ItemResultList"
     39  import="net.sf.basedb.core.ItemResultIterator"
    4040  import="net.sf.basedb.core.query.Orders"
    4141  import="net.sf.basedb.core.query.Hql"
     
    7878  String broadcastMessage = (String)application.getAttribute("broadcast.message");
    7979  boolean denyLogin = Boolean.TRUE.equals(application.getAttribute("broadcast.deny-login"));
    80   ItemResultList<News> news = null;
     80  ItemResultIterator<News> news = null;
    8181  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext);
    8282  ExtensionsInvoker<LoginFormAction> invoker = (ExtensionsInvoker<LoginFormAction>)ExtensionsControl.useExtensions(jspContext, "net.sf.basedb.clients.web.login-form");
     
    242242      {
    243243        %>
    244         <div class="item">
     244        <div class="item note sticky">
    245245          <div class="headline">
    246             <base:icon image="warning.png" />
    247246            <span class="date"><%=dateFormatter.format(new Date())%></span>
    248247            <%=HTML.encodeTags(broadcastTitle)%><%=denyLogin ? " (login disabled)" : "" %>
     
    254253     
    255254      ItemQuery<News> query = News.getQuery();
     255      query.order(Orders.desc(Hql.property("sticky")));
    256256      query.order(Orders.desc(Hql.property("newsDate")));
    257257      query.order(Orders.desc(Hql.property("id")));
    258258      query.setCacheResult(true);
    259259      query.setReturnTotalCount(true);
    260       query.setMaxResults(10);
    261       news = query.list(dc);
    262       for (News n : news)
    263       {
    264         %>
    265         <div class="item">
     260      news = query.iterate(dc);
     261      int numListed = 0;
     262      while (news.hasNext())
     263      {
     264        News n = news.next();
     265        if (numListed >= 10 && !n.isSticky()) break;
     266        %>
     267        <div class="item <%=n.isSticky() ? "note sticky" : ""%>">
    266268          <div class="headline">
    267269            <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>
     
    271273        </div>
    272274        <%
    273       }
    274       if (news.getTotalCount() > 10)
     275        numListed++;
     276      }
     277      if (numListed < news.getTotalCount())
    275278      {
    276279        %>
    277280        <base:icon image="bullet.png" /><a href="info/news.jsp"
    278           title="Show older news..."><%=news.getTotalCount()-10%> more</a>
     281          title="Show older news..."><%=news.getTotalCount()-numListed%> more</a>
    279282        <%
    280283      }
  • trunk/www/my_base/index.jsp

    r6625 r7394  
    160160    )
    161161  );
     162  newsQuery.order(Orders.desc(Hql.property("sticky")));
    162163  newsQuery.order(Orders.desc(Hql.property("newsDate")));
    163164  newsQuery.order(Orders.desc(Hql.property("id")));
     
    252253        String broadcastMessage = (String)application.getAttribute("broadcast.message");
    253254        %>
    254         <div class="item">
     255        <div class="item note sticky">
    255256          <div class="headline">
    256             <base:icon image="warning.png" />
    257257            <span class="date"><%=dateFormatter.format(new Date())%></span>
    258258            <%=HTML.encodeTags(broadcastTitle)%>
     
    362362          {
    363363            %>
    364             <div class="item">
     364            <div class="item <%=n.isSticky() ? "note sticky" :""%>">
    365365              <div class="headline">
    366366                <span class="date"><%=dateFormatter.format(n.getNewsDate())%></span>
Note: See TracChangeset for help on using the changeset viewer.