roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r429486 - in /incubator/roller/branches/roller_3.0: src/org/apache/roller/pojos/WeblogEntryData.java web/WEB-INF/classes/ApplicationResources.properties
Date Mon, 07 Aug 2006 21:37:27 GMT
Author: agilliland
Date: Mon Aug  7 14:37:27 2006
New Revision: 429486

URL: http://svn.apache.org/viewvc?rev=429486&view=rev
Log:
add new pojo method which encapsulages the summary vs. content display logic.  template writers
can now use the entry.getDisplayContent() method to easily display the right content.


Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java
    incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java?rev=429486&r1=429485&r2=429486&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntryData.java
Mon Aug  7 14:37:27 2006
@@ -47,6 +47,7 @@
 import org.apache.roller.model.WeblogEntryPlugin;
 import org.apache.roller.model.WeblogManager;
 import org.apache.roller.util.DateUtil;
+import org.apache.roller.util.MessageUtilities;
 import org.apache.roller.util.URLUtilities;
 import org.apache.roller.util.Utilities;
 
@@ -1138,5 +1139,67 @@
         }        
         return ret;
     }
+    
+    
+    /**
+     * Get the right transformed display content depending on the situation.
+     *
+     * If the readMoreLink is specified then we assume the caller wants to
+     * prefer summary over content and we include a "Read More" link at the
+     * end of the summary if it exists.  Otherwise, if the readMoreLink is
+     * empty or null then we assume the caller prefers content over summary.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     */
+    public String displayContent(String readMoreLink) {
+        
+        String displayContent = null;
+        
+        if(readMoreLink == null || readMoreLink.trim().length() < 1 || 
+                "nil".equals(readMoreLink)) {
+            
+            // no readMore link means permalink, so prefer text over summary
+            if(StringUtils.isNotEmpty(this.getText())) {
+                displayContent = this.getTransformedText();
+            } else {
+                displayContent = this.getTransformedSummary();
+            }
+        } else {
+            // not a permalink, so prefer summary over text
+            // include a "read more" link if needed
+            if(StringUtils.isNotEmpty(this.getSummary())) {
+                displayContent = this.getTransformedSummary();
+                if(StringUtils.isNotEmpty(this.getText())) {
+                    // add read more
+                    List args = new ArrayList();
+                    args.add(readMoreLink);
+                    try {
+                        String readMore = MessageUtilities.getString("macro.weblog.readMoreLink",
args);
+                        displayContent += readMore;
+                    } catch (RollerException ex) {
+                        mLogger.error("trouble with message utils", ex);
+                    }
+                }
+            } else {
+                displayContent = this.getTransformedText();
+            }
+        }
+        
+        return displayContent;
+    }
+    
+    
+    /**
+     * Get the right transformed display content.
+     *
+     * @roller.wrapPojoMethod type="simple"
+     */
+    public String getDisplayContent() { 
+        return displayContent(null);
+    }
+    
+    
+    /** No-op method to please XDoclet */
+    public void setDisplayContent(String ignored) {}
     
 }

Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties?rev=429486&r1=429485&r2=429486&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties
(original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties
Mon Aug  7 14:37:27 2006
@@ -654,6 +654,7 @@
 macro.weblog.preview=Preview
 macro.weblog.commentpermalink.title=comment permalink
 macro.weblog.readMore=Read More
+macro.weblog.readMoreLink=[<a class="readmore" href="{0}">Read More</a>]
 
 macro.weblog.postedby=Posted by
 macro.weblog.on=on



Mime
View raw message