Package org.apache.maven.doxia.sink.render

Examples of org.apache.maven.doxia.sink.render.RenderingContext


        if ( categories.containsKey( MavenReport.CATEGORY_PROJECT_INFORMATION ) && generateProjectInfo )
        {
            List<MavenReport> categoryReports = categories.get( MavenReport.CATEGORY_PROJECT_INFORMATION );

            RenderingContext renderingContext = new RenderingContext( siteDirectory, "project-info.html" );
            String title = i18n.getString( "site-plugin", locale, "report.information.title" );
            String desc1 = i18n.getString( "site-plugin", locale, "report.information.description1" );
            String desc2 = i18n.getString( "site-plugin", locale, "report.information.description2" );
            DocumentRenderer renderer = new CategorySummaryDocumentRenderer( renderingContext, title, desc1, desc2,
                                                                             i18n, categoryReports, getLog() );

            if ( !documents.containsKey( renderer.getOutputName() ) )
            {
                documents.put( renderer.getOutputName(), renderer );
            }
            else
            {
                getLog().info( "Category summary '" + renderer.getOutputName() + "' skipped; already exists" );
            }
        }

        if ( categories.containsKey( MavenReport.CATEGORY_PROJECT_REPORTS ) )
        {
            List<MavenReport> categoryReports = categories.get( MavenReport.CATEGORY_PROJECT_REPORTS );
            RenderingContext renderingContext = new RenderingContext( siteDirectory, "project-reports.html" );
            String title = i18n.getString( "site-plugin", locale, "report.project.title" );
            String desc1 = i18n.getString( "site-plugin", locale, "report.project.description1" );
            String desc2 = i18n.getString( "site-plugin", locale, "report.project.description2" );
            DocumentRenderer renderer = new CategorySummaryDocumentRenderer( renderingContext, title, desc1, desc2,
                                                                             i18n, categoryReports, getLog() );
View Full Code Here


        StringWriter writer = new StringWriter();

        SiteRenderingContext siteRenderingContext = new SiteRenderingContext();
        siteRenderingContext.setDecoration(new DecorationModel());
        siteRenderingContext.setTemplateName( "org/apache/maven/doxia/siterenderer/velocity-toolmanager.vm" );
        RenderingContext context = new RenderingContext( new File( "" ), "document.html" );
        SiteRendererSink sink = new SiteRendererSink( context );
        renderer.generateDocument( writer, sink, siteRenderingContext );

        String renderResult = writer.toString();
        String expectedResult = IOUtils.toString( getClass().getResourceAsStream( "velocity-toolmanager.expected.txt" ) );
View Full Code Here

        File templateFile = new File( getBasedir(), "target/test-classes/org/apache/maven/doxia/siterenderer/velocity-toolmanager.vm" );
        Map<String, ?> attributes = Collections.emptyMap();

        SiteRenderingContext siteRenderingContext = renderer.createContextForTemplate( templateFile, null, attributes, new DecorationModel(), "defaultWindowTitle", Locale.ENGLISH );
        RenderingContext context = new RenderingContext( new File( "" ), "document.html" );
        SiteRendererSink sink = new SiteRendererSink( context );
        renderer.generateDocument( writer, sink, siteRenderingContext );

        String renderResult = writer.toString();
        String expectedResult = IOUtils.toString( getClass().getResourceAsStream( "velocity-toolmanager.expected.txt" ) );
View Full Code Here

        StringWriter writer = new StringWriter();

        File skinFile = skinJar;
        Map<String, ?> attributes = Collections.emptyMap();
        SiteRenderingContext siteRenderingContext = renderer.createContextForSkin( skinFile, attributes, new DecorationModel(), "defaultWindowTitle", Locale.ENGLISH );
        RenderingContext context = new RenderingContext( new File( "" ), "document.html" );
        SiteRendererSink sink = new SiteRendererSink( context );
        renderer.generateDocument( writer, sink, siteRenderingContext );

        String renderResult = writer.toString();
        String expectedResult = IOUtils.toString( getClass().getResourceAsStream( "velocity-toolmanager.expected.txt" ) );
View Full Code Here

            for ( String doc : docs )
            {
                String docc = doc.trim();

                RenderingContext context =
                        new RenderingContext( moduleBasedir, docc, module.getParserId(), module.getExtension() );

                // TODO: DOXIA-111: we need a general filter here that knows how to alter the context
                if ( docc.toLowerCase( Locale.ENGLISH ).endsWith( ".vm" ) )
                {
                    context.setAttribute( "velocity", "true" );
                }

                String key = context.getOutputName();
                key = StringUtils.replace( key, "\\", "/" );

                if ( files.containsKey( key ) )
                {
                    DocumentRenderer renderer = files.get( key );

                    RenderingContext originalContext = renderer.getRenderingContext();

                    File originalDoc = new File( originalContext.getBasedir(), originalContext.getInputName() );

                    throw new RendererException( "Files '" + module.getSourceDirectory() + File.separator + docc
                        + "' clashes with existing '" + originalDoc + "'." );
                }
                // -----------------------------------------------------------------------
                // Handle key without case differences
                // -----------------------------------------------------------------------
                for ( Map.Entry<String, DocumentRenderer> entry : files.entrySet() )
                {
                    if ( entry.getKey().equalsIgnoreCase( key ) )
                    {
                        RenderingContext originalContext = entry.getValue().getRenderingContext();

                        File originalDoc = new File( originalContext.getBasedir(), originalContext.getInputName() );

                        if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
                        {
                            throw new RendererException( "Files '" + module.getSourceDirectory() + File.separator
                                + docc + "' clashes with existing '" + originalDoc + "'." );
View Full Code Here

                               File outputDirectory )
            throws IOException, RendererException
    {
        for ( DocumentRenderer docRenderer : docs )
        {
            RenderingContext renderingContext = docRenderer.getRenderingContext();

            File outputFile = new File( outputDirectory, docRenderer.getOutputName() );

            File inputFile = new File( renderingContext.getBasedir(), renderingContext.getInputName() );

            boolean modified = !outputFile.exists() || ( inputFile.lastModified() > outputFile.lastModified() )
                || ( siteRenderingContext.getDecoration().getLastModified() > outputFile.lastModified() );

            if ( modified || docRenderer.isOverwrite() )
View Full Code Here

        // ----------------------------------------------------------------------
        // Data objects
        // ----------------------------------------------------------------------

        RenderingContext renderingContext = sink.getRenderingContext();
        context.put( "relativePath", renderingContext.getRelativePath() );

        // Add infos from document
        context.put( "authors", sink.getAuthors() );

        context.put( "shortTitle", sink.getTitle() );

        // DOXIASITETOOLS-70: Prepend the project name to the title, if any
        String title = "";
        if ( siteRenderingContext.getDecoration() != null
                && siteRenderingContext.getDecoration().getName() != null )
        {
            title = siteRenderingContext.getDecoration().getName();
        }
        else if ( siteRenderingContext.getDefaultWindowTitle() != null )
        {
            title = siteRenderingContext.getDefaultWindowTitle();
        }

        if ( title.length() > 0 )
        {
            title += " - ";
        }
        title += sink.getTitle();

        context.put( "title", title );

        context.put( "headContent", sink.getHead() );

        context.put( "bodyContent", sink.getBody() );

        context.put( "decoration", siteRenderingContext.getDecoration() );

        SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd" );
        if ( StringUtils.isNotEmpty( sink.getDate() ) )
        {
            try
            {
                // we support only ISO-8601 date
                context.put( "dateCreation",
                        sdf.format( new SimpleDateFormat( "yyyy-MM-dd" ).parse( sink.getDate() ) ) );
            }
            catch ( java.text.ParseException e )
            {
                getLogger().debug( "Could not parse date: " + sink.getDate() + ", ignoring!", e );
            }
        }
        context.put( "dateRevision", sdf.format( new Date() ) );

        context.put( "currentDate", new Date() );

        context.put( "publishDate", siteRenderingContext.getPublishDate() );

        Locale locale = siteRenderingContext.getLocale();

        DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.DEFAULT, locale );

        if ( siteRenderingContext.getDecoration().getPublishDate() != null )
        {
            if ( StringUtils.isNotBlank( siteRenderingContext.getDecoration().getPublishDate().getFormat() ) )
            {
                dateFormat =
                    new SimpleDateFormat( siteRenderingContext.getDecoration().getPublishDate().getFormat(), locale );
            }
        }

        context.put( "dateFormat", dateFormat );

        String currentFileName = renderingContext.getOutputName().replace( '\\', '/' );
        context.put( "currentFileName", currentFileName );

        context.put( "alignedFileName", PathTool.calculateLink( currentFileName, renderingContext.getRelativePath() ) );

        context.put( "locale", locale );
        context.put( "supportedLocales", Collections.unmodifiableList( siteRenderingContext.getSiteLocales() ) );

        InputStream inputStream = null;
View Full Code Here

        try
        {
            SiteRenderingContext siteContext =
                siteRenderer.createContextForSkin( getSkinArtifactFile(), attributes, model, getName( locale ),
                                                   locale );
            RenderingContext context = new RenderingContext( outputDirectory, getOutputName() + ".html" );

            SiteRendererSink sink = new SiteRendererSink( context );
            generate( sink, locale );

            if( !outputDirectory.mkdirs() && !outputDirectory.isDirectory() ) {
View Full Code Here

                                   + "\" already exists for the " + displayLanguage + " version." );
                reports.remove( mavenReportExecution );
            }
            else
            {
                RenderingContext renderingContext = new RenderingContext( siteDirectory, outputName );
                ReportDocumentRenderer renderer = new ReportDocumentRenderer( mavenReportExecution, renderingContext, getLog() );
                documents.put( outputName, renderer );
            }
        }
        return reportsByOutputName;
View Full Code Here

        if ( categories.containsKey( MavenReport.CATEGORY_PROJECT_INFORMATION ) )
        {
            List categoryReports = (List) categories.get( MavenReport.CATEGORY_PROJECT_INFORMATION );

            RenderingContext renderingContext = new RenderingContext( siteDirectory, "project-info.html" );
            String title = i18n.getString( "site-plugin", locale, "report.information.title" );
            String desc1 = i18n.getString( "site-plugin", locale, "report.information.description1" );
            String desc2 = i18n.getString( "site-plugin", locale, "report.information.description2" );
            DocumentRenderer renderer = new CategorySummaryDocumentRenderer( renderingContext, title, desc1, desc2,
                                                                             i18n, categoryReports, getLog() );

            if ( !documents.containsKey( renderer.getOutputName() ) )
            {
                documents.put( renderer.getOutputName(), renderer );
            }
            else
            {
                getLog().info( "Category summary '" + renderer.getOutputName() + "' skipped; already exists" );
            }
        }

        if ( categories.containsKey( MavenReport.CATEGORY_PROJECT_REPORTS ) )
        {
            List categoryReports = (List) categories.get( MavenReport.CATEGORY_PROJECT_REPORTS );
            RenderingContext renderingContext = new RenderingContext( siteDirectory, "project-reports.html" );
            String title = i18n.getString( "site-plugin", locale, "report.project.title" );
            String desc1 = i18n.getString( "site-plugin", locale, "report.project.description1" );
            String desc2 = i18n.getString( "site-plugin", locale, "report.project.description2" );
            DocumentRenderer renderer = new CategorySummaryDocumentRenderer( renderingContext, title, desc1, desc2,
                                                                             i18n, categoryReports, getLog() );
View Full Code Here

TOP

Related Classes of org.apache.maven.doxia.sink.render.RenderingContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.