?stage
@@ -231,22 +279,16 @@ def getData(graph,res_template):
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
- def compare_sublists(l, lol):
- for sublist in lol:
- temp = [i for i in sublist if i in l]
- if sorted(temp) == sorted(l):
- return True
- return False
-
data = defaultdict(list)
for result in results["results"]["bindings"]:
result.pop('subject',None)
- label = result.pop('graph_title',None)
+ graph_label = result.pop('graph_title',None)
for k,v in result.items():
if '_label' not in k and v['type'] == 'literal': # string values
value = v['value']
if 'xml:lang' in v:
- value = (v['value'],v['xml:lang'],'mainLang') if v['value']==label['value'] and v['xml:lang']==label['xml:lang'] else (v['value'],v['xml:lang'])
+ value = (v['value'],v['xml:lang'],'mainLang') if v['value']==graph_label['value'] and v['xml:lang']==graph_label['xml:lang'] else (v['value'],v['xml:lang'])
+
if value not in data[k]:
data[k].append(value)
elif v['type'] == 'uri': # uri values
@@ -380,10 +422,8 @@ def saveHiddenTriples(graph, tpl):
}
}
'''
- print(queryNGraph)
sparql = SPARQLWrapper(conf.myEndpoint)
sparql.setQuery(queryNGraph)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
- print(results)
return results
diff --git a/static/css/main.css b/static/css/main.css
index ea4cb95..0d2925c 100644
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -732,8 +732,9 @@ nav .wditem, nav .viafitem {
.searchWikidata~.tag,
.searchGeonames~.tag,
+.searchSkos~.tag,
textarea~.tags-nlp {
- margin-left: 35px !important;
+ margin-left: 15px !important;
}
.tag::after {
@@ -752,7 +753,7 @@ span[class^='tag Q']:hover {
}
.tags-nlp {
- margin: 25px;
+ margin: 15px;
}
.tags-nlp::before {
@@ -760,10 +761,11 @@ span[class^='tag Q']:hover {
font-size: 0.7em;
color: grey;
display: block;
+ margin-left: 20px;
}
.tags-url {
- margin-left: 35px;
+ margin-left: 15px;
}
.tags-url::before {
@@ -771,6 +773,7 @@ span[class^='tag Q']:hover {
font-size: 0.7em;
color: grey;
display: block;
+ margin-left: 20px;
}
@@ -1954,7 +1957,7 @@ button#showTemplates {
}
.multimediaTag .tag{
- margin-left:35px !important;
+ margin-left:15px !important;
word-wrap:break-word;
max-width: calc(100% - 35px);
}
diff --git a/static/js/main.js b/static/js/main.js
index 8077470..277b882 100644
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -1,8 +1,8 @@
if (graph.length) {var in_graph = "FROM <"+graph+">"} else {var in_graph = ""}
-const wd_img = ' '
+const wd_img = ' '
const geo_img = '';
-const viaf_img = '';
+const viaf_img = '';
const wikidataEndpoint = "https://query.wikidata.org/sparql"
$(document).ready(function() {
@@ -101,10 +101,27 @@ $(document).ready(function() {
areas.forEach(element => { element.after(tags); });
// Textbox > URL: suggestion
- const textboxURL = document.querySelectorAll('#recordForm input.urlField, #modifyForm input.urlField');
- var suggestionTags = document.createElement('div');
- suggestionTags.setAttribute('class','tags-url');
- textboxURL.forEach(element => { element.after(suggestionTags); });
+ const textboxURL = document.querySelectorAll('#recordForm input.urlField, #modifyForm input.urlField, #recordForm input.multimediaField, #modifyForm input.multimediaField');
+ textboxURL.forEach(element => {
+ var suggestionTags = document.createElement('div');
+ suggestionTags.setAttribute('class','tags-url');
+ const parent = element.parentNode;
+ if (element.className.includes('multimediaField')) {
+ const previousURLS = Array.from(parent.querySelectorAll('.multimediaTag'));
+ previousURLS.forEach(tag => {
+ tag.remove();
+ suggestionTags.appendChild(tag);
+ });
+ } else {
+ console.log(element)
+ const previousURLS = Array.from(parent.querySelectorAll('span.tag, input.hiddenInput'));
+ previousURLS.forEach(tag => {
+ tag.remove();
+ suggestionTags.appendChild(tag);
+ });
+ };
+ element.after(suggestionTags.cloneNode(true));
+ });
// Suggest vocabularies links
$("input[type='text'].searchSkos").each(function() {
@@ -1123,7 +1140,7 @@ function searchGeonames(searchterm) {
e.preventDefault();
var oldID = this.getAttribute('data-id').substr(this.getAttribute('data-id').lastIndexOf('/') + 1);
var oldLabel = $(this).text();
- $('#'+searchterm).after(""+oldLabel+"");
+ $('#'+searchterm).after(""+oldLabel+"");
$("#searchresult").hide();
$('#'+searchterm).val('');
});
@@ -1143,7 +1160,7 @@ function searchGeonames(searchterm) {
$('a[data-id="'+ item.geonameId+'"]').each( function() {
$(this).bind('click', function(e) {
e.preventDefault();
- $('#'+searchterm).after(""+item.name+"");
+ $('#'+searchterm).after(""+item.name+"");
$("#searchresult").hide();
$('#'+searchterm).val('');
//colorForm();
@@ -1817,8 +1834,37 @@ function addURL(searchterm, iframe=false) {
$('#'+searchterm).after("");
}
else {
- $('#'+searchterm).after(""+$('#'+searchterm).val()+"");
+ $('#'+searchterm).next('.tags-url').prepend(""+$('#'+searchterm).val()+"");
}
+
+ // popover Wayback Machine
+ var tooltip_save = '\
+ ';
+
+ var tooltip_saved = '\
+ ';
+
+ $('#'+searchterm).parent().append(tooltip_save);
+ $('#'+searchterm).parent().append(tooltip_saved);
+ $(".savetheweb").popover({
+ html: true,
+ title : "Need to save a source for the future?
",
+ content: "If you have a web page that is important to you, \
+ we can save it using the \
+ Wayback Machine
\
+ Shall we?
\
+ \
+ \
+ ",
+ placement: "bottom",
+ }).popover('show');
+
}
else if ($('#'+searchterm).val().length > 0 && !regexURL.test($('#'+searchterm).val()) ) {
alert('Insert a valid URL');
@@ -2033,7 +2079,7 @@ function searchSkos(searchterm) {
$(this).bind('click', function (e) {
e.preventDefault();
if (!skos_vocabs.includes("oneVocableAccepted") || $('#' + searchterm).nextAll("span").length == 0) {
- $('#' + searchterm).after("" + label+" - "+vocabulary_noun + "");
+ $('#' + searchterm).after("" + label+" - "+vocabulary_noun + "");
}
else if (skos_vocabs.includes("oneVocableAccepted") && $('#' + searchterm).nextAll("span").length > 0) {
alert("Only one term is accepted!");
@@ -2068,18 +2114,18 @@ function addMultimedia(searchterm) {
if ($('#'+searchterm).val().length > 0 && regexURL.test($('#'+searchterm).val()) ) {
// IMAGE
if ($('#'+searchterm).hasClass("Image") && stringEndsWith($('#'+searchterm).val(), imageFormats)) {
- $('#'+searchterm).after("");
- $('.multimediaTag.'+newID).prepend(""+$('#'+searchterm).val()+"");
+ $('#'+searchterm).next('.tags-url').prepend("");
+ $('.multimediaTag.'+newID).prepend(""+$('#'+searchterm).val()+"");
$('.multimediaTag.'+newID).prepend("");
} // AUDIO
else if ($('#'+searchterm).hasClass("Audio") && stringEndsWith($('#'+searchterm).val(), audioFormats)) {
- $('#'+searchterm).after("");
- $('.multimediaTag.'+newID).prepend(""+$('#'+searchterm).val()+"");
+ $('#'+searchterm).next('.tags-url').prepend("");
+ $('.multimediaTag.'+newID).prepend(""+$('#'+searchterm).val()+"");
$('.multimediaTag.'+newID).prepend("");
} // VIDEO
else if ($('#'+searchterm).hasClass("Video") && stringEndsWith($('#'+searchterm).val(), videoFormats)) {
- $('#'+searchterm).after("");
- $('.multimediaTag.'+newID).prepend(""+$('#'+searchterm).val()+"");
+ $('#'+searchterm).next('.tags-url').prepend("");
+ $('.multimediaTag.'+newID).prepend(""+$('#'+searchterm).val()+"");
$('.multimediaTag.'+newID).prepend("");
}
else {
@@ -2109,6 +2155,7 @@ function stringEndsWith(string, formatList) {
// NLP
function nlpText(searchterm) {
var lang = searchterm.split('_')[1];
+ var baseID = searchterm.split('_')[0];
$('textarea#'+searchterm).keypress( throttle(function(e) {
if(e.which == 13) {
//$('textarea#'+searchterm).parent().parent().append('');
@@ -2137,7 +2184,7 @@ function nlpText(searchterm) {
function(data) {
console.log(data);
$.each(data.search, function(i, item) {
- $('textarea#'+searchterm).next('.tags-nlp').append(''+item.label+'');
+ $('textarea#'+searchterm).next('.tags-nlp').append(''+item.label+'');
});
});
};
diff --git a/templates/modify.html b/templates/modify.html
index e2e62fe..a8a7f94 100644
--- a/templates/modify.html
+++ b/templates/modify.html
@@ -1,9 +1,14 @@
-$def with (graphdata, pageID, record_form, user, ids_dropdown,is_git_auth,invalid, project,template, skos_vocabs, knowledge_extractor)
+$def with (graphdata,pageID,record_form,user,ids_dropdown,is_git_auth,invalid,project,template,query_templates,knowledge_extractor)
$var user = user
$var is_git_auth = is_git_auth
$var project = project
+$if query_templates!=None:
+
$else:
-
- $if " vocabularyField " in input.attrs["class"]:
- $:input.render()
- $ list_vocabs = "//".join(list(skos_vocabs.keys()))
- $ selectedVocabs = str(skos_vocabs)
-
-
$if len(graphdata[id]) > 0 and "multimedia" not in input.attrs["class"] and "websitePreview" not in input.attrs["class"]:
+
+
$if type(graphdata[id][0]) is list:
$:input.render()
@@ -132,14 +127,6 @@ Modify record
- $elif "vocabularyField" in input.attrs["class"]:
- $ list_vocabs = "//".join(list(skos_vocabs.keys()))
- $ selectedVocabs = str(skos_vocabs)
-
$if knowledge_extractor != False:
diff --git a/templates/record.html b/templates/record.html
index d95d7c3..e6f88cc 100644
--- a/templates/record.html
+++ b/templates/record.html
@@ -4,10 +4,10 @@
$var project = project
$if query_templates!=None:
-
+
$if alert == False:
diff --git a/templates/review.html b/templates/review.html
index b51b824..f3b4aaa 100644
--- a/templates/review.html
+++ b/templates/review.html
@@ -1,8 +1,13 @@
-$def with (graphdata, pageID, record_form, graph, user,ids_dropdown,is_git_auth,invalid,project,template,skos_vocabs,knowledge_extractor)
+$def with (graphdata, pageID, record_form, graph, user,ids_dropdown,is_git_auth,invalid,project,template,query_templates,knowledge_extractor)
$var user = user
$var is_git_auth = is_git_auth
$var project = project
+$if query_templates!=None:
+