From 1e9cba4315f4afa3b5230096c6c333d3682d84b9 Mon Sep 17 00:00:00 2001 From: Bridget Almas Date: Tue, 6 Jan 2015 14:46:20 -0500 Subject: [PATCH 1/2] Rudimentary implementation of provenance display eventually we probably want to move this plus the editors implementation to its own plugin, arethusa.provenance or something like that --- .../arethusa.core/directives/arethusa_tool.js | 17 +++++++++++++++++ app/js/arethusa.core/directives/prov_tools.js | 15 +++++++++++++++ app/js/arethusa.core/prov_tools.js | 19 +++++++++++++++++++ app/js/arethusa.core/tool.js | 9 +++++++++ .../arethusa.core/arethusa_tool.html | 1 + app/templates/arethusa.core/prov_tools.html | 12 ++++++++++++ dist/i18n/de.json | 2 ++ dist/i18n/en.json | 4 ++++ dist/i18n/fr.json | 6 +++++- 9 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 app/js/arethusa.core/directives/arethusa_tool.js create mode 100644 app/js/arethusa.core/directives/prov_tools.js create mode 100644 app/js/arethusa.core/prov_tools.js create mode 100644 app/js/arethusa.core/tool.js create mode 100644 app/templates/arethusa.core/arethusa_tool.html create mode 100644 app/templates/arethusa.core/prov_tools.html diff --git a/app/js/arethusa.core/directives/arethusa_tool.js b/app/js/arethusa.core/directives/arethusa_tool.js new file mode 100644 index 000000000..3a4fec4e6 --- /dev/null +++ b/app/js/arethusa.core/directives/arethusa_tool.js @@ -0,0 +1,17 @@ +"use strict"; + +angular.module('arethusa.core').directive('arethusaTool', [ + function() { + return { + restrict: 'A', + scope: { + tool: '=arethusaTool', + }, + link: function(scope, element, attrs) { + var tool = scope.tool; + scope.uri = tool.uri; + }, + templateUrl: 'templates/arethusa.core/arethusa_tool.html' + }; + } +]); diff --git a/app/js/arethusa.core/directives/prov_tools.js b/app/js/arethusa.core/directives/prov_tools.js new file mode 100644 index 000000000..c0ec968da --- /dev/null +++ b/app/js/arethusa.core/directives/prov_tools.js @@ -0,0 +1,15 @@ +"use strict"; + +angular.module('arethusa.core').directive('provTools', [ + 'provTools', + function(provTools) { + return { + restrict: 'A', + scope: {}, + link: function(scope, element, attrs) { + scope.provTools = provTools; + }, + templateUrl: 'templates/arethusa.core/prov_tools.html' + }; + } +]); diff --git a/app/js/arethusa.core/prov_tools.js b/app/js/arethusa.core/prov_tools.js new file mode 100644 index 000000000..c6d013e25 --- /dev/null +++ b/app/js/arethusa.core/prov_tools.js @@ -0,0 +1,19 @@ +"use strict"; + +angular.module('arethusa.core').service('provTools', [ + 'Tool', + function(Tool) { + var self = this; + + this.perDocument = {}; + + this.addTool = function(docId, tool) { + var doc = self.perDocument[docId]; + if (!doc) doc = self.perDocument[docId] = []; + doc.push(new Tool(tool)); + self.toolsPresent = true; + }; + + this.toolsPresent = false; + } +]); diff --git a/app/js/arethusa.core/tool.js b/app/js/arethusa.core/tool.js new file mode 100644 index 000000000..f8b7390a4 --- /dev/null +++ b/app/js/arethusa.core/tool.js @@ -0,0 +1,9 @@ +"use strict"; + +angular.module('arethusa.core').factory('Tool', [ + function() { + return function(args) { + this.uri = args.uri; + }; + } +]); diff --git a/app/templates/arethusa.core/arethusa_tool.html b/app/templates/arethusa.core/arethusa_tool.html new file mode 100644 index 000000000..a40438b25 --- /dev/null +++ b/app/templates/arethusa.core/arethusa_tool.html @@ -0,0 +1 @@ +{{ uri }} diff --git a/app/templates/arethusa.core/prov_tools.html b/app/templates/arethusa.core/prov_tools.html new file mode 100644 index 000000000..d3def23c7 --- /dev/null +++ b/app/templates/arethusa.core/prov_tools.html @@ -0,0 +1,12 @@ + + +
diff --git a/dist/i18n/de.json b/dist/i18n/de.json index c045c84ee..aca275e07 100644 --- a/dist/i18n/de.json +++ b/dist/i18n/de.json @@ -132,6 +132,8 @@ "noEditorsPresent": "Keine Bearbeiter bekannt.", "title": "Bearbeiter" }, + "provTools": { + }, "plugins": { "alreadyLoaded": "{{ name }} ist bereits geladen!", "failed": "Laden von {{ name }} gescheitert", diff --git a/dist/i18n/en.json b/dist/i18n/en.json index 21adea2b7..fe15be300 100644 --- a/dist/i18n/en.json +++ b/dist/i18n/en.json @@ -132,6 +132,10 @@ "noEditorsPresent": "No editors known.", "title": "Editors" }, + "provTools": { + "noToolsPresent": "No tools known.", + "title": "Document Provenance - Tools Used" + }, "plugins": { "alreadyLoaded": "{{ name }} is already loaded!", "failed": "Failed to load {{ name }}", diff --git a/dist/i18n/fr.json b/dist/i18n/fr.json index 1bd1510a3..7b7134628 100644 --- a/dist/i18n/fr.json +++ b/dist/i18n/fr.json @@ -116,6 +116,10 @@ "noEditorsPresent": "Aucun éditeur connu.", "title": "Éditeurs" }, + "provTools": { + "noToolsPresent": "Pas d'outils", + "title": "Provenance du Document - Outils Utilisé(s)" + }, "plugins": { "alreadyLoaded": "{{ name }} est déjà chargé!", "failed": "Impossible de charger {{ name }}", @@ -154,4 +158,4 @@ "matchAll": "Tout" }, "exitHandler": {} -} \ No newline at end of file +} From d0f862cb3702a3b3561445eb07c70521e9f39be3 Mon Sep 17 00:00:00 2001 From: Bridget Almas Date: Tue, 6 Jan 2015 14:49:05 -0500 Subject: [PATCH 2/2] populate provenance tools from doc and show in help --- app/js/arethusa/treebank_retriever.js | 7 ++++++- app/templates/arethusa.core/help_panel.html | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/js/arethusa/treebank_retriever.js b/app/js/arethusa/treebank_retriever.js index 9cef30624..0df035768 100644 --- a/app/js/arethusa/treebank_retriever.js +++ b/app/js/arethusa/treebank_retriever.js @@ -12,8 +12,9 @@ angular.module('arethusa').factory('TreebankRetriever', [ 'idHandler', 'commons', 'editors', + 'provTools', function (configurator, documentStore, retrieverHelper, - idHandler, commons, editors) { + idHandler, commons, editors, provTools) { function parseDocument(json, docId) { var annotators = arethusaUtil.toAry(json.treebank.annotator || []); parseEditors(annotators, docId); @@ -30,6 +31,10 @@ angular.module('arethusa').factory('TreebankRetriever', [ page: annotator.url, mail: annotator.address }); + } else { + provTools.addTool(docId, { + uri: annotator.uri + }); } }); } diff --git a/app/templates/arethusa.core/help_panel.html b/app/templates/arethusa.core/help_panel.html index 3a7ed707f..c50e8e047 100644 --- a/app/templates/arethusa.core/help_panel.html +++ b/app/templates/arethusa.core/help_panel.html @@ -42,6 +42,9 @@
+
+
+