Skip to content
Snippets Groups Projects
Commit d868f8c7 authored by Thorge Petersen's avatar Thorge Petersen
Browse files

Removed unused matomo code

parent 3ce2741d
Branches
Tags
3 merge requests!41Version 2.0.0,!38Merge py3 into dev,!36Removed unused matomo code
......@@ -23,6 +23,5 @@ Die Extension benötigt Konfigurationsparameter in der CKAN-Konfigurationsdatei
| Parameter | Erläuterung | Wert für Entwicklungssysteme |
|---------------------------------------|---------------------------------------------------------------|-------------------------------------------|
| ckanext.odsh.use_matomo | `true` schaltet das matomo-Tracking ein. | `false` |
| ckanext.odsh.skip_icap_virus_check | `false` schaltet den Virus-Check ein. | `true` |
| ckanext.odsh.showtestbanner | `true` schaltet das Banner "Testsystem" ein, Muss `false` für Production-Server sein. | - |
\ No newline at end of file
......@@ -12,7 +12,6 @@ from ckan.controllers.feed import FeedController, ITEMS_LIMIT, _package_search,
import ckan.lib.helpers as h
import ckan.authz as authz
import logging
from . import matomo
import ckan.logic as logic
from ckan.common import c, request, config
import hashlib
......@@ -172,9 +171,9 @@ class OdshApiController(ApiController):
userid = None
if c.user:
userid = hashlib.md5(c.user).hexdigest()[:16]
matomo.create_matomo_request(userid)
else:
matomo.create_matomo_request()
# matomo.create_matomo_request(userid)
#else:
# matomo.create_matomo_request()
except Exception as e:
log.error(e)
......@@ -182,15 +181,8 @@ class OdshApiController(ApiController):
return ApiController.action(self, logic_function, ver)
class OdshDCATController(DCATController):
def read_catalog(self, _format):
matomo.create_matomo_request()
return DCATController.read_catalog(self, _format)
class OdshFeedController(FeedController):
def custom(self):
matomo.create_matomo_request()
extra_fields = ['ext_startdate', 'ext_enddate',
'ext_bbox', 'ext_prev_extent']
q = request.params.get('q', '')
......
......@@ -155,12 +155,6 @@ def odsh_upload_known_formats():
value = toolkit.aslist(value)
return value
def odsh_tracking_id():
return config.get('ckanext.odsh.matomo_id')
def odsh_tracking_url():
return config.get('ckanext.odsh.matomo_url')
def odsh_encodeurl(url):
return urllib.parse.quote(url, safe='')
......
......@@ -50,23 +50,6 @@ def add_pkg_to_collection(id_pkg, id_collection):
}
toolkit.get_action('package_relationship_create')(None, relationship_dict)
def use_matomo():
'''Return the value of the use_matomo config setting.
To enable using matomo, add this line to the
[app:main] section of your CKAN config file::
ckanext.odsh.use_matomo = True
Returns ``False`` by default, if the setting is not in the config file.
:rtype: bool
'''
value = config.get('ckanext.odsh.use_matomo', False)
value = toolkit.asbool(value)
return value
def correct_missing_relationship(pkg_dict, pkg_relationships_from_model):
'''
This function corrects missing relationship in show package.
......
from piwikapi.tracking import PiwikTracker
from piwikapi.tests.request import FakeRequest
from ckan.common import c, request
import ckan.plugins.toolkit as tk
import logging
from ckan.plugins.toolkit import enqueue_job
import ckanext.odsh.helpers_tpsh as helpers_tpsh
def do_if_use_matomo(func):
def wrapper(*args, **kwargs):
use_matomo = helpers_tpsh.use_matomo()
if use_matomo:
return func(*args, **kwargs)
return wrapper
@do_if_use_matomo
def create_matomo_request(userId=None):
headers = {
'HTTP_USER_AGENT': request.headers.get('User-Agent'),
'REMOTE_ADDR': request.headers.get('Host'),
# 'HTTP_REFERER': 'http://referer.com/somewhere/',
'HTTP_ACCEPT_LANGUAGE': request.headers.get('Accept-Language'),
'SERVER_NAME': tk.config.get('ckan.site_url'),
'PATH_INFO': c.environ['PATH_INFO'],
# 'QUERY_STRING': 'something=bar',
'HTTPS': False,
}
fakerequest = FakeRequest(headers)
piwiktracker =PiwikTracker(tk.config.get('ckanext.odsh.matomo_id'), fakerequest)
piwiktracker.set_api_url(tk.config.get('ckanext.odsh.matomo_url'))
if userId:
piwiktracker.set_visitor_id(userId)
# enqueue_job(piwiktracker.do_track_page_view,[request.path_qs], queue='tracking')
......@@ -7,6 +7,7 @@ import os
from routes.mapper import SubMapper
import sys
from collections import OrderedDict
from flask import Blueprint
# imports from ckan
import ckan.lib.helpers as helpers
......@@ -262,20 +263,7 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
map.redirect('/dataset/{id}/resource/{resource_id}', '/dataset/{id}')
if plugins.toolkit.asbool(tk.config.get('ckanext.dcat.enable_rdf_endpoints', True)):
odsh_helpers.odsh_remove_route(map, 'dcat_catalog')
map.connect(
'dcat_catalog',
tk.config.get(
'ckanext.dcat.catalog_endpoint',
'/catalog.{_format}'
),
controller='ckanext.odsh.controller:OdshDCATController',
action='read_catalog',
requirements={'_format': 'xml|rdf|n3|ttl|jsonld'}
)
# /api ver 3 or none with matomo
# /api ver 3
GET_POST = dict(method=['GET', 'POST'])
with SubMapper(
map,
......@@ -360,8 +348,6 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'odsh_extract_value_from_extras': odsh_helpers.odsh_extract_value_from_extras,
'odsh_create_checksum': odsh_helpers.odsh_create_checksum,
'presorted_license_options': odsh_helpers.presorted_license_options,
'odsh_tracking_id': odsh_helpers.odsh_tracking_id,
'odsh_tracking_url': odsh_helpers.odsh_tracking_url,
'odsh_has_more_facets': odsh_helpers.odsh_has_more_facets,
'odsh_public_url': odsh_helpers.odsh_public_url,
'odsh_spatial_extends_available': odsh_helpers.spatial_extends_available,
......@@ -369,7 +355,6 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
'odsh_get_version_id': odsh_helpers.odsh_get_version_id,
'odsh_show_testbanner': odsh_helpers.odsh_show_testbanner,
'odsh_is_slave': odsh_helpers.odsh_is_slave,
'odsh_use_matomo': helpers_tpsh.use_matomo,
'tpsh_get_daterange_prettified': helper_pkg_dict.get_daterange_prettified,
'tpsh_get_language_of_package': helpers_tpsh.get_language_of_package,
'get_language_icon': helpers_tpsh.get_language_icon,
......
......@@ -10,31 +10,8 @@
{% block head_extras %}
{{ super() }}
{% if h.odsh_use_matomo() %}
{% set matomo_url = h.odsh_tracking_url()%}
{% set matomo_id = h.odsh_tracking_id()%}
{% endif %}
<meta data-name="type" content="{{h.odsh_is_slave()}}">
{% if h.odsh_use_matomo() %}
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["setExcludedQueryParams", ["zeile","cms_gtp","cms_range","kurzenachricht","zeig","projekt","datum","nn"]]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://landesportal-sh.dwebanalytics.de/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '3']);
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>
<noscript><p><img src="https://landesportal-sh.dwebanalytics.de/matomo.php?idsite=3&amp;rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->
{% endif %}
{% endblock %}
{% block bodytag %} data-site-root="{{ h.odsh_public_url() }}" data-locale-root="{{ h.odsh_public_url() }}" {% endblock %}
{% block page %}
......
......@@ -10,12 +10,6 @@
<div class="blur-layer"></div>
{% block maintag %}<div role="main">{% endblock %}
{% if h.odsh_use_matomo() %}
{% set matomo_url = h.odsh_tracking_url()%}
{% set matomo_id = h.odsh_tracking_id()%}
<noscript><p><img src="{{matomo_url}}?idsite={{matomo_id}}&rec=1" style="border:0;" alt="" /></p></noscript>
{% endif %}
<div id="content" class="container">
{% if h.odsh_show_testbanner() %}
<div id="testsystem">
......
......@@ -167,19 +167,6 @@ class TestEnv:
profiles.resource_formats()
assert len(profiles._RESOURCE_FORMATS_IMPORT) > 120
def test_matomo(self):
checkConfig('ckanext.odsh.matomo_id', expected='3')
checkConfigUrl('ckanext.odsh.matomo_url',
responseContains='This resource is part of Matomo')
# def test_version(self):
# url = checkConfig('ckan.site_url')
# if url[-1] == '/':
# url = url[:-1]
# version = readUrl(url+'/api/3/action/resource_qv4yAI2rgotamXGk98gJ').strip()
# # version = checkConfig('ckanext.odsh.version')
# assert version == expected_commit, "wrong version: {was}!={exp}".format(was=version, exp=expected_commit)
def test_routes(self):
if isMaster():
return
......
......@@ -87,7 +87,7 @@ setup(
odsh_autocomplete=ckanext.odsh.plugin_odsh_autocomplete:OdshAutocompletePlugin
odsh_harvest=ckanext.odsh.plugin_odsh_harvest:OdshHarvestPlugin
odsh_dcat_harvest=ckanext.odsh.plugin_odsh_dcat_harvest:OdshDCATHarvestPlugin
tpsh_collections=ckanext.odsh.collection.plugin:CollectionsPlugin
odsh_collections=ckanext.odsh.collection.plugin:CollectionsPlugin
thumbnail=ckanext.odsh.pdf_to_thumbnail.plugin:ThumbnailPlugin
[paste.paster_command]
odsh_initialization = ckanext.odsh.commands.initialization:Initialization
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment