roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r521615 - in /incubator/roller/trunk: metadata/database/ metadata/database/tmpls/ src/org/apache/roller/business/ src/org/apache/roller/business/hibernate/ src/org/apache/roller/pojos/ src/org/apache/roller/ui/authoring/struts/actions/ src/...
Date Fri, 23 Mar 2007 07:53:21 GMT
Author: agilliland
Date: Fri Mar 23 00:53:04 2007
New Revision: 521615

URL: http://svn.apache.org/viewvc?view=rev&rev=521615
Log:
initial support for individual templates by action as described here ...

http://cwiki.apache.org/confluence/display/ROLLER/Proposal+Individual+Templates+by+Action

this commit focuses on the functional aspects of the proposal, the UI elements of the proposal
are expected to get further refinement and improvement before being considered final.


Modified:
    incubator/roller/trunk/metadata/database/dbscripts.properties
    incubator/roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm
    incubator/roller/trunk/metadata/database/tmpls/createdb.vm
    incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java
    incubator/roller/trunk/src/org/apache/roller/business/UserManager.java
    incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
    incubator/roller/trunk/src/org/apache/roller/pojos/StaticTemplate.java
    incubator/roller/trunk/src/org/apache/roller/pojos/Template.java
    incubator/roller/trunk/src/org/apache/roller/pojos/Theme.java
    incubator/roller/trunk/src/org/apache/roller/pojos/ThemeTemplate.java
    incubator/roller/trunk/src/org/apache/roller/pojos/WeblogTemplate.java
    incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogTemplateFormAction.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java
    incubator/roller/trunk/tests/org/apache/roller/business/WeblogPageTest.java
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp

Modified: incubator/roller/trunk/metadata/database/dbscripts.properties
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/metadata/database/dbscripts.properties?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/metadata/database/dbscripts.properties (original)
+++ incubator/roller/trunk/metadata/database/dbscripts.properties Fri Mar 23 00:53:04 2007
@@ -7,5 +7,5 @@
 # list all db templates to generate, separated by spaces
 templates=createdb 200-to-210-migration 210-to-230-migration \
 230-to-240-migration 240-to-300-migration 300-to-310-migration \
-310-to-320-migration
+310-to-320-migration 3xx-to-400-migration
 

Modified: incubator/roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm (original)
+++ incubator/roller/trunk/metadata/database/tmpls/3xx-to-400-migration.vm Fri Mar 23 00:53:04
2007
@@ -6,6 +6,9 @@
 
 #addColumnNull("webpage" "outputtype" "varchar(48)")
 
+-- add new action column to webpage table, default value is custom
+#addColumnNotNull("webpage" "action" "varchar(16)" "'custom'")
+update webpage set action = 'weblog' where name = 'Weblog';
 
 -- remove old id column of group subscription table
 alter table rag_group_subscription drop column id;

Modified: incubator/roller/trunk/metadata/database/tmpls/createdb.vm
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/metadata/database/tmpls/createdb.vm?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/metadata/database/tmpls/createdb.vm (original)
+++ incubator/roller/trunk/metadata/database/tmpls/createdb.vm Fri Mar 23 00:53:04 2007
@@ -78,7 +78,8 @@
     navbar          $db.BOOLEAN_SQL_TYPE_FALSE not null,
     templatelang    varchar(20) not null,
     decorator       varchar(255) default null,
-    outputtype      varchar(48) default null
+    outputtype      varchar(48) default null,
+    action          varchar(16) not null default 'custom'
 );
 create index wp_name_idx on webpage( name$!db.INDEXSIZE );
 create index wp_link_idx on webpage( link$!db.INDEXSIZE );

Modified: incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/ThemeManagerImpl.java Fri Mar 23
00:53:04 2007
@@ -143,10 +143,10 @@
                 
                 WeblogTemplate template = null;
                 
