roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From she...@apache.org
Subject svn commit: r1140970 [1/2] - in /roller/branches/roller_mobile: weblogger-business/src/main/java/org/apache/roller/weblogger/business/ weblogger-business/src/main/java/org/apache/roller/weblogger/business/jpa/ weblogger-business/src/main/java/org/apach...
Date Wed, 29 Jun 2011 05:55:07 GMT
Author: shelan
Date: Wed Jun 29 05:55:05 2011
New Revision: 1140970

URL: http://svn.apache.org/viewvc?rev=1140970&view=rev
Log:
Adding patch1 and patch2 to the branch.work upto editing custom templates included

Added:
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/mobile/
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/mobile/MobileDeviceRepository.java
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/mobile/
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/mobile/_day.vm
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/mobile/basic-custom.css
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/mobile/basic-preview.png   (with props)
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/mobile/permalink.vm
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/mobile/searchresults.vm
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/mobile/sidebar.vm
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/mobile/theme.xml
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/mobile/weblog.vm
Modified:
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/WeblogManager.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedTheme.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManager.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadata.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataParser.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogCustomTheme.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogSharedTheme.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticTemplate.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticThemeTemplate.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Template.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Theme.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/WeblogTemplate.java
    roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
    roller/branches/roller_mobile/weblogger-business/src/main/resources/sql/createdb.vm
    roller/branches/roller_mobile/weblogger-business/src/test/java/org/apache/roller/weblogger/business/WeblogPageTest.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblogBean.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/TemplateEdit.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/TemplateEditBean.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Templates.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/ThemeEdit.java
    roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/webservices/adminprotocol/RollerWeblogHandler.java
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/WEB-INF/jsps/editor/TemplateEdit.jsp
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/WEB-INF/jsps/editor/ThemeEdit.jsp
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/WEB-INF/jsps/editor/ThemeEditSharedThemesOnly.jsp
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/basic/theme.xml
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/brushedmetal/theme.xml
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/fauxcoly/theme.xml
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/frontpage/theme.xml
    roller/branches/roller_mobile/weblogger-webapp/src/main/webapp/themes/sotto/theme.xml

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/WeblogManager.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/WeblogManager.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/WeblogManager.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/WeblogManager.java Wed Jun 29 05:55:05 2011
@@ -174,7 +174,7 @@ public interface WeblogManager {
     /**
      * Get website's page by link.
      */
-    public WeblogTemplate getPageByLink(Weblog w, String p)
+    public List<WeblogTemplate> getPagesByLink(Weblog w, String p)
         throws WebloggerException;
     
     

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java Wed Jun 29 05:55:05 2011
@@ -18,51 +18,19 @@
 
 package org.apache.roller.weblogger.business.jpa;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.sql.Timestamp;
-import java.util.Comparator;
-import java.util.Hashtable;
-import javax.persistence.NoResultException;
-
-import javax.persistence.Query;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.roller.weblogger.WebloggerException;
-import org.apache.roller.weblogger.business.BookmarkManager;
-import org.apache.roller.weblogger.business.MediaFileManager;
-import org.apache.roller.weblogger.business.UserManager;
-import org.apache.roller.weblogger.business.WeblogEntryManager;
-import org.apache.roller.weblogger.business.WeblogManager;
-import org.apache.roller.weblogger.business.Weblogger;
-import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.business.*;
 import org.apache.roller.weblogger.business.pings.AutoPingManager;
 import org.apache.roller.weblogger.business.pings.PingTargetManager;
 import org.apache.roller.weblogger.config.WebloggerConfig;
-import org.apache.roller.weblogger.pojos.AutoPing;
-import org.apache.roller.weblogger.pojos.MediaFileDirectory;
-import org.apache.roller.weblogger.pojos.PingQueueEntry;
-import org.apache.roller.weblogger.pojos.PingTarget;
-import org.apache.roller.weblogger.pojos.WeblogReferrer;
-import org.apache.roller.weblogger.pojos.StatCount;
-import org.apache.roller.weblogger.pojos.StatCountCountComparator;
-import org.apache.roller.weblogger.pojos.TagStat;
-import org.apache.roller.weblogger.pojos.WeblogCategory;
-import org.apache.roller.weblogger.pojos.WeblogEntry;
-import org.apache.roller.weblogger.pojos.WeblogEntryTagAggregate;
-import org.apache.roller.weblogger.pojos.WeblogEntryTag;
-import org.apache.roller.weblogger.pojos.Weblog;
-import org.apache.roller.weblogger.pojos.User;
-import org.apache.roller.weblogger.pojos.WeblogBookmark;
-import org.apache.roller.weblogger.pojos.WeblogBookmarkFolder;
-import org.apache.roller.weblogger.pojos.WeblogPermission;
-import org.apache.roller.weblogger.pojos.WeblogTemplate;
+import org.apache.roller.weblogger.pojos.*;
+
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.*;
 
 
 /*
@@ -531,7 +499,7 @@ public class JPAWeblogManagerImpl implem
     /**
      * Use JPA directly because Weblogger's Query API does too much allocation.
      */
-    public WeblogTemplate getPageByLink(Weblog website, String pagelink)
+    public List<WeblogTemplate> getPagesByLink(Weblog website, String pagelink)
     throws WebloggerException {
         
         if (website == null)
@@ -544,7 +512,7 @@ public class JPAWeblogManagerImpl implem
         query.setParameter(1, website);
         query.setParameter(2, pagelink);
         try {
-            return (WeblogTemplate)query.getSingleResult();
+            return (List<WeblogTemplate>)query.getResultList();
         } catch (NoResultException e) {
             return null;
         }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedTheme.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedTheme.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedTheme.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedTheme.java Wed Jun 29 05:55:05 2011
@@ -18,18 +18,12 @@
 
 package org.apache.roller.weblogger.business.themes;
 
-import java.io.File;
+import org.apache.roller.weblogger.pojos.Theme;
+import org.apache.roller.weblogger.pojos.ThemeResource;
+
 import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import org.apache.roller.weblogger.pojos.Theme;
-import org.apache.roller.weblogger.pojos.ThemeResource;
-import org.apache.roller.weblogger.pojos.ThemeTemplate;
 
 
 /**
@@ -41,6 +35,7 @@ public abstract class SharedTheme implem
     protected String id = null;
     protected String name = null;
     protected String description = null;
+    private   String type = null;
     protected String author = null;
     protected Date lastModified = null;
     protected boolean enabled = false;
@@ -107,4 +102,11 @@ public abstract class SharedTheme implem
         this.enabled = enabled;
     }
 
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
 }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java Wed Jun 29 05:55:05 2011
@@ -18,17 +18,6 @@
 
 package org.apache.roller.weblogger.business.themes;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -36,6 +25,12 @@ import org.apache.roller.weblogger.pojos
 import org.apache.roller.weblogger.pojos.ThemeTemplate;
 import org.apache.roller.weblogger.pojos.WeblogTemplate;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.*;
+
 
 /**
  * The Theme object encapsulates all elements of a single weblog theme.  It
@@ -60,7 +55,7 @@ public class SharedThemeFromDir extends 
     private Map templatesByName = new HashMap();
     
     // we keep templates in a Map for faster lookups by link
-    // the Map contains ... (template link, ThemeTemplate)
+    // the Map contains ... (template link, List<tThemeTemplate>)
     private Map templatesByLink = new HashMap();
     
     // we keep templates in a Map for faster lookups by action
@@ -88,8 +83,8 @@ public class SharedThemeFromDir extends 
     public ThemeResource getPreviewImage() {
         return this.previewImage;
     }
-    
-    
+
+
     /**
      * Get the collection of all templates associated with this Theme.
      */
@@ -129,8 +124,8 @@ public class SharedThemeFromDir extends 
      * Lookup the specified template by link.
      * Returns null if the template cannot be found.
      */
-    public ThemeTemplate getTemplateByLink(String link) {
-        return (ThemeTemplate) this.templatesByLink.get(link);
+    public List<ThemeTemplate> getTemplatesByLink(String link) {
+        return (List<ThemeTemplate>) this.templatesByLink.get(link);
     }
     
     
@@ -206,6 +201,7 @@ public class SharedThemeFromDir extends 
         setId(themeMetadata.getId());
         setName(themeMetadata.getName());
         setDescription(themeMetadata.getName());
+        setType(themeMetadata.getType());
         setAuthor(themeMetadata.getAuthor());
         setLastModified(null);
         setEnabled(true);
@@ -246,7 +242,7 @@ public class SharedThemeFromDir extends 
                         new Date(templateFile.lastModified()),
                         stylesheetTmpl.getTemplateLanguage(),
                         false,
-                        false);
+                        false,stylesheetTmpl.getType());
                 
                 // store it
                 this.stylesheet = theme_template;
@@ -316,7 +312,9 @@ public class SharedThemeFromDir extends 
                     new Date(templateFile.lastModified()),
                     templateMetadata.getTemplateLanguage(),
                     templateMetadata.isHidden(),
-                    templateMetadata.isNavbar());
+                    templateMetadata.isNavbar(),
+                    templateMetadata.getType());
+                ;
 
             // add it to the theme
             addTemplate(theme_template);
