You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2006/09/07 00:50:06 UTC

svn commit: r440893 - in /incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller: presentation/velocity/plugins/acronyms/ presentation/velocity/plugins/bookmarks/ presentation/velocity/plugins/convertbreaks/ presentation/velocity/pl...

Author: agilliland
Date: Wed Sep  6 15:50:05 2006
New Revision: 440893

URL: http://svn.apache.org/viewvc?view=rev&rev=440893
Log:
final cleanup for contrib plugins directory.  this code can now be properly moved to the roller support project at java.net


Added:
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/ReadMorePlugin.java
      - copied, changed from r440737, incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/readmore/ReadMorePlugin.java
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/TextilePlugin.java
      - copied, changed from r440737, incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/textile/TextilePlugin.java
Removed:
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/acronyms/
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/bookmarks/
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/convertbreaks/
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/email/
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/readmore/ReadMorePlugin.java
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/readmore/package.html
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/search/
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/smileys/
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/textile/TextilePlugin.java
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/textile/package.html
    incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/topictag/

Copied: incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/ReadMorePlugin.java (from r440737, incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/readmore/ReadMorePlugin.java)
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/ReadMorePlugin.java?view=diff&rev=440893&p1=incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/readmore/ReadMorePlugin.java&r1=440737&p2=incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/ReadMorePlugin.java&r2=440893
==============================================================================
--- incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/readmore/ReadMorePlugin.java (original)
+++ incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/ReadMorePlugin.java Wed Sep  6 15:50:05 2006
@@ -16,63 +16,64 @@
  * directory of this distribution.
  */
 
-package org.apache.roller.presentation.velocity.plugins.readmore;
+package org.apache.roller.ui.rendering.plugins;
 
-import java.util.Map;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
-import org.apache.roller.model.RollerFactory;
-import org.apache.roller.model.UserManager;
-import org.apache.roller.model.WeblogEntryPlugin;
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WebsiteData;
-import org.apache.roller.ui.core.RollerContext;
+import org.apache.roller.model.WeblogEntryPlugin;
 import org.apache.roller.util.Utilities;
 
 
 /**
- * DEPRECATED. Truncates entry text and displays a link to read more.
- *
- * This plugin is no longer functional.  It now just returns the orginal
- * text without performing any transformation.
+ * Truncates the string passed in and applies a "Read More" link if the
+ * text is longer than the truncation limit.
  */
 public class ReadMorePlugin implements WeblogEntryPlugin {
     
-    private static Log mLogger = LogFactory.getLog(ReadMorePlugin.class);
+    private static Log log = LogFactory.getLog(ReadMorePlugin.class);
     
-    protected String name = "Read More Summary";
-    protected String description = "This plugin is no longer functional.  "+
-            "Please use Roller's entry summary field instead.";
-    
-    private String baseURL = "";
+    private String name = "Read More Summary";
+    private String description = "Stops entry after 250 characters and creates " +
+            "a link to the full entry.";
     
     
     public ReadMorePlugin() {
-        mLogger.debug("ReadMorePlugin instantiated.");
+        log.debug("ReadMorePlugin instantiated.");
     }
     
     
-    public String getName() {
-        return name;
+    public String getName() { 
+        return name; 
     }
     
-    
-    public String getDescription() {
-        return StringEscapeUtils.escapeJavaScript(description);
+    public String getDescription() { 
+        return StringEscapeUtils.escapeJavaScript(description); 
     }
     
     
-    public void init(WebsiteData website, Map model) throws RollerException {}
+    public void init(WebsiteData website) throws RollerException {
+        // no-op
+    }
     
     
     public String render(WeblogEntryData entry, String str) {
         
-        // this plugin has been deprecated now that Roller supports multiple
-        // entry text fields (summary & content).  this plugin now just returns
-        // the text it is passed in.
-        return str;
+        String result = Utilities.removeHTML(str, true);
+        result = Utilities.truncateText(result, 240, 260, "...");
+        
+        // if the result is shorter, we need to add "Read More" link
+        if (result.length() < str.length()) {
+            String link = "<div class=\"readMore\"><a href=\"" +
+                    entry.getPermalink() + "\">Read More</a></div>";
+            
+            result += link;
+        }
+        
+        return result;
     }
     
 }

Copied: incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/TextilePlugin.java (from r440737, incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/textile/TextilePlugin.java)
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/TextilePlugin.java?view=diff&rev=440893&p1=incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/textile/TextilePlugin.java&r1=440737&p2=incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/TextilePlugin.java&r2=440893
==============================================================================
--- incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/presentation/velocity/plugins/textile/TextilePlugin.java (original)
+++ incubator/roller/branches/roller_3.0/contrib/plugins/src/org/apache/roller/ui/rendering/plugins/TextilePlugin.java Wed Sep  6 15:50:05 2006
@@ -16,7 +16,7 @@
  * directory of this distribution.
  */
 
-package org.apache.roller.presentation.velocity.plugins.textile;
+package org.apache.roller.ui.rendering.plugins;
 
 import java.util.Map;
 import org.apache.commons.lang.StringEscapeUtils;
@@ -57,17 +57,17 @@
     
     
     /**
-     * Put plugin into the page context so templates may access it.
+     * Init.
      */
-    public void init(WebsiteData website, Map model) {
-        // TODO: we probably shouldn't allow plugins access to the model
-        model.put("textileRenderer",this);
+    public void init(WebsiteData website) {
+        // no-op
     }
     
     
     /**
      * Convert an input string that contains text that uses the Textile
      * syntax to an output string in HTML format.
+     *
      * @param src Input string that uses Textile syntax
      * @return Output string in HTML format.
      */