Class DefaultSiteRenderer
java.lang.Object
org.apache.maven.doxia.siterenderer.DefaultSiteRenderer
- All Implemented Interfaces:
Renderer, SiteRenderer
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String, ContextCustomizer> private org.apache.maven.doxia.Doxiaprivate static final Stringprivate static final org.slf4j.Loggerstatic final Stringprivate org.apache.maven.doxia.parser.module.ParserModuleManagerprivate org.codehaus.plexus.PlexusContainerprivate static final Stringprivate static final Stringprivate org.codehaus.plexus.velocity.VelocityComponent -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddModuleFiles(File siteRootDirectory, SiteRenderingContext.SiteDirectory siteDirectory, File moduleBasedir, org.apache.maven.doxia.parser.module.ParserModule module, String excludes, Map<String, DocumentRenderer> files) Populates the files map withDocumentRenderers per output name in parameterfilesfor all files in the moduleBasedir matching the module extensions, taking care of duplicates if needed.private booleancheckForDuplicate(DocumentRenderingContext newDocRenderingContext, Function<String, DocumentRenderer> lookupFunction, DefaultSiteRenderer.DuplicateCallback callback) private booleancheckForDuplicate(DocumentRenderingContext newDocRenderingContext, Map<String, DocumentRenderer> existingDocumentRenderers, boolean skipDuplicates) Checks if the newDocRenderingContext clashes with an existing document renderer.private static voidcloseZipFile(ZipFile zipFile) protected voidcopyDirectory(File source, File destination) Copy the directoryprivate static voidcopyFileFromResource(String name, File destFile) private static voidcopyFileFromZip(ZipFile file, ZipEntry entry, File destFile) voidcopyResources(SiteRenderingContext siteRenderingContext, File outputDirectory) Copy resource files from skin, template, and site resources.createContextForSkin(org.apache.maven.artifact.Artifact skin, Map<String, ?> attributes, SiteModel siteModel, String defaultTitle, 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.createResourceConditionsMap(SkinModel skinModel) private SiteRenderingContextcreateSiteRenderingContext(Map<String, ?> attributes, SiteModel siteModel, String defaultTitle, 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(String str, String searchStr) private static StringescapeLineBreaksForLogging(String input) filterExtensionIgnoreCase(List<String> fileNames, String extension) voidgenerateDocument(Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext) (package private) static PropertiesProperties contain some resolved properties from this project's Maven modelprivate static Stringprivate static ZipFilegetZipFile(File file) private booleanisResourceRelevant(String name, org.apache.velocity.context.Context velocityContext, Map<String, String> resourceConditions) locateDocumentFiles(SiteRenderingContext siteRenderingContext) Locate Doxia document source files in the site source context.(package private) booleanmatchVersion(String current, String prerequisite) voidmergeDocumentIntoSite(Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext) Generate a document output integrated in a site from a document content, i.e.voidrender(Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, File outputDirectory) Render a collection of documents into a site.voidrenderDocument(Writer writer, DocumentRenderingContext docRenderingContext, SiteRenderingContext siteContext) Render a document written in a Doxia markup language.private voidsaveVelocityProcessedContent(DocumentRenderingContext docRenderingContext, SiteRenderingContext siteContext, String doxiaContent) private ReaderMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SiteRenderer
locateDocumentFiles
-
Field Details
-
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 -
contextCustomizers
-
SKIN_TEMPLATE_LOCATION
- See Also:
-
TOOLS_LOCATION
- See Also:
-
DOXIA_SITE_RENDERER_VERSION
-
MERMAID_VERSION
-
-
Constructor Details
-
DefaultSiteRenderer
public DefaultSiteRenderer()
-
-
Method Details
-
getMavenProjectProperties
Properties contain some resolved properties from this project's Maven model- Returns:
- some resolved Maven project properties
- Throws:
IOException- in case the underlying file could not be accessed
-
locateDocumentFiles
public Map<String, DocumentRenderer> locateDocumentFiles(SiteRenderingContext siteRenderingContext) throws 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:
IOException- if it bombs.RendererException- if it bombs.
-
filterExtensionIgnoreCase
-
addModuleFiles
private void addModuleFiles(File siteRootDirectory, SiteRenderingContext.SiteDirectory siteDirectory, File moduleBasedir, org.apache.maven.doxia.parser.module.ParserModule module, String excludes, Map<String, DocumentRenderer> files) throws IOException, RendererException Populates the files map withDocumentRenderers per output name in parameterfilesfor all files in the moduleBasedir matching the module extensions, taking care of duplicates if needed.- Parameters:
siteRootDirectory-siteDirectory-moduleBasedir-module-excludes-files-- Throws:
IOExceptionRendererException
-
checkForDuplicate
private boolean checkForDuplicate(DocumentRenderingContext newDocRenderingContext, Map<String, DocumentRenderer> existingDocumentRenderers, boolean skipDuplicates) throws RendererException Checks if the newDocRenderingContext clashes with an existing document renderer. This check involves checking for duplicates both case-sensitive and case-insensitive.- Parameters:
newDocRenderingContext- the doc rendering context of a new fileexistingDocumentRenderers- the map of already existing renderers- Returns:
trueif no duplicates were found,falseotherwise- Throws:
RendererException
-
checkForDuplicate
private boolean checkForDuplicate(DocumentRenderingContext newDocRenderingContext, Function<String, DocumentRenderer> lookupFunction, DefaultSiteRenderer.DuplicateCallback callback) throws RendererException - Throws:
RendererException
-
render
public void render(Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, File outputDirectory) throws RendererException, 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.IOException- if it bombs.
-
renderDocument
public void renderDocument(Writer writer, DocumentRenderingContext docRenderingContext, SiteRenderingContext siteContext) throws RendererException Render 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, String doxiaContent) throws IOException - Throws:
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 context (may benullin which case the context does not contain document-specific information)siteRenderingContext- 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(Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext) throws RendererException - Throws:
RendererException
-
mergeDocumentIntoSite
public void mergeDocumentIntoSite(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:
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
-
createContextForSkin
public SiteRenderingContext createContextForSkin(org.apache.maven.artifact.Artifact skin, Map<String, ?> attributes, SiteModel siteModel, String defaultTitle, Locale locale) throws IOException, RendererExceptionCreate 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:
IOException- if it bombs.RendererException- if it bombs.
-
matchVersion
- Throws:
RendererException
-
copyResources
public void copyResources(SiteRenderingContext siteRenderingContext, File outputDirectory) throws 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:
IOException- if it bombs.
-
copyFileFromResource
- Throws:
IOException
-
isResourceRelevant
-
createResourceConditionsMap
-
escapeLineBreaksForLogging
-
copyFileFromZip
- Throws:
IOException
-
copyDirectory
Copy the directory- Parameters:
source- source file to be copieddestination- destination file- Throws:
IOException- if any
-
validate
private Reader validate(Reader source, String resource) throws org.apache.maven.doxia.parser.ParseException, IOException - Throws:
org.apache.maven.doxia.parser.ParseExceptionIOException
-
endsWithIgnoreCase
-
getZipFile
- Throws:
IOException
-
closeZipFile
-
getSiteRendererVersion
-