You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2022/04/21 06:51:13 UTC
[maven-fluido-skin] branch master updated: [MSKINS-177] Support Matomo (e.g. Apache Analytics) as macro (#22)
This is an automated email from the ASF dual-hosted git repository.
olamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-fluido-skin.git
The following commit(s) were added to refs/heads/master by this push:
new 9e71264 [MSKINS-177] Support Matomo (e.g. Apache Analytics) as macro (#22)
9e71264 is described below
commit 9e7126450058f6e83a9fdeecb5b5ab13996e826b
Author: Olivier Lamy <ol...@apache.org>
AuthorDate: Thu Apr 21 16:51:09 2022 +1000
[MSKINS-177] Support Matomo (e.g. Apache Analytics) as macro (#22)
[MSKINS-177] Support Matomo (e.g. Apache Analytics) as macro
Signed-off-by: Olivier Lamy <ol...@apache.org>
---
pom.xml | 18 ++++++-
src/it/mskins-177-apache-analytics/pom.xml | 62 ++++++++++++++++++++++
.../src/site/apt/index.apt.vm | 36 +++++++++++++
.../mskins-177-apache-analytics/src/site/site.xml | 54 +++++++++++++++++++
src/it/mskins-177-apache-analytics/verify.groovy | 28 ++++++++++
src/it/mskins-177-matomo-no-options/pom.xml | 62 ++++++++++++++++++++++
.../src/site/apt/index.apt.vm | 36 +++++++++++++
.../mskins-177-matomo-no-options/src/site/site.xml | 48 +++++++++++++++++
src/it/mskins-177-matomo-no-options/verify.groovy | 28 ++++++++++
src/main/resources/META-INF/maven/site-macros.vm | 28 ++++++++++
src/main/resources/META-INF/maven/site.vm | 1 +
src/site/apt/ITs.apt | 2 +
src/site/apt/index.apt.vm | 23 ++++++++
13 files changed, 425 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index aaa8297..6ac9f2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@ under the License.
</parent>
<artifactId>maven-fluido-skin</artifactId>
- <version>1.10.1-SNAPSHOT</version>
+ <version>1.11.0-SNAPSHOT</version>
<name>Apache Maven Fluido Skin</name>
<description>The Apache Maven Fluido Skin is an Apache Maven site skin
@@ -260,6 +260,7 @@ under the License.
<goals>
<goal>site</goal>
</goals>
+ <streamLogsOnFailures>true</streamLogsOnFailures>
</configuration>
<executions>
<execution>
@@ -793,6 +794,21 @@ under the License.
<outputDirectory>${project.build.directory}/site/mskins-161-topbar-fb-recommend-share/</outputDirectory>
</configuration>
</execution>
+ <execution>
+ <id>copy-mskins-177-apache-analytics</id>
+ <phase>site</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <resources>
+ <resource>
+ <directory>${project.build.directory}/it/mskins-177-apache-analytics/target/site/</directory>
+ </resource>
+ </resources>
+ <outputDirectory>${project.build.directory}/site/mskins-177-apache-analytics/</outputDirectory>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
diff --git a/src/it/mskins-177-apache-analytics/pom.xml b/src/it/mskins-177-apache-analytics/pom.xml
new file mode 100644
index 0000000..a737ca0
--- /dev/null
+++ b/src/it/mskins-177-apache-analytics/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-skins</artifactId>
+ <version>@project.parent.version@</version>
+ </parent>
+
+ <groupId>org.apache.maven.skins.its</groupId>
+ <artifactId>mskins-177_apache_analytics</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <skinName>@project.name@</skinName>
+ <skinDescription>@project.description@</skinDescription>
+ <skinGroupId>@project.groupId@</skinGroupId>
+ <skinArtifactId>@project.artifactId@</skinArtifactId>
+ <skinVersion>@project.version@</skinVersion>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>@sitePluginVersion@</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>3.2.2</version>
+ <configuration>
+ <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+</project>
\ No newline at end of file
diff --git a/src/it/mskins-177-apache-analytics/src/site/apt/index.apt.vm b/src/it/mskins-177-apache-analytics/src/site/apt/index.apt.vm
new file mode 100644
index 0000000..32251e5
--- /dev/null
+++ b/src/it/mskins-177-apache-analytics/src/site/apt/index.apt.vm
@@ -0,0 +1,36 @@
+ ------
+ ${project.name}
+ ------
+ Jens Reimann
+ ------
+ 2018-03-23
+ ------
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements. See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership. The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License. You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied. See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+${project.name}
+
+ This is a test for ${skinName} with additional Apache Analytics options.
+ ${skinDescription}
+
+* Actual configuration
+
+%{snippet|id=skin-apache-analytics|file=${project.basedir}/src/site/site.xml}
diff --git a/src/it/mskins-177-apache-analytics/src/site/site.xml b/src/it/mskins-177-apache-analytics/src/site/site.xml
new file mode 100644
index 0000000..33d48b8
--- /dev/null
+++ b/src/it/mskins-177-apache-analytics/src/site/site.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ -->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd"
+ name="${skinName}">
+
+ <skin>
+ <groupId>${skinGroupId}</groupId>
+ <artifactId>${skinArtifactId}</artifactId>
+ <version>${skinVersion}</version>
+ </skin>
+
+ <!-- START SNIPPET: skin-apache-analytics -->
+ <custom>
+ <matomo>
+ <siteId>3</siteId>
+ <url>https://analytics.apache.org</url>
+ <options>
+ <disableCookies/>
+ <trackPageView/>
+ <enableLinkTracking/>
+ <foo>Bar</foo>
+ </options>
+ </matomo>
+ </custom>
+ <!-- END SNIPPET: skin-apache-analytics -->
+
+ <body/>
+
+ <!-- empty one to disable inherited from parent -->
+ <googleAnalyticsAccountId></googleAnalyticsAccountId>
+
+</project>
\ No newline at end of file
diff --git a/src/it/mskins-177-apache-analytics/verify.groovy b/src/it/mskins-177-apache-analytics/verify.groovy
new file mode 100644
index 0000000..e0a6415
--- /dev/null
+++ b/src/it/mskins-177-apache-analytics/verify.groovy
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+File index = new File( basedir, "target/site/index.html" )
+assert index.exists()
+assert index.getText().contains( 'var u=\"https://analytics.apache.org\";')
+assert index.getText().contains( '_paq.push([\'setSiteId\', \'3\']);')
+assert index.getText().contains( '_paq.push([\'setTrackerUrl\', u+\'/matomo.php\']');
+assert index.getText().contains( '_paq.push([\'disableCookies\']);')
+assert index.getText().contains( '_paq.push([\'trackPageView\']);')
+assert index.getText().contains( '_paq.push([\'enableLinkTracking\']);')
+assert index.getText().contains( '_paq.push([\'foo\', \'Bar\']);')
\ No newline at end of file
diff --git a/src/it/mskins-177-matomo-no-options/pom.xml b/src/it/mskins-177-matomo-no-options/pom.xml
new file mode 100644
index 0000000..001fc0c
--- /dev/null
+++ b/src/it/mskins-177-matomo-no-options/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-skins</artifactId>
+ <version>@project.parent.version@</version>
+ </parent>
+
+ <groupId>org.apache.maven.skins.its</groupId>
+ <artifactId>mskins-177_matomo-no-options</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <skinName>@project.name@</skinName>
+ <skinDescription>@project.description@</skinDescription>
+ <skinGroupId>@project.groupId@</skinGroupId>
+ <skinArtifactId>@project.artifactId@</skinArtifactId>
+ <skinVersion>@project.version@</skinVersion>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>@sitePluginVersion@</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>3.2.2</version>
+ <configuration>
+ <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
+</project>
\ No newline at end of file
diff --git a/src/it/mskins-177-matomo-no-options/src/site/apt/index.apt.vm b/src/it/mskins-177-matomo-no-options/src/site/apt/index.apt.vm
new file mode 100644
index 0000000..32251e5
--- /dev/null
+++ b/src/it/mskins-177-matomo-no-options/src/site/apt/index.apt.vm
@@ -0,0 +1,36 @@
+ ------
+ ${project.name}
+ ------
+ Jens Reimann
+ ------
+ 2018-03-23
+ ------
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements. See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership. The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License. You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied. See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+${project.name}
+
+ This is a test for ${skinName} with additional Apache Analytics options.
+ ${skinDescription}
+
+* Actual configuration
+
+%{snippet|id=skin-apache-analytics|file=${project.basedir}/src/site/site.xml}
diff --git a/src/it/mskins-177-matomo-no-options/src/site/site.xml b/src/it/mskins-177-matomo-no-options/src/site/site.xml
new file mode 100644
index 0000000..13c979a
--- /dev/null
+++ b/src/it/mskins-177-matomo-no-options/src/site/site.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ -->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd"
+ name="${skinName}">
+
+ <skin>
+ <groupId>${skinGroupId}</groupId>
+ <artifactId>${skinArtifactId}</artifactId>
+ <version>${skinVersion}</version>
+ </skin>
+
+ <!-- START SNIPPET: skin-apache-analytics -->
+ <custom>
+ <matomo>
+ <siteId>3</siteId>
+ <url>https://analytics.apache.org</url>
+ </matomo>
+ </custom>
+ <!-- END SNIPPET: skin-apache-analytics -->
+
+ <body/>
+
+ <!-- empty one to disable inherited from parent -->
+ <googleAnalyticsAccountId></googleAnalyticsAccountId>
+
+</project>
\ No newline at end of file
diff --git a/src/it/mskins-177-matomo-no-options/verify.groovy b/src/it/mskins-177-matomo-no-options/verify.groovy
new file mode 100644
index 0000000..ae47ac2
--- /dev/null
+++ b/src/it/mskins-177-matomo-no-options/verify.groovy
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+File index = new File( basedir, "target/site/index.html" )
+assert index.exists()
+assert index.getText().contains( 'var u=\"https://analytics.apache.org\";')
+assert index.getText().contains( '_paq.push([\'setSiteId\', \'3\']);')
+assert index.getText().contains( '_paq.push([\'setTrackerUrl\', u+\'/matomo.php\']');
+assert !index.getText().contains( '_paq.push([\'disableCookies\']);')
+assert !index.getText().contains( '_paq.push([\'trackPageView\']);')
+assert !index.getText().contains( '_paq.push([\'enableLinkTracking\']);')
+assert !index.getText().contains( '_paq.push([\'foo\', \'Bar\']);')
\ No newline at end of file
diff --git a/src/main/resources/META-INF/maven/site-macros.vm b/src/main/resources/META-INF/maven/site-macros.vm
index 8dab6f8..cf24948 100644
--- a/src/main/resources/META-INF/maven/site-macros.vm
+++ b/src/main/resources/META-INF/maven/site-macros.vm
@@ -585,6 +585,34 @@ $indent </ul>##
</script>
#**##end
#end
+
+#macro ( matomo $matomoDom )
+#**##if ( $decoration.getCustomValue( 'matomo.url' ) && $decoration.getCustomValue( 'matomo.url' ) != ''
+&& $decoration.getCustomValue( 'matomo.siteId' ) && $decoration.getCustomValue( 'matomo.siteId' ) != '')
+
+ <!-- Matomo -->
+ <script>
+ var _paq = window._paq = window._paq || [];
+ #* *##foreach( $option in $matomoDom.getChild("options").getChildren() )
+ #* *##if( $option.value && $option.value != "" )
+ _paq.push(['$option.name', '$option.value']);
+ #* *##else
+ _paq.push(['$option.name']);
+ #* *##end
+ #* *##end
+
+ (function() {
+ var u="$decoration.getCustomValue( 'matomo.url' )";
+ _paq.push(['setTrackerUrl', u+'/matomo.php']);
+ _paq.push(['setSiteId', '$decoration.getCustomValue( 'matomo.siteId' )']);
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+ g.async=true; g.src=u+'/matomo.js'; s.parentNode.insertBefore(g,s);
+ })();
+ </script>
+ <!-- End Matomo Code -->
+#**##end
+#end
+
##
#macro ( googleSearch $top )
<form id="search-form" action="https://www.google.com/search" method="get" #if ( $top ) class="navbar-search pull-right" #end>
diff --git a/src/main/resources/META-INF/maven/site.vm b/src/main/resources/META-INF/maven/site.vm
index d62435c..5230723 100644
--- a/src/main/resources/META-INF/maven/site.vm
+++ b/src/main/resources/META-INF/maven/site.vm
@@ -52,6 +52,7 @@
#**##end
#**##if( $headContent )$headContent#end
#**##googleAnalytics( $decoration.googleAnalyticsAccountId )
+#**##matomo( $decoration.custom.getChild('matomo') )
#**##flattrHead()
</head>
#**##set ( $topBarEnabled = 'true' == $decoration.getCustomValue( 'fluidoSkin.topBarEnabled' ) )
diff --git a/src/site/apt/ITs.apt b/src/site/apt/ITs.apt
index dd71c24..6f4fb4c 100644
--- a/src/site/apt/ITs.apt
+++ b/src/site/apt/ITs.apt
@@ -32,6 +32,8 @@ Maven Fuido Skin ITs
* {{{./mskins-14/index.html}Search}}
+ * {{{./mskins-177-apache-analytics/index.html}Apache Analytics}}
+
* {{{./mskins-14_sitesearch/index.html}Search (sitesearch)}}
* {{{./mskins-22/index.html}GitHub}}
diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm
index 4f54a59..0195ffe 100644
--- a/src/site/apt/index.apt.vm
+++ b/src/site/apt/index.apt.vm
@@ -166,6 +166,29 @@ Welcome to ${project.name}!
</project>
+-----+
+** Matomo (e.g. Apache Analytics)
+
+ Users can optionally enable <<Matomo>>.
+ How to configure it for Apache Analytics, the <<options>> element will contain some configuration (here some privacy setup):
+
++-----+
+<project name="xxx">
+ [...]
+ <custom>
+ <matomo>
+ <siteId>xxx</siteId>
+ <url>https://analytics.apache.org</url>
+ <options>
+ <disableCookies/>
+ <trackPageView/>
+ <enableLinkTracking/>
+ </options>
+ </matomo>
+ </custom>
+ [...]
+</project>
++-----+
+
** GoogleAnalytics
Users can optionally enable <<Google Analytics>> for the generated site: