You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2006/04/19 15:18:26 UTC
svn commit: r395240 - in
/incubator/roller/trunk/src/org/roller/presentation/weblog/tags:
ShowEntryContentTag.java ShowEntrySummaryTag.java ShowEntryTextTag.java
Author: snoopdave
Date: Wed Apr 19 06:18:14 2006
New Revision: 395240
URL: http://svn.apache.org/viewcvs?rev=395240&view=rev
Log:
Fixed in text/summary/content JSP tags
Modified:
incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryContentTag.java
incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntrySummaryTag.java
incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryTextTag.java
Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryContentTag.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryContentTag.java?rev=395240&r1=395239&r2=395240&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryContentTag.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryContentTag.java Wed Apr 19 06:18:14 2006
@@ -1,4 +1,4 @@
-/* Created on Feb 27, 2004 */
+/* Created on April 14, 2006 */
package org.roller.presentation.weblog.tags;
import javax.servlet.http.HttpServletRequest;
@@ -24,7 +24,6 @@
/**
* Shows entry text with plugins applied.
* @jsp.tag name="ShowEntryContent"
- * @author David M Johnson
*/
public class ShowEntryContentTag extends TagSupport {
static final long serialVersionUID = 3166731504235428544L;
@@ -44,48 +43,46 @@
*/
public int doStartTag() throws JspException {
Roller roller = RollerFactory.getRoller();
- WeblogEntryData entry =
- (WeblogEntryData)RequestUtils.lookup(pageContext, name, property, scope);
-
- String xformed = null;
-
- if (entry.getPlugins() != null) {
- RollerContext rctx =
- RollerContext.getRollerContext();
+ WeblogEntryData entry = (WeblogEntryData)
+ RequestUtils.lookup(pageContext, name, property, scope);
+ if (Utilities.isNotEmpty(entry.getText())) {
+ String xformed = entry.getText();;
try {
- PagePluginManager ppmgr = roller.getPagePluginManager();
- Map plugins = ppmgr.createAndInitPagePlugins(
- entry.getWebsite(),
- rctx.getServletContext(),
- rctx.getAbsoluteContextUrl(),
- new VelocityContext());
- xformed = ppmgr.applyPagePlugins(
- entry, plugins, entry.getText(), singleEntry);
-
- } catch (Exception e) {
- mLogger.error(e);
+ if (entry.getPlugins() != null) {
+ RollerContext rctx =
+ RollerContext.getRollerContext();
+ try {
+ PagePluginManager ppmgr = roller.getPagePluginManager();
+ Map plugins = ppmgr.createAndInitPagePlugins(
+ entry.getWebsite(),
+ rctx.getServletContext(),
+ rctx.getAbsoluteContextUrl(),
+ new VelocityContext());
+ xformed = ppmgr.applyPagePlugins(
+ entry, plugins, entry.getText(), singleEntry);
+ } catch (Exception e) {
+ mLogger.error(e);
+ }
+ }
+
+ if (stripHtml) {
+ // don't escape ampersands
+ xformed = Utilities.escapeHTML( Utilities.removeHTML(xformed), false );
+ }
+
+ if (maxLength != -1) {
+ xformed = Utilities.truncateNicely(xformed, maxLength, maxLength, "...");
+ }
+
+ // somehow things (“) are getting double-escaped
+ // but I cannot seem to track it down
+ xformed = Utilities.stringReplace(xformed, "&#", "&#");
+
+ pageContext.getOut().println(xformed);
+
+ } catch (Throwable e) {
+ throw new JspException("ERROR applying plugin to entry", e);
}
- } else {
- xformed = entry.getText();
- }
-
- if (stripHtml) {
- // don't escape ampersands
- xformed = Utilities.escapeHTML( Utilities.removeHTML(xformed), false );
- }
-
- if (maxLength != -1) {
- xformed = Utilities.truncateNicely(xformed, maxLength, maxLength, "...");
- }
-
- // somehow things (“) are getting double-escaped
- // but I cannot seem to track it down
- xformed = Utilities.stringReplace(xformed, "&#", "&#");
-
- try {
- pageContext.getOut().println(xformed);
- } catch (IOException e) {
- throw new JspException("ERROR applying plugin to entry", e);
}
return TagSupport.SKIP_BODY;
}
Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntrySummaryTag.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntrySummaryTag.java?rev=395240&r1=395239&r2=395240&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntrySummaryTag.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntrySummaryTag.java Wed Apr 19 06:18:14 2006
@@ -1,4 +1,4 @@
-/* Created on Feb 27, 2004 */
+/* Created on April 14, 2006 */
package org.roller.presentation.weblog.tags;
import javax.servlet.http.HttpServletRequest;
@@ -24,7 +24,6 @@
/**
* Shows entry summary with plugins applied.
* @jsp.tag name="ShowEntrySummary"
- * @author David M Johnson
*/
public class ShowEntrySummaryTag extends TagSupport {
static final long serialVersionUID = 3166731504235428544L;
@@ -41,35 +40,27 @@
*/
public int doStartTag() throws JspException {
Roller roller = RollerFactory.getRoller();
- WeblogEntryData entry =
- (WeblogEntryData)RequestUtils.lookup(pageContext, name, property, scope);
-
- String xformed = null;
-
- if (entry.getPlugins() != null) {
- RollerContext rctx =
- RollerContext.getRollerContext();
- try {
- PagePluginManager ppmgr = roller.getPagePluginManager();
- Map plugins = ppmgr.createAndInitPagePlugins(
+ WeblogEntryData entry = (WeblogEntryData)
+ RequestUtils.lookup(pageContext, name, property, scope);
+ if (Utilities.isNotEmpty(entry.getSummary())) {
+ String xformed = entry.getSummary();
+ try {
+ if (entry.getPlugins() != null) {
+ RollerContext rctx =
+ RollerContext.getRollerContext();
+ PagePluginManager ppmgr = roller.getPagePluginManager();
+ Map plugins = ppmgr.createAndInitPagePlugins(
entry.getWebsite(),
rctx.getServletContext(),
rctx.getAbsoluteContextUrl(),
new VelocityContext());
- xformed = ppmgr.applyPagePlugins(
- entry, plugins, entry.getSummary(), true);
-
- } catch (Exception e) {
- mLogger.error(e);
+ xformed = ppmgr.applyPagePlugins(
+ entry, plugins, entry.getSummary(), true);
+ }
+ pageContext.getOut().println(xformed);
+ } catch (Throwable e) {
+ throw new JspException("ERROR applying plugin to entry", e);
}
- } else {
- xformed = entry.getText();
- }
-
- try {
- pageContext.getOut().println(xformed);
- } catch (IOException e) {
- throw new JspException("ERROR applying plugin to entry", e);
}
return TagSupport.SKIP_BODY;
}
Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryTextTag.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryTextTag.java?rev=395240&r1=395239&r2=395240&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryTextTag.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ShowEntryTextTag.java Wed Apr 19 06:18:14 2006
@@ -1,4 +1,4 @@
-/* Created on Feb 27, 2004 */
+/* Created on April 14, 2006 */
package org.roller.presentation.weblog.tags;
import javax.servlet.http.HttpServletRequest;
@@ -25,7 +25,6 @@
/**
* Shows either entry summary or text, as appropriate and with plugins applied.
* @jsp.tag name="ShowEntryText"
- * @author David M Johnson
*/
public class ShowEntryTextTag extends TagSupport {
static final long serialVersionUID = 3166731504235428544L;
@@ -45,50 +44,58 @@
*/
public int doStartTag() throws JspException {
Roller roller = RollerFactory.getRoller();
- WeblogEntryData entry =
- (WeblogEntryData)RequestUtils.lookup(pageContext, name, property, scope);
+ WeblogEntryData entry = (WeblogEntryData)
+ RequestUtils.lookup(pageContext, name, property, scope);
- String sourceText = entry.getSummary();
- if (sourceText == null || (singleEntry && entry.getText() != null)) {
- sourceText = entry.getText();
+ String sourceText = null;
+ boolean hasSummary = Utilities.isNotEmpty(entry.getSummary());
+ boolean hasText= Utilities.isNotEmpty(entry.getText());
+ if (singleEntry) {
+ if (hasText) sourceText = entry.getText();
+ else if (hasSummary) sourceText = entry.getSummary();
+ } else {
+ if (hasSummary) sourceText = entry.getSummary();
+ else if (hasText) sourceText = entry.getText();
}
-
- String xformed = sourceText;
- if (entry.getPlugins() != null) {
- RollerContext rctx =
- RollerContext.getRollerContext();
+ if (Utilities.isNotEmpty(sourceText)) {
try {
- PagePluginManager ppmgr = roller.getPagePluginManager();
- Map plugins = ppmgr.createAndInitPagePlugins(
- entry.getWebsite(),
- rctx.getServletContext(),
- rctx.getAbsoluteContextUrl(),
- new VelocityContext());
+ String xformed = sourceText;
+ if (entry.getPlugins() != null) {
+ RollerContext rctx =
+ RollerContext.getRollerContext();
+ try {
+ PagePluginManager ppmgr = roller.getPagePluginManager();
+ Map plugins = ppmgr.createAndInitPagePlugins(
+ entry.getWebsite(),
+ rctx.getServletContext(),
+ rctx.getAbsoluteContextUrl(),
+ new VelocityContext());
+
+ xformed = ppmgr.applyPagePlugins(entry, plugins, sourceText, true);
+
+ } catch (Exception e) {
+ mLogger.error(e);
+ }
+ }
+
+ if (stripHtml) {
+ // don't escape ampersands
+ xformed = Utilities.escapeHTML( Utilities.removeHTML(xformed), false );
+ }
- xformed = ppmgr.applyPagePlugins(entry, plugins, sourceText, true);
+ if (maxLength != -1) {
+ xformed = Utilities.truncateNicely(xformed, maxLength, maxLength, "...");
+ }
+
+ // somehow things (“) are getting double-escaped
+ // but I cannot seem to track it down
+ xformed = Utilities.stringReplace(xformed, "&#", "&#");
+
+ pageContext.getOut().println(xformed);
- } catch (Exception e) {
- mLogger.error(e);
+ } catch (Throwable e) {
+ throw new JspException("ERROR applying plugin to entry", e);
}
- }
-
- if (stripHtml) {
- // don't escape ampersands
- xformed = Utilities.escapeHTML( Utilities.removeHTML(xformed), false );
- }
-
- if (maxLength != -1) {
- xformed = Utilities.truncateNicely(xformed, maxLength, maxLength, "...");
- }
-
- // somehow things (“) are getting double-escaped
- // but I cannot seem to track it down
- xformed = Utilities.stringReplace(xformed, "&#", "&#");
-
- try {
- pageContext.getOut().println(xformed);
- } catch (IOException e) {
- throw new JspException("ERROR applying plugin to entry", e);
}
return TagSupport.SKIP_BODY;
}