Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provtools #729

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/js/arethusa.core/directives/arethusa_tool.js
Original file line number Diff line number Diff line change
@@ -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'
};
}
]);
15 changes: 15 additions & 0 deletions app/js/arethusa.core/directives/prov_tools.js
Original file line number Diff line number Diff line change
@@ -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'
};
}
]);
19 changes: 19 additions & 0 deletions app/js/arethusa.core/prov_tools.js
Original file line number Diff line number Diff line change
@@ -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;
}
]);
9 changes: 9 additions & 0 deletions app/js/arethusa.core/tool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";

angular.module('arethusa.core').factory('Tool', [
function() {
return function(args) {
this.uri = args.uri;
};
}
]);
7 changes: 6 additions & 1 deletion app/js/arethusa/treebank_retriever.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -30,6 +31,10 @@ angular.module('arethusa').factory('TreebankRetriever', [
page: annotator.url,
mail: annotator.address
});
} else {
provTools.addTool(docId, {
uri: annotator.uri
});
}
});
}
Expand Down
1 change: 1 addition & 0 deletions app/templates/arethusa.core/arethusa_tool.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span>{{ uri }}</span>
3 changes: 3 additions & 0 deletions app/templates/arethusa.core/help_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<div help-panel-item toggler="editors" heading="editors.title" height="200px">
<div editors/>
</div>
<div help-panel-item toggler="provTools" heading="provTools.title" height="200px">
<div prov-tools/>
</div>
</div>

<div class="small-6 large-6 columns">
Expand Down
12 changes: 12 additions & 0 deletions app/templates/arethusa.core/prov_tools.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<ul ng-if="provTools.toolsPresent" class="no-list">
<li ng-repeat="(doc, tools) in provTools.perDocument">
<strong>{{ doc }}</strong>
<ul class="no-list">
<li ng-repeat="tool in tools">
<div arethusa-tool="tool"/>
</li>
</ul>
</li>
</ul>

<div ng-if="!provTools.toolsPresent" translate="provTools.noToolsPresent"/>
2 changes: 2 additions & 0 deletions dist/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
"noEditorsPresent": "Keine Bearbeiter bekannt.",
"title": "Bearbeiter"
},
"provTools": {
},
"plugins": {
"alreadyLoaded": "{{ name }} ist bereits geladen!",
"failed": "Laden von {{ name }} gescheitert",
Expand Down
4 changes: 4 additions & 0 deletions dist/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}",
Expand Down
6 changes: 5 additions & 1 deletion dist/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}",
Expand Down Expand Up @@ -154,4 +158,4 @@
"matchAll": "Tout"
},
"exitHandler": {}
}
}