Skip to content
Snippets Groups Projects
Commit e1ea89c6 authored by chbaeh's avatar chbaeh
Browse files

add catalog tracking

parent f1ef81ec
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,8 @@ import matomo
import ckan.logic as logic
from ckan.common import c, request, config
import hashlib
import ckan.plugins.toolkit as toolkit
from ckanext.dcat.controllers import DCATController
abort = base.abort
log = logging.getLogger(__name__)
......@@ -64,7 +66,7 @@ class OdshUserController(UserController):
class OdshPackageController(PackageController):
pass
class MamotoApiController(ApiController):
class OdshApiController(ApiController):
def action(self, logic_function, ver=None):
try:
function = logic.get_action(logic_function)
......@@ -89,6 +91,11 @@ class MamotoApiController(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()
......
......@@ -61,13 +61,27 @@ def odsh_group_id_selected(selected, group_id):
return False
def remove_route(map,routename):
route = None
for i,r in enumerate(map.matchlist):
if r.name == routename:
route = r
break
if route is not None:
map.matchlist.remove(route)
for key in map.maxkeys:
if key == route.maxkeys:
map.maxkeys.pop(key)
map._routenames.pop(route.name)
break
class OdshIcapPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IUploader, inherit=True)
def get_resource_uploader(self, data_dict):
return ODSHResourceUpload(data_dict)
class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm):
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.ITemplateHelpers)
......@@ -128,9 +142,21 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
map.redirect('/dataset/{id}/resource/{resource_id}', '/dataset/{id}')
if p.toolkit.asbool(config.get('ckanext.dcat.enable_rdf_endpoints', True)):
remove_route(map, 'dcat_catalog')
map.connect('dcat_catalog',
config.get('ckanext.dcat.catalog_endpoint', '/catalog.{_format}'),
controller='ckanext.odsh.controller:OdshDCATController', action='read_catalog',
requirements={'_format': 'xml|rdf|n3|ttl|jsonld'})
# with SubMapper(map, controller='ckanext.odsh.controller:OdshApiController') as m:
# m.connect('/catalog2', action='read_catalog')
# /api ver 3 or none with matomo
GET_POST = dict(method=['GET', 'POST'])
with SubMapper(map, controller='ckanext.odsh.controller:MamotoApiController', path_prefix='/api{ver:/3|}', ver='/3') as m:
with SubMapper(map, controller='ckanext.odsh.controller:OdshApiController', path_prefix='/api{ver:/3|}', ver='/3') as m:
m.connect('/action/{logic_function}', action='action', conditions=GET_POST)
with SubMapper(map, controller='ckanext.odsh.controller:OdshFeedController') as m:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment