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

    • Improvement
    • Resolution: Fixed
    • Minor
    • 3.3-milestone-1
    • 3.2
    • Standalone
    • None

    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

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

            Dates

              Created:
              Updated:
              Resolved: