Support Google Analytics params on apiref page

enableGoogleAnalytics (default 1, set to 0 to disable)
googleAnalyticsId (default=UA-17511903-1)
googleAnalyticsDomain (default=.openstack.org)

Change-Id: Ife9b41be47b17acedd9886326d5f09a21f221244
This commit is contained in:
dcramer
2014-01-29 11:45:47 -06:00
committed by Diane Fleming
parent 308e23881d
commit ad669ec756
3 changed files with 39 additions and 7 deletions

View File

@@ -30,13 +30,34 @@ public abstract class ApiRefMojo extends AbstractHtmlMojo {
private String canonicalUrlBase;
/**
*
*
* @parameter
* expression="${generate-html.failOnValidationError}"
* default-value="0"
*/
private String failOnValidationError;
/**
* Specifies the Goggle Analytics Id to use on the page
*
* @parameter expression="${generate-html.enableGoogleAnalytics}" default-value="1"
*/
private String enableGoogleAnalytics;
/**
* Specifies the Goggle Analytics Id to use on the page
*
* @parameter expression="${generate-html.googleAnalyticsId}" default-value="UA-17511903-1"
*/
private String googleAnalyticsId;
/**
* Specifies the Goggle Analytics domain to use on the page
*
* @parameter expression="${generate-html.googleAnalyticsDomain}" default-value=".openstack.org"
*/
private String googleAnalyticsDomain;
/**
* A parameter used to specify the security level (external, internal, reviewer, writeronly) of the document.
*
@@ -85,7 +106,10 @@ public abstract class ApiRefMojo extends AbstractHtmlMojo {
map.put("canonicalUrlBase", canonicalUrlBase);
map.put("failOnValidationError", failOnValidationError);
map.put("project.build.directory", this.projectBuildDirectory);
map.put("enableGoogleAnalytics", enableGoogleAnalytics);
map.put("googleAnalyticsId", googleAnalyticsId);
map.put("googleAnalyticsDomain", googleAnalyticsDomain);
return CalabashHelper.createSource(getLog(), source, pathToPipelineFile, map);
}
}

View File

@@ -25,6 +25,9 @@
<xsl:param name="wadl.norequest.msg"><p class="nobody">This operation does not require a request body.</p></xsl:param>
<xsl:param name="wadl.noresponse.msg"><p class="nobody">This operation does not return a response body.</p></xsl:param>
<xsl:param name="wadl.noreqresp.msg"><p class="nobody">This operation does not require a request body and does not return a response body.</p></xsl:param>
<xsl:param name="googleAnalyticsId"/>
<xsl:param name="googleAnalyticsDomain"/>
<xsl:param name="enableGoogleAnalytics">0</xsl:param>
<xsl:template match="node() | @*">
<xsl:copy>
@@ -118,9 +121,11 @@
<script type="text/javascript" src="apiref/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="apiref/js/bootstrap.min.js"></script>
<script type="text/javascript" src="apiref/js/api-site.js"></script>
<xsl:if test="$enableGoogleAnalytics != '0'">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17511903-8']);
_gaq.push(['_setAccount', '<xsl:value-of select="$googleAnalyticsId"/>']);
_gaq.push(['_setDomainName', '<xsl:value-of select="$googleAnalyticsDomain"/>']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script');
@@ -128,9 +133,10 @@
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
s.parentNode.insertBefore(ga, s);\
})();
</script>
</xsl:if>
</body>
</html>
</xsl:template>

View File

@@ -46,7 +46,9 @@
<p:input port="stylesheet">
<p:document href="classpath:///cloud/apipage/process-embedded-wadl-apipage.xsl"/>
</p:input>
<p:with-param name="project.build.directory" select="//c:param[@name = 'project.build.directory']/@value"/>
<p:input port="parameters" >
<p:pipe step="main" port="parameters"/>
</p:input>
</p:xslt>
<!-- <l:xhtml2docbook name="xhtml2docbook"/> -->
@@ -63,7 +65,7 @@
<p:document href="classpath:///cloud/apipage/apipage-main.xsl"/>
</p:input>
<p:input port="parameters" >
<p:empty/>
<p:pipe step="main" port="parameters"/>
</p:input>
</p:xslt>