Search in sources :

Example 1 with BoxMacroParameters

use of org.xwiki.rendering.macro.box.BoxMacroParameters in project xwiki-platform by xwiki.

the class RssMacro method execute.

@Override
public List<Block> execute(RssMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException {
    List<Block> result;
    SyndFeed feed = this.romeFeedFactory.createFeed(parameters);
    if (parameters.isDecoration()) {
        BoxMacroParameters boxParameters = new BoxMacroParameters();
        boolean hasImage = parameters.isImage() && (feed.getImage() != null);
        boxParameters.setCssClass(FEED_CLASS_VALUE);
        if (StringUtils.isNotEmpty(parameters.getWidth())) {
            boxParameters.setWidth(parameters.getWidth());
        }
        boxParameters.setBlockTitle(generateBoxTitle("rsschanneltitle", feed));
        if (hasImage) {
            boxParameters.setImage(new ResourceReference(feed.getImage().getUrl(), ResourceType.URL));
        }
        result = this.boxMacro.execute(boxParameters, content == null ? StringUtils.EMPTY : content, context);
    } else {
        result = Arrays.<Block>asList(new GroupBlock(Collections.singletonMap(CLASS_ATTRIBUTE, FEED_CLASS_VALUE)));
    }
    generateEntries(result.get(0), feed, parameters);
    return result;
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) GroupBlock(org.xwiki.rendering.block.GroupBlock) LinkBlock(org.xwiki.rendering.block.LinkBlock) Block(org.xwiki.rendering.block.Block) ImageBlock(org.xwiki.rendering.block.ImageBlock) RawBlock(org.xwiki.rendering.block.RawBlock) ParagraphBlock(org.xwiki.rendering.block.ParagraphBlock) GroupBlock(org.xwiki.rendering.block.GroupBlock) ResourceReference(org.xwiki.rendering.listener.reference.ResourceReference) BoxMacroParameters(org.xwiki.rendering.macro.box.BoxMacroParameters)

Aggregations

SyndFeed (com.sun.syndication.feed.synd.SyndFeed)1 Block (org.xwiki.rendering.block.Block)1 GroupBlock (org.xwiki.rendering.block.GroupBlock)1 ImageBlock (org.xwiki.rendering.block.ImageBlock)1 LinkBlock (org.xwiki.rendering.block.LinkBlock)1 ParagraphBlock (org.xwiki.rendering.block.ParagraphBlock)1 RawBlock (org.xwiki.rendering.block.RawBlock)1 ResourceReference (org.xwiki.rendering.listener.reference.ResourceReference)1 BoxMacroParameters (org.xwiki.rendering.macro.box.BoxMacroParameters)1