Class DefaultSiteRenderer
- java.lang.Object
-
- org.codehaus.plexus.logging.AbstractLogEnabled
-
- org.apache.maven.doxia.siterenderer.DefaultSiteRenderer
-
- All Implemented Interfaces:
Renderer
,org.codehaus.plexus.logging.LogEnabled
@Component(role=Renderer.class) public class DefaultSiteRenderer extends org.codehaus.plexus.logging.AbstractLogEnabled implements Renderer
DefaultSiteRenderer class.
- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DEFAULT_TEMPLATE
private org.apache.maven.doxia.Doxia
doxia
private org.codehaus.plexus.i18n.I18N
i18n
private org.apache.maven.doxia.parser.module.ParserModuleManager
parserModuleManager
private org.codehaus.plexus.PlexusContainer
plexus
private static java.lang.String
RESOURCE_DIR
private static java.lang.String
SKIN_TEMPLATE_LOCATION
private static java.lang.String
TOOLS_LOCATION
private org.codehaus.plexus.velocity.VelocityComponent
velocity
-
Constructor Summary
Constructors Constructor Description DefaultSiteRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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)
private static void
closeZipFile(java.util.zip.ZipFile zipFile)
protected void
copyDirectory(java.io.File source, java.io.File destination)
Copy the directoryprivate static void
copyFileFromZip(java.util.zip.ZipFile file, java.util.zip.ZipEntry entry, java.io.File destFile)
void
copyResources(SiteRenderingContext siteRenderingContext, java.io.File outputDirectory)
Copy resource files from skin, template, and site resources.void
copyResources(SiteRenderingContext siteRenderingContext, java.io.File resourcesDirectory, java.io.File outputDirectory)
Copy resource files.SiteRenderingContext
createContextForSkin(org.apache.maven.artifact.Artifact skin, java.util.Map<java.lang.String,?> attributes, DecorationModel decoration, java.lang.String defaultWindowTitle, java.util.Locale locale)
Create a Site Rendering Context for a site using a skin.SiteRenderingContext
createContextForTemplate(java.io.File templateFile, java.util.Map<java.lang.String,?> attributes, DecorationModel decoration, java.lang.String defaultWindowTitle, java.util.Locale locale)
Deprecated.protected org.apache.velocity.context.Context
createDocumentVelocityContext(RenderingContext renderingContext, SiteRenderingContext siteRenderingContext)
Create a Velocity Context for a Doxia document, containing every information about rendered document.private SiteRenderingContext
createSiteRenderingContext(java.util.Map<java.lang.String,?> attributes, DecorationModel decoration, java.lang.String defaultWindowTitle, java.util.Locale locale)
protected org.apache.velocity.context.Context
createSiteTemplateVelocityContext(DocumentContent content, SiteRenderingContext siteRenderingContext)
Create a Velocity Context for the site template decorating the document.protected org.apache.velocity.context.Context
createToolManagedVelocityContext(SiteRenderingContext siteRenderingContext)
Creates a Velocity Context with all generic tools configured wit the site rendering context.(package private) static boolean
endsWithIgnoreCase(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)
void
generateDocument(java.io.Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext)
Generate a document output from a Doxia SiteRenderer Sink, i.e.private static java.util.zip.ZipFile
getZipFile(java.io.File file)
java.util.Map<java.lang.String,DocumentRenderer>
locateDocumentFiles(SiteRenderingContext siteRenderingContext)
Locate Doxia document source files in the site source context.java.util.Map<java.lang.String,DocumentRenderer>
locateDocumentFiles(SiteRenderingContext siteRenderingContext, boolean editable)
Locate Doxia document source files in the site source context.(package private) boolean
matchVersion(java.lang.String current, java.lang.String prerequisite)
void
mergeDocumentIntoSite(java.io.Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext)
Generate a document output integrated in a site from a document content, i.e.void
render(java.util.Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, java.io.File outputDirectory)
Render a collection of documents into a site.void
renderDocument(java.io.Writer writer, RenderingContext docRenderingContext, SiteRenderingContext siteContext)
Render a document written in a Doxia markup language.private void
saveVelocityProcessedContent(RenderingContext docRenderingContext, SiteRenderingContext siteContext, java.lang.String doxiaContent)
private java.io.Reader
validate(java.io.Reader source, java.lang.String resource)
-
-
-
Field Detail
-
velocity
@Requirement private org.codehaus.plexus.velocity.VelocityComponent velocity
-
parserModuleManager
@Requirement private org.apache.maven.doxia.parser.module.ParserModuleManager parserModuleManager
-
doxia
@Requirement private org.apache.maven.doxia.Doxia doxia
-
i18n
@Requirement private org.codehaus.plexus.i18n.I18N i18n
-
plexus
@Requirement private org.codehaus.plexus.PlexusContainer plexus
-
RESOURCE_DIR
private static final java.lang.String RESOURCE_DIR
- See Also:
- Constant Field Values
-
DEFAULT_TEMPLATE
private static final java.lang.String DEFAULT_TEMPLATE
- See Also:
- Constant Field Values
-
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
-
-
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:
locateDocumentFiles
in interfaceRenderer
- Returns:
- the Doxia document renderers in a Map keyed by output file name.
- Throws:
java.io.IOException
- if it bombs.RendererException
- if it bombs.
-
locateDocumentFiles
public java.util.Map<java.lang.String,DocumentRenderer> locateDocumentFiles(SiteRenderingContext siteRenderingContext, boolean editable) throws java.io.IOException, RendererException
Locate Doxia document source files in the site source context.- Specified by:
locateDocumentFiles
in interfaceRenderer
- Returns:
- the Doxia document renderers in a Map keyed by output file name.
- 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.IOException
RendererException
-
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:
render
in interfaceRenderer
- 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, RenderingContext docRenderingContext, SiteRenderingContext siteContext) throws RendererException, java.io.FileNotFoundException, java.io.UnsupportedEncodingException
Render a document written in a Doxia markup language. This method is an internal method, used byDoxiaDocumentRenderer
.- Specified by:
renderDocument
in interfaceRenderer
- 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.java.io.FileNotFoundException
- if it bombs.java.io.UnsupportedEncodingException
- if it bombs.
-
saveVelocityProcessedContent
private void saveVelocityProcessedContent(RenderingContext 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(RenderingContext renderingContext, SiteRenderingContext siteRenderingContext)
Create a Velocity Context for a Doxia document, containing every information about rendered document.- Parameters:
sink
- the site renderer sink for the documentsiteRenderingContext
- the site rendering context- Returns:
-
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 inSiteRendererSink
during document rendering.- Parameters:
content
- the document content to be merged into the templatesiteRenderingContext
- the site rendering context- Returns:
-
generateDocument
public void generateDocument(java.io.Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext) throws RendererException
Generate a document output from a Doxia SiteRenderer Sink, i.e. merge the document content into the site template.- Specified by:
generateDocument
in interfaceRenderer
- Parameters:
writer
- the Writer to use.sink
- the Site Renderer Sink that received the Doxia events during document content rendering.siteRenderingContext
- the SiteRenderingContext to use.- Throws:
RendererException
- if it bombs.
-
mergeDocumentIntoSite
public void mergeDocumentIntoSite(java.io.Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext) throws RendererException
Generate a document output integrated in a site from a document content, i.e. merge the document content into the site template.- Specified by:
mergeDocumentIntoSite
in interfaceRenderer
- Parameters:
writer
- the Writer to use.content
- the document content to be mergedsiteRenderingContext
- the SiteRenderingContext to use.- Throws:
RendererException
- if it bombs.
-
createSiteRenderingContext
private SiteRenderingContext createSiteRenderingContext(java.util.Map<java.lang.String,?> attributes, DecorationModel decoration, java.lang.String defaultWindowTitle, java.util.Locale locale)
-
createContextForSkin
public SiteRenderingContext createContextForSkin(org.apache.maven.artifact.Artifact skin, java.util.Map<java.lang.String,?> attributes, DecorationModel decoration, java.lang.String defaultWindowTitle, java.util.Locale locale) throws java.io.IOException, RendererException
Create a Site Rendering Context for a site using a skin.- Specified by:
createContextForSkin
in interfaceRenderer
- Returns:
- a SiteRenderingContext.
- Throws:
java.io.IOException
- if it bombs.RendererException
-
matchVersion
boolean matchVersion(java.lang.String current, java.lang.String prerequisite) throws RendererException
- Throws:
RendererException
-
createContextForTemplate
@Deprecated public SiteRenderingContext createContextForTemplate(java.io.File templateFile, java.util.Map<java.lang.String,?> attributes, DecorationModel decoration, java.lang.String defaultWindowTitle, java.util.Locale locale) throws java.net.MalformedURLException
Deprecated.Create a Site Rendering Context for a site using a local template.- Specified by:
createContextForTemplate
in interfaceRenderer
- Returns:
- a SiteRenderingContext.
- Throws:
java.net.MalformedURLException
- if it bombs.- See Also:
#createContextForSkin(File, Map, DecorationModel, String, Locale)
-
copyResources
public void copyResources(SiteRenderingContext siteRenderingContext, java.io.File resourcesDirectory, java.io.File outputDirectory) throws java.io.IOException
Copy resource files.- Specified by:
copyResources
in interfaceRenderer
- Throws:
java.io.IOException
- if it bombs.
-
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:
copyResources
in interfaceRenderer
- 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.IOException
Copy 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.ParseException
java.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)
-
-