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:
@@ -30,13 +30,34 @@ public abstract class ApiRefMojo extends AbstractHtmlMojo {
|
|||||||
private String canonicalUrlBase;
|
private String canonicalUrlBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @parameter
|
* @parameter
|
||||||
* expression="${generate-html.failOnValidationError}"
|
* expression="${generate-html.failOnValidationError}"
|
||||||
* default-value="0"
|
* default-value="0"
|
||||||
*/
|
*/
|
||||||
private String failOnValidationError;
|
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.
|
* 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("canonicalUrlBase", canonicalUrlBase);
|
||||||
map.put("failOnValidationError", failOnValidationError);
|
map.put("failOnValidationError", failOnValidationError);
|
||||||
map.put("project.build.directory", this.projectBuildDirectory);
|
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);
|
return CalabashHelper.createSource(getLog(), source, pathToPipelineFile, map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.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.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="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:template match="node() | @*">
|
||||||
<xsl:copy>
|
<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/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/bootstrap.min.js"></script>
|
||||||
<script type="text/javascript" src="apiref/js/api-site.js"></script>
|
<script type="text/javascript" src="apiref/js/api-site.js"></script>
|
||||||
|
<xsl:if test="$enableGoogleAnalytics != '0'">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var _gaq = _gaq || [];
|
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']);
|
_gaq.push(['_trackPageview']);
|
||||||
(function () {
|
(function () {
|
||||||
var ga = document.createElement('script');
|
var ga = document.createElement('script');
|
||||||
@@ -128,9 +133,10 @@
|
|||||||
ga.async = true;
|
ga.async = true;
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||||
var s = document.getElementsByTagName('script')[0];
|
var s = document.getElementsByTagName('script')[0];
|
||||||
s.parentNode.insertBefore(ga, s);
|
s.parentNode.insertBefore(ga, s);\
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
</xsl:if>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|||||||
@@ -46,7 +46,9 @@
|
|||||||
<p:input port="stylesheet">
|
<p:input port="stylesheet">
|
||||||
<p:document href="classpath:///cloud/apipage/process-embedded-wadl-apipage.xsl"/>
|
<p:document href="classpath:///cloud/apipage/process-embedded-wadl-apipage.xsl"/>
|
||||||
</p:input>
|
</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>
|
</p:xslt>
|
||||||
|
|
||||||
<!-- <l:xhtml2docbook name="xhtml2docbook"/> -->
|
<!-- <l:xhtml2docbook name="xhtml2docbook"/> -->
|
||||||
@@ -63,7 +65,7 @@
|
|||||||
<p:document href="classpath:///cloud/apipage/apipage-main.xsl"/>
|
<p:document href="classpath:///cloud/apipage/apipage-main.xsl"/>
|
||||||
</p:input>
|
</p:input>
|
||||||
<p:input port="parameters" >
|
<p:input port="parameters" >
|
||||||
<p:empty/>
|
<p:pipe step="main" port="parameters"/>
|
||||||
</p:input>
|
</p:input>
|
||||||
</p:xslt>
|
</p:xslt>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user