roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r522638 - in /incubator/roller/trunk/src/org/apache/roller: business/hibernate/ pojos/ ui/authoring/struts/actions/ ui/rendering/ ui/rendering/servlets/ ui/rendering/util/ ui/rendering/util/cache/
Date Mon, 26 Mar 2007 21:43:25 GMT
Author: agilliland
Date: Mon Mar 26 14:43:24 2007
New Revision: 522638

URL: http://svn.apache.org/viewvc?view=rev&rev=522638
Log:
add support for tags index template action.


Modified:
    incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
    incubator/roller/trunk/src/org/apache/roller/pojos/Template.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/SiteWideCache.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/WeblogPageCache.java

Modified: incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java?view=diff&rev=522638&r1=522637&r2=522638
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
Mon Mar 26 14:43:24 2007
@@ -238,6 +238,9 @@
         
     public void removePage(WeblogTemplate page) throws RollerException {
         this.strategy.remove(page);
+        
+        // update weblog last modified date.  date updated by saveWebsite()
+        RollerFactory.getRoller().getUserManager().saveWebsite(page.getWebsite());
     }
         
     public void addUser(UserData newUser) throws RollerException {

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/Template.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/Template.java?view=diff&rev=522638&r1=522637&r2=522638
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/Template.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/Template.java Mon Mar 26 14:43:24 2007
@@ -32,6 +32,7 @@
     public static final String ACTION_WEBLOG = "weblog";
     public static final String ACTION_PERMALINK = "permalink";
     public static final String ACTION_SEARCH = "search";
+    public static final String ACTION_TAGSINDEX = "tagsIndex";
     public static final String ACTION_CUSTOM = "custom";
     
     

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java?view=diff&rev=522638&r1=522637&r2=522638
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java
Mon Mar 26 14:43:24 2007
@@ -241,6 +241,7 @@
                 availableActions.add(WeblogTemplate.ACTION_PERMALINK);
                 availableActions.add(WeblogTemplate.ACTION_SEARCH);
                 availableActions.add(WeblogTemplate.ACTION_WEBLOG);
+                availableActions.add(WeblogTemplate.ACTION_TAGSINDEX);
                 
                 WeblogTemplate tmpPage = null;
                 Iterator pagesIter = model.getPages().iterator();

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java?view=diff&rev=522638&r1=522637&r2=522638
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/WeblogRequestMapper.java Mon
Mar 26 14:43:24 2007
@@ -193,6 +193,15 @@
             response.sendRedirect(redirectUrl);
             return true;
             
+        } else if(weblogRequestContext != null &&
+                "tags".equals(weblogRequestContext)) {
+            // tags section can have an index page at /<weblog>/tags/ and
+            // a tags query at /<weblog>/tags/tag1+tag2, buth that's it
+            if((weblogRequestData == null && !trailingSlash) ||
+                    (weblogRequestData != null && trailingSlash)) {
+                response.sendError(HttpServletResponse.SC_NOT_FOUND);
+                return true;
+            }
         } else if(weblogRequestContext != null && trailingSlash) {
             // this means that someone has accessed a weblog url and included
             // a trailing slash, like /<weblog>/entry/<anchor>/ which is not

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java?view=diff&rev=522638&r1=522637&r2=522638
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java Mon
Mar 26 14:43:24 2007
@@ -242,8 +242,25 @@
             }
             
         // If request specified the page, then go with that