@@ -363,8 +361,18 @@ public class SharedThemeFromDir extends 
      */
     private void addTemplate(ThemeTemplate template) {
         this.templatesByName.put(template.getName(), template);
-        this.templatesByLink.put(template.getLink(), template);
-        if(!ThemeTemplate.ACTION_CUSTOM.equals(template.getAction())) {
+
+          // check if there is an existing template for given link and append if exists.
+        List<ThemeTemplate> templates = new ArrayList<ThemeTemplate>();
+        if (!templatesByLink.containsKey(template.getLink())) {
+            templates.add(template);
+            templatesByLink.put(template.getLink(), templates);
+        } else {
+            templates = (List<ThemeTemplate>) templatesByLink.get(template.getLink());
+            templates.add(template);
+            templatesByLink.put(template.getLink(), templates);
+        }
+        if (!ThemeTemplate.ACTION_CUSTOM.equals(template.getAction())) {
             this.templatesByAction.put(template.getAction(), template);
         }
     }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java Wed Jun 29 05:55:05 2011
@@ -18,10 +18,10 @@
 
 package org.apache.roller.weblogger.business.themes;
 
+import org.apache.roller.weblogger.pojos.ThemeTemplate;
+
 import java.io.Serializable;
 import java.util.Date;
-import org.apache.roller.weblogger.WebloggerException;
-import org.apache.roller.weblogger.pojos.ThemeTemplate;
 
 
 /**
@@ -41,6 +41,7 @@ public class SharedThemeTemplate impleme
     private boolean hidden = false;
     private boolean navbar = false;
     private String  outputContentType = null;
+    private String type = null;
     
     private SharedTheme myTheme = null;
     
@@ -49,7 +50,7 @@ public class SharedThemeTemplate impleme
     
     public SharedThemeTemplate(SharedTheme theme, String id, String action, String name, 
             String desc, String contents, String link, Date date, 
-            String tempLang, boolean hid, boolean navbar) {
+            String tempLang, boolean hid, boolean navbar, String type) {
         
         this.myTheme = theme;
         this.id = id;
@@ -62,6 +63,7 @@ public class SharedThemeTemplate impleme
         this.templateLanguage = tempLang;
         this.hidden = hid;
         this.navbar = navbar;
+        this.type = type;
     }
     
     
@@ -171,5 +173,12 @@ public class SharedThemeTemplate impleme
     public void setAction(String action) {
         this.action = action;
     }
-    
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
 }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManager.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManager.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManager.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManager.java Wed Jun 29 05:55:05 2011
@@ -92,4 +92,18 @@ public interface ThemeManager {
 	 * @return true, if reloaded theme from disk
 	 */
 	public boolean reLoadThemeFromDisk(String reloadTheme);
+
+    /**
+     * To return the list of Mobile themes in themes list
+     *
+     * @return  ListofMobileThemes
+     */
+    public List getEnabledMobileThemeList();
+
+    /**
+     * To return the list of Standard themes in themes list
+     *
+     * @return
+     */
+    public List getEnabledStandardThemeList();
 }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java Wed Jun 29 05:55:05 2011
@@ -17,39 +17,25 @@
  */
 package org.apache.roller.weblogger.business.themes;
 
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.activation.FileTypeMap;
-import javax.activation.MimetypesFileTypeMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.InitializationException;
 import org.apache.roller.weblogger.business.MediaFileManager;
