diff --git a/ckanext/semantic_media_wiki/controllers/media_wiki.py b/ckanext/semantic_media_wiki/controllers/media_wiki.py index 5242f77..7b6d2d6 100644 --- a/ckanext/semantic_media_wiki/controllers/media_wiki.py +++ b/ckanext/semantic_media_wiki/controllers/media_wiki.py @@ -144,4 +144,16 @@ def cancel_dataset_plugin_is_enabled(): if Helper.check_plugin_enabled('cancel_dataset_creation'): return True return False + + + def get_smw_link(): + ckan_root_path = toolkit.config.get('ckan.root_path') + if ckan_root_path and 'sfb1368/ckan' in ckan_root_path: + return ['1368', "https://service.tib.eu/sfb1368/wiki/Equipment", None] + + elif ckan_root_path and 'sfb1153/ckan' in ckan_root_path: + return ['1153', "https://service.tib.eu/sfb1153/wiki/Tools", "https://service.tib.eu/sfb1153/wiki/Machines"] + else: + return ['1368', "https://service.tib.eu/sfb1368/wiki/Equipment", None] + diff --git a/ckanext/semantic_media_wiki/plugin.py b/ckanext/semantic_media_wiki/plugin.py index e5e7643..66b6a60 100644 --- a/ckanext/semantic_media_wiki/plugin.py +++ b/ckanext/semantic_media_wiki/plugin.py @@ -68,4 +68,5 @@ def get_blueprint(self): return blueprint def get_helpers(self): - return {'cancel_dataset_is_enabled': MediaWikiController.cancel_dataset_plugin_is_enabled} + return {'cancel_dataset_is_enabled': MediaWikiController.cancel_dataset_plugin_is_enabled, + 'get_smw_link': MediaWikiController.get_smw_link} diff --git a/ckanext/semantic_media_wiki/public/statics/machines.js b/ckanext/semantic_media_wiki/public/statics/machines.js index 558194b..bab314f 100644 --- a/ckanext/semantic_media_wiki/public/statics/machines.js +++ b/ckanext/semantic_media_wiki/public/statics/machines.js @@ -18,15 +18,6 @@ function formatState (state) { }; $(document).ready(function(){ - let cUrl = window.location.pathname; - console.info(cUrl); - if (cUrl.includes('1368/ckan')){ - $('#add_new_machine_btn').attr('href', 'https://service.tib.eu/sfb1368/wiki/Equipment'); - } - else{ - $('#add_new_machine_btn').attr('href', 'https://service.tib.eu/sfb1153/wiki/Equipment'); - } - $("select.machine_dropdown").select2({ formatResult: formatState diff --git a/ckanext/semantic_media_wiki/templates/add_machines.html b/ckanext/semantic_media_wiki/templates/add_machines.html index c2ac560..877b958 100644 --- a/ckanext/semantic_media_wiki/templates/add_machines.html +++ b/ckanext/semantic_media_wiki/templates/add_machines.html @@ -25,9 +25,20 @@