roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eli...@apache.org
Subject svn commit: r521877 - in /incubator/roller/trunk/src/org/apache/roller/ui/rendering: model/FeedModel.java model/SearchResultsFeedModel.java pagers/SearchResultsFeedPager.java
Date Fri, 23 Mar 2007 19:27:44 GMT
Author: eliast
Date: Fri Mar 23 12:27:44 2007
New Revision: 521877

URL: http://svn.apache.org/viewvc?view=rev&rev=521877
Log:
Fixed URL creation for paging of feeds because our current URLUtilities.getXXX model doesn't
work well with paging.

Modified:
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SearchResultsFeedModel.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/SearchResultsFeedPager.java

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java?view=diff&rev=521877&r1=521876&r2=521877
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java Fri Mar
23 12:27:44 2007
@@ -20,6 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -51,6 +52,8 @@
     
     private static Log log = LogFactory.getLog(FeedModel.class); 
     
+    private static int DEFAULT_ENTRIES = RollerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");
+    
     private WeblogFeedRequest feedRequest = null;
     private WebsiteData weblog = null;
     
@@ -114,29 +117,12 @@
         return feedRequest.getWeblogCategoryName();
     }
     
-    
     /**
      * Gets most recent entries limited by: weblog and category specified in 
      * request plus the weblog.entryDisplayCount.
      */
     public Pager getWeblogEntriesPager() {
-        
-        // all feeds get the site-wide default # of entries
-        int entryCount =
-                RollerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");
-        
-        String  pagerUrl = URLUtilities.getWeblogFeedURL(weblog, 
-                    feedRequest.getLocale(), feedRequest.getType(),
-                    feedRequest.getFormat(), feedRequest.getWeblogCategoryName(), 
-                    null, feedRequest.getTags(), feedRequest.isExcerpts(), true);
-       
-        return new WeblogEntriesListPager(
-            pagerUrl, weblog, null, feedRequest.getWeblogCategoryName(),
-            feedRequest.getTags(),
-            feedRequest.getLocale(),
-            -1,
-            feedRequest.getPage(), 
-            entryCount);        
+        return new FeedEntriesPager(feedRequest);        
     }
     
     
@@ -145,24 +131,9 @@
      * the weblog.entryDisplayCount.
      */
     public Pager getCommentsPager() {
-            
-        // all feeds get the site-wide default # of entries
-        int entryCount =
-                RollerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");
-        
-        String pagerUrl = URLUtilities.getWeblogFeedURL(weblog, 
-                    feedRequest.getLocale(), feedRequest.getType(),
-                    feedRequest.getFormat(), null, null, null,
-                    feedRequest.isExcerpts(), true);
+        return new FeedCommentsPager(feedRequest);
+    }    
         
-        return new CommentsPager(
-            pagerUrl,
-            feedRequest.getLocale(),
-            -1,
-            feedRequest.getPage(), 
-            entryCount);        
-    }
-    
     /**
      * Returns the list of tags specified in the request /?tags=foo+bar
      * @return
@@ -170,5 +141,69 @@
     public List getTags() {
         return feedRequest.getTags();
     }    
+
+    public static class FeedEntriesPager extends WeblogEntriesListPager {
+        
+        private WeblogFeedRequest feedRequest;
+        
+        public FeedEntriesPager(WeblogFeedRequest feedRequest) {
+            super(URLUtilities.getWeblogFeedURL(feedRequest.getWeblog(), 
+                    feedRequest.getLocale(), feedRequest.getType(),
+                    feedRequest.getFormat(), null, null, null, false, true), 
+                    feedRequest.getWeblog(), null, null, feedRequest.getTags(),
+                    feedRequest.getLocale(), -1, feedRequest.getPage(), DEFAULT_ENTRIES);
+            this.feedRequest = feedRequest;
+        }
+        
+        protected String createURL(String url, Map params) {
+            List tags = feedRequest.getTags();
+            if(tags != null && tags.size() > 0) {
+                params.put("tags", URLUtilities.getEncodedTagsString(tags));
+            }
+            String category = feedRequest.getWeblogCategoryName();
+            if(category != null && category.trim().length() > 0) {
+                params.put("cat", URLUtilities.encode(category));
+            }  
+            if(feedRequest.isExcerpts()) {
+                params.put("excerpts", "true");
+            }            
+            return super.createURL(url, params);
+        }
+        
+        public String getUrl() {
+            return createURL(super.getUrl(), new HashMap());
+        }
+    }
     
+    public static class FeedCommentsPager extends CommentsPager {
+        
+        private WeblogFeedRequest feedRequest;
+        
+        public FeedCommentsPager(WeblogFeedRequest feedRequest) {            
+            super(URLUtilities.getWeblogFeedURL(feedRequest.getWeblog(), 
+                    feedRequest.getLocale(), feedRequest.getType(),
+                    feedRequest.getFormat(), null, null,
+                    null, false, true), feedRequest.getLocale(), -1, feedRequest.getPage(),
DEFAULT_ENTRIES);
+            this.feedRequest = feedRequest;
+        }
+        
+        protected String createURL(String url, Map params) {
+            List tags = feedRequest.getTags();
+            if(tags != null && tags.size() > 0) {
+                params.put("tags", URLUtilities.getEncodedTagsString(tags));
+            }
+            String category = feedRequest.getWeblogCategoryName();
+            if(category != null && category.trim().length() > 0) {
+                params.put("cat", URLUtilities.encode(category));
+            }  
+            if(feedRequest.isExcerpts()) {
+                params.put("excerpts", "true");
+            }   
+            return super.createURL(url, params);
+        }
+        
+        public String getUrl() {
+            return createURL(super.getUrl(), new HashMap());
+        }
+    }      
 }

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SearchResultsFeedModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SearchResultsFeedModel.java?view=diff&rev=521877&r1=521876&r2=521877
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SearchResultsFeedModel.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SearchResultsFeedModel.java
Fri Mar 23 12:27:44 2007
@@ -111,7 +111,7 @@
         String  pagerUrl = URLUtilities.getWeblogFeedURL(weblog, 
                 feedRequest.getLocale(), feedRequest.getType(),
                 feedRequest.getFormat(), null, null, /* cat and term are null but added to
the url in the pager */
-                feedRequest.getTags(), feedRequest.isExcerpts(), true);
+                null, false, true);
         
         // if there is no query, then we are done
         if(feedRequest.getTerm() == null) {

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/SearchResultsFeedPager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/SearchResultsFeedPager.java?view=diff&rev=521877&r1=521876&r2=521877
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/SearchResultsFeedPager.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/SearchResultsFeedPager.java
Fri Mar 23 12:27:44 2007
@@ -89,6 +89,13 @@
         String term = feedRequest.getTerm();
         if(term != null && term.trim().length() > 0) {
             params.put("q", URLUtilities.encode(term.trim()));
+        }     
+        List tags = feedRequest.getTags();
+        if(tags != null && tags.size() > 0) {
+            params.put("tags", URLUtilities.getEncodedTagsString(tags));
+        }
+        if(feedRequest.isExcerpts()) {
+            params.put("excerpts", "true");
         }        
         return super.createURL(url, params);
     }



Mime
View raw message