From 979bd469d62ffb0ad53391a31aa789978ce1d6b8 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 22 Oct 2020 14:02:47 -0700 Subject: integrate goatcounter JS (analytics) --- fatcat_scholar/templates/base.html | 4 ++++ fatcat_scholar/templates/search.html | 5 +++++ fatcat_scholar/templates/search_macros.html | 8 +++++--- settings.toml | 4 ++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/fatcat_scholar/templates/base.html b/fatcat_scholar/templates/base.html index 079b298..6302f6f 100644 --- a/fatcat_scholar/templates/base.html +++ b/fatcat_scholar/templates/base.html @@ -276,6 +276,10 @@ document.getElementById("search_form").onsubmit = function(){ document.getElementById("search_submit_button").classList.add("loading"); }; +{% if settings.ENABLE_GOATCOUNTER -%} + {# for local testing: #} + +{%- endif %} {% block postscript %}{% endblock %} diff --git a/fatcat_scholar/templates/search.html b/fatcat_scholar/templates/search.html index 35ecfa5..86355e2 100644 --- a/fatcat_scholar/templates/search.html +++ b/fatcat_scholar/templates/search.html @@ -9,6 +9,11 @@ {% endif %} {%- endmacro %} +{% block extra_head %} +{# among other things, this prevents query parameters from ending up in goatcounter #} + +{% endblock %} + {% block fullmain %} diff --git a/fatcat_scholar/templates/search_macros.html b/fatcat_scholar/templates/search_macros.html index 57a9011..879f96a 100644 --- a/fatcat_scholar/templates/search_macros.html +++ b/fatcat_scholar/templates/search_macros.html @@ -31,7 +31,7 @@

{% if paper.doc_type == "work" %} - + {% if paper.biblio.title %} {{ paper.biblio.title[:512] }} {% if paper.biblio.title|length > 512 %}...{% endif %} @@ -61,7 +61,9 @@ {% endif %} {% elif paper.doc_type == "sim_page" %} - {% trans page_num = paper.ia_sim.first_page, journal_name = paper.biblio.container_name, volume = paper.biblio.volume, issue = paper.biblio.issue %}Page {{ page_num }} of {{ journal_name }} Vol. {{ volume }}, Issue {{ issue }}{% endtrans %} + + {% trans page_num = paper.ia_sim.first_page, journal_name = paper.biblio.container_name, volume = paper.biblio.volume, issue = paper.biblio.issue %}Page {{ page_num }} of {{ journal_name }} Vol. {{ volume }}, Issue {{ issue }}{% endtrans %} + [{{ _("page") }}] {% endif %} @@ -268,7 +270,7 @@ {% set access_alt = _('fulltext access') %} {% endif %} - + {% if paper.fulltext.thumbnail_url %}
fulltext thumbnail diff --git a/settings.toml b/settings.toml index 50910cf..657e2dc 100644 --- a/settings.toml +++ b/settings.toml @@ -14,6 +14,9 @@ KAFKA_BROKERS = [] FATCAT_API_HOST = "https://api.fatcat.wiki/v0" INDEX_WORKER_BATCH_SIZE = 50 SENTRY_DSN = "" +ENABLE_GOATCOUNTER = 0 +GOATCOUNTER_ENDPOINT = "https://goatcounter.scholar.fatcat.wiki/count" +GOATCOUNTER_SCRIPT_URL = "https://goatcounter.scholar.fatcat.wiki/count.js" [test] SCHOLAR_ENV = "test" @@ -38,3 +41,4 @@ FATCAT_ELASTICSEARCH_BACKEND = "https://search.qa.fatcat.wiki" ELASTICSEARCH_FULLTEXT_INDEX = "scholar_fulltext_v01" ELASTICSEARCH_BACKEND = "http://localhost:9200" KAFKA_BROKERS = ["wbgrp-svc263.us.archive.org"] +ENABLE_GOATCOUNTER = 1 -- cgit v1.2.3