-import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.business.WeblogManager;
+import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.config.WebloggerConfig;
-import org.apache.roller.weblogger.pojos.MediaFileDirectory;
-import org.apache.roller.weblogger.pojos.Theme;
-import org.apache.roller.weblogger.pojos.ThemeResource;
-import org.apache.roller.weblogger.pojos.ThemeTemplate;
-import org.apache.roller.weblogger.pojos.WeblogTemplate;
-import org.apache.roller.weblogger.pojos.WeblogTheme;
-import org.apache.roller.weblogger.pojos.Weblog;
-import org.apache.roller.weblogger.pojos.MediaFile;
+import org.apache.roller.weblogger.pojos.*;
 import org.apache.roller.weblogger.util.RollerMessages;
 
+import javax.activation.FileTypeMap;
+import javax.activation.MimetypesFileTypeMap;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+
 /**
  * Base implementation of a ThemeManager.
  * 
@@ -241,6 +227,7 @@ public class ThemeManagerImpl implements
                 // NOTE: decorators are deprecated starting in 4.0
                 template.setDecoratorName(null);
                 template.setLastModified(new Date());
+                template.setType(themeTemplate.getType());
 
                 // save it
                 wmgr.savePage(template);
@@ -423,4 +410,38 @@ public class ThemeManagerImpl implements
         return reloaded;
 
     }
+
+    public List getEnabledMobileThemeList() {
+        List all_themes = new ArrayList(this.themes.values());
+        List mobileThemes = new ArrayList();
+
+        for(int i = 0 ; i<all_themes.size(); i++){
+            Theme theme = (Theme) all_themes.get(i);
+
+           if("mobile".equals(theme.getType())){
+               mobileThemes.add(theme);
+           }
+        }
+        // sort 'em ... default ordering for themes is by name
+        Collections.sort(mobileThemes);
+
+        return mobileThemes;
+    }
+
+    public List getEnabledStandardThemeList() {
+       List all_themes = new ArrayList(this.themes.values());
+        List standardThemes = new ArrayList();
+
+        for(int i = 0 ; i<all_themes.size(); i++){
+            Theme theme = (Theme) all_themes.get(i);
+
+           if("standard".equals(theme.getType())){
+               standardThemes.add(theme);
+           }
+        }
+        // sort 'em ... default ordering for themes is by name
+        Collections.sort(standardThemes);
+
+        return standardThemes;
+    }
 }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadata.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadata.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadata.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadata.java Wed Jun 29 05:55:05 2011
@@ -30,6 +30,7 @@ public class ThemeMetadata {
     private String id = null;
     private String name = null;
     private String author = null;
+    private String type = null;
     private String previewImage = null;
     private ThemeMetadataTemplate stylesheet = null;
     private Set templates = new HashSet();
@@ -103,5 +104,12 @@ public class ThemeMetadata {
     public void setStylesheet(ThemeMetadataTemplate stylesheet) {
         this.stylesheet = stylesheet;
     }
-    
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
 }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataParser.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataParser.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataParser.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataParser.java Wed Jun 29 05:55:05 2011
@@ -18,10 +18,6 @@
 
 package org.apache.roller.weblogger.business.themes;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
 import org.apache.commons.lang.StringUtils;
 import org.apache.roller.weblogger.pojos.WeblogTemplate;
 import org.jdom.Document;
@@ -29,6 +25,11 @@ import org.jdom.Element;
 import org.jdom.JDOMException;
 import org.jdom.input.SAXBuilder;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+
 
 /**
  * The parser for theme xml descriptors.
@@ -58,6 +59,7 @@ public class ThemeMetadataParser {
         theme.setId(root.getChildText("id"));
         theme.setName(root.getChildText("name"));
         theme.setAuthor(root.getChildText("author"));
+        theme.setType(root.getChildText("type"));
         
         // if either id or name is null then throw a parsing exception
         if(StringUtils.isEmpty(theme.getId()) || StringUtils.isEmpty(theme.getName())) {
@@ -76,6 +78,11 @@ public class ThemeMetadataParser {
         Element stylesheet = root.getChild("stylesheet");
         if(stylesheet != null) {
             theme.setStylesheet(elementToStylesheet(stylesheet));
+            if ("mobile".equals(theme.getType())) {
+               theme.getStylesheet().setType("mobile");
+            } else {
+               theme.getStylesheet().setType("standard");
+            }
         }
         
         // now grab the static resources
@@ -93,6 +100,13 @@ public class ThemeMetadataParser {
         while (templatesIter.hasNext()) {
             Element template = (Element) templatesIter.next();
             ThemeMetadataTemplate tmpl = elementToTemplateMetadata(template);
+
+            if ("mobile".equals(theme.getType())) {
+                tmpl.setType("mobile");
+            } else {
+                tmpl.setType("standard");
+            }
+
             theme.addTemplate(tmpl);
             
             if(WeblogTemplate.ACTION_WEBLOG.equals(tmpl.getAction())) {
@@ -122,6 +136,7 @@ public class ThemeMetadataParser {
         template.setTemplateLanguage(element.getChildText("templateLanguage"));
         template.setContentType(element.getChildText("contentType"));
         template.setContentsFile(element.getChildText("contentsFile"));
+
         
         String navbar = element.getChildText("navbar");
         if("true".equalsIgnoreCase(navbar)) {

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.java Wed Jun 29 05:55:05 2011
@@ -33,6 +33,7 @@ public class ThemeMetadataTemplate {
     private String templateLanguage = null;
     private String contentType = null;
     private String contentsFile = null;
+    private String type = null;
 
     public String getAction() {
         return action;
@@ -105,5 +106,12 @@ public class ThemeMetadataTemplate {
     public void setContentsFile(String contentsFile) {
         this.contentsFile = contentsFile;
     }
-    
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
 }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogCustomTheme.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogCustomTheme.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogCustomTheme.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogCustomTheme.java Wed Jun 29 05:55:05 2011
@@ -18,16 +18,13 @@
 
 package org.apache.roller.weblogger.business.themes;
 
-import java.util.Date;
-import java.util.List;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.MediaFileManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.pojos.MediaFile;
-import org.apache.roller.weblogger.pojos.ThemeResource;
-import org.apache.roller.weblogger.pojos.ThemeTemplate;
-import org.apache.roller.weblogger.pojos.WeblogTheme;
-import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.roller.weblogger.pojos.*;
+
+import java.util.Date;
+import java.util.List;
 
 
 /**
@@ -48,7 +45,11 @@ public class WeblogCustomTheme extends W
     public String getName() {
         return CUSTOM;
     }
-    
+
+    public String getType() {
+        return CUSTOM;
+    }
+
     public String getDescription() {
         return CUSTOM;
     }
@@ -79,7 +80,13 @@ public class WeblogCustomTheme extends W
      * Returns null if no stylesheet can be found.
      */
     public ThemeTemplate getStylesheet() throws WebloggerException {
-        return getTemplateByLink(this.weblog.getCustomStylesheetPath());
+        List styleSheetsList = getTemplatesByLink(this.weblog.getCustomStylesheetPath());
+
+        if(styleSheetsList != null && !styleSheetsList.isEmpty()){
+           return (ThemeTemplate) styleSheetsList.get(0);
+        }
+
+        return null;
     }
     
     