-                if(theme_template.getName().equals(WeblogTemplate.DEFAULT_PAGE)) {
+                if(theme_template.getAction().equals(WeblogTemplate.ACTION_WEBLOG)) {
                     // this is the main Weblog template
                     try {
-                        template = userMgr.getPage(website.getDefaultPageId());
+                        template = userMgr.getPageByAction(website, WeblogTemplate.ACTION_WEBLOG);
                     } catch(Exception e) {
                         // user may not have a default page yet
                     }
@@ -155,6 +155,9 @@
                     template = userMgr.getPageByName(website, theme_template.getName());
                 }
                 
+                // TODO: in order to ensure that left over templates don't cause
+                // conflicts we should probably delete all templates where
+                // action!=custom that isn't in the theme we are customizing
                 
                 if (template != null) {
                     // User already has page by that name, so overwrite it.
@@ -163,19 +166,19 @@
                     
                 } else {
                     // User does not have page by that name, so create new page.
-                    template = new WeblogTemplate(
-                            null,                               // id
-                            website,                            // website
-                            theme_template.getName(),           // name
-                            theme_template.getDescription(),    // description
-                            theme_template.getLink(),           // link
-                            theme_template.getContents(),       // contents
-                            new Date(),                         // last mod
-                            theme_template.getTemplateLanguage(), // temp lang
-                            theme_template.isHidden(),          // hidden
-                            theme_template.isNavbar(),          // navbar
-                            theme_template.getDecoratorName()   // decorator
-                            );
+                    template = new WeblogTemplate();
+                    template.setWebsite(website);
+                    template.setAction(theme_template.getAction());
+                    template.setName(theme_template.getName());
+                    template.setDescription(theme_template.getDescription());
+                    template.setContents(theme_template.getContents());
+                    template.setHidden(theme_template.isHidden());
+                    template.setNavbar(theme_template.isNavbar());
+                    template.setTemplateLanguage(theme_template.getTemplateLanguage());
+                    template.setDecoratorName(theme_template.getDecoratorName());
+                    template.setLastModified(new Date());
+                    
+                    // save it
                     userMgr.savePage( template );
                     
                     // we just created and saved the default page for the first
@@ -361,6 +364,7 @@
             theme_template = new ThemeTemplate(
                     theme,
                     themeMetadata.getId()+":"+templateMetadata.getName(),
+                    templateMetadata.getAction(),
                     templateMetadata.getName(),
                     templateMetadata.getDescription(),
                     new String(chars, 0, length),

Modified: incubator/roller/trunk/src/org/apache/roller/business/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/UserManager.java?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/UserManager.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/UserManager.java Fri Mar 23 00:53:04
2007
@@ -27,6 +27,7 @@
 import org.apache.roller.pojos.UserData;
 import org.apache.roller.pojos.WebsiteData;
 
+
 /**
  * Manages users, weblogs, permissions, and weblog pages.
  */
@@ -349,6 +350,12 @@
      * Get page by id.
      */
     public WeblogTemplate getPage(String id) throws RollerException;
+    
+    
+    /**
+     * Get user's page by action.
+     */
+    public WeblogTemplate getPageByAction(WebsiteData w, String a) throws RollerException;
     
     
     /**

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=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
Fri Mar 23 00:53:04 2007
@@ -674,6 +674,32 @@
         }
     }
     
+    
+    /**
+     * @see org.apache.roller.model.UserManager#getPageByAction(WebsiteData, java.lang.String)
+     */
+    public WeblogTemplate getPageByAction(WebsiteData website, String action)
+            throws RollerException {
+        
+        if (website == null)
+            throw new RollerException("website is null");
+        
+        if (action == null)
+            throw new RollerException("Action name is null");
+        
+        try {
+            Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
+            Criteria criteria = session.createCriteria(WeblogTemplate.class);
+            criteria.add(Expression.eq("website", website));
+            criteria.add(Expression.eq("action", action));
+            
+            return (WeblogTemplate) criteria.uniqueResult();
+        } catch (HibernateException e) {
+            throw new RollerException(e);
+        }
+    }
+    
+    
     /**
      * @see org.apache.roller.model.UserManager#getPageByName(WebsiteData, java.lang.String)
      */

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/StaticTemplate.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/StaticTemplate.java?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/StaticTemplate.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/StaticTemplate.java Fri Mar 23 00:53:04
2007
@@ -32,6 +32,7 @@
 public class StaticTemplate implements Template, Serializable {
     
     private String id = null;
+    private String action = null;
     private String name = null;
     private String description = null;
     private String contents = null;
@@ -140,4 +141,12 @@
     public void setOutputContentType(String outputContentType) {
         this.outputContentType = outputContentType;
     }    
+
+    public String getAction() {
+        return action;
+    }
+
+    public void setAction(String action) {
+        this.action = action;
+    }
 }

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=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/Template.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/Template.java Fri Mar 23 00:53:04 2007
@@ -29,12 +29,23 @@
  */
 public interface Template {
     
+    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_CUSTOM = "custom";
+    
+    
     /**
      * The unique identifier for this Template.
      *
      * @roller.wrapPojoMethod type="simple"
      */
     public String getId();
+    
+    /**
+     * The action this template is defined for.
+     */
+    public String getAction();
     
     /**
      * A simple name for this Template.

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/Theme.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/Theme.java?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/Theme.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/Theme.java Fri Mar 23 00:53:04 2007
@@ -55,6 +55,10 @@
     // the Map contains ... (template link, ThemeTemplate)
     private Map templatesByLink = new HashMap();
     
+    // we keep templates in a Map for faster lookups by action
+    // the Map contains ... (template action, ThemeTemplate)
+    private Map templatesByAction = new HashMap();
+    
     // we keep resources in a Map for faster lookups by path
     // the Map contains ... (resource path, File)
     private Map resources = new HashMap();
@@ -72,8 +76,7 @@
     
     
     public Template getDefaultTemplate() {
-        // TODO: this should return the template defined as action="weblog"
-        return (ThemeTemplate) this.templatesByName.get("Weblog");
+        return (ThemeTemplate) this.templatesByAction.get(Template.ACTION_WEBLOG);
     }
     
     
@@ -96,11 +99,21 @@
     
     
     /**
+     * Lookup the specified template by action.
+     * Returns null if the template cannot be found.
+     */
+    public Template getTemplateByAction(String action) {
+        return (ThemeTemplate) this.templatesByAction.get(action);
+    }
+    
+    
+    /**
      * Set the value for a given template name.
      */
     public void addTemplate(ThemeTemplate template) {
         this.templatesByName.put(template.getName(), template);
         this.templatesByLink.put(template.getLink(), template);
+        this.templatesByAction.put(template.getAction(), template);
     }
     
     

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/ThemeTemplate.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/ThemeTemplate.java?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/ThemeTemplate.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/ThemeTemplate.java Fri Mar 23 00:53:04
2007
@@ -30,6 +30,7 @@
 public class ThemeTemplate implements Template, Serializable {
     
     private String id = null;
+    private String action = null;
     private String name = null;
     private String description = null;
     private String contents = null;
@@ -46,12 +47,13 @@
     
     public ThemeTemplate() {}
     
-    public ThemeTemplate(Theme theme, String id, String name, String desc, 
-            String contents, String link, Date date, String tempLang, 
-            boolean hid, boolean navbar, String decor) {
+    public ThemeTemplate(Theme theme, String id, String action, String name, 
+            String desc, String contents, String link, Date date, 
+            String tempLang, boolean hid, boolean navbar, String decor) {
         
         this.myTheme = theme;
         this.id = id;
+        this.action = action;
         this.name = name;
         this.description = desc;
         this.contents = contents;
@@ -164,6 +166,14 @@
     public String toString() {
         return (id + "," + name + "," + description + "," + link + "," + 
                 lastModified + "\n\n" + contents + "\n");
+    }
+
+    public String getAction() {
+        return action;
+    }
+
+    public void setAction(String action) {
+        this.action = action;
     }
     
 }

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/WeblogTemplate.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/WeblogTemplate.java?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/WeblogTemplate.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/WeblogTemplate.java Fri Mar 23 00:53:04
2007
@@ -28,6 +28,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
 
+
 /**
  * POJO that represents a single user defined template page.
  *
@@ -48,6 +49,7 @@
     private static Set requiredTemplates = null;
     
     private String  id = null;
+    private String  action = null;
     private String  name = null;
     private String  description = null;
     private String  link = null;
@@ -70,32 +72,9 @@
         requiredTemplates.add("_decorator");
     }
     
+    
     public WeblogTemplate() {}
     
-    public WeblogTemplate(
-            java.lang.String id,
-            WebsiteData website,
-            java.lang.String name,
-            java.lang.String description,
-            java.lang.String link,
-            java.lang.String template,
-            java.util.Date updateTime,
-            String tempLang,
-            boolean hid,
-            boolean navbar,
-            String decorator) {
-        this.id = id;
-        this.weblog = website;
-        this.name = name;
-        this.description = description;
-        this.link = link;
-        this.contents = template;
-        this.lastModified = (Date)updateTime.clone();
-        this.templateLanguage = tempLang;
-        this.hidden = hid;
-        this.navbar = navbar;
-        this.decoratorName = decorator;
-    }
     
     public WeblogTemplate( WeblogTemplate otherData ) {
         setData(otherData);
@@ -143,6 +122,19 @@
     /** @ejb:persistent-field */
     public void setWebsite( WebsiteData website ) {
         this.weblog = website;
+    }
+    
+    
+    /**
+     * @ejb:persistent-field
+     * @hibernate.property column="action" non-null="true" unique="false"
+     */
+    public String getAction() {
+        return action;
+    }
+
+    public void setAction(String action) {
+        this.action = action;
     }
     
     

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java Fri Mar 23 00:53:04
2007
@@ -264,6 +264,50 @@
     
     
     /**
+     * Lookup a Template for this website by action.
+     * 
+     * @roller.wrapPojoMethod type="pojo"
+     */
+    public Template getPageByAction(String action) throws RollerException {
+        
+        if(action == null)
+            return null;
+        
+        log.debug("looking up template for action ["+action+"]");
+        
+        Template template = null;
+        
+        // first check if this user has selected a theme
+        // if so then return the proper theme template
+        if(this.editorTheme != null && !this.editorTheme.equals(Theme.CUSTOM)) {
+            
+            try {
+                ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
+                Theme usersTheme = themeMgr.getTheme(this.editorTheme);
+                template = usersTheme.getTemplateByAction(action);
+                
+            } catch(ThemeNotFoundException tnfe) {
+                // i sure hope not!
+                log.error(tnfe);
+            }
+            
+        } else {
+        
+            // NOTE: we specifically do *NOT* return templates by action from the
+            // weblog's custom templates if the weblog is using a theme because we
+            // don't want old templates to take effect when using a specific theme
+            UserManager userMgr = RollerFactory.getRoller().getUserManager();
+            template = userMgr.getPageByAction(this, action);
+        }
+
+        if(template != null)
+            log.debug("returning template ["+template.getId()+"]");
+        
+        return template;
+    }
+    
+    
+    /**
      * Lookup a Template for this website by name.
      * @roller.wrapPojoMethod type="pojo"
      */

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=521615&r1=521614&r2=521615
==============================================================================
--- 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
Fri Mar 23 00:53:04 2007
@@ -107,6 +107,7 @@
                 WeblogTemplate page = new WeblogTemplate();
                 form.copyTo(page, request.getLocale());
                 page.setWebsite(website);
+                page.setAction(WeblogTemplate.ACTION_CUSTOM);
                 page.setLastModified( new Date() );
                 page.setDescription(page.getName());
                 page.setContents(bundle.getString("pageForm.newTemplateContent"));

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=521615&r1=521614&r2=521615
==============================================================================
--- 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 Fri
Mar 23 00:53:04 2007
@@ -41,9 +41,9 @@
 import org.apache.roller.config.RollerRuntimeConfig;
 import org.apache.roller.business.RollerFactory;
 import org.apache.roller.business.WeblogManager;
+import org.apache.roller.pojos.StaticTemplate;
 import org.apache.roller.pojos.Template;
 import org.apache.roller.pojos.WeblogEntryData;
-import org.apache.roller.pojos.WeblogTemplate;
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.ui.core.RollerContext;
 import org.apache.roller.ui.rendering.util.InvalidRequestException;
@@ -221,9 +221,9 @@
                 log.debug("MISS "+cacheKey);
             }
         }
-
         
-        // figure out what we are going to render
+        
+        // figure out what template to use
         Template page = null;
         
         // If this is a popup request, then deal with it specially
@@ -238,21 +238,29 @@
             
             // User doesn't have one so return the default
             if(page == null) {
-                page = new WeblogTemplate("templates/weblog/popupcomments.vm", weblog,
-                        "Comments", "Comments", "dummy_link",
-                        "dummy_template", new Date(), "velocity", true, false, null);
+                page = new StaticTemplate("templates/weblog/popupcomments.vm", null, "velocity");
             }
             
         // If request specified the page, then go with that
-        } else if (pageRequest.getWeblogPageName() != null) {
+        } else if(pageRequest.getWeblogPageName() != null) {
             page = pageRequest.getWeblogPage();
             
-        // If page not available from request, then use weblog's default
-        } else {
+        // If this is a permalink then look for a permalink template
+        } else if(pageRequest.getWeblogAnchor() != null) {
+            try {
+                page = weblog.getPageByAction(Template.ACTION_PERMALINK);
+            } catch(Exception e) {
+                log.error("Error getting weblog page for action 'permalink'", e);
+            }
+        }
+        
+        // if we haven't found a page yet then try our default page
+        if(page == null) {
             try {
                 page = weblog.getDefaultPage();
             } catch(Exception e) {
-                log.error("Error getting weblogs default page", e);
+                log.error("Error getting default page for weblog = "+
+                        weblog.getHandle(), e);
             }
         }
         

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java
(original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java
Fri Mar 23 00:53:04 2007
@@ -95,16 +95,25 @@
             return;
         }
         
-        // get their default page template to use for rendering
+        // lookup template to use for rendering
         Template page = null;
         try {
-            page = weblog.getDefaultPage();
+            // first try looking for a specific search page
+            page = weblog.getPageByAction(Template.ACTION_SEARCH);
+            
+            // if not found then fall back on default page
+            if(page == null) {
+                page = weblog.getDefaultPage();
+            }
+            
+            // if still null then that's a problem
             if(page == null) {
                 throw new RollerException("Could not lookup default page "+
                         "for weblog "+weblog.getHandle());
             }
         } catch(Exception e) {
-            log.error("Error getting weblogs default page", e);
+            log.error("Error getting default page for weblog "+
+                    weblog.getHandle(), e);
         }
         
         // set the content type

Modified: incubator/roller/trunk/tests/org/apache/roller/business/WeblogPageTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/WeblogPageTest.java?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/WeblogPageTest.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/business/WeblogPageTest.java Fri Mar 23
00:53:04 2007
@@ -69,6 +69,7 @@
         }
         
         testPage = new WeblogTemplate();
+        testPage.setAction(WeblogTemplate.ACTION_WEBLOG);
         testPage.setName("testTemplate");
         testPage.setDescription("Test Weblog Template");
         testPage.setLink("testTemp");
@@ -148,6 +149,12 @@
         
         // lookup by id
         page = mgr.getPage(id);
+        assertNotNull(page);
+        assertEquals(testPage.getContents(), page.getContents());
+        
+        // lookup by action
+        page = null;
+        page = mgr.getPageByAction(testWeblog, testPage.getAction());
         assertNotNull(page);
         assertEquals(testPage.getContents(), page.getContents());
         

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp?view=diff&rev=521615&r1=521614&r2=521615
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/edit-page.jsp Fri Mar 23 00:53:04 2007
@@ -279,6 +279,19 @@
                 </td>
                 <td class="description"></td>
             </tr>
+            
+            <tr>
+                <td class="field">
+                            <tr>
+                                <td class="label"><fmt:message key="pageForm.action"
/>&nbsp;</td>
+                                <td class="field">
+                                    <html:text property="action" size="30" />
+                                </td>
+                                <td class="description"></td>
+                            </tr>
+                </td>
+                <td class="description"></td>
+            </tr>
                         
         </table>
         <br />



Mime
View raw message