Class DefaultSiteRenderer
- java.lang.Object
-
- org.apache.maven.doxia.siterenderer.DefaultSiteRenderer
-
- All Implemented Interfaces:
Renderer,SiteRenderer
@Singleton @Named public class DefaultSiteRenderer extends java.lang.Object implements Renderer
DefaultSiteRenderer class.
- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.maven.doxia.Doxiadoxiaprivate static java.lang.StringDOXIA_SITE_RENDERER_VERSIONprivate static org.slf4j.LoggerLOGGERprivate org.apache.maven.doxia.parser.module.ParserModuleManagerparserModuleManagerprivate org.codehaus.plexus.PlexusContainerplexusprivate static java.lang.StringSKIN_TEMPLATE_LOCATIONprivate static java.lang.StringTOOLS_LOCATIONprivate org.codehaus.plexus.velocity.VelocityComponentvelocity
-
Constructor Summary
Constructors Constructor Description DefaultSiteRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddModuleFiles(java.io.File rootDir, java.io.File moduleBasedir, org.apache.maven.doxia.parser.module.ParserModule module, java.lang.String excludes, java.util.Map<java.lang.String,DocumentRenderer> files, boolean editable)private static voidcloseZipFile(java.util.zip.ZipFile zipFile)protected voidcopyDirectory(java.io.File source, java.io.File destination)Copy the directoryprivate static voidcopyFileFromZip(java.util.zip.ZipFile file, java.util.zip.ZipEntry entry, java.io.File destFile)voidcopyResources(SiteRenderingContext siteRenderingContext, java.io.File outputDirectory)Copy resource files from skin, template, and site resources.SiteRenderingContextcreateContextForSkin(org.apache.maven.artifact.Artifact skin, java.util.Map<java.lang.String,?> attributes, SiteModel siteModel, java.lang.String defaultTitle, java.util.Locale locale)Create a Site Rendering Context for a site using a skin.protected org.apache.velocity.context.ContextcreateDocumentVelocityContext(DocumentRenderingContext docRenderingContext, SiteRenderingContext siteRenderingContext)Create a Velocity Context for a Doxia document, containing every information about rendered document.private SiteRenderingContextcreateSiteRenderingContext(java.util.Map<java.lang.String,?> attributes, SiteModel siteModel, java.lang.String defaultTitle, java.util.Locale locale)protected org.apache.velocity.context.ContextcreateSiteTemplateVelocityContext(DocumentContent content, SiteRenderingContext siteRenderingContext)Create a Velocity Context for the site template decorating the document.protected org.apache.velocity.context.ContextcreateToolManagedVelocityContext(SiteRenderingContext siteRenderingContext)Creates a Velocity Context with all generic tools configured wit the site rendering context.(package private) static booleanendsWithIgnoreCase(java.lang.String str, java.lang.String searchStr)private java.util.List<java.lang.String>filterExtensionIgnoreCase(java.util.List<java.lang.String> fileNames, java.lang.String extension)voidgenerateDocument(java.io.Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext)private static java.lang.StringgetSiteRendererVersion()private static java.util.zip.ZipFilegetZipFile(java.io.File file)java.util.Map<java.lang.String,DocumentRenderer>locateDocumentFiles(SiteRenderingContext siteRenderingContext)Locate Doxia document source files in the site source context.(package private) booleanmatchVersion(java.lang.String current, java.lang.String prerequisite)voidmergeDocumentIntoSite(java.io.Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext)Generate a document output integrated in a site from a document content, i.e.voidrender(java.util.Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, java.io.File outputDirectory)Render a collection of documents into a site.voidrenderDocument(java.io.Writer writer, DocumentRenderingContext docRenderingContext, SiteRenderingContext siteContext)Render a document written in a Doxia markup language.private voidsaveVelocityProcessedContent(DocumentRenderingContext docRenderingContext, SiteRenderingContext siteContext, java.lang.String doxiaContent)private java.io.Readervalidate(java.io.Reader source, java.lang.String resource)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.maven.doxia.siterenderer.SiteRenderer
locateDocumentFiles
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
velocity
@Inject private org.codehaus.plexus.velocity.VelocityComponent velocity
-
parserModuleManager
@Inject private org.apache.maven.doxia.parser.module.ParserModuleManager parserModuleManager
-
doxia
@Inject private org.apache.maven.doxia.Doxia doxia
-
plexus
@Inject private org.codehaus.plexus.PlexusContainer plexus
-
SKIN_TEMPLATE_LOCATION
private static final java.lang.String SKIN_TEMPLATE_LOCATION
- See Also:
- Constant Field Values
-
TOOLS_LOCATION
private static final java.lang.String TOOLS_LOCATION
- See Also:
- Constant Field Values
-
DOXIA_SITE_RENDERER_VERSION
private static final java.lang.String DOXIA_SITE_RENDERER_VERSION
-
-
Method Detail
-
locateDocumentFiles
public java.util.Map<java.lang.String,DocumentRenderer> locateDocumentFiles(SiteRenderingContext siteRenderingContext) throws java.io.IOException, RendererException
Locate Doxia document source files in the site source context.- Specified by:
locateDocumentFilesin interfaceSiteRenderer- Parameters:
siteRenderingContext- the SiteRenderingContext to use- Returns:
- the Doxia document renderers in a Map keyed by output file path.
- Throws:
java.io.IOException- if it bombs.RendererException- if it bombs.
-
filterExtensionIgnoreCase
private java.util.List<java.lang.String> filterExtensionIgnoreCase(java.util.List<java.lang.String> fileNames, java.lang.String extension)
-
addModuleFiles
private void addModuleFiles(java.io.File rootDir, java.io.File moduleBasedir, org.apache.maven.doxia.parser.module.ParserModule module, java.lang.String excludes, java.util.Map<java.lang.String,DocumentRenderer> files, boolean editable) throws java.io.IOException, RendererException- Throws:
java.io.IOExceptionRendererException
-
render
public void render(java.util.Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, java.io.File outputDirectory) throws RendererException, java.io.IOException
Render a collection of documents into a site.- Specified by:
renderin interfaceSiteRenderer- Parameters:
documents- the documents to render.siteRenderingContext- the SiteRenderingContext to use.outputDirectory- the output directory to write results.- Throws:
RendererException- if it bombs.java.io.IOException- if it bombs.
-
renderDocument
public void renderDocument(java.io.Writer writer, DocumentRenderingContext docRenderingContext, SiteRenderingContext siteContext) throws RendererExceptionRender a document written in a Doxia markup language. This method is an internal method, used byDoxiaDocumentRenderer.- Specified by:
renderDocumentin interfaceSiteRenderer- Parameters:
writer- the writer to render the document to.docRenderingContext- the document's rendering context, which is expected to have a non-null parser id.siteContext- the site's rendering context- Throws:
RendererException- if it bombs.
-
saveVelocityProcessedContent
private void saveVelocityProcessedContent(DocumentRenderingContext docRenderingContext, SiteRenderingContext siteContext, java.lang.String doxiaContent) throws java.io.IOException
- Throws:
java.io.IOException
-
createToolManagedVelocityContext
protected org.apache.velocity.context.Context createToolManagedVelocityContext(SiteRenderingContext siteRenderingContext)
Creates a Velocity Context with all generic tools configured wit the site rendering context.- Parameters:
siteRenderingContext- the site rendering context- Returns:
- a Velocity tools managed context
-
createDocumentVelocityContext
protected org.apache.velocity.context.Context createDocumentVelocityContext(DocumentRenderingContext docRenderingContext, SiteRenderingContext siteRenderingContext)
Create a Velocity Context for a Doxia document, containing every information about rendered document.- Parameters:
docRenderingContext- the document's rendering contextsiteRenderingContext- the site rendering context- Returns:
- a Velocity tools managed context
-
createSiteTemplateVelocityContext
protected org.apache.velocity.context.Context createSiteTemplateVelocityContext(DocumentContent content, SiteRenderingContext siteRenderingContext)
Create a Velocity Context for the site template decorating the document. In addition to all the informations from the document, this context contains data gathered inSiteRendererSinkduring document rendering.- Parameters:
content- the document content to be merged into the templatesiteRenderingContext- the site rendering context- Returns:
- a Velocity tools managed context
-
generateDocument
public void generateDocument(java.io.Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext) throws RendererException- Throws:
RendererException
-
mergeDocumentIntoSite
public void mergeDocumentIntoSite(java.io.Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext) throws RendererExceptionGenerate a document output integrated in a site from a document content, i.e. merge the document content into the site template.- Specified by:
mergeDocumentIntoSitein interfaceSiteRenderer- Parameters:
writer- the Writer to use.content- the document content to be merged.siteRenderingContext- the SiteRenderingContext to use.- Throws:
RendererException- if it bombs.
-
createSiteRenderingContext
private SiteRenderingContext createSiteRenderingContext(java.util.Map<java.lang.String,?> attributes, SiteModel siteModel, java.lang.String defaultTitle, java.util.Locale locale)
-
createContextForSkin
public SiteRenderingContext createContextForSkin(org.apache.maven.artifact.Artifact skin, java.util.Map<java.lang.String,?> attributes, SiteModel siteModel, java.lang.String defaultTitle, java.util.Locale locale) throws java.io.IOException, RendererException
Create a Site Rendering Context for a site using a skin.- Specified by:
createContextForSkinin interfaceSiteRenderer- Parameters:
skin- a skinattributes- attributes to usesiteModel- a site modeldefaultTitle- default titlelocale- locale to use- Returns:
- a SiteRenderingContext.
- Throws:
java.io.IOException- if it bombs.RendererException- if it bombs.
-
matchVersion
boolean matchVersion(java.lang.String current, java.lang.String prerequisite) throws RendererException- Throws:
RendererException
-
copyResources
public void copyResources(SiteRenderingContext siteRenderingContext, java.io.File outputDirectory) throws java.io.IOException
Copy resource files from skin, template, and site resources.- Specified by:
copyResourcesin interfaceSiteRenderer- Parameters:
siteRenderingContext- the SiteRenderingContext to use.outputDirectory- output directory as file- Throws:
java.io.IOException- if it bombs.
-
copyFileFromZip
private static void copyFileFromZip(java.util.zip.ZipFile file, java.util.zip.ZipEntry entry, java.io.File destFile) throws java.io.IOException- Throws:
java.io.IOException
-
copyDirectory
protected void copyDirectory(java.io.File source, java.io.File destination) throws java.io.IOExceptionCopy the directory- Parameters:
source- source file to be copieddestination- destination file- Throws:
java.io.IOException- if any
-
validate
private java.io.Reader validate(java.io.Reader source, java.lang.String resource) throws org.apache.maven.doxia.parser.ParseException, java.io.IOException- Throws:
org.apache.maven.doxia.parser.ParseExceptionjava.io.IOException
-
endsWithIgnoreCase
static boolean endsWithIgnoreCase(java.lang.String str, java.lang.String searchStr)
-
getZipFile
private static java.util.zip.ZipFile getZipFile(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
closeZipFile
private static void closeZipFile(java.util.zip.ZipFile zipFile)
-
getSiteRendererVersion
private static java.lang.String getSiteRendererVersion()
-
-