Binary file web/hdalab/locale/de/LC_MESSAGES/django.mo has changed
--- a/web/hdalab/locale/de/LC_MESSAGES/django.po Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/locale/de/LC_MESSAGES/django.po Wed Aug 29 16:23:13 2012 +0200
@@ -124,3 +124,7 @@
#: templates/facettes.html:152
msgid "Resultats de recherche"
msgstr "Suchergebnisse"
+
+#: templates/completion.html:37
+msgid "Recherche par liste de completion"
+msgstr "Autovervollständigen Suche"
Binary file web/hdalab/locale/en/LC_MESSAGES/django.mo has changed
--- a/web/hdalab/locale/en/LC_MESSAGES/django.po Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/locale/en/LC_MESSAGES/django.po Wed Aug 29 16:23:13 2012 +0200
@@ -71,7 +71,7 @@
#: templates/facettes.html:73
msgid "Creer une vue sur des resultats de recherche"
-msgstr "Create a view on research results"
+msgstr "Create a view on search results"
#: templates/facettes.html:74
msgid "Creer une liste de notices"
@@ -124,3 +124,7 @@
#: templates/facettes.html:152
msgid "Resultats de recherche"
msgstr "Search results"
+
+#: templates/completion.html:37
+msgid "Recherche par liste de completion"
+msgstr "Autocomplete Search"
Binary file web/hdalab/locale/es/LC_MESSAGES/django.mo has changed
--- a/web/hdalab/locale/es/LC_MESSAGES/django.po Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/locale/es/LC_MESSAGES/django.po Wed Aug 29 16:23:13 2012 +0200
@@ -124,3 +124,7 @@
#: templates/facettes.html:152
msgid "Resultats de recherche"
msgstr "Resultados de búsqueda"
+
+#: templates/completion.html:37
+msgid "Recherche par liste de completion"
+msgstr "Busqueda con autocompletar"
Binary file web/hdalab/locale/it/LC_MESSAGES/django.mo has changed
--- a/web/hdalab/locale/it/LC_MESSAGES/django.po Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/locale/it/LC_MESSAGES/django.po Wed Aug 29 16:23:13 2012 +0200
@@ -124,3 +124,7 @@
#: templates/facettes.html:152
msgid "Resultats de recherche"
msgstr "Risultati della ricerca"
+
+#: templates/completion.html:37
+msgid "Recherche par liste de completion"
+msgstr "Ricerca con autocompletamento"
--- a/web/hdalab/static/hdalab/css/common.css Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/static/hdalab/css/common.css Wed Aug 29 16:23:13 2012 +0200
@@ -104,7 +104,7 @@
}
#nav li {
- float: left; font-size: 14px; margin-left: 10px; font-weight: bold;
+ float: left; font-size: 14px; margin-left: 15px; font-weight: bold;
}
#nav a {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/hdalab/static/hdalab/css/completion.css Wed Aug 29 16:23:13 2012 +0200
@@ -0,0 +1,179 @@
+#titlebar, #columns {
+ width: 100%;
+ clear: both;
+}
+
+.langbutton {
+ width: 19px; height: 13px; margin: 2px; padding: 0; border: none; text-indent: -999px; background-position: 0 -26px; cursor: pointer;
+}
+
+.langbutton:hover {
+ background-position: 0 -13px;
+}
+
+.langbutton.selected {
+ background-position: 0 0; cursor: default;
+}
+
+.barrebloc {
+ float: left; width: 473px; border: 1px solid #b0b0b0;
+ background-image: url(../img/bgdhdalab.png); background-position: 0 -22px; background-repeat: repeat-x; cursor: pointer; cursor: hand;
+ border-top-left-radius: 4px; border-top-right-radius: 4px
+}
+
+.barrebloc h2 {
+ margin: 4px 0; font-size: 16px; text-align: center; color: #ffffff; font-weight: bold;
+}
+
+.bloc {
+ float: left; width: 475px; margin-bottom: 10px;
+}
+
+#bloc_translationinfo {
+ color: #666;
+ font-style: italic;
+}
+
+.corpsbloc {
+ float: left; width: 465px; border: 1px solid #b0b0b0; padding: 8px 4px; border-top-style: none;
+ background-color: #ffffff; background-image: url(../img/bgdhdalab.png); background-position: 0 -62px; background-repeat: repeat-x;
+ border-bottom-left-radius: 4px; border-bottom-right-radius: 4px
+}
+
+#hdatitle {
+ float: left; width: 475px; margin: 5px 0; font-size: 20px;
+}
+
+#titleleft {
+ float: left;
+}
+
+#titleright {
+ float: right;
+}
+
+#langselect {
+ float: right;
+}
+
+#leftcol {
+ float: left; width: 475px; margin-right: 5px;
+}
+
+#rightcol {
+ float: left; width: 475px; margin-left: 5px;
+}
+
+#contentlist {
+ list-style: none;
+}
+
+li.content-item {
+ margin: 2px 0 12px;
+}
+
+.content-item h3 {
+ font-size: 18px; margin: 3px 0; clear: both;
+}
+
+.content-item h4 {
+ font-size: 11px; margin: 3px 0;
+}
+
+.content-item h4 a {
+ color: #000066;
+}
+
+.maplet {
+ float: right;
+}
+
+.content-item p {
+ font-size: 12px; margin: 3px 0;
+}
+
+.content-annotation ul {
+ list-style : disc; margin: 2px 0; padding-left: 1.5em; font-size: 12px;
+ cursor: pointer; cursor: hand;
+}
+
+.content-annotation li {
+ margin: 2px 0;
+}
+
+.content-annotation textarea {
+ width: 99%; margin: 0; padding: 0; font-size: 12px;
+}
+
+ul.content-tags {
+ list-style: none;
+}
+
+li.content-tag-item {
+ display: inline-block; margin: 2px; padding: 2px; font-size: 13px; background: #666666;
+}
+
+.content-tag-item a {
+ color: #ffffff;
+}
+
+.content-tag-item a:hover {
+ color: #ff8080;
+}
+
+.content-tag-item a.tagmatch {
+ color: #ffff00; font-weight: bold;
+}
+
+#taginfo p, h2, h3 {
+ margin: 5px 0;
+}
+
+#taginfo h3 {
+ font-size: 14px;
+}
+
+#taginfo p {
+ font-size: 11px;
+}
+
+#img_wikipedia {
+ float: left; max-width: 160px; max-height: 120px; margin: 2px 2px 2px 0;
+}
+
+#tagsearch {
+ width: 100%; font-size: 16px; font-weight: bold; border-style: none; border-bottom: 1px solid #000;
+}
+
+#tagsearch.grise {
+ color: #666; font-style: italic; font-weight: normal;
+}
+
+ul.ui-autocomplete {
+ width: 180px; font-family: "Open Sans";
+ max-height: 600px; overflow-y: auto; overflow-x: hidden; padding-right: 20px;
+}
+
+h4.actitle {
+ font-size: 14px; font-weight: bold;
+}
+
+.acimgwrap {
+ float: left; width: 80px; text-align: center;
+}
+
+img.acimg {
+ max-width: 80px; max-height: 60px;
+}
+
+p.acabstract {
+ margin-left: 82px;
+}
+
+.clear {
+ clear: both;
+}
+
+.actitle strong {
+ color: #c000c0;
+}
\ No newline at end of file
--- a/web/hdalab/static/hdalab/css/facettes.css Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/static/hdalab/css/facettes.css Wed Aug 29 16:23:13 2012 +0200
@@ -269,31 +269,6 @@
color: #800000;
}
-
-#tagsearchwrap {
- width: 200px;
-}
-
-#tagsearch {
- width: 100%; font-size: 16px; font-weight: bold; border-style: none; border-bottom: 1px solid #000;
-}
-
-#tagsearch.grise {
- color: #666; font-style: italic; font-weight: normal;
-}
-
-ul.ui-autocomplete {
- width: 200px; font-family: "Open Sans";
-}
-
-.ui-autocomplete strong {
- font-weight: bold;
-}
-
-#tagdata {
- float: right; width: 465px;
-}
-
#rightcol {
float: left; width: 475px; margin-left: 5px;
}
--- a/web/hdalab/static/hdalab/css/index.css Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/static/hdalab/css/index.css Wed Aug 29 16:23:13 2012 +0200
@@ -76,6 +76,10 @@
background: url(../img/categories-thumb.jpg);
}
+#bloc-completion {
+ background: url(../img/completion-thumb.jpg);
+}
+
.mini-table {
float: left; width: 960px; clear: both; margin: 5px 0;
}
Binary file web/hdalab/static/hdalab/img/completion-thumb.jpg has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/hdalab/static/hdalab/js/completion.js Wed Aug 29 16:23:13 2012 +0200
@@ -0,0 +1,117 @@
+var gomNs = {
+ languageCode: 'fr'
+}
+
+function showResults(data) {
+ $("#contentcount").html('<b>'+data.count+'</b> ' + ngettext('notice', 'notices', data.count));
+ var contentdata = data.contents;
+ if (contentdata && contentdata.length) {
+ var _htmlCl = '<ul id="contentlist">'
+ + contentdata.map(function(_d) {
+ var _html = '<li class="content-item"><h3>'
+ + _d.title
+ + '</h3>'
+ + ( typeof _d.coords == "object" ?
+ '<div class="maplet"><img src="http://maps.googleapis.com/maps/api/staticmap?center=47,1.5&zoom=4&size=160x160&maptype=roadmap&markers=color:red%7C'
+ + _d.coords.latitude
+ + ','
+ + _d.coords.longitude
+ + '&sensor=false" /><h4>Localisation : '
+ + _d.coords.city_name
+ + '</h4></div>'
+ : '')
+ + '<h4><a href="'
+ + _d.url
+ + '" target="_blank">'
+ + _d.url.replace(/(^.{40}).+(.{30}$)/m,'$1 … $2')
+ + '</a></h4><p>'
+ + _d.description.replace(/(^.{0,160})([\s]|$)(.*)/,'$1…')
+ + '</p><ul class="content-tags">'
+ + _d.tags.map(function(_t) {
+ return '<li class="content-tag-item"><a href="#" onclick="tagInfo(this.getAttribute(\'original-label\'), true); return false;" original-label="'
+ + _t.label
+ + '"'
+ + (_t.match ? ' class="tagmatch"' : '')
+ + '>'
+ + _t.translated_label
+ + '</a></li>';
+ }).join('')
+ + '</ul>';
+ _html += '</li>';
+ return _html;
+ }).join('')
+ + '</ul>';
+ $("#contents").html(_htmlCl).scrollTop(0);
+ }
+ else {
+ $("#contents").html("");
+ }
+}
+
+function getContents(label) {
+ $.getJSON(
+ gomNs.urls['filter'],
+ {
+ label: label,
+ tagcount: 0,
+ contentcount: 30
+ },
+ showResults
+ );
+}
+
+$(document).ready(function() {
+ $(" #tagform ").submit(function() {
+ return false;
+ });
+ $( "#tagsearch" ).autocomplete({
+ source: gomNs.urls['tag_search'],
+ minLength: 2,
+ select: function( event, ui ) {
+ getContents(ui.item.original_label);
+ }
+ })
+ .addClass("grise")
+ .focusin(function() {
+ $(this).removeClass("grise");
+ })
+ .focusout(function() {
+ if (!$(this).val()) {
+ $(this).addClass("grise");
+ }
+ })
+ .data("autocomplete")._renderItem = function(ul, item) {
+ var _contents = $('<a>'),
+ _title = $('<h4>')
+ .addClass("actitle")
+ .html(
+ item.value.replace(
+ new RegExp('('
+ + $("#tagsearch").val().replace(/(\W)/g, '\\$1')
+ + ')','gi') ,
+ '<strong>$1</strong>')
+ ),
+ _clear = $('<div>').addClass('clear');
+ _contents.append(_title);
+ if (item.thumbnail) {
+ var _img = $('<img>')
+ .addClass("acimg")
+ .attr("src",item.thumbnail),
+ _imgwrap = $('<div>')
+ .addClass("acimgwrap")
+ .append(_img);
+ _contents.append(_imgwrap);
+ }
+ if (item.abstract) {
+ var _abstract = $('<p>')
+ .addClass("acabstract")
+ .text( item.abstract.replace(/(^.{0,240})([\s]|$)(.*)/,'$1…') );
+ _contents.append(_abstract);
+ }
+ _contents.append(_clear);
+ return $( "<li>" )
+ .data( "item.autocomplete", item )
+ .append( _contents )
+ .appendTo( ul );
+ };
+});
--- a/web/hdalab/static/hdalab/js/gomina.js Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/static/hdalab/js/gomina.js Wed Aug 29 16:23:13 2012 +0200
@@ -112,54 +112,6 @@
gomNs.map.addLayer(gJ);
}
-
-function tagInfo(_taglabel, _filter) {
- var _urlParam = { "label": _taglabel };
- $.getJSON(gomNs.urls['tag_info'],
- _urlParam,
- function(data) {
- $("#tagsearch").val(data.translated_label).removeClass("grise");
- $("#tagcount").html(data.content_count
- + ' ' + ngettext("contenu", "contenus", data.content_count) + ' '+gettext("pour ce tag"));
- var _html = '';
- if (data.wikipedia_url) {
- _html += '<h3><a href="'
- + data.wikipedia_url
- + '" target="_blank">Wikipedia: '
- + decodeURI(data.wikipedia_url.match(/[^\/]+$/)[0]).replace("_"," ")
- + '</a></h3>'
- }
- if (data.thumbnail) {
- _html += '<img id="img_wikipedia" src="'
- + data.thumbnail
- + '" />';
- }
- if (data.translated_abstract) {
- _html += '<p>' + _(data.translated_abstract).escape().replace(/(^.{0,240})([\s]|$)(.*)/,'$1…') + '</p>';
- }
-/* if (data.links) {
- var _lC = data.requested_label.toLowerCase();
- var _t = data.links.map(function(d) {
- return (d.subject.toLowerCase() == _lC) ? d.object : d.subject;
- });
- _t.sort();
- _t = _(_t).uniq(true);
- _html += '<h3>Tags liés (dbpedia)</h3><ul class="content-tags">'
- + _t.map(function(d) {
- return '<li class="content-tag-item"><a href="#" onclick="tagInfo($(this).text()); return false;">'
- + d
- + '</a></li>';
- }).join('')
- + '</ul>';
- } */
- $("#tagdata").html(_html);
- });
- if (typeof _filter !== "undefined" && _filter) {
- addFilter('tag', _taglabel);
- }
- $("#showlist").removeClass("actif");
-}
-
function addFilter(_type, _label) {
var _curView = gomNs.sessiondata.views[gomNs.sessiondata.view];
if (_curView.type == 'filter') {
@@ -254,9 +206,6 @@
var _htmFilters = '',
_fl = _curView.tag.length,
_cl = _curView.country.length;
-/* if (!_curView.period && !_fl && !_cl) {
- _htmFilters = '<li class="nofilter">Aucun filtre</li>';
-} */
if (_curView.period[0] == gomNs.minYear && _curView.period[1] == gomNs.maxYear) {
_htmFilters += '<li class="filperiod">'+gettext("Toutes periodes")+'</li>';
} else {
@@ -326,7 +275,7 @@
+ _d.description.replace(/(^.{0,160})([\s]|$)(.*)/,'$1…')
+ '</p><ul class="content-tags">'
+ _d.tags.map(function(_t) {
- return '<li class="content-tag-item"><a href="#" onclick="tagInfo(this.getAttribute(\'original-label\'), true); return false;" original-label="'
+ return '<li class="content-tag-item"><a href="#" onclick="addFilter(\'tag\', this.getAttribute(\'original-label\')); return false;" original-label="'
+ _t.label
+ '"'
+ (_t.match ? ' class="tagmatch"' : '')
@@ -456,7 +405,7 @@
+ _(data.tags).map(function(_d) {
return '<li style="font-size:'
+ parseInt(10 + _scale * Math.sqrt(_d.score - _minTag))
- + 'px;"><a href="#" onclick="tagInfo(this.getAttribute(\'original-label\'), true); return false;" original-label="'
+ + 'px;"><a href="#" onclick="addFilter(\'tag\', this.getAttribute(\'original-label\'), true); return false;" original-label="'
+ _d.label
+'"'
+ (_d.match ? ' class="tagmatch"' : '')
@@ -505,7 +454,7 @@
'<ul class="disc-ul">'
+ _disc.map(function(_d) {
var _col = getGradient(_d.score / _max);
- return '<li class="disc-li" onclick="tagInfo(this.getAttribute(\'original-label\'), true); return false;" original-label="'
+ return '<li class="disc-li" onclick="addFilter(\'tag\', this.getAttribute(\'original-label\'), true); return false;" original-label="'
+ _d.label
+ '"><div class="disc-label"><a href="#">'
+ _d.translated_label
@@ -788,50 +737,7 @@
debouncedSaveChanges();
}
}
- })
- var _defLab = $( "#tagsearch" ).val();
- $( "#tagsearch" ).autocomplete({
- source: gomNs.urls['tag_search'],
- minLength: 2,
- focus: function( event, ui ) {
- tagInfo(ui.item.value, false);
- return false;
- },
- select: function( event, ui ) {
- tagInfo(ui.item.value, true);
- return false;
- },
- open: function() {
- $('#tagdata').css({
- width: "250px"
- })
- },
- close: function() {
- $('#tagdata').css({
- width: "465px"
- })
- }
- })
- .addClass("grise")
- .focusin(function() {
- if ($(this).val() == _defLab) {
- $(this).val("").removeClass("grise");
- }
- })
- .data("autocomplete")._renderItem = function(ul, item) {
- return $( "<li></li>" )
- .data( "item.autocomplete", item )
- .append( '<a><span style="float: right;">'
- + item.nb
- + '</span>'
- + item.label.replace(
- new RegExp('('
- + $("#tagsearch").val().replace(/(\W)/g, '\\$1')
- + ')','gi') ,
- '<strong>$1</strong>')
- + "</a>" )
- .appendTo( ul );
- };
+ });
$("#sessionname").click(function() {
if (gomNs.write_allowed && !$(this).children().length) {
var _el = document.createElement('input');
--- a/web/hdalab/templates/base.html Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/templates/base.html Wed Aug 29 16:23:13 2012 +0200
@@ -26,7 +26,10 @@
<ul id="nav">
<li><a class="{% block home_actif %}{% endblock %}" href="{% url home %}">Accueil</a></li>
<li><a class="{% block facettes_actif %}{% endblock %}" href="{% url facettes %}">Recherche par facettes</a></li>
- <!--li><a class="{% block categories_actif %}{% endblock %}" href="{% url categories %}">Catégories de Wikipedia</a></li-->
+<!--
+ <li><a class="{% block categories_actif %}{% endblock %}" href="{% url categories %}">Catégories de Wikipedia</a></li>
+ <li><a class="{% block completion_actif %}{% endblock %}" href="{% url completion %}">Liste de complétion</a></li>
+-->
</ul>
<h1>
<a href="{% url home %}">HdA Lab</a>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/hdalab/templates/completion.html Wed Aug 29 16:23:13 2012 +0200
@@ -0,0 +1,82 @@
+{% extends "base.html" %}
+
+{% load i18n %}
+
+{% block title %}{{block.super}} > {% trans "Recherche par liste de completion" %}{% endblock %}
+
+{% block css_import %}
+{{block.super}}
+ <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}hdalab/lib/leaflet/leaflet.css" />
+ <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}hdalab/css/ui-lightness/jquery-ui-1.8.16.custom.css" />
+ <link rel="stylesheet" type="text/css" href="{{STATIC_URL}}hdalab/css/completion.css" />
+{% endblock %}
+
+{% block js_import %}
+{{block.super}}
+ <script src="{{STATIC_URL}}hdalab/lib/raphael-min.js"></script>
+ <script src="{{STATIC_URL}}hdalab/lib/underscore-min.js"></script>
+ <script src="{{STATIC_URL}}hdalab/lib/jquery-ui-1.8.16.custom.min.js"></script>
+
+ <script src="{% url jsi18n 'hdalab' %}"></script>
+ <script src="{{STATIC_URL}}hdalab/js/completion.js?v=130829"></script>
+
+ <script type="text/javascript">
+ gomNs.languageCode = '{{LANGUAGE_CODE}}';
+ gomNs.urls = {
+ 'filter': "{% url filter %}",
+ 'tag_search': "{% url tag_search %}"
+ };
+ </script>
+{% endblock %}
+
+{% block completion_actif %}actif{% endblock %}
+
+{% block main_content %}
+ <div id="titlebar">
+ <div id="titleleft">
+ <h2 id="hdatitle">{% trans "Recherche par liste de completion" %} </h2>
+ </div>
+ <div id="titleright">
+ <div id='langselect'>
+ <form action="{% url django.views.i18n.set_language %}" method="post" id="lang_form">
+ {% csrf_token %}
+ <!--input name="next" type="hidden" value="" /-->
+ {% get_language_info_list for LANGUAGES as languages %}
+ {% for language in languages %}
+ <input type="submit" name="language" class="langbutton{% if language.code == LANGUAGE_CODE %} selected{% endif %}" style="background-image: url({{STATIC_URL}}hdalab/img/flag_{{ language.code }}.png)" value="{{ language.code }}" title="{{ language.name_local }}" />
+ {% endfor %}
+ </form>
+ </div>
+ </div>
+ </div>
+ <div id="columns">
+ <div id="leftcol">
+ <div class="bloc" id="bloc_taginfo">
+ <div class="barrebloc">
+ <h2>{% trans "Rechercher un tag" %}</h2>
+ </div>
+ <div class="corpsbloc" id="taginfo">
+ <form id="tagform">
+ <input id="tagsearch" placeholder="{% trans "Rechercher un tag" %}" />
+ </form>
+ </div>
+ </div>
+ <div class="bloc" id="bloc_translationinfo">
+ {% trans "translation_info" %}
+ </div>
+ </div>
+ <div id="rightcol">
+ <div class="bloc" id="bloc_notices">
+ <div class="barrebloc">
+ <h2>{% trans "Resultats de recherche" %}</h2>
+ </div>
+ <div class="corpsbloc">
+ <div id="contentcount"></div>
+ <div id="contents"></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+{% endblock %}
--- a/web/hdalab/templates/facettes.html Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/templates/facettes.html Wed Aug 29 16:23:13 2012 +0200
@@ -20,15 +20,13 @@
<script src="{{STATIC_URL}}hdalab/lib/ZeroClipboard.js"></script>
<script src="{% url jsi18n 'hdalab' %}"></script>
- <script src="{{STATIC_URL}}hdalab/js/gomina.js?v=1"></script>
+ <script src="{{STATIC_URL}}hdalab/js/gomina.js?v=120829"></script>
<script type="text/javascript">
gomNs.languageCode = '{{LANGUAGE_CODE}}';
gomNs.urls = {
'filter': "{% url filter %}",
'session_info': "{% url session_info %}",
- 'tag_search': "{% url tag_search %}",
- 'tag_info': "{% url tag_info %}",
'countries': "{{STATIC_URL}}hdalab/lib/countries.geo.json",
};
ZeroClipboard.setMoviePath('{{STATIC_URL}}hdalab/lib/ZeroClipboard.swf');
@@ -120,16 +118,6 @@
<div class="corpsbloc" id="tagcloud">
</div>
</div>
- <div class="bloc" id="bloc_taginfo">
- <div class="barrebloc">
- <h2>{% trans "Information sur un mot-cle" %}</h2>
- </div>
- <div class="corpsbloc" id="taginfo">
- <div id="tagcount"></div>
- <div id="tagsearchwrap"><input id="tagsearch" value="{% trans "Rechercher un tag" %}" /></div>
- <div id="tagdata"></div>
- </div>
- </div>
<div class="bloc" id="bloc_translationinfo">
{% trans "translation_info" %}
</div>
--- a/web/hdalab/templates/index.html Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/templates/index.html Wed Aug 29 16:23:13 2012 +0200
@@ -43,8 +43,8 @@
</div>
</div>
</div>
- <div style="clear: both;"> </div>
- <!--div class="separateur-applis"></div>
+<!--
+ <div class="separateur-applis"></div>
<div class="bloc-appli">
<h3>Catégories de Wikipedia</h3>
<div class="fond-bloc" id="bloc-categories">
@@ -54,7 +54,18 @@
<p class="goto"><a href="{% url categories %}">»</a></p>
</div>
</div>
- </div-->
+ </div>
+ <div class="bloc-appli">
+ <h3>Recherche par liste de complétion</h3>
+ <div class="fond-bloc" id="bloc-completion">
+ <div class="overlay-bloc">
+ <p>Recherchez les contenus en choisissant parmi les tags sémantisés de la base Histoire des Arts, correspondant chacun à une page Wikipédia</p>
+ <p class="goto"><a href="{% url completion %}">»</a></p>
+ </div>
+ </div>
+ </div>
+-->
+ <div style="clear: both;"> </div>
</div>
<h3>À propos de HdA Lab</h3>
<p>Le portail Histoire des arts a pour vocation de mettre à la disposition de publics prescripteurs — via un site Internet — une sélection de ressources culturelles et éducatives riches en lien avec le programme officiel de l’enseignement de l’Histoire des arts. Le volet HDA-Lab de ce projet s’inscrit dans le cadre d’une collaboration entre l’Institut de Recherche et d'Innovation (IRI) et le Ministère de la Culture et de la Communication. Ce projet de recherche et développement prévoit la réalisation d’une preuve de concept destinée à montrer le potentiel heuristique du tagging sémantique.</p>
--- a/web/hdalab/urls.py Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/urls.py Wed Aug 29 16:23:13 2012 +0200
@@ -25,13 +25,13 @@
url(r'^facettes/', TemplateView.as_view(template_name="facettes.html"), name='facettes'),
url(r'^categories/', TemplateView.as_view(template_name="categories.html"), name='categories'),
+ url(r'^completion/', TemplateView.as_view(template_name="completion.html"), name='completion'),
url(r'^$', TemplateView.as_view(template_name="index.html"), name='home'),
)
urlpatterns += patterns('hdalab.views.ajax',
(r'^a/filter$', 'filter', {}, 'filter'),
- (r'^a/taginfo$', 'taginfo', {}, 'tag_info'),
(r'^a/sessioninfo$', 'sessioninfo', {}, 'session_info'),
(r'^a/tagsearch$', 'tagsearch', {}, 'tag_search'),
(r'^a/catsearch$', 'catsearch', {}, 'cat_search'),
--- a/web/hdalab/views/ajax.py Tue Aug 28 15:56:38 2012 +0200
+++ b/web/hdalab/views/ajax.py Wed Aug 29 16:23:13 2012 +0200
@@ -19,48 +19,9 @@
import itertools
import uuid
-def taginfo(request):
- label = request.GET.get('label', None)
-
- resobj = {'requested_label' : label}
-
- resobj["content_count"] = Datasheet.objects.filter(taggedsheet__tag__label__iexact = label).distinct().count()
-
- res = Tag.objects.select_related('dbpedia_fields').filter(~Q(dbpedia_uri = None), label__iexact = label).order_by('-dbpedia_uri')[0:1]
- if len(res) == 1:
- restag = res.get()
- resobj["dbpedia_uri"] = restag.dbpedia_uri
- if resobj["dbpedia_uri"] is not None and restag.dbpedia_fields is not None:
- dbfield = restag.dbpedia_fields
- resobj["abstract"] = dbfield.abstract
- resobj["dbpedia_label"] = dbfield.label
- resobj["thumbnail"] = dbfield.thumbnail
- transqs = DbpediaFieldsTranslation.objects.filter(master=dbfield, language_code=request.LANGUAGE_CODE)[0:1]
- if transqs:
- trans = transqs.get()
- resobj['translated_abstract'] = trans.abstract
- resobj['translated_label'] = trans.label
- else:
- resobj['translated_abstract'] = dbfield.abstract
- resobj['translated_label'] = dbfield.label
-
- #res = Tag.objects.filter(label__iexact = label).order_by('-wikipedia_url')[0:1]
- #if len(res) == 1:
- # resobj["wikipedia_url"] = res.get().wikipedia_url
- if 'translated_label' in resobj:
- wikipedia_label = resobj['translated_label']
- else:
- wikipedia_label = label
- wikipedia_label = wikipedia_label[0].capitalize() + wikipedia_label[1:]
- resobj["wikipedia_url"] = "http://%s.wikipedia.org/wiki/%s" % (request.LANGUAGE_CODE,wikipedia_label.replace(' ', '_'))
-# We don't use links at the moment, so I'll comment this line to speed up requests
-# resobj["links"] = [{'subject':tl.subject.label, 'object':tl.object.label} for tl in TagLinks.objects.select_related().filter(Q(subject__label__iexact = label) | Q(object__label__iexact = label))]
-
- return HttpResponse(content=json.dumps(resobj), mimetype='application/json')
-
-
def tagtranslation(request):
+ lang = request.GET.get('lang',request.LANGUAGE_CODE)
labels = request.GET.get('labels',None)
if not labels:
@@ -76,7 +37,7 @@
if tag.dbpedia_fields:
masters.append(tag.dbpedia_fields)
- translationqs = DbpediaFieldsTranslation.objects.select_related("master", "master__tag").filter(master__in = masters, language_code=request.LANGUAGE_CODE)
+ translationqs = DbpediaFieldsTranslation.objects.select_related("master", "master__tag").filter(master__in = masters, language_code=lang)
translations = dict([(t.master.label, t.label) for t in translationqs])
@@ -223,27 +184,54 @@
def tagsearch(request):
q = request.GET.get('term',None)
+ lang = request.GET.get('lang',request.LANGUAGE_CODE)
+
+ stemming_langs = [ 'fr', 'en', 'de', 'it' ]
+ # For Japanese, there are no word boundaries, we should not use the regexp in that case
+ no_translate_langs = [ 'fr' ]
+
if q:
lq = q.lower()
- qs = Tag.objects.filter(datasheet__validated=True).filter( Q(label__icontains = q ) | Q(dbpedia_fields__translations__label__icontains = q, dbpedia_fields__translations__language_code=request.LANGUAGE_CODE), ~Q(dbpedia_uri = None)) if q else Tag.objects.filter(~Q(dbpedia_uri = None))
- qs = qs.annotate(nb=Count('datasheet')).order_by('-nb')[:20]
+ qs = Tag.objects.select_related('dbpedia_fields').filter(datasheet__validated=True)
+ qrx = '(\\m|\\b)%s'%q
+ if lang in no_translate_langs:
+ if lang in stemming_langs:
+ qs = qs.filter( label__iregex = qrx )
+ else:
+ qs = qs.filter( label__icontains = q )
+ else:
+ if lang in stemming_langs:
+ qs = qs.filter( Q(label__iregex=q ) | Q(dbpedia_fields__translations__label__iregex=q, dbpedia_fields__translations__language_code=lang), ~Q(dbpedia_uri = None))
+ else:
+ qs = qs.filter( Q(label__icontains=q ) | Q(dbpedia_fields__translations__label__icontains=q, dbpedia_fields__translations__language_code=lang), ~Q(dbpedia_uri = None))
+ else:
+ qs = Tag.objects.filter(~Q(dbpedia_uri = None))
+
+ qs = qs.annotate(nb=Count('datasheet',distinct=True)).order_by('-nb')[:20]
qslist = list(qs)
- transqs = DbpediaFieldsTranslation.objects.filter(master__tag__in = qslist, language_code=request.LANGUAGE_CODE).select_related("master")
-
- translations = dict([(tr.master.tag_id, tr.label) for tr in transqs])
+ if lang in no_translate_langs:
+ translations = {}
+ else:
+ transqs = DbpediaFieldsTranslation.objects.filter(master__tag__in = qslist, language_code=lang).select_related("master")
+ translations = dict([(tr.master.tag_id, {'label':tr.label,'abstract':tr.abstract}) for tr in transqs])
res = []
for t in qslist:
- resobj = {'value':t.label,'nb':t.nb}
+ dbfields = t.dbpedia_fields
+ resobj = {'original_label':t.label,'nb':t.nb}
+ resobj['thumbnail'] = dbfields.thumbnail if dbfields is not None else None
if t.id in translations:
- resobj['label'] = translations[t.id]
+ resobj['value'] = translations[t.id]['label']
+ resobj['abstract'] = translations[t.id]['abstract']
else:
- resobj['label'] = t.label
- if q is None or resobj['label'].lower().find(lq) != -1:
+ resobj['value'] = t.label
+ resobj['abstract'] = dbfields.abstract if dbfields is not None else None
+ if q is None or resobj['value'].lower().find(lq) != -1:
res.append(resobj)
+ res.sort(key=lambda resobj: resobj['value'])
return HttpResponse(content=json.dumps(res), mimetype='application/json')
@@ -252,12 +240,12 @@
q = request.GET.get('term',None)
# On ne récupère que les catégories qui sont également des tags
-
- qs = Tag.objects.filter(Q(label__icontains = ' ' + q ) | Q(label__istartswith = q))
+ qrx = '(\\m|\\b)%s'%q
+ qs = Tag.objects.filter(label__iregex=q)
labels = [tag.label for tag in qs]
- qs = WpCategory.objects.filter(label__in = labels)
+ qs = WpCategory.objects.annotate(nb=Count('child_categories__child_category__tags')).filter(label__in = labels, nb__gt=0)
res = [{'value':t.label} for t in qs]
@@ -265,6 +253,7 @@
def filter(request):
+ lang = request.GET.get('lang',request.LANGUAGE_CODE)
periode = request.GET.get('period',None)
label = request.GET.get('label', None)
country = request.GET.get('country', None)
@@ -273,7 +262,7 @@
content_count = request.GET.get('contentcount', 12)
tag_count = request.GET.get('tagcount', 30)
- key_parts = ("filter",request.LANGUAGE_CODE,periode,label,country,contentlist,max_tag_order,content_count,tag_count)
+ key_parts = ("filter",lang,periode,label,country,contentlist,max_tag_order,content_count,tag_count)
key_parts = [unicode(p).encode("utf-8") for p in key_parts]
cache_key = fix_cache_key("-".join(key_parts))
@@ -336,7 +325,7 @@
matchtagids = [t.id for t in matchtagidsqs]
masters = [t.dbpedia_fields for t in matchtagidsqs if t.dbpedia_fields is not None]
- translationqs = DbpediaFieldsTranslation.objects.select_related("master", "master__tag").filter(master__in = masters, language_code=request.LANGUAGE_CODE)
+ translationqs = DbpediaFieldsTranslation.objects.select_related("master", "master__tag").filter(master__in = masters, language_code=lang)
labeltranslations = [{'label':t.master.label, 'translated_label':t.label} for t in translationqs]
@@ -359,7 +348,7 @@
qs = list(TaggedSheet.objects.select_related('tag', 'tag__dbpedia_fields').filter(datasheet__in = contentids, order__lte = max_tag_order).order_by('order'))
- transqs = DbpediaFieldsTranslation.objects.filter(master__in = [ts.tag.dbpedia_fields for ts in qs], language_code = request.LANGUAGE_CODE)
+ transqs = DbpediaFieldsTranslation.objects.filter(master__in = [ts.tag.dbpedia_fields for ts in qs], language_code = lang)
translations = dict([(trans.master_id,trans.label) for trans in transqs])
for ts in qs:
@@ -387,7 +376,7 @@
dbpediafields = dict([(df.tag_id, df) for df in DbpediaFields.objects.filter(tag__in = tagqslist)])
- transqs = DbpediaFieldsTranslation.objects.filter(master__in = dbpediafields.values(), language_code = request.LANGUAGE_CODE)
+ transqs = DbpediaFieldsTranslation.objects.filter(master__in = dbpediafields.values(), language_code = lang)
translations = dict([(trans.master_id,trans.label) for trans in transqs])
tags = [{'id': tag.id, 'label': tag.label, 'score': tag.nb, 'translated_label': translations.get(dbpediafields[tag.id].id, tag.label) if tag.id in dbpediafields else tag.label} for tag in tagqslist]
@@ -397,7 +386,7 @@
discqslist = list(discqs.annotate(nb=Count('taggedsheet')).order_by('-nb')[:10])
- transqs = DbpediaFieldsTranslation.objects.filter(master__in = [tag.dbpedia_fields for tag in discqslist], language_code = request.LANGUAGE_CODE)
+ transqs = DbpediaFieldsTranslation.objects.filter(master__in = [tag.dbpedia_fields for tag in discqslist], language_code = lang)
translations = dict([(trans.master_id,trans.label) for trans in transqs])