@@ -121,11 +128,12 @@ public class WeblogCustomTheme extends W
      * Lookup the specified template by link.
      * Returns null if the template cannot be found.
      */
-    public ThemeTemplate getTemplateByLink(String link) throws WebloggerException {
+    public List<ThemeTemplate> getTemplatesByLink(String link) throws WebloggerException {
         if(link == null)
             return null;
+        List templatesList = WebloggerFactory.getWeblogger().getWeblogManager().getPagesByLink(this.weblog, link);
         
-        return WebloggerFactory.getWeblogger().getWeblogManager().getPageByLink(this.weblog, link);
+        return templatesList;
     }
     
     

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogSharedTheme.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogSharedTheme.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogSharedTheme.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/business/themes/WeblogSharedTheme.java Wed Jun 29 05:55:05 2011
@@ -18,22 +18,14 @@
 
 package org.apache.roller.weblogger.business.themes;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.MediaFileManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.pojos.MediaFile;
-import org.apache.roller.weblogger.pojos.ThemeResource;
-import org.apache.roller.weblogger.pojos.ThemeTemplate;
-import org.apache.roller.weblogger.pojos.WeblogTheme;
-import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.roller.weblogger.pojos.*;
+
+import java.util.*;
 
 
 /**
@@ -59,7 +51,11 @@ public class WeblogSharedTheme extends W
     public String getName() {
         return this.theme.getName();
     }
-    
+
+    public String getType() {
+        return this.theme.getType();
+    }
+
     public String getDescription() {
         return this.theme.getDescription();
     }
@@ -128,8 +124,18 @@ public class WeblogSharedTheme extends W
         ThemeTemplate stylesheet = this.theme.getStylesheet();
         if(stylesheet != null) {
             // now try getting custom version from weblog
-            ThemeTemplate override = WebloggerFactory.getWeblogger()
-                    .getWeblogManager().getPageByLink(this.weblog, stylesheet.getLink());
+
+            // Get the style sheet for link. We do not have duplicates for same link as we have
+            //in other template pages for a theme.
+
+            List  styleSheetList = WebloggerFactory.getWeblogger()
+                    .getWeblogManager().getPagesByLink(this.weblog, stylesheet.getLink());
+
+            ThemeTemplate override = null;
+
+             if(styleSheetList != null && !styleSheetList.isEmpty()) {
+             override = (ThemeTemplate) styleSheetList.get(0);
+             }
             if(override != null) {
                 stylesheet = override;
             }
@@ -197,8 +203,9 @@ public class WeblogSharedTheme extends W
      * Lookup the specified template by link.
      * Returns null if the template cannot be found.
      */
-    public ThemeTemplate getTemplateByLink(String link) throws WebloggerException {
-        
+    public List<ThemeTemplate> getTemplatesByLink(String link) throws WebloggerException {
+
+        List templatesList = null;
         if(link == null)
             return null;
         
@@ -206,21 +213,24 @@ public class WeblogSharedTheme extends W
         
         // if name refers to the stylesheet then return result of getStylesheet()
         ThemeTemplate stylesheet = getStylesheet();
-        if(stylesheet != null && link.equals(stylesheet.getLink())) {
-            return stylesheet;
+        if(stylesheet != null && (link.equals(stylesheet.getLink()))) {
+            //we cannot return single Style sheet so we need to return a list with one single Style Sheet
+            List<ThemeTemplate> styleSheetList = new ArrayList<ThemeTemplate>();
+            styleSheetList.add(stylesheet);
+            return styleSheetList;
         }
         
         // first check if this user has selected a theme
         // if so then return the proper theme template
-        template = this.theme.getTemplateByLink(link);
+        templatesList = this.theme.getTemplatesByLink(link);
         
         // if we didn't get the Template from a theme then look in the db
-        if(template == null) {
-            template = WebloggerFactory.getWeblogger()
-                    .getWeblogManager().getPageByLink(this.weblog, link);
+        if(templatesList == null || templatesList.isEmpty()) {
+            templatesList = WebloggerFactory.getWeblogger()
+                    .getWeblogManager().getPagesByLink(this.weblog, link);
         }
         
-        return template;
+        return templatesList;
     }
     
     

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticTemplate.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticTemplate.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticTemplate.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticTemplate.java Wed Jun 29 05:55:05 2011
@@ -37,6 +37,7 @@ public class StaticTemplate implements T
     private Date lastModified = new Date();
     private String templateLanguage = null;
     private String  outputContentType = null;
+    private String type = "standard";
     
     
     public StaticTemplate(String id, String lang) {
@@ -91,6 +92,14 @@ public class StaticTemplate implements T
         return outputContentType;
     }
 
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type){
+         this.type = type;
+    }
+
     public void setOutputContentType(String outputContentType) {
         this.outputContentType = outputContentType;
     }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticThemeTemplate.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticThemeTemplate.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticThemeTemplate.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/StaticThemeTemplate.java Wed Jun 29 05:55:05 2011
@@ -44,6 +44,7 @@ public class StaticThemeTemplate impleme
     private String outputContentType = null;
     private String decoratorName = null;
     private ThemeTemplate decorator = null;
+    private String type = "standard";
     
     
     public StaticThemeTemplate(String id, String lang) {
@@ -99,6 +100,14 @@ public class StaticThemeTemplate impleme
         return outputContentType;
     }
 
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type){
+          this.type = type;
+    }
+
     public void setOutputContentType(String outputContentType) {
         this.outputContentType = outputContentType;
     }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Template.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Template.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Template.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Template.java Wed Jun 29 05:55:05 2011
@@ -63,5 +63,11 @@ public interface Template {
      * Content-type of output or null if none defined.
      */
     public String getOutputContentType();
+
+    /**
+     *
+     * type of the template , eg: standard , mobile etc.
+     */
+    public String getType();
     
 }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Theme.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Theme.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Theme.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Theme.java Wed Jun 29 05:55:05 2011
@@ -18,9 +18,10 @@
 
 package org.apache.roller.weblogger.pojos;
 
+import org.apache.roller.weblogger.WebloggerException;
+
 import java.util.Date;
 import java.util.List;
-import org.apache.roller.weblogger.WebloggerException;
 
 
 /**
@@ -39,7 +40,11 @@ public interface Theme {
      * A common or display name for this Theme.
      */
     public String getName();
-    
+
+    /**
+     * Metadata to identify a theme Type  eg: standard , mobile  etc.
+     */
+     public String getType();
     
     /**
      * A description of the Theme.
@@ -95,7 +100,7 @@ public interface Theme {
      * Lookup a template by link.
      * Returns null if the template cannot be found.
      */
-    public ThemeTemplate getTemplateByLink(String link) throws WebloggerException;
+    public List<ThemeTemplate> getTemplatesByLink(String link) throws WebloggerException;
     
     
     /**

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java Wed Jun 29 05:55:05 2011
@@ -94,6 +94,7 @@ public class Weblog implements Serializa
     private String  iconPath         = null;
     private String  about            = null;
     private String  creator          = null;
+    private String mobileThemeName = null;
     
     // Associated objects
     private List           permissions = new ArrayList();
@@ -113,6 +114,7 @@ public class Weblog implements Serializa
             String email,
             String emailFrom,
             String editorTheme,
+            String mobileTheme,
             String locale,
             String timeZone) {
         
@@ -123,6 +125,7 @@ public class Weblog implements Serializa
         this.emailAddress = email;
         this.emailFromAddress = emailFrom;
         this.editorTheme = editorTheme;
+        this.mobileThemeName = mobileTheme;
         this.locale = locale;
         this.timeZone = timeZone;
     }
@@ -1252,4 +1255,30 @@ public class Weblog implements Serializa
 
     /** No-op method to please XDoclet */
     public void setEntryCount(int ignored) {}
+
+
+    /**
+     *
+     * @return  mobileTheme
+     */
+    public String getMobileThemeName() {
+        return mobileThemeName;
+    }
+
+    public void setMobileThemeName(String mobileTheme) {
+        this.mobileThemeName = mobileTheme;
+    }
+
+    public Theme getMobileTheme(){
+            try {
+            // let the ThemeManager handle it
+            ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
+            return themeMgr.getTheme(getMobileThemeName());
+        } catch (WebloggerException ex) {
+            log.error("Error getting theme for weblog - "+getHandle(), ex);
+        }
+
+        // TODO: maybe we should return a default theme in this case?
+        return null;
+    }
 }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/WeblogTemplate.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/WeblogTemplate.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/WeblogTemplate.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/WeblogTemplate.java Wed Jun 29 05:55:05 2011
@@ -18,16 +18,17 @@
 
 package org.apache.roller.weblogger.pojos;
 
-import java.io.Serializable;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.util.UUIDGenerator;
+import org.apache.roller.weblogger.WebloggerException;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
 
 
 /**
@@ -57,6 +58,7 @@ public class WeblogTemplate implements T
     private boolean navbar = false;
     private String  decoratorName = null;
     private String  outputContentType = null;
+    private String  type = null;
     
     // associations
     private Weblog weblog = null;
@@ -263,5 +265,12 @@ public class WeblogTemplate implements T
             .append(getWebsite())
             .toHashCode();
     }
-    
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
 }

Modified: roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java Wed Jun 29 05:55:05 2011
@@ -18,22 +18,12 @@
 
 package org.apache.roller.weblogger.pojos.wrapper;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-import java.util.TimeZone;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.URLStrategy;
-import org.apache.roller.weblogger.pojos.ThemeTemplate;
-import org.apache.roller.weblogger.pojos.Weblog;
-import org.apache.roller.weblogger.pojos.WeblogCategory;
-import org.apache.roller.weblogger.pojos.WeblogEntry;
-import org.apache.roller.weblogger.pojos.WeblogEntryComment;
-import org.apache.roller.weblogger.pojos.WeblogReferrer;
+import org.apache.roller.weblogger.pojos.*;
+
+import java.util.*;
 
 
 /**
@@ -76,9 +66,9 @@ public class WeblogWrapper {
     }
     
     
-    public ThemeTemplateWrapper getPageByLink(String link)
+    public List <ThemeTemplateWrapper> getPageByLink(String link)
             throws WebloggerException {
-        return ThemeTemplateWrapper.wrap(this.pojo.getTheme().getTemplateByLink(link));
+        return (List<ThemeTemplateWrapper>) ThemeTemplateWrapper.wrap((ThemeTemplate) this.pojo.getTheme().getTemplatesByLink(link));
     }
     
     
@@ -268,6 +258,14 @@ public class WeblogWrapper {
         }
         return null;
     }
+
+    public String getMobileStylesheet() throws WebloggerException {
+            // custom stylesheet comes from the weblog theme
+        if(this.pojo.getMobileTheme().getStylesheet() != null) {
+            return urlStrategy.getWeblogPageURL(this.pojo, null, this.pojo.getMobileTheme().getStylesheet().getLink(), null, null, null, null, 0, false);
+        }
+        return null;
+    }
     
     
     /**

Modified: roller/branches/roller_mobile/weblogger-business/src/main/resources/sql/createdb.vm
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/main/resources/sql/createdb.vm?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/main/resources/sql/createdb.vm (original)
+++ roller/branches/roller_mobile/weblogger-business/src/main/resources/sql/createdb.vm Wed Jun 29 05:55:05 2011
@@ -91,7 +91,8 @@ create table webpage (
     templatelang    varchar(20) not null,
     decorator       varchar(255) default null,
     outputtype      varchar(48) default null,
-    #columnNotNullWithDefault('action' 'varchar(16)' 'custom')
+    #columnNotNullWithDefault('action' 'varchar(16)' 'custom'),
+    #columnNotNullWithDefault('type' 'varchar(16)' 'standard')
 );
 create index wp_name_idx on webpage( name$!db.INDEXSIZE );
 create index wp_link_idx on webpage( link$!db.INDEXSIZE );
@@ -115,6 +116,7 @@ create table website (
     emailfromaddress  varchar(255),
     emailaddress      varchar(255) not null,
     editortheme       varchar(255),
+    mobilethemename       varchar(255),
     locale            varchar(20), 
     timezone          varchar(50),  
     defaultplugins    varchar(255),

Modified: roller/branches/roller_mobile/weblogger-business/src/test/java/org/apache/roller/weblogger/business/WeblogPageTest.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-business/src/test/java/org/apache/roller/weblogger/business/WeblogPageTest.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-business/src/test/java/org/apache/roller/weblogger/business/WeblogPageTest.java (original)
+++ roller/branches/roller_mobile/weblogger-business/src/test/java/org/apache/roller/weblogger/business/WeblogPageTest.java Wed Jun 29 05:55:05 2011
@@ -80,6 +80,7 @@ public class WeblogPageTest extends Test
         testPage.setLastModified(new java.util.Date());
         testPage.setWebsite(TestUtils.getManagedWebsite(testWeblog));
         testPage.setTemplateLanguage("velocity");
+        testPage.setType("standard");
     }
     
     public void tearDown() throws Exception {
@@ -173,7 +174,7 @@ public class WeblogPageTest extends Test
         
         // lookup by link
         page = null;
-        page = mgr.getPageByLink(testWeblog, testPage.getLink());
+        page = mgr.getPagesByLink(testWeblog, testPage.getLink()).get(0);
         assertNotNull(page);
         assertEquals(testPage.getContents(), page.getContents());
         

Added: roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/mobile/MobileDeviceRepository.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/mobile/MobileDeviceRepository.java?rev=1140970&view=auto
==============================================================================
--- roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/mobile/MobileDeviceRepository.java (added)
+++ roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/mobile/MobileDeviceRepository.java Wed Jun 29 05:55:05 2011
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.ui.rendering.mobile;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class MobileDeviceRepository {
+
+
+    public static final String possibleDevices1 = ".*(android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)" +
+            "|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\\\/|" +
+            "plucker|pocket|psp|symbian|treo|up\\\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino).*" ;
+
+    public static final String possibleDevices2=
+            "\"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\\\-)|" +
+            "ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\\\-m|r |s )|" +
+            "avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\\\-(n|u)|c55\\\\/|capi|ccwa|cdm\\\\-|" +
+            "cell|chtm|cldc|cmd\\\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\\\-d)|" +
+            "el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\\\-|_)|g1 u|g560|gene|gf\\\\-5|g\\\\-mo|" +
+            "go(\\\\.w|od)|gr(ad|un)|haie|hcit|hd\\\\-(m|p|t)|hei\\\\-|hi(pt|ta)|hp( i|ip)|hs\\\\-c|" +
+            "ht(c(\\\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\\\-(20|go|ma)|i230|iac( |\\\\-|\\\\/)|ibro|idea|ig01|ikom|im1k|" +
+            "inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\\\/)|klon|kpt |kwc\\\\-|kyo(c|k)|le(no|xi)|" +
+            "lg( g|\\\\/(k|l|u)|50|54|e\\\\-|e\\\\/|\\\\-[a-w])|libw|lynx|m1\\\\-w|m3ga|m50\\\\/|" +
+            "ma(te|ui|xo)|mc(01|21|ca)|m\\\\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\\\-| |o|v)|zz)|" +
+            "mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\\\-|on|tf|wf|wg|wt)|" +
+            "nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\\\-([1-8]|c))|phil|pire|pl(ay|uc)|" +
+            "pn\\\\-2|po(ck|rt|se)|prox|psio|pt\\\\-g|qa\\\\-a|qc(07|12|21|32|60|\\\\-[2-7]|i\\\\-)|qtek|r380|r600|raks|" +
+            "rim9|ro(ve|zo)|s55\\\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\\\-|oo|p\\\\-)|sdk\\\\/|" +
+            "se(c(\\\\-|0|1)|47|mc|nd|ri)|sgh\\\\-|shar|sie(\\\\-|m)|sk\\\\-0|sl(45|id)|" +
+            "sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\\\-|v\\\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|" +
+            "ta(gt|lk)|tcl\\\\-|tdg\\\\-|tel(i|m)|tim\\\\-|t\\\\-mo|to(pl|sh)|ts(70|m\\\\-|m3|m5)|tx\\\\-9|" +
+            "up(\\\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\\\-v)|vm40|voda|vulc|" +
+            "vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\\\\-|2|g)|" +
+            "yas\\\\-|your|zeto|zte\\\\-";
+
+    /**
+     *
+     * ToCheck if a request is mobile.
+     * @param request
+     * @return   boolean
+     */
+    public static boolean isMobileDevice(HttpServletRequest request) {
+
+        String userAgent = request.getHeader("User-Agent").toLowerCase();
+        return (userAgent.matches(possibleDevices1)||userAgent.substring(0,4).matches(possibleDevices2));
+
+    }
+
+}

