The RSS macro and its RSSMAcroParameters class should extends the Box
macro since it's exactly the goal of AbstractBoxMacro. The way it
works currently make copy the same parameters in BoxMacroParameters
and RssMacroParameters when we should have RssMacroParameters extends
BoxMacroParameters. This would remove some useless code in rss
macro...
On Sat, Mar 14, 2009 at 11:00, SVN jvelociter
<platform-notifications(a)xwiki.org> wrote:
Author: jvelociter
Date: 2009-03-14 11:00:44 +0100 (Sat, 14 Mar 2009)
New Revision: 17624
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/AbstractBoxMacro.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/BoxMacroParameters.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-rss/src/main/java/org/xwiki/rendering/internal/macro/rss/RssMacro.java
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-rss/src/main/java/org/xwiki/rendering/macro/rss/RssMacroParameters.java
Log:
XWIKI-3359 Add "width" parameter to box macro
XWIKI-3358 Add ability to control the width of the box containing the output of the RSS
macro 2.0
Merged from branch 1.8
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/AbstractBoxMacro.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/AbstractBoxMacro.java
2009-03-14 09:58:04 UTC (rev 17623)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/AbstractBoxMacro.java
2009-03-14 10:00:44 UTC (rev 17624)
@@ -21,6 +21,7 @@
import java.io.StringReader;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -123,19 +124,24 @@
String titleParameter = parameters.getTitle();
List< ? extends Block> titleBlockList = parameters.getBlockTitle();
+ Map<String, String> boxParameters = new HashMap<String, String>();
String classParameter = parameters.getCssClass();
String cssClass =
StringUtils.isEmpty(classParameter) ? getClassProperty() : getClassProperty()
+ " " + classParameter;
- Map<String, String> classParameterMap =
Collections.singletonMap("class", cssClass);
+ boxParameters.put("class", cssClass);
+ if (!StringUtils.isEmpty(parameters.getWidth())) {
+ boxParameters.put("style", "width:" +
parameters.getWidth());
+ }
+
Block boxBlock;
if (context.isInline()) {
List<Block> contentBlocks = parseContent(parameters, content,
context);
FormatBlock spanBlock = new FormatBlock(contentBlocks, Format.NONE);
- spanBlock.setParameters(classParameterMap);
+ spanBlock.setParameters(boxParameters);
boxBlock = spanBlock;
} else {
- boxBlock = new XMLBlock(new XMLElement("div",
classParameterMap));
+ boxBlock = new XMLBlock(new XMLElement("div", boxParameters));
// we add the image, if there is one
if (!StringUtils.isEmpty(imageParameter)) {
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/BoxMacroParameters.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/BoxMacroParameters.java
2009-03-14 09:58:04 UTC (rev 17623)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-box/src/main/java/org/xwiki/rendering/macro/box/BoxMacroParameters.java
2009-03-14 10:00:44 UTC (rev 17624)
@@ -48,6 +48,11 @@
private String image = StringUtils.EMPTY;
/**
+ * Refer to {@link #getWidth()}.
+ */
+ private String width = StringUtils.EMPTY;
+
+ /**
* @return the title to be displayed in the message box. Note that it can be
specified using Wiki 2.0 syntax.
*/
private List< ? extends Block> blockTitle;
@@ -117,10 +122,26 @@
/**
* @param cssClass - refer to {@link BoxMacroParameters#getCssClass()}
*/
- @ParameterDescription("the CSS sheet used for rendering the document")
+ @ParameterDescription("A CSS class to add to the box element")
public void setCssClass(String cssClass)
{
this.cssClass = cssClass;
}
+ /**
+ * @return an optional width to enforce as an inline style on the DIV element the
box will be formed of.
+ */
+ public String getWidth()
+ {
+ return this.width;
+ }
+
+ /**
+ * @param width - refer to {@link BoxMacroParameters#getWidth()}
+ */
+ @ParameterDescription("An optional width for the box, expressed in px or
%")
+ public void setWidth(String width)
+ {
+ this.width = width;
+ }
}
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-rss/src/main/java/org/xwiki/rendering/internal/macro/rss/RssMacro.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-rss/src/main/java/org/xwiki/rendering/internal/macro/rss/RssMacro.java
2009-03-14 09:58:04 UTC (rev 17623)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-rss/src/main/java/org/xwiki/rendering/internal/macro/rss/RssMacro.java
2009-03-14 10:00:44 UTC (rev 17624)
@@ -28,6 +28,7 @@
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
+import org.apache.commons.lang.StringUtils;
import org.xwiki.rendering.block.Block;
import org.xwiki.rendering.block.LinkBlock;
import org.xwiki.rendering.block.MacroBlock;
@@ -178,6 +179,11 @@
if (parameters.isCss()) {
boxParameters.setCssClass("rssfeed");
}
+
+ if (!StringUtils.isEmpty(parameters.getWidth())) {
+ boxParameters.setWidth(parameters.getWidth());
+ }
+
renderFeedOrEntryTitle(boxParameters, parameters.isCss(),
"rsschanneltitle", feed.getTitle(), feed.getLink());
List<Block> result = null;
Modified:
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-rss/src/main/java/org/xwiki/rendering/macro/rss/RssMacroParameters.java
===================================================================
---
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-rss/src/main/java/org/xwiki/rendering/macro/rss/RssMacroParameters.java
2009-03-14 09:58:04 UTC (rev 17623)
+++
platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-rss/src/main/java/org/xwiki/rendering/macro/rss/RssMacroParameters.java
2009-03-14 10:00:44 UTC (rev 17624)
@@ -22,6 +22,7 @@
import java.net.URL;
+import org.apache.commons.lang.StringUtils;
import org.xwiki.rendering.macro.descriptor.ParameterDescription;
import org.xwiki.rendering.macro.descriptor.ParameterMandatory;
@@ -55,6 +56,11 @@
private boolean image;
/**
+ * The width of the enclosing box containing the RSS macro output.
+ */
+ private String width = StringUtils.EMPTY;
+
+ /**
* If "true" then adds class id elements (rssitem, rssitemtitle,
rssitemdescription, rsschanneltitle, etc) which you
* can style by modifying your skin's CSS file.
*/
@@ -103,6 +109,23 @@
}
/**
+ * @param width the width of the RSS box, that will dismiss potential CSS rules
defining its default value.
+ */
+ @ParameterDescription("The width, in px or %, of the box containing the RSS
output (default is 30%)")
+ public void setWidth(String width)
+ {
+ this.width = width;
+ }
+
+ /**
+ * @return the width of the RSS box, that will dismiss potential CSS rules defining
its default value.
+ */
+ public String getWidth()
+ {
+ return this.width;
+ }
+
+ /**
* @param css whether to add class id elements (rssitem, rssitemtitle,
rssitemdescription, rsschanneltitle, etc).
*/
@ParameterDescription("Specifies whether to add class id elements (rssitem,
rssitemtitle, rssitemdescription etc).")
_______________________________________________
notifications mailing list
notifications(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications