Write out the pdf file with the date from <pubdate>

and adjust the pdf url and bookinfo accordingly.
This commit is contained in:
dcramer
2012-10-25 13:30:30 -05:00
parent a22ac020b5
commit 4078a136c6
5 changed files with 144 additions and 81 deletions

View File

@@ -683,7 +683,7 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
getLog().error("Unable to move auto-generated PDF file to Webhelp target directory!");
}
}
autoPdfUrl = "../"+pdfFile.getName();
autoPdfUrl = "../"+foFile.getName();
getLog().info("************************************* END: Automatically generating PDF for WEBHELP *************************************\n");
}

View File

@@ -17,6 +17,7 @@ import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.servlet.jsp.el.ELException;
import javax.servlet.jsp.el.VariableResolver;
@@ -214,6 +215,21 @@ public class PDFBuilder {
// First transform the cover page
transformCover();
// Get properties file from webhelp war
String warBasename = result.getName().substring(0, result.getName().lastIndexOf('.'));
Properties properties = new Properties();
InputStream is = null;
try {
File f = new File(projectBuildDirectory + "/autopdf/pdf.properties");
is = new FileInputStream( f );
properties.load(is);
}
catch ( Exception e ) {
System.out.println("Got an Exception: " + e.getMessage());
}
// FOUserAgent can be used to set PDF metadata
Configuration configuration = loadFOPConfig();
InputStream in = null;
@@ -228,7 +244,8 @@ public class PDFBuilder {
getLog().info("Absolute path is "+baseURL);
in = new FileInputStream(result);
targetPdfFile = new File (result.getAbsolutePath().replaceAll(".fo$","-latest.pdf"));
targetPdfFile = new File (result.getAbsolutePath().replaceAll(".fo$", properties.getProperty("pdfsuffix","") + ".pdf"));
out = new FileOutputStream(targetPdfFile);
fopFactory.setUserConfig(configuration);
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out);

View File

@@ -25,9 +25,9 @@
<xsl:variable name="warprefix"><xsl:if test="/*/db:info/raxm:metadata/raxm:product and /*/db:info/raxm:metadata/raxm:product/@version"><xsl:value-of select="translate(translate(concat(/*/db:info/raxm:metadata/raxm:product,'-',/*/db:info/raxm:metadata/raxm:product/@version,'-'),' ','_'),' ','')"/></xsl:if></xsl:variable>
<xsl:variable name="warsuffix"><xsl:if test="not($security = 'external')">-<xsl:value-of select="normalize-space($security)"/></xsl:if></xsl:variable>
<xsl:variable name="pdfsuffix"><xsl:if test="/*/db:info/db:pubdate">-<xsl:value-of select="translate(/*/db:info/db:pubdate,'-','')"/></xsl:if></xsl:variable>
<xsl:template match="/">
<xsl:processing-instruction name="rax-warinfo"><xsl:value-of select="concat($warprefix,$input.filename,$warsuffix)"/></xsl:processing-instruction>
<xsl:apply-templates/>
@@ -37,7 +37,7 @@
method="xml" indent="yes" encoding="UTF-8">
<products xmlns="">
<latestpdf><xsl:choose>
<xsl:when test="normalize-space($autoPdfUrl) != ''"><xsl:value-of select="substring-after($autoPdfUrl,'../')"/></xsl:when><xsl:otherwise><xsl:value-of select="$input.filename"/>.pdf</xsl:otherwise></xsl:choose></latestpdf>
<xsl:when test="normalize-space($autoPdfUrl) != ''"><xsl:value-of select="substring($autoPdfUrl,4,string-length($autoPdfUrl) - 6)"/>-latest.pdf</xsl:when><xsl:otherwise><xsl:value-of select="$input.filename"/>.pdf</xsl:otherwise></xsl:choose></latestpdf>
<pdfoutname><xsl:choose><xsl:when test="/*/db:info/db:pubdate"><xsl:value-of select="concat($input.filename,'-',translate(/*/db:info/db:pubdate,'-',''),'.pdf')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="concat($input.filename,'.pdf')"/></xsl:otherwise>
</xsl:choose></pdfoutname>
@@ -96,6 +96,7 @@
<c:result xmlns:c="http://www.w3.org/ns/xproc-step">
warprefix=<xsl:value-of select="$warprefix"/>
warsuffix=<xsl:value-of select="$warsuffix"/>
pdfsuffix=<xsl:value-of select="$pdfsuffix"/>
product=<xsl:value-of select="/*/db:info/db:productname"/>
version=<xsl:value-of select="/*/db:info/db:releaseinfo"/>
buildtime=<xsl:value-of select="format-dateTime(current-dateTime(),'[Y]-[M,2]-[D,2] [H]:[m]:[s]')"/>

View File

@@ -239,7 +239,7 @@ ERROR: Feedback email not set but internal comments are enabled.
</p>
<xsl:choose>
<xsl:when test="normalize-space($autoPdfUrl) != ''">
<a onclick="_gaq.push(['_trackEvent', 'Header', 'pdfDownload', 'click', 1]);" alt="Download a pdf of this document" class="pdficon" href="{normalize-space($autoPdfUrl)}"><img src="{$webhelp.common.dir}images/pdf.png"/></a>
<a onclick="_gaq.push(['_trackEvent', 'Header', 'pdfDownload', 'click', 1]);" alt="Download a pdf of this document" class="pdficon" href="{normalize-space(substring($autoPdfUrl,1,string-length($autoPdfUrl) - 3))}-latest.pdf"><img src="{$webhelp.common.dir}images/pdf.png"/></a>
</xsl:when>
<xsl:when test="normalize-space($pdf.url) != '' and not(normalize-space($autoPdfUrl) != '')">
<a onclick="_gaq.push(['_trackEvent', 'Header', 'pdfDownload', 'click', 1]);" alt="Download a pdf of this document" class="pdficon" href="{normalize-space($pdf.url)}"><img src="{$webhelp.common.dir}images/pdf.png"/></a>

View File

@@ -3,29 +3,74 @@
<p:declare-step version="1.0" xmlns:p="http://www.w3.org/ns/xproc"
xmlns:l="http://xproc.org/library"
xmlns:db="http://docbook.org/ns/docbook"
xmlns:ut="http://grtjn.nl/ns/xproc/util"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:cx="http://xmlcalabash.com/ns/extensions" name="main">
<p:input port="source"/>
<p:input port="parameters" kind="parameter"/>
<p:output port="result"/>
<p:import href="classpath:/rackspace-library.xpl"/><!-- classpath:/ -->
<p:import href="http://xmlcalabash.com/extension/steps/library-1.0.xpl"/>
<p:input port="source"/>
<p:output port="result"/>
<cx:message>
<p:with-option name="message" select="'Entering xproc pipeline'"/>
</cx:message>
<p:input port="parameters" kind="parameter"/>
<ut:parameters name="params"/>
<p:sink/>
<cx:message>
<p:with-option name="message" select="'Validating DocBook version'"/>
</cx:message>
<p:group name="group">
<p:output port="result" primary="true">
<p:pipe step="validate-post-wadl-idrefs" port="result"/>
</p:output>
<p:output port="secondary" primary="false" sequence="true"/>
<p:variable name="project.build.directory" select="//c:param[@name = 'project.build.directory']/@value">
<p:pipe step="params" port="parameters"/>
</p:variable>
<!-- <cx:message name="msg1"> -->
<!-- <p:with-option name="message" select="'Entering xproc pipeline'"/> -->
<!-- </cx:message> -->
<!-- <cx:message name="msg2"> -->
<!-- <p:with-option name="message" select="'Validating DocBook version'"/> -->
<!-- </cx:message> -->
<l:validate-docbook-format>
<p:input port="source">
<p:pipe step="main" port="source"/>
</p:input>
<p:with-option name="docbookNamespace" select="'http://docbook.org/ns/docbook'"/>
</l:validate-docbook-format>
<p:add-xml-base/>
<p:xslt name="pdfprops">
<p:input port="source">
<p:pipe step="main" port="source"/>
</p:input>
<p:input port="stylesheet">
<p:inline>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<c:result xmlns:c="http://www.w3.org/ns/xproc-step">
pdfsuffix=<xsl:if test="/*/db:info/db:pubdate">-<xsl:value-of select="translate(/*/db:info/db:pubdate,'-','')"/></xsl:if>
</c:result>
</xsl:template>
</xsl:stylesheet>
</p:inline>
</p:input>
<p:input port="parameters" >
<p:pipe step="main" port="parameters"/>
</p:input>
</p:xslt>
<p:store name="store" encoding="utf-8" method="text" media-type="text">
<p:with-option name="href" select="concat('file://',$project.build.directory,'/docbkx/autopdf/pdf.properties')"/>
</p:store>
<p:add-xml-base>
<p:input port="source">
<p:pipe step="main" port="source"/>
</p:input>
</p:add-xml-base>
<p:xinclude fixup-xml-base="true"/>
@@ -41,12 +86,12 @@
</p:input>
</l:validate-transform>
<cx:message>
<cx:message name="msg3">
<p:with-option name="message" select="'Validating images'"/>
</cx:message>
<l:validate-images/>
<cx:message>
<cx:message name="msg4">
<p:with-option name="message" select="'Performing programlisting keep together'"/>
</cx:message>
@@ -55,18 +100,18 @@
<p:delete match="//db:imageobject[@role='html']"/>
<p:delete match="//db:imageobject/@role[. ='fo']"/>
<cx:message>
<cx:message name="msg5">
<p:with-option name="message" select="'Adding extension info'"/>
</cx:message>
<l:extensions-info/>
<cx:message>
<cx:message name="msg6">
<p:with-option name="message" select="'Making replacements'"/>
</cx:message>
<l:search-and-replace/>
<cx:message>
<cx:message name="msg7">
<p:with-option name="message" select="'Normalize wadls'"/>
</cx:message>
@@ -82,6 +127,6 @@
</p:input>
</l:validate-transform-idrefs>
<!-- <p:identity/>-->
</p:group>
</p:declare-step>