Modified: roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java (original)
+++ roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java Wed Jun 29 05:55:05 2011
@@ -18,47 +18,49 @@
 
 package org.apache.roller.weblogger.ui.rendering.servlets;
 
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Pattern;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.JspFactory;
-import javax.servlet.jsp.PageContext;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.HitCountQueue;
+import org.apache.roller.weblogger.business.WeblogEntryManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.referrers.IncomingReferrer;
 import org.apache.roller.weblogger.business.referrers.ReferrerQueueManager;
 import org.apache.roller.weblogger.business.themes.ThemeManager;
 import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
-import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.pojos.StaticThemeTemplate;
 import org.apache.roller.weblogger.pojos.ThemeTemplate;
-import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.ui.core.RollerContext;
-import org.apache.roller.weblogger.ui.rendering.util.InvalidRequestException;
-import org.apache.roller.weblogger.ui.rendering.util.WeblogPageRequest;
-import org.apache.roller.weblogger.util.cache.CachedContent;
 import org.apache.roller.weblogger.ui.rendering.Renderer;
 import org.apache.roller.weblogger.ui.rendering.RendererManager;
+import org.apache.roller.weblogger.ui.rendering.mobile.MobileDeviceRepository;
 import org.apache.roller.weblogger.ui.rendering.model.ModelLoader;
