# HG changeset patch # User veltr # Date 1376673192 -7200 # Node ID 90a5258b3cc4fd2d716f5a2b2224a2fafca5b464 # Parent fa40437d5991c88d213ec50ca160439acea53c42 i18n bugfixes diff -r fa40437d5991 -r 90a5258b3cc4 src/jocondelab/management/commands/import_dbpedia_translations.py --- 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 diff -r fa40437d5991 -r 90a5258b3cc4 src/jocondelab/static/jocondelab/js/front-common.js --- 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, diff -r fa40437d5991 -r 90a5258b3cc4 src/jocondelab/static/jocondelab/js/front-search.js --- 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 = $('
').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 = $('').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({ diff -r fa40437d5991 -r 90a5258b3cc4 src/jocondelab/templates/jocondelab/front_base.html --- 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 @@