Package org.apache.maven.doxia.siterenderer

Examples of org.apache.maven.doxia.siterenderer.SiteRenderingContext


     */
    private void renderer( SurefireReportMojo mojo, File outputHtml )
        throws RendererException, IOException
    {
        Writer writer = null;
        SiteRenderingContext context = new SiteRenderingContext();
        context.setDecoration( new DecorationModel() );
        context.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
        context.setLocale( Locale.ENGLISH );

        try
        {
            outputHtml.getParentFile().mkdirs();
            writer = WriterFactory.newXmlWriter( outputHtml );
View Full Code Here


        Map<String, String> attributes = new HashMap<String, String>();
        attributes.put( "outputEncoding", "UTF-8" );
        Locale locale = Locale.getDefault();
        try
        {
            SiteRenderingContext siteContext =
                siteRenderer.createContextForSkin( getSkinArtifactFile(), attributes, model, getName( locale ),
                                                   locale );
            RenderingContext context = new RenderingContext( outputDirectory, getOutputName() + ".html" );

            SiteRendererSink sink = new SiteRendererSink( context );
View Full Code Here

    {
      final DecorationModel model = new DecorationModel();
      model.setBody(new Body());
      final Map<String, String> attributes = new HashMap<String, String>();
      attributes.put("outputEncoding", "UTF-8"); // TODO correct???
      final SiteRenderingContext siteContext =
          siteRenderer.createContextForSkin(ReportUtils.getSkinArtifactFile(
              project, localRepository, resolver, factory), attributes, model,
              getName(reportLocale), reportLocale);

      final RenderingContext context =
View Full Code Here

            Map<String, Object> attributes = new HashMap<String, Object>();
            attributes.put("outputEncoding", "UTF-8");
            attributes.put("project", project);
            Locale locale = Locale.getDefault();

            SiteRenderingContext siteContext = renderer.createContextForSkin(
                    getSkinArtifactFile(model), attributes, model,
                    getName(locale), locale);

            RenderingContext context = new RenderingContext(
                    getReportOutputDirectory(), getOutputName() + ".html");
View Full Code Here

     */
    private void renderer( CheckstyleReport mojo, File outputHtml )
        throws RendererException, Exception
    {
        Writer writer = null;
        SiteRenderingContext context = new SiteRenderingContext();
        context.setDecoration( new DecorationModel() );
        context.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
        context.setLocale( Locale.ENGLISH );

        try
        {
            outputHtml.getParentFile().mkdirs();
            writer = WriterFactory.newXmlWriter( outputHtml );
View Full Code Here

        // Remove the /
        path = path.substring( 1 );

        // Handle locale request
        SiteRenderingContext context;
        Map documents;
        File generatedSiteDirectory;

        String localeWanted = null;
        for ( Iterator it = localesList.iterator(); it.hasNext(); )
        {
            Locale locale = (Locale) it.next();

            if ( path.startsWith( locale.getLanguage() + "/" ) )
            {
                localeWanted = locale.toString();
                path = path.substring( locale.getLanguage().length() + 1 );
            }
        }

        if ( localeWanted == null )
        {
            DoxiaBean defaultDoxiaBean = (DoxiaBean) i18nDoxiaContexts.get( "default" );
            if ( defaultDoxiaBean == null )
            {
                throw new ServletException( "No doxia bean found for the default locale" );
            }
            context = defaultDoxiaBean.getContext();
            documents = defaultDoxiaBean.getDocuments();
            generatedSiteDirectory = defaultDoxiaBean.getGeneratedSiteDirectory();
        }
        else
        {
            DoxiaBean i18nDoxiaBean = (DoxiaBean) i18nDoxiaContexts.get( localeWanted );
            if ( i18nDoxiaBean == null )
            {
                throw new ServletException( "No doxia bean found for the locale " + localeWanted );
            }
            context = i18nDoxiaBean.getContext();
            documents = i18nDoxiaBean.getDocuments();
            generatedSiteDirectory = i18nDoxiaBean.getGeneratedSiteDirectory();
        }

        // ----------------------------------------------------------------------
        // Handle report and documents
        // ----------------------------------------------------------------------
        if ( documents.containsKey( path ) )
        {
            try
            {
                DocumentRenderer renderer = (DocumentRenderer) documents.get( path );
                renderer.renderDocument( servletResponse.getWriter(), siteRenderer, context );

                if ( renderer instanceof ReportDocumentRenderer )
                {
                    ReportDocumentRenderer reportDocumentRenderer = (ReportDocumentRenderer) renderer;
                    if ( reportDocumentRenderer.isExternalReport() )
                    {
                        try
                        {
                            filterChain.doFilter( servletRequest, servletResponse );
                        }
                        catch ( Exception e )
                        {
                            throw new ServletException( e );
                        }
                    }
                }
            }
            catch ( RendererException e )
            {
                throw new ServletException( e );
            }
        }
        else if ( generatedSiteDirectory != null && generatedSiteDirectory.exists() )
        {
            context.getSiteDirectories().clear();
            context.addSiteDirectory( generatedSiteDirectory );
            try
            {
                Map locateDocuments = siteRenderer.locateDocumentFiles( context );

                if ( locateDocuments.containsKey( path ) )
                {
                    DocumentRenderer renderer = (DocumentRenderer) locateDocuments.get( path );
                    renderer.renderDocument( servletResponse.getWriter(), siteRenderer, context );
                }
            }
            catch ( RendererException e )
            {
                throw new ServletException( e );
            }

            List originalSiteDirectories = new ArrayList( context.getSiteDirectories() );
            for ( Iterator i = originalSiteDirectories.iterator(); i.hasNext(); )
            {
                File dir = (File) i.next();
                context.addSiteDirectory( dir );
            }
        }
        else
        {
            filterChain.doFilter( servletRequest, servletResponse );
View Full Code Here

    }

    private void renderLocale( Locale locale, List<MavenReportExecution> reports )
        throws IOException, RendererException, MojoFailureException, MojoExecutionException
    {
        SiteRenderingContext context = createSiteRenderingContext( locale );

        context.setInputEncoding( getInputEncoding() );
        context.setOutputEncoding( getOutputEncoding() );

        Map documents = locateDocuments( context, reports, locale );

        File outputDir = getOutputDirectory( locale );

        // For external reports
        for ( MavenReportExecution mavenReportExecution : reports )
        {
            MavenReport report = mavenReportExecution.getMavenReport();
            report.setReportOutputDirectory( outputDir );
        }

        siteRenderer.render( documents.values(), context, outputDir );

        if ( generateSitemap )
        {
            getLog().info( "Generating Sitemap." );

            new SiteMap( getOutputEncoding(), i18n )
                    .generate( context.getDecoration(), generatedSiteDirectory, locale );
        }

        // Generated docs must be done afterwards as they are often generated by reports
        context.getSiteDirectories().clear();
        context.addSiteDirectory( generatedSiteDirectory );

        documents = siteRenderer.locateDocumentFiles( context );

        siteRenderer.render( documents.values(), context, outputDir );
    }
View Full Code Here

        }
        catch ( SiteToolException e )
        {
            throw new MojoExecutionException( "SiteToolException: " + e.getMessage(), e );
        }
        SiteRenderingContext context;
        if ( templateFile != null )
        {
            if ( !templateFile.exists() )
            {
                throw new MojoFailureException( "Template file '" + templateFile + "' does not exist" );
            }
            context = siteRenderer.createContextForTemplate( templateFile, skinFile, attributes, decorationModel,
                                                             project.getName(), locale );
        }
        else
        {
            context = siteRenderer.createContextForSkin( skinFile, attributes, decorationModel, project.getName(),
                                                         locale );
        }

        // Generate static site
        if ( !locale.getLanguage().equals( Locale.getDefault().getLanguage() ) )
        {
            context.addSiteDirectory( new File( siteDirectory, locale.getLanguage() ) );
            context.addModuleDirectory( new File( xdocDirectory, locale.getLanguage() ), "xdoc" );
            context.addModuleDirectory( new File( xdocDirectory, locale.getLanguage() ), "fml" );
        }
        else
        {
            context.addSiteDirectory( siteDirectory );
            context.addModuleDirectory( xdocDirectory, "xdoc" );
            context.addModuleDirectory( xdocDirectory, "fml" );
        }

        if ( moduleExcludes != null )
        {
            context.setModuleExcludes( moduleExcludes );
        }

        return context;
    }
View Full Code Here

            for ( Iterator it = localesList.iterator(); it.hasNext(); )
            {
                Locale locale = (Locale) it.next();

                SiteRenderingContext i18nContext = createSiteRenderingContext( locale );
                i18nContext.setInputEncoding( getInputEncoding() );
                i18nContext.setOutputEncoding( getOutputEncoding() );

                Map i18nDocuments = locateDocuments( i18nContext, filteredReports, locale );
                DoxiaBean doxiaBean;
                if ( defaultLocale.equals( locale ) )
                {
View Full Code Here

        {
            Map<String, DoxiaBean> i18nDoxiaContexts = new HashMap<String, DoxiaBean>();

            for ( Locale locale : localesList )
            {
                SiteRenderingContext i18nContext = createSiteRenderingContext( locale );
                i18nContext.setInputEncoding( getInputEncoding() );
                i18nContext.setOutputEncoding( getOutputEncoding() );

                Map<String, DocumentRenderer> i18nDocuments = locateDocuments( i18nContext, reports, locale );
                DoxiaBean doxiaBean;
                if ( defaultLocale.equals( locale ) )
                {
View Full Code Here

TOP

Related Classes of org.apache.maven.doxia.siterenderer.SiteRenderingContext

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.