diff --git a/README.md b/README.md index 3e20b46d5b2c9e7b7153e2af6c9bcad183335306..39eb07c8e0d5d0bc2d8ef27cade7df06b79ee2ae 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ckanext/odsh/controller.py b/ckanext/odsh/controller.py index ac63f954139113975a7073197188ea44bbcaab3b..4c37023cd7bd3739e2c36e8beb73a7d567a95d7a 100644 --- a/ckanext/odsh/controller.py +++ b/ckanext/odsh/controller.py @@ -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', '') diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index ff6bcd3c1a7f73c54523138ca9e65e393eb89efc..4ef5d8fef1a5e972cc9ed7cd08011036014f2e53 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -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='') diff --git a/ckanext/odsh/helpers_tpsh.py b/ckanext/odsh/helpers_tpsh.py index 38bae6f1dcc8d8986518d0fc2f1cafc556aaeae3..c70ce0f3b6a1df64e8e41189130e141383967a4a 100644 --- a/ckanext/odsh/helpers_tpsh.py +++ b/ckanext/odsh/helpers_tpsh.py @@ -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. diff --git a/ckanext/odsh/matomo.py b/ckanext/odsh/matomo.py deleted file mode 100644 index 710099ac2abdc83b66656f0c8c300b7fe2b6c342..0000000000000000000000000000000000000000 --- a/ckanext/odsh/matomo.py +++ /dev/null @@ -1,33 +0,0 @@ -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') diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index 0ee35bf262e896f7816b7caa6748ee7ec9aebbf6..94d7ec5f7a96bd31eb4e8a6d9e2bee1a205c1831 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -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 @@ -260,22 +261,9 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm action='start' ) - 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 + map.redirect('/dataset/{id}/resource/{resource_id}', '/dataset/{id}') + + # /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, diff --git a/ckanext/odsh/templates/base.html b/ckanext/odsh/templates/base.html index fc19aedb7f8eb4a5705c54971a091cb446d64d96..5e2a2ac29dff6458256ebdfad63f216a772b6952 100644 --- a/ckanext/odsh/templates/base.html +++ b/ckanext/odsh/templates/base.html @@ -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&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 %} diff --git a/ckanext/odsh/templates/page.html b/ckanext/odsh/templates/page.html index 134079dd6ced8e52b3e01a7eec0fcef0a3db1a22..3285be966916081d563ecfe09f97ccfd73e9dcbf 100644 --- a/ckanext/odsh/templates/page.html +++ b/ckanext/odsh/templates/page.html @@ -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"> diff --git a/ckanext/odsh/tests/test_env.py b/ckanext/odsh/tests/test_env.py index 39144f5c4fdb936546285f0cf4a8660694a63a45..3162b25fe050dcd0decd86ed6fc94267ff7c5937 100644 --- a/ckanext/odsh/tests/test_env.py +++ b/ckanext/odsh/tests/test_env.py @@ -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 diff --git a/setup.py b/setup.py index 56287f08b92df2409200a83f764ab61a294c50df..4c717d157017d59b2cfb090ff2e9ad384244e5e5 100755 --- a/setup.py +++ b/setup.py @@ -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