--- a/src/jocondelab/management/commands/import_dbpedia_translations.py Fri Aug 16 16:32:06 2013 +0200
+++ b/src/jocondelab/management/commands/import_dbpedia_translations.py Fri Aug 16 19:13:12 2013 +0200
@@ -48,19 +48,19 @@
for i,obj in enumerate(qs):
writer = show_progress(i+1, count, obj.uri, 50, writer)
- for langtuple in settings.LANGUAGES:
- lang = langtuple[0]
- try:
- with transaction.commit_on_success():
- DbpediaTranslation.objects.filter(dbpediaresource=obj).delete()
+ try:
+ with transaction.commit_on_success():
+ DbpediaTranslation.objects.filter(dbpediaresource=obj).delete()
+ for langtuple in settings.LANGUAGES:
+ lang = langtuple[0]
endpointuri = settings.WIKIPEDIA_URLS[obj.lang]['dbpedia_sparql_url']
endpoint = SPARQLWrapper2(endpointuri)
uri = urllib.unquote(str(obj.uri)).decode('utf8')
sparql = u"""
select ?label, ?rlabel where {
- OPTIONAL { <%s> rdfs:label ?label FILTER (lang(?label) = "%s") } .
+ OPTIONAL { <%s> rdfs:label ?label FILTER ( langMatches(?label, "%s") ) } .
OPTIONAL { <%s> dbpedia-owl:wikiPageRedirects ?r }.
- OPTIONAL { ?r rdfs:label ?rlabel FILTER (lang(?rlabel) = "%s") }.
+ OPTIONAL { ?r rdfs:label ?rlabel FILTER ( langMatches(?rlabel, "%s") ) }.
}
"""%(uri, lang, uri, lang)
endpoint.setQuery(sparql)
@@ -76,8 +76,8 @@
label = label
)
- except Exception as e:
- print "\nError processing resource %s : %s" %(obj.uri,unicode(e))
- traceback.print_exception(type(e), e, sys.exc_info()[2])
+ except Exception as e:
+ print "\nError processing resource %s : %s" %(obj.uri,unicode(e))
+ traceback.print_exception(type(e), e, sys.exc_info()[2])
\ No newline at end of file
--- a/src/jocondelab/static/jocondelab/js/front-common.js Fri Aug 16 16:32:06 2013 +0200
+++ b/src/jocondelab/static/jocondelab/js/front-common.js Fri Aug 16 19:13:12 2013 +0200
@@ -3,13 +3,13 @@
var lang = $("html").attr("lang"),
sparqlTpl = _.template(
'select distinct * where { '
- + '<<%= uri %>> rdfs:label ?l FILTER( lang(?l) = "<%- lang %>" ). '
+ + 'OPTIONAL { <<%= uri %>> rdfs:label ?l FILTER( langMatches( lang(?l), "<%- lang %>" ) ) }. '
+ 'OPTIONAL { <<%= uri %>> dbpedia-owl:thumbnail ?t }. '
- + 'OPTIONAL { <<%= uri %>> dbpedia-owl:abstract ?a FILTER( lang(?a) = "<%- lang %>" ) }. '
- + 'OPTIONAL { <<%= uri %>> foaf:isPrimaryTopicOf ?w }. '
+ + 'OPTIONAL { <<%= uri %>> dbpedia-owl:abstract ?a FILTER( langMatches( lang(?a), "<%- lang %>" ) ) }. '
+ 'OPTIONAL { <<%= uri %>> dbpedia-owl:wikiPageRedirects ?r }. '
+ + 'OPTIONAL { ?r rdfs:label ?lr FILTER( langMatches( lang(?lr), "<%- lang %>" ) ) }. '
+ 'OPTIONAL { ?r dbpedia-owl:thumbnail ?tr }. '
- + 'OPTIONAL { ?r dbpedia-owl:abstract ?ar FILTER( lang(?ar) = "fr" ) }. '
+ + 'OPTIONAL { ?r dbpedia-owl:abstract ?ar FILTER( langMatches( lang(?ar), "<%- lang %>" ) ) }. '
+ '}'
),
$overlay = $(".dbpedia-overlay"),
@@ -51,9 +51,14 @@
} else {
$img.hide();
}
- $h2.text(uriData.l || "");
+ var label = uriData.l || uriData.lr || "",
+ wkUrl = "http://" + lang + ".wikipedia.org/";
+ if (label) {
+ wkUrl += "wiki/" + encodeURI(label.replace(/ /g,'_'));
+ }
+ $h2.text(uriData.l || uriData.lr || "");
$abstract.text((uriData.a || uriData.ar || "").replace(/^(.{240,260})\s.+$/,'$1…'));
- $source.attr("href", uriData.w || "http://www.wikipedia.org/").show();
+ $source.attr("href", wkUrl);
moveDbpediaPopin();
}
return true;
@@ -64,7 +69,7 @@
return;
}
var sparqlEndpoint = dbpediaUri.replace(/\/resource\/.*$/,'/sparql'),
- query = sparqlTpl({uri: dbpediaUri, lang: lang});
+ query = sparqlTpl({uri: decodeURI(dbpediaUri), lang: lang});
dbpediaCache[dbpediaUri] = false;
$.getJSON(sparqlEndpoint, {
query: query,
--- a/src/jocondelab/static/jocondelab/js/front-search.js Fri Aug 16 16:32:06 2013 +0200
+++ b/src/jocondelab/static/jocondelab/js/front-search.js Fri Aug 16 19:13:12 2013 +0200
@@ -31,7 +31,7 @@
$popin.css({
top: refo.top - 11,
width: refw + 260
- })
+ });
if (x < winw / 2) {
$img.css({
float: "left"
@@ -62,32 +62,38 @@
var hoverPopin = false;
- $tblist.find(".notice-item").mouseenter(function() {
- var $this = $(this);
- removePopin();
- if (!$this.find(".notice-image")[0].width) {
- return;
- }
- $popin = $('<div class="notice-popin"></div>').append($this.find(".notice-contents").clone());
- $popin.attr("data-notice-id",$this.attr("data-notice-id"));
- $popin.find(".notice-image").css("margin", 0);
- $("body").append($popin);
- movePopin();
- $popin.hover(function() {
- hoverPopin = true;
- }, function() {
- hoverPopin = false;
- if ($dbpOverlay.is(":hidden")) {
+ function deferredRemovePopin() {
+ window.setTimeout(function() {
+ if (!hoverPopin) {
removePopin();
}
- });
+ }, 0);
+ }
+
+ $tblist.find(".notice-item").mouseover(function() {
+ var $this = $(this);
+ window.setTimeout(function() {
+ removePopin();
+ if (!$this.find(".notice-image")[0].width) {
+ return;
+ }
+ $popin = $('<div class="notice-popin"></div>').append($this.find(".notice-contents").clone());
+ $popin.attr("data-notice-id",$this.attr("data-notice-id"));
+ $popin.find(".notice-image").css("margin", 0);
+ $("body").append($popin);
+ movePopin();
+ $popin.mouseover(function() {
+ hoverPopin = true;
+ }).mouseleave(function() {
+ hoverPopin = false;
+ if ($dbpOverlay.is(":hidden")) {
+ deferredRemovePopin();
+ }
+ });
+ }, 0);
});
- $dbpOverlay.mouseleave(function() {
- if (!hoverPopin) {
- removePopin();
- }
- })
+ $dbpOverlay.mouseleave(deferredRemovePopin);
function adaptGrid() {
$tblist.css({
--- a/src/jocondelab/templates/jocondelab/front_base.html Fri Aug 16 16:32:06 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/front_base.html Fri Aug 16 19:13:12 2013 +0200
@@ -70,7 +70,7 @@
<img />
<h2></h2>
<p class="dbpedia-abstract"></p>
- <p class="dbpedia-source"><a href="#">{% trans 'Source: Wikipedia' %}</a></p>
+ <p class="dbpedia-source"><a href="#" target="_blank">{% trans 'Source: Wikipedia' %}</a></p>
</div>
{% endblock %}
</body>
--- a/src/jocondelab/templates/jocondelab/front_notice.html Fri Aug 16 16:32:06 2013 +0200
+++ b/src/jocondelab/templates/jocondelab/front_notice.html Fri Aug 16 19:13:12 2013 +0200
@@ -58,7 +58,7 @@
<ul class="datasheet-contents notice-term-list">
{% for termtype, terms in terms.items %}
{% for term in terms %}
- <li class="notice-term term-{{termtype}}" data-dbpedia-uri="{{term.dbpedia_uri}}"><a href="{% url 'multilingual_search' %}?q={{term.locale_label|urlencode}}">{{term.locale_label}}</a></li>
+ <li class="notice-term term-{{termtype}}"><a href="{% url 'multilingual_search' %}?q={{term.locale_label|urlencode}}" data-dbpedia-uri="{{term.dbpedia_uri}}">{{term.locale_label}}</a></li>
{% endfor %}
{% endfor %}
</ul>
--- a/src/jocondelab/views/front_office.py Fri Aug 16 16:32:06 2013 +0200
+++ b/src/jocondelab/views/front_office.py Fri Aug 16 19:13:12 2013 +0200
@@ -88,7 +88,7 @@
wpp = 30
if show_tagcloud:
- wqs = DbpediaResource.objects.filter(translations__lang=lang, notices__in=qs).annotate(notice_count=Count('notices')).order_by("-notice_count")[:wpp]
+ wqs = DbpediaResource.objects.filter(translations__lang=lang, notices__notice__in=qs).annotate(notice_count=Count('notices')).order_by("-notice_count")[:wpp]
words = [{
"uri": w.uri,