-        } else if(pageRequest.getWeblogPageName() != null) {
+        } else if("page".equals(pageRequest.getContext())) {
             page = pageRequest.getWeblogPage();
+            
+        // If request specified tags section index, then look for custom template
+        } else if("tags".equals(pageRequest.getContext()) &&
+                pageRequest.getTags() == null) {
+            try {
+                page = weblog.getPageByAction(Template.ACTION_TAGSINDEX);
+            } catch(Exception e) {
+                log.error("Error getting weblog page for action 'tagsIndex'", e);
+            }
+            
+            // if we don't have a custom tags page then 404, we don't let
+            // this one fall through to the default template
+            if(page == null) {
+                if(!response.isCommitted()) response.reset();
+                response.sendError(HttpServletResponse.SC_NOT_FOUND);
+                return;
+            }
             
         // If this is a permalink then look for a permalink template
         } else if(pageRequest.getWeblogAnchor() != null) {

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java?view=diff&rev=522638&r1=522637&r2=522638
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
Mon Mar 26 14:43:24 2007
@@ -108,7 +108,7 @@
          * /entry/<anchor> - permalink
          * /date/<YYYYMMDD> - date collection view
          * /category/<category> - category collection view
-         * /tags/spring+framework - tags
+         * /tags/<tag>+<tag> - tags
          * /page/<pagelink> - custom page
          *
          * path info may be null, which indicates the weblog homepage
@@ -116,22 +116,14 @@
         if(pathInfo != null && pathInfo.trim().length() > 0) {
             
             // all views use 2 path elements, except category
-            String[] pathElements = pathInfo.split("/");
-            if(pathElements.length > 1 && "category".equals(pathElements[0]))
{
-                
-                // category may have multiple path elements, so re-split with max 2
-                pathElements = pathInfo.split("/", 2);
-                this.context = pathElements[0];
-                this.weblogCategoryName = "/"+URLUtilities.decode(pathElements[1]);
-                
-                // all categories must start with a /
-                if(!this.weblogCategoryName.startsWith("/")) {
-                    this.weblogCategoryName = "/"+this.weblogCategoryName;
-                }
-
-            } else if(pathElements.length == 2) {
+            String[] pathElements = pathInfo.split("/", 2);
+            
+            // the first part of the path always represents the context
+            this.context = pathElements[0];
+            
+            // now check the rest of the path and extract other details
+            if(pathElements.length == 2) {
                 
-                this.context = pathElements[0];
                 if("entry".equals(this.context)) {
                     this.weblogAnchor = URLUtilities.decode(pathElements[1]);
                     
@@ -143,6 +135,14 @@
                             request.getRequestURL());
                     }
                     
+                } else if("category".equals(this.context)) {
+                    this.weblogCategoryName = URLUtilities.decode(pathElements[1]);
+                    
+                    // all categories must start with a /
+                    if(!this.weblogCategoryName.startsWith("/")) {
+                        this.weblogCategoryName = "/"+this.weblogCategoryName;
+                    }
+                    
                 } else if("page".equals(this.context)) {
                     this.weblogPageName = pathElements[1];
 
@@ -159,8 +159,11 @@
                 }
                 
             } else {
-                throw new InvalidRequestException("bad path info, "+
-                        request.getRequestURL());
+                // empty data is only allowed for the tags section
+                if(!"tags".equals(this.context)) {
+                    throw new InvalidRequestException("invalid index page, "+
+                            request.getRequestURL());
+                }
             }
             
         } else {

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/SiteWideCache.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/SiteWideCache.java?view=diff&rev=522638&r1=522637&r2=522638
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/SiteWideCache.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/SiteWideCache.java
Mon Mar 26 14:43:24 2007
@@ -25,6 +25,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeSet;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -228,10 +229,13 @@
                 key.append("/").append(cat);
             }
             
-            if(pageRequest.getTags() != null && pageRequest.getTags().size() >
0) {
-              String[] tags = new String[pageRequest.getTags().size()];
-              new TreeSet(pageRequest.getTags()).toArray(tags);
-              key.append("/tags/").append(Utilities.stringArrayToString(tags,"+"));
+            if("tags".equals(pageRequest.getContext())) {
+                key.append("/tags/");
+                if(pageRequest.getTags() != null && pageRequest.getTags().size()
> 0) {
+                    Set ordered = new TreeSet(pageRequest.getTags());
+                    String[] tags = (String[]) ordered.toArray(new String[ordered.size()]);
+                    key.append(Utilities.stringArrayToString(tags,"+"));
+                }
             }
         }
         

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/WeblogPageCache.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/WeblogPageCache.java?view=diff&rev=522638&r1=522637&r2=522638
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/WeblogPageCache.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/util/cache/WeblogPageCache.java
Mon Mar 26 14:43:24 2007
@@ -201,11 +201,14 @@
                 key.append("/").append(cat);
             }
             
-            if(pageRequest.getTags() != null && pageRequest.getTags().size() >
0) {
-              Set ordered = new TreeSet(pageRequest.getTags());
-              String[] tags = (String[]) ordered.toArray(new String[ordered.size()]);  
-              key.append("/tags/").append(Utilities.stringArrayToString(tags,"+"));
-            }            
+            if("tags".equals(pageRequest.getContext())) {
+                key.append("/tags/");
+                if(pageRequest.getTags() != null && pageRequest.getTags().size()
> 0) {
+                    Set ordered = new TreeSet(pageRequest.getTags());
+                    String[] tags = (String[]) ordered.toArray(new String[ordered.size()]);
+                    key.append(Utilities.stringArrayToString(tags,"+"));
+                }
+            }
         }
         
         if(pageRequest.getLocale() != null) {



Mime
View raw message