Update to include PDF link on API site pages

Closes-Bug: #1243631

Change-Id: Ibeacbc2797f66733a89f2453a4036d23c5ed9817
author: diane fleming
This commit is contained in:
Diane Fleming
2014-03-31 10:29:42 -05:00
parent be4b958690
commit c1b994af7b
4 changed files with 24 additions and 30 deletions

View File

@@ -66,13 +66,20 @@ public abstract class ApiRefMojo extends AbstractHtmlMojo {
* default-value="" * default-value=""
*/ */
private String security; private String security;
/**
* Base for the html dir name. By default this is the
* base of the input xml file.
*
* @parameter expression="${generate-webhelp.webhelpDirname}"
*/
private String pdfFilename;
/** /**
* Specifies the branding to use on the page * Specifies the branding to use on the page
* *
* @parameter expression="${generate-html.branding}" default-value="openstack" * @parameter expression="${generate-html.branding}" default-value="openstack"
*/ */
private String branding; private String branding;
protected TransformerBuilder createTransformerBuilder(URIResolver resolver) { protected TransformerBuilder createTransformerBuilder(URIResolver resolver) {
return super.createTransformerBuilder (new DocBookResolver (resolver, getType())); return super.createTransformerBuilder (new DocBookResolver (resolver, getType()));
} }
@@ -109,6 +116,7 @@ public abstract class ApiRefMojo extends AbstractHtmlMojo {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put("security", security); map.put("security", security);
map.put("pdfFilename", pdfFilename);
map.put("branding", branding); map.put("branding", branding);
map.put("canonicalUrlBase", canonicalUrlBase); map.put("canonicalUrlBase", canonicalUrlBase);
map.put("failOnValidationError", failOnValidationError); map.put("failOnValidationError", failOnValidationError);
@@ -116,7 +124,7 @@ public abstract class ApiRefMojo extends AbstractHtmlMojo {
map.put("enableGoogleAnalytics", enableGoogleAnalytics); map.put("enableGoogleAnalytics", enableGoogleAnalytics);
map.put("googleAnalyticsId", googleAnalyticsId); map.put("googleAnalyticsId", googleAnalyticsId);
map.put("googleAnalyticsDomain", googleAnalyticsDomain); map.put("googleAnalyticsDomain", googleAnalyticsDomain);
map.put("targetHtmlContentDir", new File(getTargetDirectory(), "/wadls/")); map.put("targetHtmlContentDir", new File(getTargetDirectory(), "/wadls/"));
return CalabashHelper.createSource(getLog(), source, pathToPipelineFile, map); return CalabashHelper.createSource(getLog(), source, pathToPipelineFile, map);
} }
} }

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -33,6 +33,8 @@
<xsl:param name="googleAnalyticsDomain"/> <xsl:param name="googleAnalyticsDomain"/>
<xsl:param name="enableGoogleAnalytics">0</xsl:param> <xsl:param name="enableGoogleAnalytics">0</xsl:param>
<xsl:param name="branding">openstack</xsl:param> <xsl:param name="branding">openstack</xsl:param>
<xsl:param name="autoPdfUrl">http://api.openstack.org/api-ref-guides/bk-</xsl:param>
<xsl:param name="pdfFilename"/>
<xsl:template match="node() | @*"> <xsl:template match="node() | @*">
<xsl:copy> <xsl:copy>
<xsl:apply-templates select="node() | @*"/> <xsl:apply-templates select="node() | @*"/>
@@ -64,10 +66,10 @@
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<head> <head>
<meta http-equiv="content-type" <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
content="text/html; charset=UTF-8"/> <meta charset="UTF-8"/>
<meta name="viewport" <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
content="width=device-width, initial-scale=1.0"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>OpenStack API Documentation</title> <title>OpenStack API Documentation</title>
<link rel="stylesheet" href="apiref/css/bootstrap.min.css"/> <link rel="stylesheet" href="apiref/css/bootstrap.min.css"/>
<!-- OpenStack Specific CSS --> <!-- OpenStack Specific CSS -->
@@ -166,6 +168,10 @@
title="Go to OpenStack Documentation" title="Go to OpenStack Documentation"
>Documentation</a> >Documentation</a>
</li> </li>
<li><a title="Open the PDF for this page" 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)), $pdfFilename,'.pdf')}">
<xsl:value-of select="translate(d:title,' ','&#160;')"
/>&#160;&#160;&#160;<img src="apiref/images/pdf.png"/>
</a></li>
</ul> </ul>
</div> </div>
</div> </div>
@@ -335,17 +341,18 @@
</li> </li>
</xsl:template> </xsl:template>
<xsl:template match="d:link" mode="menu-toc"> <xsl:template match="d:link" mode="menu-toc">
<!-- show sub-menu items in side nav bar -->
<li> <li>
<a href="{@xlink:href}"> <a href="{@xlink:href}">
<xsl:value-of select="."/> <xsl:value-of select="."/>
</a> </a></li>
</li>
</xsl:template> </xsl:template>
<!-- Do nothing when you see this list - just used to seed the menu --> <!-- Do nothing when you see this list - just used to seed the menu -->
<xsl:template match="d:itemizedlist[@xml:id='service-list']"/> <xsl:template match="d:itemizedlist[@xml:id='service-list']"/>
<xsl:template match="d:section"> <xsl:template match="d:section">
<div id="{@xml:id}"> <div id="{@xml:id}">
<div class="subhead"> <div class="subhead">
<!-- headings for API sections -->
<h3><xsl:value-of select="d:title"/> <h3><xsl:value-of select="d:title"/>
<a class="headerlink" title="Permalink to this headline" href="#{@xml:id}"> <a class="headerlink" title="Permalink to this headline" href="#{@xml:id}">
<span class="glyphicon glyphicon-link"></span> <span class="glyphicon glyphicon-link"></span>
@@ -368,6 +375,7 @@
</li> </li>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<!-- show top menu item in side nav bar -->
<li> <li>
<a href="#{@xml:id}"> <a href="#{@xml:id}">
<xsl:value-of select="translate(d:title,' ','&#160;')" <xsl:value-of select="translate(d:title,' ','&#160;')"
@@ -440,7 +448,6 @@
<!-- process response codes --> <!-- process response codes -->
<xsl:if <xsl:if
test="wadl:response[starts-with(normalize-space(@status),'2') or starts-with(normalize-space(@status),'3')]"> test="wadl:response[starts-with(normalize-space(@status),'2') or starts-with(normalize-space(@status),'3')]">
<!-- Don't output if there are no status codes --> <!-- Don't output if there are no status codes -->
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
@@ -454,7 +461,6 @@
</xsl:if> </xsl:if>
<xsl:if <xsl:if
test="wadl:response[not(starts-with(normalize-space(@status),'2') or starts-with(normalize-space(@status),'3'))]"> test="wadl:response[not(starts-with(normalize-space(@status),'2') or starts-with(normalize-space(@status),'3'))]">
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<b>Error Response Codes</b> <b>Error Response Codes</b>
@@ -491,7 +497,6 @@
</tbody> </tbody>
</table> </table>
</xsl:if> </xsl:if>
<!-- Don't output if there are no params --> <!-- Don't output if there are no params -->
<xsl:if test="./wadl:response//wadl:param"> <xsl:if test="./wadl:response//wadl:param">
<b>Response parameters</b> <b>Response parameters</b>
@@ -564,14 +569,11 @@
select="wadl:response/wadl:representation[ends-with(@mediaType,'/xml') ]/wadl:doc//xsdxt:code"/> select="wadl:response/wadl:representation[ends-with(@mediaType,'/xml') ]/wadl:doc//xsdxt:code"/>
</div> </div>
</div> </div>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:apply-templates select="wadl:response/wadl:representation/wadl:doc//xsdxt:code"/> <xsl:apply-templates select="wadl:response/wadl:representation/wadl:doc//xsdxt:code"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<!-- we allow no response text and we dont have a 200 level response with a representation --> <!-- we allow no response text and we dont have a 200 level response with a representation -->
<xsl:choose> <xsl:choose>
<xsl:when <xsl:when
@@ -585,60 +587,48 @@
<xsl:copy-of select="$wadl.noresponse.msg"/> <xsl:copy-of select="$wadl.noresponse.msg"/>
</xsl:when> </xsl:when>
</xsl:choose> </xsl:choose>
</div> </div>
</div> </div>
</div> </div>
<xsl:text></xsl:text> <xsl:text></xsl:text>
</xsl:template> </xsl:template>
<xsl:template match="wadl:doc|wadl:resource|wadl:link"> <xsl:template match="wadl:doc|wadl:resource|wadl:link">
<xsl:apply-templates/> <xsl:apply-templates/>
</xsl:template> </xsl:template>
<xsl:template match="wadl:doc[parent::wadl:resource]"/> <xsl:template match="wadl:doc[parent::wadl:resource]"/>
<xsl:template match="d:para"> <xsl:template match="d:para">
<p><xsl:apply-templates/></p> <p><xsl:apply-templates/></p>
</xsl:template> </xsl:template>
<xsl:template match="d:link" xmlns:xlink="http://www.w3.org/1999/xlink"> <xsl:template match="d:link" xmlns:xlink="http://www.w3.org/1999/xlink">
<a href="{@xlink:href}"><xsl:apply-templates/></a> <a href="{@xlink:href}"><xsl:apply-templates/></a>
</xsl:template> </xsl:template>
<xsl:template match="d:programlisting"> <xsl:template match="d:programlisting">
<pre><xsl:apply-templates/></pre> <pre><xsl:apply-templates/></pre>
</xsl:template> </xsl:template>
<xsl:template match="d:title[parent::d:chapter or parent::d:section or parent::d:book]|d:info|wadl:param"/> <xsl:template match="d:title[parent::d:chapter or parent::d:section or parent::d:book]|d:info|wadl:param"/>
<xsl:template match="d:example/d:title"> <xsl:template match="d:example/d:title">
<b><xsl:apply-templates/></b> <b><xsl:apply-templates/></b>
</xsl:template> </xsl:template>
<xsl:template match="d:example|xsdxt:code"> <xsl:template match="d:example|xsdxt:code">
<div class="example"> <div class="example">
<xsl:apply-templates/> <xsl:apply-templates/>
</div> </div>
</xsl:template> </xsl:template>
<xsl:template match="d:itemizedlist"> <xsl:template match="d:itemizedlist">
<ul> <ul>
<xsl:apply-templates/> <xsl:apply-templates/>
</ul> </ul>
</xsl:template> </xsl:template>
<xsl:template match="d:orderedlist"> <xsl:template match="d:orderedlist">
<ol> <ol>
<xsl:apply-templates/> <xsl:apply-templates/>
</ol> </ol>
</xsl:template> </xsl:template>
<xsl:template match="d:listitem"> <xsl:template match="d:listitem">
<li> <li>
<xsl:apply-templates/> <xsl:apply-templates/>
</li> </li>
</xsl:template> </xsl:template>
<xsl:template match="wadl:param" mode="param2tr"> <xsl:template match="wadl:param" mode="param2tr">
<tr> <tr>
<td><xsl:value-of select="@name"/><xsl:if test="not(@required = 'true') and not(@style = 'template') and not(@style = 'matrix')"> (Optional)</xsl:if></td> <td><xsl:value-of select="@name"/><xsl:if test="not(@required = 'true') and not(@style = 'template') and not(@style = 'matrix')"> (Optional)</xsl:if></td>
@@ -647,14 +637,12 @@
<td><xsl:apply-templates select="./wadl:doc/*|./wadl:doc/text()"/></td> <td><xsl:apply-templates select="./wadl:doc/*|./wadl:doc/text()"/></td>
</tr> </tr>
</xsl:template> </xsl:template>
<xsl:template match="d:code"><code><xsl:apply-templates/></code></xsl:template> <xsl:template match="d:code"><code><xsl:apply-templates/></code></xsl:template>
<xsl:template match="d:*"> <xsl:template match="d:*">
<xsl:copy> <xsl:copy>
<xsl:apply-templates select="@*|node()"/> <xsl:apply-templates select="@*|node()"/>
</xsl:copy> </xsl:copy>
</xsl:template> </xsl:template>
<xsl:template name="trimUri"> <xsl:template name="trimUri">
<!-- Trims elements --> <!-- Trims elements -->
<xsl:param name="trimCount"/> <xsl:param name="trimCount"/>
@@ -686,7 +674,6 @@
</xsl:call-template> </xsl:call-template>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="wadl:response" mode="preprocess-faults"> <xsl:template match="wadl:response" mode="preprocess-faults">
<xsl:if <xsl:if
test="(not(@status) or not(starts-with(normalize-space(@status),'2') or starts-with(normalize-space(@status),'3')))"> test="(not(@status) or not(starts-with(normalize-space(@status),'2') or starts-with(normalize-space(@status),'3')))">
@@ -728,7 +715,6 @@
</xsl:choose> </xsl:choose>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template name="statusCodeList"> <xsl:template name="statusCodeList">
<xsl:param name="codes" select="'400 500 &#x2026;'"/> <xsl:param name="codes" select="'400 500 &#x2026;'"/>
<xsl:param name="separator" select="','"/> <xsl:param name="separator" select="','"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB