This is an automated email from the ASF dual-hosted git repository. paulk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/groovy-geb.git
commit 896704d36477ece4c7b5d45a09f2d6c90d61f8d1 Author: Sergio del Amo <[email protected]> AuthorDate: Wed Feb 12 10:20:04 2025 +0100 reple google analytics with matomo in old manuals --- doc/site/site.gradle | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/doc/site/site.gradle b/doc/site/site.gradle index 071420eb..3852136f 100644 --- a/doc/site/site.gradle +++ b/doc/site/site.gradle @@ -70,6 +70,42 @@ tasks.generateIndex { inputs.files(file("templates/main.html")) } +tasks.register("replaceAnalyticsWithMatomo") { + group = "website" + description = "Replace Google Analytics with Matomo in manuals" + dependsOn("generateResources") + doLast { + File baseDir = file("${project.projectDir}/src/main/resources/public/manual") + baseDir.eachFileRecurse(groovy.io.FileType.FILES) { file -> + if (file.name == 'index.html') { + String html = file.text + String ga = ''' +<script type="text/javascript"> + + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-15031038-2']); + _gaq.push(['_trackPageview', location.pathname + location.hash]); + + window.onhashchange = function() { + _gaq.push(['_trackPageview', location.pathname + location.hash]); + }; + + (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> +''' + String matomo = new File("${project.rootDir}/doc/manual/src/docs/asciidoc/docinfo.html").text + file.text = html.replace(ga, matomo) + // Add your processing logic here + } + } + } +} + tasks.register("placeIndex", Copy) { group = "website" description = "move the generated src/main/resources/index.html to src/main/resources/public/index.html and deletes it from src/main/resources" @@ -90,7 +126,7 @@ tasks.register("copyPublicResources", Copy) { tasks.register("generatePublic") { group = "website" - dependsOn("copyPublicResources", "generateResources", "placeIndex") + dependsOn("copyPublicResources", "generateResources", "placeIndex", "replaceAnalyticsWithMatomo") } processResources.dependsOn("generatePublic") test.dependsOn("generatePublic")
