roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r1201532 - in /roller/trunk: weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/ weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/model/ weblogger-webapp/src/main/webapp/WEB-INF/velocity/ weblogge...
Date Sun, 13 Nov 2011 22:16:34 GMT
Author: snoopdave
Date: Sun Nov 13 22:16:33 2011
New Revision: 1201532

URL: http://svn.apache.org/viewvc?rev=1201532&view=rev
Log:
More fixes to ensure that deviceType is appended properly in all calls to Velocity resource
loader
related to https://issues.apache.org/jira/browse/ROL-1930

Modified:
    roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
    roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java
    roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/deprecated/weblog.vm
    roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/weblog.vm

Modified: roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java?rev=1201532&r1=1201531&r2=1201532&view=diff
==============================================================================
--- roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
(original)
+++ roller/trunk/weblogger-business/src/main/java/org/apache/roller/weblogger/pojos/wrapper/WeblogWrapper.java
Sun Nov 13 22:16:33 2011
@@ -18,7 +18,6 @@
 
 package org.apache.roller.weblogger.pojos.wrapper;
 
-import com.sun.org.apache.bcel.internal.generic.RETURN;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.URLStrategy;
@@ -38,38 +37,25 @@ public class WeblogWrapper {
     // url strategy to use for any url building
     private final URLStrategy urlStrategy;
 
-    // type of the request detected at  Page model
-    private String type = "standard";
-    
-    
     // this is private so that we can force the use of the .wrap(pojo) method
-    private WeblogWrapper(Weblog toWrap, URLStrategy strat, String type) {
+    private WeblogWrapper(Weblog toWrap, URLStrategy strat) {
         this.pojo = toWrap;
         this.urlStrategy = strat;
-        this.type = type;
     }
     
     
     // wrap the given pojo if it is not null with detected type
-    public static WeblogWrapper wrap(Weblog toWrap, URLStrategy strat, String type) {
+    public static WeblogWrapper wrap(Weblog toWrap, URLStrategy strat) {
         if(toWrap != null)
-            return new WeblogWrapper(toWrap, strat , type);
+            return new WeblogWrapper(toWrap, strat);
         
         return null;
     }
-      //wrap the given pojo if it is not null without changing type. (i.e using default)
-     public static WeblogWrapper wrap(Weblog toWrap, URLStrategy strat) {
-        if(toWrap != null)
-            return new WeblogWrapper(toWrap, strat , "standard");
 
-        return null;
-    }
-    
-    
+
     public ThemeTemplateWrapper getPageByAction(String action)
             throws WebloggerException {
         ThemeTemplate templateToWrap = this.pojo.getTheme().getTemplateByAction(action);
-        prepareTemplate(templateToWrap, type);
         return ThemeTemplateWrapper.wrap(templateToWrap);
     }
     
@@ -77,7 +63,6 @@ public class WeblogWrapper {
     public ThemeTemplateWrapper getPageByName(String name)
             throws WebloggerException {
        ThemeTemplate templateToWrap = this.pojo.getTheme().getTemplateByName(name);
-        prepareTemplate(templateToWrap, type);
         return ThemeTemplateWrapper.wrap(templateToWrap);
     }
     
@@ -85,7 +70,6 @@ public class WeblogWrapper {
     public ThemeTemplateWrapper getPageByLink(String link)
             throws WebloggerException {
         ThemeTemplate templateToWrap = this.pojo.getTheme().getTemplateByLink(link);
-        prepareTemplate(templateToWrap, type);
         return ThemeTemplateWrapper.wrap(templateToWrap);
     }
     
@@ -472,35 +456,4 @@ public class WeblogWrapper {
     public Weblog getPojo() {
         return this.pojo;
     }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    /**
-     * @param page
-     * @param type
-     * @return
-     *
-     * Prepare template to add the correct template content
-     */
-    private ThemeTemplate prepareTemplate(ThemeTemplate page, String type) throws WebloggerException
{
-
-        WeblogTemplateCode templateCode = page.getTemplateCode(type);
-
-        if (templateCode != null) {
-            page.setContents(templateCode.getTemplate());
-            page.setTemplateLanguage(templateCode.getTemplateLanguage());
-            return page;
-        } else {
-            // if there is no template code present we fall back to default template
-            return page;
-        }
-
-    }
-
 }

Modified: roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java?rev=1201532&r1=1201531&r2=1201532&view=diff
==============================================================================
--- roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java
(original)
+++ roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java
Sun Nov 13 22:16:33 2011
@@ -125,7 +125,7 @@ public class PageModel implements Model 
      * Get weblog being displayed.
      */
     public WeblogWrapper getWeblog() {
-        return WeblogWrapper.wrap(weblog, urlStrategy, getDeviceType().toString());
+        return WeblogWrapper.wrap(weblog, urlStrategy);
     }
     
     
@@ -193,7 +193,16 @@ public class PageModel implements Model 
         return pageRequest.getTags();
     }
     
-    
+
+	/**
+	 * Access to device type, which is either 'mobile' or 'standard'
+	 * @return 
+	 */
+	public String getDeviceType() {
+		return deviceType.toString();
+	}
+
+
     /**
      * A map of entries representing this page. The collection is grouped by 
      * days of entries.  Each value is a list of entry objects keyed by the 
@@ -318,11 +327,4 @@ public class PageModel implements Model 
         return null;
     }
 
-    public DeviceType getDeviceType() {
-        return deviceType;
-    }
-
-    public void setDeviceType(DeviceType type) {
-        this.deviceType = type;
-    }
 }

Modified: roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/deprecated/weblog.vm
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/deprecated/weblog.vm?rev=1201532&r1=1201531&r2=1201532&view=diff
==============================================================================
--- roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/deprecated/weblog.vm (original)
+++ roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/deprecated/weblog.vm Sun
Nov 13 22:16:33 2011
@@ -71,7 +71,7 @@
     #set($map = $pager.getEntries())
     #foreach($day in $map.keySet())
         #set($entries = $map.get($day))   
-        #parse($dayPage.id)
+        #parse($dayPage.id "|" $model.deviceType)
     #end
 
     #if ($model.permalink)
@@ -186,7 +186,7 @@
 #macro( showEntryText $entry )
     ## updated for roller 3.0
    #if( $entryPage )
-      #parse($entryPage.id)
+      #parse($entryPage.id "|" $model.deviceType)
    #elseif($model.permalink) 
         #if($utils.isNotEmpty($entry.text))
             $entry.transformedText

Modified: roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/weblog.vm
URL: http://svn.apache.org/viewvc/roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/weblog.vm?rev=1201532&r1=1201531&r2=1201532&view=diff
==============================================================================
--- roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/weblog.vm (original)
+++ roller/trunk/weblogger-webapp/src/main/webapp/WEB-INF/velocity/weblog.vm Sun Nov 13 22:16:33
2011
@@ -59,7 +59,7 @@ Parse and include page template from web
     #set($pageArg = false)## This is required for such constructs; see Velocity docs and
ROL-689
     #set($pageArg = $weblog.getPageByName($pageName))
     #if ($pageArg) 
-       #parse($pageArg.id)
+       #parse($pageArg.id "|" $model.deviceType)
     #end
 #end
 
@@ -137,7 +137,7 @@ Shows weblog entries pager via default d
     #set($map = $pager.getEntries())
     #foreach($day in $map.keySet())
         #set($entries = $map.get($day))   
-        #parse($dayPage.id)
+        #parse($dayPage.id "|" $model.deviceType)
     #end
 #end
 



Mime
View raw message