Browse Source

add matomo, slim down a few lines

max.mehl 3 months ago
parent
commit
0bc20b77b3
No account linked to committer's email address

+ 1
- 0
.gitignore View File

@@ -1,2 +1,3 @@
1 1
 resources/
2 2
 public/
3
+static/proxy.php

+ 14
- 0
layouts/partials/matomo.html View File

@@ -0,0 +1,14 @@
1
+<!-- Piwik -->
2
+<script type="text/javascript">
3
+  var _paq = _paq || [];
4
+  _paq.push(['trackPageView']);
5
+  _paq.push(['enableLinkTracking']);
6
+  (function() {
7
+    var u="//mehl.mx/";
8
+    _paq.push(["setTrackerUrl", u+"piwik.php"]);
9
+    _paq.push(["setSiteId", "9"]);
10
+    var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0];
11
+    g.type="text/javascript"; g.async=true; g.defer=true; g.src=u+"piwik.php"; s.parentNode.insertBefore(g,s);
12
+  })();
13
+</script>
14
+<!-- End Piwik Code -->

+ 36
- 0
static/matomo-proxy.php View File

@@ -0,0 +1,36 @@
1
+<?php
2
+
3
+define('MATOMO_PROXY_FROM_ENDPOINT', 1);
4
+
5
+$path = 'index.php';
6
+
7
+$SUPPORTED_METHODS = [
8
+    'CoreAdminHome.optOut'
9
+];
10
+$VALID_FILES = [
11
+    'plugins/CoreAdminHome/javascripts/optOut.js'
12
+];
13
+
14
+$module = isset($_GET['module']) ? $_GET['module'] : null;
15
+if (empty($module)) {
16
+    $module = isset($_POST['module']) ? $_POST['module'] : null;
17
+}
18
+
19
+$action = isset($_GET['action']) ? $_GET['action'] : null;
20
+if (empty($action)) {
21
+    $action = isset($_POST['action']) ? $_POST['action'] : null;
22
+}
23
+
24
+$filerequest = isset($_GET['file']) ? $_GET['file'] : null;
25
+if (empty($filerequest)) {
26
+    $filerequest = isset($_POST['file']) ? $_POST['file'] : null;
27
+}
28
+
29
+if (!(isset($filerequest) && in_array($filerequest, $VALID_FILES))
30
+    && !(isset($module) && isset($action) && in_array("$module.$action", $SUPPORTED_METHODS))
31
+) {
32
+    http_response_code(404);
33
+    exit;
34
+}
35
+
36
+include dirname(__FILE__) . '/proxy.php';

+ 14
- 0
static/piwik.php View File

@@ -0,0 +1,14 @@
1
+<?php
2
+/**
3
+ * Piwik - free/libre analytics platform
4
+ * Piwik Proxy Hide URL
5
+ *
6
+ * @link http://piwik.org/faq/how-to/#faq_132
7
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8
+ */
9
+
10
+define('MATOMO_PROXY_FROM_ENDPOINT', 1);
11
+
12
+$path = "piwik.php";
13
+
14
+include dirname(__FILE__) . '/proxy.php';

+ 6
- 0
themes/hugo-sustain/layouts/_default/single.html View File

@@ -56,6 +56,12 @@
56 56
 
57 57
     <!-- Footer -->
58 58
     {{ partial "footer" . }}
59
+
60
+    <!-- JS -->
61
+    {{ partial "js" . }}
62
+
63
+    <!-- Matomo -->
64
+    {{ partial "matomo" . }}
59 65
     
60 66
   </body>
61 67
 </html>

+ 0
- 2
themes/hugo-sustain/layouts/partials/footer.html View File

@@ -6,5 +6,3 @@
6 6
   </div>
7 7
 </footer>
8 8
 <div class="footer"></div>
9
-
10
-{{ partial "js" . }}

+ 16
- 17
themes/hugo-sustain/layouts/partials/social.html View File

@@ -1,36 +1,35 @@
1 1
 <div class="social">
2 2
   <ul class="social-links">
3
-
4
-    {{ with .Site.Params.Social.Email }}
5
-      <li><a href="{{ . }}" title="Email"><i class="fa fa-envelope"></i></a></li>
3
+    {{- with .Site.Params.Social.Email -}}
4
+      <li><a href="{{- . -}}" title="Email"><i class="fa fa-envelope"></i></a></li>
6 5
     {{ end }}
7 6
 
8
-    {{ with .Site.Params.Social.Mastodon }}
9
-      <li><a href="https://{{ . }}" title="Mastodon"><i class="fab fa-mastodon"></i></a></li>
7
+    {{- with .Site.Params.Social.Mastodon -}}
8
+      <li><a href="https://{{- . -}}" title="Mastodon"><i class="fab fa-mastodon"></i></a></li>
10 9
     {{ end }}
11 10
 
12
-    {{ with .Site.Params.Social.Twitter }}
13
-      <li><a href="https://twitter.com/{{ . }}" title="Twitter"><i class="fab fa-twitter"></i></a></li>
11
+    {{- with .Site.Params.Social.Twitter -}}
12
+      <li><a href="https://twitter.com/{{- . -}}" title="Twitter"><i class="fab fa-twitter"></i></a></li>
14 13
     {{ end }}
15 14
 
16
-    {{ with .Site.Params.Social.Diaspora }}
17
-      <li><a href="https://{{ . }}" title="Diaspora"><i class="fab fa-diaspora"></i></a></li>
15
+    {{- with .Site.Params.Social.Diaspora -}}
16
+      <li><a href="https://{{- . -}}" title="Diaspora"><i class="fab fa-diaspora"></i></a></li>
18 17
     {{ end }}
19 18
 
20
-    {{ with .Site.Params.Social.Stackoverflow }}
21
-      <li><a href="https://stackoverflow.com/{{ . }}" title="Stackoverflow"><i class="fab fa-stack-overflow"></i></a></li>
19
+    {{- with .Site.Params.Social.Stackoverflow -}}
20
+      <li><a href="https://stackoverflow.com/{{- . -}}" title="Stackoverflow"><i class="fab fa-stack-overflow"></i></a></li>
22 21
     {{ end }}
23 22
 
24
-    {{ with .Site.Params.Social.Git }}
25
-      <li><a href="{{ . }}" title="Git"><i class="fab fa-git"></i></a></li>
23
+    {{- with .Site.Params.Social.Git -}}
24
+      <li><a href="{{- . -}}" title="Git"><i class="fab fa-git"></i></a></li>
26 25
     {{ end }}
27 26
 
28
-    {{ with .Site.Params.Social.Github }}
29
-      <li><a href="https://github.com/{{ . }}" title="Github"><i class="fab fa-github"></i></a></li>
27
+    {{- with .Site.Params.Social.Github -}}
28
+      <li><a href="https://github.com/{{- . -}}" title="Github"><i class="fab fa-github"></i></a></li>
30 29
     {{ end }}
31 30
 
32
-    {{ with .Site.Params.Social.LinkedIn }}
33
-      <li><a href="https://linkedin.com/in/{{ . }}" title="LinkedIn"><i class="fab fa-linkedin"></i></a></li>
31
+    {{- with .Site.Params.Social.LinkedIn -}}
32
+      <li><a href="https://linkedin.com/in/{{- . -}}" title="LinkedIn"><i class="fab fa-linkedin"></i></a></li>
34 33
     {{ end }}
35 34
   </ul>
36 35
 </div>

Loading…
Cancel
Save