Uploaded image for project: 'XWiki Rendering'
  1. XWiki Rendering
  2. XRENDERING-146

Make it simple to add Icon Transformation mappings when using the Rendering in standalone mode

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.3-milestone-1
    • Component/s: Standalone
    • Labels:
      None
    • Similar issues:

      Description

      Right now it means providing an implementation of Configuration Source which is too complex. A better solution is to add an addMapping API in the IconTransformationConfiguration interface

              // Initialize Rendering components and allow getting instances
              final EmbeddableComponentManager cm = new EmbeddableComponentManager();
              cm.initialize(this.getClass().getClassLoader());
      
              XDOM xdom = new XDOM(Arrays.<Block>asList(new ParagraphBlock(Arrays.asList((Block) new SpecialSymbolBlock(':'),
                  new SpecialSymbolBlock(':')))));
      
              // Test adding a new Icon Mapping by registering a Configuration Source implementation (note that this can
              // also be done by writing a Java class, using annotations and registering it in components.txt)
              cm.lookup(IconTransformationConfiguration.class).addMapping("::", "something");
      
              Transformation transformation = cm.lookup(Transformation.class, "icon");
              TransformationContext txContext = new TransformationContext();
              transformation.transform(xdom, txContext);
      
              WikiPrinter printer = new DefaultWikiPrinter();
              BlockRenderer renderer = cm.lookup(BlockRenderer.class, Syntax.XWIKI_2_0.toIdString());
              renderer.render(xdom, printer);
      
              String expected = "image:something";
      
              Assert.assertEquals(expected, printer.toString());
      

        Attachments

          Activity

            People

            Assignee:
            vmassol Vincent Massol
            Reporter:
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: