mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 10:41:06 +01:00
added google analytics support to plugin backend
This commit is contained in:
@@ -116,6 +116,17 @@ public class BackendConfiguration
|
|||||||
return scannInterval;
|
return scannInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getTrackingCode()
|
||||||
|
{
|
||||||
|
return trackingCode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -195,6 +206,17 @@ public class BackendConfiguration
|
|||||||
this.scannInterval = scannInterval;
|
this.scannInterval = scannInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param trackingCode
|
||||||
|
*/
|
||||||
|
public void setTrackingCode(String trackingCode)
|
||||||
|
{
|
||||||
|
this.trackingCode = trackingCode;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
@@ -211,7 +233,7 @@ public class BackendConfiguration
|
|||||||
private boolean multithreaded = true;
|
private boolean multithreaded = true;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
@XmlElement(name= "news-url")
|
@XmlElement(name = "news-url")
|
||||||
private URL newsUrl;
|
private URL newsUrl;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
@@ -223,4 +245,8 @@ public class BackendConfiguration
|
|||||||
@XmlElement(name = "scann-interval")
|
@XmlElement(name = "scann-interval")
|
||||||
@XmlJavaTypeAdapter(XmlIntervalAdapter.class)
|
@XmlJavaTypeAdapter(XmlIntervalAdapter.class)
|
||||||
private Long scannInterval;
|
private Long scannInterval;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
@XmlElement(name = "tracking-code")
|
||||||
|
private String trackingCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ package sonia.scm.plugin.rest;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import sonia.scm.plugin.BackendConfiguration;
|
||||||
import sonia.scm.plugin.PluginBackend;
|
import sonia.scm.plugin.PluginBackend;
|
||||||
import sonia.scm.plugin.PluginInformation;
|
import sonia.scm.plugin.PluginInformation;
|
||||||
import sonia.scm.plugin.PluginUtil;
|
import sonia.scm.plugin.PluginUtil;
|
||||||
@@ -74,11 +75,13 @@ public class DetailResource extends ViewableResource
|
|||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param backend
|
* @param backend
|
||||||
|
* @param configuration
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public DetailResource(ServletContext context, PluginBackend backend)
|
public DetailResource(ServletContext context, PluginBackend backend,
|
||||||
|
BackendConfiguration configuration)
|
||||||
{
|
{
|
||||||
super(context);
|
super(context, configuration);
|
||||||
this.backend = backend;
|
this.backend = backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,8 +103,8 @@ public class DetailResource extends ViewableResource
|
|||||||
@DefaultValue("false")
|
@DefaultValue("false")
|
||||||
@QueryParam("snapshot") boolean snapshot)
|
@QueryParam("snapshot") boolean snapshot)
|
||||||
{
|
{
|
||||||
List<PluginInformation> pluginVersions = PluginUtil.getFilteredPluginVersions(
|
List<PluginInformation> pluginVersions =
|
||||||
backend, groupId, artifactId);
|
PluginUtil.getFilteredPluginVersions(backend, groupId, artifactId);
|
||||||
|
|
||||||
if (Util.isEmpty(pluginVersions))
|
if (Util.isEmpty(pluginVersions))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ package sonia.scm.plugin.rest;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
import sonia.scm.plugin.BackendConfiguration;
|
||||||
import sonia.scm.plugin.Category;
|
import sonia.scm.plugin.Category;
|
||||||
import sonia.scm.plugin.CategoryNameComaparator;
|
import sonia.scm.plugin.CategoryNameComaparator;
|
||||||
import sonia.scm.plugin.PluginBackend;
|
import sonia.scm.plugin.PluginBackend;
|
||||||
@@ -78,11 +79,13 @@ public class OverviewResource extends ViewableResource
|
|||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param backend
|
* @param backend
|
||||||
|
* @param configuration
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public OverviewResource(ServletContext context, PluginBackend backend)
|
public OverviewResource(ServletContext context, PluginBackend backend,
|
||||||
|
BackendConfiguration configuration)
|
||||||
{
|
{
|
||||||
super(context);
|
super(context, configuration);
|
||||||
this.backend = backend;
|
this.backend = backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
import sonia.scm.plugin.BackendConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -53,11 +54,14 @@ public class ViewableResource
|
|||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public ViewableResource(ServletContext context)
|
public ViewableResource(ServletContext context, BackendConfiguration configuration)
|
||||||
{
|
{
|
||||||
this.contextPath = context.getContextPath();
|
this.contextPath = context.getContextPath();
|
||||||
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BackendConfiguration configuration;
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,6 +77,7 @@ public class ViewableResource
|
|||||||
Map<String, Object> vars = new HashMap<String, Object>();
|
Map<String, Object> vars = new HashMap<String, Object>();
|
||||||
|
|
||||||
vars.put("contextPath", contextPath);
|
vars.put("contextPath", contextPath);
|
||||||
|
vars.put("configuration", configuration);
|
||||||
vars.put("title", title);
|
vars.put("title", title);
|
||||||
|
|
||||||
return vars;
|
return vars;
|
||||||
|
|||||||
@@ -48,6 +48,21 @@
|
|||||||
<script src="${contextPath}template/js/html5.js"></script>
|
<script src="${contextPath}template/js/html5.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<base href="${contextPath}" />
|
<base href="${contextPath}" />
|
||||||
|
<#if configuration.trackingConde??>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var _gaq = _gaq || [];
|
||||||
|
_gaq.push(['_setAccount', '${configuration.trackingCode}']);
|
||||||
|
_gaq.push(['_trackPageview']);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; 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);
|
||||||
|
})();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</#if>
|
||||||
</head>
|
</head>
|
||||||
<body class="home page page-id-8 page-template-default logged-in admin-bar layout-2cr">
|
<body class="home page page-id-8 page-template-default logged-in admin-bar layout-2cr">
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
|
|||||||
Reference in New Issue
Block a user