Merge branch 'master' of https://github.com/rackspace/clouddocs-maven-plugin into writer-experience-improvements

This commit is contained in:
Salman Qureshi
2012-10-31 18:48:12 +05:00
8 changed files with 279 additions and 100 deletions

View File

@@ -93,6 +93,55 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
*/
private String builtForOpenStack;
/**
* Path to an alternative cover logo.
*
* @parameter expression="${generate-pdf.coverLogoPath}" default-value=""
*/
private String coverLogoPath;
/**
* Path to an alternative cover logo.
*
* @parameter expression="${generate-webhelp.secondaryCoverLogoPath}" default-value=""
*/
private String secondaryCoverLogoPath;
/**
* Distance from the left edge of the page at which the
* cover logo is displayed.
*
* @parameter expression="${generate-webhelp.coverLogoLeft}" default-value=""
*/
private String coverLogoLeft;
/**
* Distance from the top of the page at which teh
* cover logo is displayed.
*
* @parameter expression="${generate-webhelp.coverLogoTop}" default-value=""
*/
private String coverLogoTop;
/**
* url to display under the cover logo.
*
* @parameter expression="${generate-webhelp.coverUrl}" default-value=""
*/
private String coverUrl;
/**
* The color to use for the polygon on the cover
*
* @parameter expression="${generate-webhelp.coverColor}" default-value=""
*/
private String coverColor;
/**
* Controls whether output is colorized based on revisionflag attributes.
*
@@ -170,12 +219,20 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
*/
private String pdfUrl;
/*
/**
* If makePdf is set to true then just before creating the Webhelp output this variable will be set
* with the location of the automatically created pdf file.
*/
private String autoPdfUrl;
/**
* A parameter used to control whether the autoPdfUrl is changed
* to end with -latest.pdf instead of being the actual file name.
*
* @parameter expression="${generate-webhelp.useLatestSuffixInPdfUrl}"
*/
private String useLatestSuffixInPdfUrl;
/**
* @parameter
* expression="${generate-webhelp.canonicalUrlBase}"
@@ -297,6 +354,7 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
transformer.setParameter("groupId", docProject.getGroupId());
transformer.setParameter("artifactId", docProject.getArtifactId());
transformer.setParameter("docProjectVersion", docProject.getVersion());
transformer.setParameter("pomProjectName", docProject.getName());
if(glossaryUri != null){
@@ -322,6 +380,13 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
transformer.setParameter("autoPdfUrl", autoPdfUrl);
transformer.setParameter("builtForOpenStack", builtForOpenStack);
transformer.setParameter("coverLogoPath", coverLogoPath);
transformer.setParameter("secondaryCoverLogoPath", secondaryCoverLogoPath);
transformer.setParameter("coverLogoLeft", coverLogoLeft);
transformer.setParameter("coverLogoTop", coverLogoTop);
transformer.setParameter("coverUrl", coverUrl);
transformer.setParameter("coverColor", coverColor);
transformer.setParameter("enable.disqus", enableDisqus);
if (disqusShortname != null) {
transformer.setParameter("disqus.shortname", disqusShortname);
@@ -342,6 +407,9 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
if (pdfUrl != null) {
transformer.setParameter("pdf.url", pdfUrl);
}
if (useLatestSuffixInPdfUrl != null) {
transformer.setParameter("useLatestSuffixInPdfUrl", useLatestSuffixInPdfUrl);
}
if (legalNoticeUrl != null) {
transformer.setParameter("legal.notice.url", legalNoticeUrl);
}
@@ -568,6 +636,7 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
map.put("groupId", docProject.getGroupId());
map.put("artifactId", docProject.getArtifactId());
map.put("docProjectVersion", docProject.getVersion());
map.put("pomProjectName", docProject.getName());
map.put("security", this.security);
map.put("canonicalUrlBase", this.canonicalUrlBase);
map.put("replacementsFile", this.replacementsFile);
@@ -575,6 +644,7 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
map.put("project.build.directory", this.projectBuildDirectory);
map.put("inputSrcFile", inputFilename);
map.put("strictImageValidation", String.valueOf(this.strictImageValidation));
map.put("trim.wadl.uri.count", this.trimWadlUriCount);
// Profiling attrs:
map.put("profile.os", getProperty("profileOs"));
@@ -645,13 +715,12 @@ public abstract class WebHelpMojo extends AbstractWebhelpMojo {
pdfBuilder.setProject(getMavenProject());
pdfBuilder.setSourceDirectory(getSourceDirectory());
pdfBuilder.setAutopdfTargetDirectory(targetDir);
pdfBuilder.setCoverColor("");
pdfBuilder.setCoverLogoPath("");
pdfBuilder.setSecondaryCoverLogoPath("");
pdfBuilder.setCoverLogoLeft("");
pdfBuilder.setCoverLogoTop("");
pdfBuilder.setCoverUrl("");
pdfBuilder.setCoverColor(coverColor);
pdfBuilder.setCoverLogoPath(coverLogoPath);
pdfBuilder.setSecondaryCoverLogoPath(secondaryCoverLogoPath);
pdfBuilder.setCoverLogoLeft(coverLogoLeft);
pdfBuilder.setCoverLogoTop(coverLogoTop);
pdfBuilder.setCoverUrl(coverUrl);
pdfBuilder.setBranding(branding);
pdfBuilder.setSecurity(security);
@@ -694,7 +763,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

@@ -18,6 +18,7 @@ import java.util.HashMap;
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;
@@ -227,6 +228,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;
@@ -241,7 +257,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);
@@ -303,6 +320,12 @@ public class PDFBuilder {
getLog().warn("Failed to get FO basedir", e);
}
// Only set this here! Don't ever set in PdfMojo
transformer.setParameter("autoPdfGlossaryInfix","/..");
if(glossaryUri != null){
transformer.setParameter("glossary.uri", glossaryUri);
}
transformer.setParameter("branding", branding);
if(branding=="openstack") {
@@ -318,6 +341,11 @@ public class PDFBuilder {
transformer.setParameter("coverColor", coverColor);
transformer.setParameter("project.build.directory", projectBuildDirectory);
String sysSecurity=System.getProperty("security");
if(null!=sysSecurity && !sysSecurity.isEmpty()){
security=sysSecurity;
}
if(security != null){
transformer.setParameter("security",security);
}

View File

@@ -388,7 +388,8 @@
<!-- Glossary Setup -->
<xsl:param name="glossary.as.blocks" select="1"/>
<xsl:param name="glossary.collection" select="concat($project.build.directory,'/mvn/com.rackspace.cloud.api/glossary/glossary.xml')"/>
<xsl:param name="autoPdfGlossaryInfix"/>
<xsl:param name="glossary.collection" select="concat($project.build.directory,$autoPdfGlossaryInfix,'/mvn/com.rackspace.cloud.api/glossary/glossary.xml')"/>
<!-- Sets up the Cloud Title Page -->
<xsl:template name="user.pagemasters">
@@ -940,4 +941,22 @@
</fo:block-container>
</xsl:template>
<xsl:template match="d:chapter|d:appendix" mode="insert.title.markup">
<xsl:param name="purpose"/>
<xsl:param name="xrefstyle"/>
<xsl:param name="title"/>
<xsl:choose>
<xsl:when test="$purpose = 'xref'">
<!-- <fo:inline font-style="italic"> -->
<xsl:copy-of select="$title"/>
<!-- </fo:inline> -->
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@@ -8,7 +8,10 @@
<l:gentext key="abstract" text=""/>
<l:context name="title-numbered">
<l:template name="chapter" text="%n. %t"/>
<l:template name="chapter" text='%n. %t'/>
</l:context>
<l:context name="xref-number-and-title">
<l:template name="chapter" text='Chapter %n, “%t”'/>
</l:context>
</l:l10n>
</l:i18n>

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://docbook.org/ns/docbook" xmlns:wadl="http://wadl.dev.java.net/2009/02" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:d="http://docbook.org/ns/docbook" xmlns:rax="http://docs.rackspace.com/api"
exclude-result-prefixes="wadl rax d xhtml" version="2.0">
@@ -571,7 +572,7 @@
TODO: Chop off v2.0 or whatever...
-->
<xsl:choose>
<xsl:when test="$trim.wadl.uri.count &gt; 0">
<xsl:when test="xs:integer($trim.wadl.uri.count) &gt; 0">
<xsl:call-template name="trimUri">
<xsl:with-param name="trimCount" select="$trim.wadl.uri.count"/>
<xsl:with-param name="uri" select="$resource-path-computed"/>

View File

@@ -15,6 +15,7 @@
<xsl:param name="groupId"/>
<xsl:param name="artifactId"/>
<xsl:param name="docProjectVersion"/>
<xsl:param name="pomProjectName"/>
<xsl:param name="security">external</xsl:param>
<xsl:param name="autoPdfUrl"/>
@@ -24,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/>
@@ -36,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>
@@ -47,6 +48,10 @@
<groupid><xsl:value-of select="$groupId"/></groupid>
<artifactid><xsl:value-of select="$artifactId"/></artifactid>
<version><xsl:value-of select="$docProjectVersion"/></version>
<pomname><xsl:choose>
<xsl:when test="normalize-space($pomProjectName) != ''"><xsl:value-of select="$pomProjectName"/>, <xsl:value-of select="$docProjectVersion"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$artifactId"/>, <xsl:value-of select="$docProjectVersion"/></xsl:otherwise>
</xsl:choose></pomname>
</pominfo>
<xsl:for-each-group select="//db:info/raxm:metadata" group-by="f:productnumber(raxm:product,raxm:product/@version)">
<product>
@@ -91,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

@@ -52,6 +52,13 @@
<xsl:param name="use.id.as.filename" select="1"/>
<xsl:param name="branding">not set</xsl:param>
<xsl:param name="autoPdfUrl"></xsl:param>
<xsl:param name="useLatestSuffixInPdfUrl">
<xsl:choose>
<xsl:when test="$branding = 'rackspace'">1</xsl:when>
<xsl:when test="$branding = 'openstack'">0</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="section.autolabel" select="1"/>
<xsl:param name="chapter.autolabel" select="1"/>
<xsl:param name="appendix.autolabel" select="'A'"/>
@@ -173,9 +180,6 @@ set toc,title
<xsl:param name="use.disqus.id">1</xsl:param>
<xsl:param name="glossary.uri">http://docs-beta.rackspace.com/test/jonathan/glossary</xsl:param>
<xsl:param name="glossary.xml.uri"><xsl:value-of select="$glossary.uri"/>/glossary.xml</xsl:param>
<xsl:param name="social.icons">0</xsl:param>
<xsl:param name="legal.notice.url">index.html</xsl:param>
<xsl:include href="../inline.xsl"/>
@@ -231,6 +235,7 @@ ERROR: Feedback email not set but internal comments are enabled.
<xsl:template name="breadcrumbs">
<xsl:param name="home"/>
<xsl:variable name="pubdate"><xsl:if test="/*/d:info/d:pubdate"><xsl:value-of select="concat('-',translate(/*/d:info/d:pubdate,'-',''))"/></xsl:if></xsl:variable>
<p class="breadcrumbs"><a href="{$main.docs.url}"><xsl:value-of select="$brandname"/> Manuals</a> <a><xsl:attribute name="href">
<xsl:call-template name="href.target">
<xsl:with-param name="object" select="$home"/>
@@ -238,8 +243,11 @@ ERROR: Feedback email not set but internal comments are enabled.
</xsl:attribute><xsl:value-of select="normalize-space(//d:title[1])"/><xsl:apply-templates select="/*/d:info/d:releaseinfo[1]" mode="rackspace-title"/></a>
</p>
<xsl:choose>
<xsl:when test="normalize-space($autoPdfUrl) != '' and $useLatestSuffixInPdfUrl = '0'">
<a onclick="_gaq.push(['_trackEvent', 'Header', 'pdfDownload', 'click', 1]);" alt="Download a pdf of this document" class="pdficon" href="{concat(normalize-space(substring($autoPdfUrl,1,string-length($autoPdfUrl) - 3)), $pubdate,'.pdf')}"><img src="{$webhelp.common.dir}images/pdf.png"/></a>
</xsl:when>
<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>