-import org.apache.roller.weblogger.ui.rendering.util.cache.SiteWideCache;
+import org.apache.roller.weblogger.ui.rendering.util.InvalidRequestException;
+import org.apache.roller.weblogger.ui.rendering.util.ModDateHeaderUtil;
 import org.apache.roller.weblogger.ui.rendering.util.WeblogEntryCommentForm;
+import org.apache.roller.weblogger.ui.rendering.util.WeblogPageRequest;
+import org.apache.roller.weblogger.ui.rendering.util.cache.SiteWideCache;
 import org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache;
-import org.apache.roller.weblogger.ui.rendering.util.ModDateHeaderUtil;
 import org.apache.roller.weblogger.util.BlacklistChecker;
 import org.apache.roller.weblogger.util.I18nMessages;
+import org.apache.roller.weblogger.util.cache.CachedContent;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspFactory;
+import javax.servlet.jsp.PageContext;
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
 
 /**
  * Provides access to weblog pages.
@@ -122,6 +124,8 @@ public class PageServlet extends HttpSer
 
         log.debug("Entering");
 
+
+
         // do referrer processing, if it's enabled
         // NOTE: this *must* be done first because it triggers a hibernate flush
         // which will close the active session and cause lazy init exceptions otherwise
@@ -138,6 +142,7 @@ public class PageServlet extends HttpSer
         }
 
 
+
         Weblog weblog = null;
         boolean isSiteWide = false;
 
@@ -240,6 +245,12 @@ public class PageServlet extends HttpSer
         // figure out what template to use
         ThemeTemplate page = null;
 
+        if(MobileDeviceRepository.isMobileDevice(request)){
+           // setting the editor theme as mobile theme to render for mobile device
+            weblog.setEditorTheme(weblog.getMobileThemeName()) ;
+
+        }
+
         // If this is a popup request, then deal with it specially
         // TODO: do we really need to keep supporting this?
         if (request.getParameter("popup") != null) {
@@ -636,4 +647,4 @@ public class PageServlet extends HttpSer
 
         return false;
     }
-}
\ No newline at end of file
+}

Modified: roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java (original)
+++ roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java Wed Jun 29 05:55:05 2011
@@ -18,33 +18,30 @@
 
 package org.apache.roller.weblogger.ui.rendering.servlets;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.JspFactory;
-import javax.servlet.jsp.PageContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
-import org.apache.roller.weblogger.pojos.Template;
-import org.apache.roller.weblogger.pojos.Theme;
-import org.apache.roller.weblogger.pojos.ThemeTemplate;
-import org.apache.roller.weblogger.pojos.WeblogTheme;
-import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.roller.weblogger.pojos.*;
 import org.apache.roller.weblogger.ui.core.RollerContext;
-import org.apache.roller.weblogger.util.cache.CachedContent;
 import org.apache.roller.weblogger.ui.rendering.Renderer;
 import org.apache.roller.weblogger.ui.rendering.RendererManager;
 import org.apache.roller.weblogger.ui.rendering.model.ModelLoader;
 import org.apache.roller.weblogger.ui.rendering.util.WeblogPreviewRequest;
+import org.apache.roller.weblogger.util.cache.CachedContent;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspFactory;
+import javax.servlet.jsp.PageContext;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 
 /**
@@ -113,6 +110,9 @@ public class PreviewServlet extends Http
             tmpWebsite.setData(weblog);
             if(previewTheme != null && previewTheme.isEnabled()) {
                 tmpWebsite.setEditorTheme(previewTheme.getId());
+                //set mobile theme to the preview theme so it will not return null in velocity.
+                //This is bit hacky
+                tmpWebsite.setMobileThemeName(previewTheme.getId());
             } else if(WeblogTheme.CUSTOM.equals(previewRequest.getThemeName())) {
                 tmpWebsite.setEditorTheme(WeblogTheme.CUSTOM);
             }

Modified: roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java (original)
+++ roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java Wed Jun 29 05:55:05 2011
@@ -18,27 +18,18 @@
 
 package org.apache.roller.weblogger.ui.rendering.servlets;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.JspFactory;
-import javax.servlet.jsp.PageContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
-import org.apache.roller.weblogger.config.WebloggerConfig;
-import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.themes.ThemeManager;
+import org.apache.roller.weblogger.config.WebloggerConfig;
+import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.ThemeTemplate;
 import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.ui.rendering.Renderer;
 import org.apache.roller.weblogger.ui.rendering.RendererManager;
+import org.apache.roller.weblogger.ui.rendering.mobile.MobileDeviceRepository;
 import org.apache.roller.weblogger.ui.rendering.model.Model;
 import org.apache.roller.weblogger.ui.rendering.model.ModelLoader;
 import org.apache.roller.weblogger.ui.rendering.model.SearchResultsModel;
@@ -49,6 +40,17 @@ import org.apache.roller.weblogger.ui.re
 import org.apache.roller.weblogger.util.I18nMessages;
 import org.apache.roller.weblogger.util.cache.CachedContent;
 
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspFactory;
+import javax.servlet.jsp.PageContext;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
 
 /**
  * Handles search queries for weblogs.
@@ -95,6 +97,10 @@ public class SearchServlet extends HttpS
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
+
+        //is a mobile request
+
+        boolean isMobileRequest = MobileDeviceRepository.isMobileDevice(request);
         
         // do we need to force a specific locale for the request?
         if(searchRequest.getLocale() == null && !weblog.isShowAllLangs()) {
@@ -104,9 +110,15 @@ public class SearchServlet extends HttpS
         // lookup template to use for rendering
         ThemeTemplate page = null;
         try {
-            // first try looking for a specific search page
+            // if request is from a mobile get mobile templates search page
+            if(isMobileRequest){
+              page = weblog.getMobileTheme().getTemplateByAction(ThemeTemplate.ACTION_SEARCH);
+            }
+            // if there is no search page in mobile template look for standard templates page.
+            else if(page == null){
+            // try looking for a specific search page
             page = weblog.getTheme().getTemplateByAction(ThemeTemplate.ACTION_SEARCH);
-            
+            }
             // if not found then fall back on default page
             if(page == null) {
                 page = weblog.getTheme().getDefaultTemplate();

Modified: roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java (original)
+++ roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/util/WeblogPageRequest.java Wed Jun 29 05:55:05 2011
@@ -18,25 +18,26 @@
 
 package org.apache.roller.weblogger.ui.rendering.util;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
-import org.apache.roller.weblogger.config.WebloggerConfig;
-import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.pojos.ThemeTemplate;
 import org.apache.roller.weblogger.pojos.WeblogCategory;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.pojos.WeblogTemplate;
+import org.apache.roller.weblogger.ui.rendering.mobile.MobileDeviceRepository;
 import org.apache.roller.weblogger.util.URLUtilities;
 import org.apache.roller.weblogger.util.Utilities;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 
 /**
  * Represents a request for a Roller weblog page.
@@ -353,7 +354,39 @@ public class WeblogPageRequest extends W
         
         if(weblogPage == null && weblogPageName != null) {
             try {
-                weblogPage = getWeblog().getTheme().getTemplateByLink(weblogPageName);                
+
+                List <ThemeTemplate> weblogPages = getWeblog().getTheme().getTemplatesByLink(weblogPageName);
+
+                if(weblogPages != null && weblogPages.size() ==1){
+                    // default scenario of having one template only as CSS.
+                    return weblogPages.get(0);
+                }
+
+                else if (weblogPages != null && weblogPages.size()>1) {
+
+                    // return mobile template if the request coming from a mobile device
+                    if (MobileDeviceRepository.isMobileDevice(request)) {
+                        for (ThemeTemplate weblogPage : weblogPages) {
+                            if ("mobile".equals(weblogPage.getType())) {
+                                return weblogPage;
+                            }
+                        }
+                }
+                    else {
+                        for (ThemeTemplate weblogPage : weblogPages) {
+                            if ("standard".equals(weblogPage.getType())) {
+                                return weblogPage;
+                            }
+                        }
+                    }
+                }
+                else{
+                   // return null if we cannot find anything.
+                    return null;
+                }
+
+
+
             } catch (WebloggerException ex) {
                 log.error("Error getting weblog page "+weblogPageName, ex);
             }

Modified: roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java (original)
+++ roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java Wed Jun 29 05:55:05 2011
@@ -18,17 +18,16 @@
 
 package org.apache.roller.weblogger.ui.struts2.core;
 
-import java.util.List;
 import org.apache.commons.lang.CharSetUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
-import org.apache.roller.weblogger.config.WebloggerConfig;
-import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
+import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.themes.ThemeManager;
-import org.apache.roller.weblogger.business.UserManager;
+import org.apache.roller.weblogger.config.WebloggerConfig;
+import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
@@ -36,6 +35,8 @@ import org.apache.roller.weblogger.ui.st
 import org.apache.roller.weblogger.util.Utilities;
 import org.apache.struts2.interceptor.validation.SkipValidation;
 
+import java.util.List;
+
 
 /**
  * Allows user to create a new website.
@@ -119,6 +120,7 @@ public class CreateWeblog extends UIActi
                     getBean().getEmailAddress(),
                     getBean().getEmailAddress(),
                     getBean().getTheme(),
+                    getBean().getMobileTheme(),
                     getBean().getLocale(),
                     getBean().getTimeZone());
             
@@ -184,6 +186,16 @@ public class CreateWeblog extends UIActi
         ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
         return themeMgr.getEnabledThemesList();
     }
+
+    public List getMobileThemes(){
+       ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
+        return themeMgr.getEnabledMobileThemeList();
+    }
+
+    public List getStandardThemes(){
+            ThemeManager themeMgr = WebloggerFactory.getWeblogger().getThemeManager();
+        return themeMgr.getEnabledStandardThemeList();
+    }
     
     
     public CreateWeblogBean getBean() {

Modified: roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblogBean.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblogBean.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblogBean.java (original)
+++ roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblogBean.java Wed Jun 29 05:55:05 2011
@@ -31,6 +31,7 @@ public class CreateWeblogBean {
     private String locale;
     private String timeZone;
     private String theme;
+    private String mobileTheme;
     
     
     public String getDescription() {
@@ -88,5 +89,12 @@ public class CreateWeblogBean {
     public void setTimeZone(String timeZone) {
         this.timeZone = timeZone;
     }
-    
+
+    public String getMobileTheme() {
+        return mobileTheme;
+    }
+
+    public void setMobileTheme(String mobileTheme) {
+        this.mobileTheme = mobileTheme;
+    }
 }

Modified: roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java?rev=1140970&r1=1140969&r2=1140970&view=diff
==============================================================================
--- roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java (original)
+++ roller/branches/roller_mobile/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java Wed Jun 29 05:55:05 2011
@@ -18,22 +18,19 @@
 
 package org.apache.roller.weblogger.ui.struts2.editor;
 
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.themes.ThemeManager;
-import org.apache.roller.weblogger.pojos.Theme;
-import org.apache.roller.weblogger.pojos.ThemeTemplate;
-import org.apache.roller.weblogger.pojos.WeblogPermission;
-import org.apache.roller.weblogger.pojos.WeblogTemplate;
-import org.apache.roller.weblogger.pojos.WeblogTheme;
+import org.apache.roller.weblogger.pojos.*;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.cache.CacheManager;
 
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
 
 /**
  * Action which handles editing for a weblog stylesheet override template.
@@ -75,9 +72,14 @@ public class StylesheetEdit extends UIAc
         if(stylesheet != null) {
             log.debug("custom stylesheet path is - "+stylesheet.getLink());
             try {
-                setTemplate(WebloggerFactory.getWeblogger().getWeblogManager()
-                        .getPageByLink(getActionWeblog(), stylesheet.getLink()));
-                
+                 List styleSheets =  WebloggerFactory.getWeblogger().getWeblogManager()
+                        .getPagesByLink(getActionWeblog(), stylesheet.getLink());
+
+                // Setting the template from the result set. We will be having only one style sheet.so get 0 index
+                if (stylesheet != null && !styleSheets.isEmpty()) {
+                    setTemplate((WeblogTemplate) styleSheets.get(0));
+                }
+
                 if(getTemplate() == null) {
                     log.debug("custom stylesheet not found, creating it");
                     
@@ -93,6 +95,8 @@ public class StylesheetEdit extends UIAc
                     stylesheetTmpl.setNavbar(false);
                     stylesheetTmpl.setLastModified(new Date());
                     stylesheetTmpl.setTemplateLanguage(stylesheet.getTemplateLanguage());
+                    // setting the type for stylesheet as standard
+                    stylesheetTmpl.setType("standard");
                     
                     WebloggerFactory.getWeblogger().getWeblogManager().savePage(stylesheetTmpl);
                     WebloggerFactory.getWeblogger().flush();



Mime
View raw message