# HG changeset patch # User cavaliet # Date 1388746531 -3600 # Node ID 9431920e7c9872f245689445c41af24f494d3e7b # Parent 6229894681149ca46387e3e4fe1adf90b18ef851 v1.52 : search engine for contents diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/__init__.py --- a/src/ldt/ldt/__init__.py Thu Jan 02 17:47:16 2014 +0100 +++ b/src/ldt/ldt/__init__.py Fri Jan 03 11:55:31 2014 +0100 @@ -1,6 +1,6 @@ __all__ = ["VERSION", "get_version", "__version__"] -VERSION = (1, 51, 20, "final", 0) +VERSION = (1, 52, 0, "final", 0) def get_version(): diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/indexation/__init__.py --- a/src/ldt/ldt/indexation/__init__.py Thu Jan 02 17:47:16 2014 +0100 +++ b/src/ldt/ldt/indexation/__init__.py Fri Jan 03 11:55:31 2014 +0100 @@ -25,7 +25,7 @@ if content_iri_ids is None or (content_iri_ids is not None and doc.get("iri_id") in content_iri_ids) : doc["score"] = res.score doc["indexation_id"] = res.pk - doc["context"] = doc["abstract"] + doc["context"] = doc.get("abstract", "") doc["highlighted"] = res.highlighted contexts.append(doc) return contexts diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Thu Jan 02 17:47:16 2014 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Fri Jan 03 11:55:31 2014 +0100 @@ -57,10 +57,6 @@
  • - {% if tag_cloud|length > 0 %} {% endif %} diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/ldt_utils/templates/front/front_home.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Jan 02 17:47:16 2014 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html Fri Jan 03 11:55:31 2014 +0100 @@ -47,10 +47,6 @@
  • - {% if tag_cloud|length > 0 %} {% endif %} diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/ldt_utils/templates/front/front_search_results.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Thu Jan 02 17:47:16 2014 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Fri Jan 03 11:55:31 2014 +0100 @@ -58,6 +58,28 @@ {% blocktrans %} No results for {{ search }}.{% endblocktrans %} {% endif %} {% else %} + {% if content_results %} + + {% endif %} @@ -70,9 +92,9 @@
  • {% if tag_label %} - {% trans "Search results for " %} {{ search }} > {{tag_label}} + {% trans "Results in annotations for" %} {{ search }} > {{tag_label}} {% else %} - {% trans "Search results for " %} {{ search }} + {% trans "Results in annotations for" %} {{ search }} {% endif %}

  • diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/ldt_utils/views/front.py --- a/src/ldt/ldt/ldt_utils/views/front.py Thu Jan 02 17:47:16 2014 +0100 +++ b/src/ldt/ldt/ldt_utils/views/front.py Fri Jan 03 11:55:31 2014 +0100 @@ -16,6 +16,7 @@ from tagging.models import TaggedItem import logging from guardian.shortcuts import get_objects_for_group +from ldt.indexation import get_results_with_context User = get_user_model() logger = logging.getLogger(__name__) @@ -120,8 +121,9 @@ else : content_list = TaggedItem.objects.get_by_model(Content.safe_objects.all().select_related('stat_annotation'), '"'+tag_label+'"') else : - content_list = Content.safe_objects.filter(title__icontains=media_title).select_related('stat_annotation') - + #content_list = Content.safe_objects.filter(title__icontains=media_title).select_related('stat_annotation') + content_searched = get_results_with_context(Content, "all", media_title) + content_list = Content.objects.filter(pk__in=[c['indexation_id'] for c in content_searched]).select_related('stat_annotation') nb = settings.LDT_FRONT_MEDIA_PER_PAGE if page=="x": @@ -237,9 +239,22 @@ i18nurl=static("ldt/swf/ldt/pkg/i18n") baseurl=static("ldt/swf/ldt/") sform = SearchForm(request.GET) + content_results = None + more_contents = False + + # Now we handle the segment search if sform.is_valid(): search = sform.cleaned_data["search"] field = sform.cleaned_data["field"] + # If the request has a page indicated, we are in segment search + if "page" not in request.GET: + # If not, we are in the first page of results, so we display the first contents + content_searched = get_results_with_context(Content, field, search) + if len(content_searched) > settings.LDT_MEDIA_IN_RESULTS_PAGE : + more_contents = True + content_searched = content_searched[:settings.LDT_MEDIA_IN_RESULTS_PAGE] + content_results = Content.objects.filter(pk__in=[c['indexation_id'] for c in content_searched]).select_related('stat_annotation') + page = sform.cleaned_data["page"] or 1 # If asked, we filter the request with only the contents tagged with content_tag content_tag = sform.cleaned_data["content_tag"] @@ -248,7 +263,12 @@ content_list = TaggedItem.objects.get_by_model(Content.objects.all(), '"'+content_tag+'"') results, nb, nb_segment = get_search_results(request, search, field, page, content_list) - return render_to_response('front/front_search_results.html', {'results': results, 'nb_results' : nb, 'nb_segment':nb_segment, 'search' : search, 'field': field, 'tag_label':content_tag, 'colorurl': colorurl, 'i18nurl': i18nurl, 'language': language_code, 'baseurl': baseurl}, context_instance=RequestContext(request)) + return render_to_response('front/front_search_results.html', { + 'results': results, 'nb_results' : nb, 'nb_segment':nb_segment, 'search' : search, + 'field': field, 'tag_label':content_tag, 'colorurl': colorurl, 'i18nurl': i18nurl, + 'language': language_code, 'baseurl': baseurl, + 'content_results': content_results, 'more_contents': more_contents, + }, context_instance=RequestContext(request)) \ No newline at end of file diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/locale/fr/LC_MESSAGES/django.mo Binary file src/ldt/ldt/locale/fr/LC_MESSAGES/django.mo has changed diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/locale/fr/LC_MESSAGES/django.po --- a/src/ldt/ldt/locale/fr/LC_MESSAGES/django.po Thu Jan 02 17:47:16 2014 +0100 +++ b/src/ldt/ldt/locale/fr/LC_MESSAGES/django.po Fri Jan 03 11:55:31 2014 +0100 @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-11-19 16:45+0000\n" +"POT-Creation-Date: 2014-01-03 10:41+0000\n" "PO-Revision-Date: 2010-03-09 15:52+0100\n" "Last-Translator: Yves-Marie Haussonne \n" "Language-Team: LANGUAGE \n" @@ -253,62 +253,61 @@ msgid "Filter the medias" msgstr "Filtrer les médias" -#: ldt_utils/templates/front/front_all_contents.html:61 -#: ldt_utils/templates/front/front_home.html:51 -msgid "Search in the medias title" -msgstr "Chercher dans le titre des médias" - -#: ldt_utils/templates/front/front_all_contents.html:64 -#: ldt_utils/templates/front/front_all_contents.html:120 -#: ldt_utils/templates/front/front_home.html:54 +#: ldt_utils/templates/front/front_all_contents.html:60 +#: ldt_utils/templates/front/front_all_contents.html:116 +#: ldt_utils/templates/front/front_home.html:50 msgid "All categories of medias" msgstr "Toutes les catégories de médias" -#: ldt_utils/templates/front/front_all_contents.html:72 -#: ldt_utils/templates/front/front_group.html:49 -#: ldt_utils/templates/front/front_search_results.html:138 +#: ldt_utils/templates/front/front_all_contents.html:68 +#: ldt_utils/templates/front/front_group.html:48 +#: ldt_utils/templates/front/front_search_results.html:160 #: ldt_utils/templates/ldt/ldt_utils/search_results.html:105 msgid "previous" msgstr "Précedent" -#: ldt_utils/templates/front/front_all_contents.html:90 -#: ldt_utils/templates/front/front_group.html:67 -#: ldt_utils/templates/front/front_search_results.html:158 +#: ldt_utils/templates/front/front_all_contents.html:86 +#: ldt_utils/templates/front/front_group.html:66 +#: ldt_utils/templates/front/front_search_results.html:180 #: ldt_utils/templates/ldt/ldt_utils/search_results.html:115 msgid "next" msgstr "Suivant" -#: ldt_utils/templates/front/front_all_contents.html:93 -#: ldt_utils/templates/front/front_group.html:70 +#: ldt_utils/templates/front/front_all_contents.html:89 +#: ldt_utils/templates/front/front_group.html:69 msgid "All" msgstr "Tous" -#: ldt_utils/templates/front/front_all_contents.html:102 -#: ldt_utils/templates/front/front_all_contents.html:115 -#: ldt_utils/templates/front/front_group.html:92 -#: ldt_utils/templates/front/front_group.html:94 -#: ldt_utils/templates/front/front_home.html:62 -#: ldt_utils/templates/front/front_home.html:73 -#: ldt_utils/templates/front/front_home.html:90 -#: ldt_utils/templates/front/front_home.html:99 +#: ldt_utils/templates/front/front_all_contents.html:98 +#: ldt_utils/templates/front/front_all_contents.html:111 +#: ldt_utils/templates/front/front_group.html:91 +#: ldt_utils/templates/front/front_group.html:93 +#: ldt_utils/templates/front/front_home.html:58 +#: ldt_utils/templates/front/front_home.html:69 +#: ldt_utils/templates/front/front_home.html:86 +#: ldt_utils/templates/front/front_home.html:95 +#: ldt_utils/templates/front/front_search_results.html:68 +#: ldt_utils/templates/front/front_search_results.html:77 msgid "open this media" msgstr "voir ce média" -#: ldt_utils/templates/front/front_all_contents.html:114 -#: ldt_utils/templates/front/front_group.html:93 -#: ldt_utils/templates/front/front_home.html:72 -#: ldt_utils/templates/front/front_home.html:98 +#: ldt_utils/templates/front/front_all_contents.html:110 +#: ldt_utils/templates/front/front_group.html:92 +#: ldt_utils/templates/front/front_home.html:68 +#: ldt_utils/templates/front/front_home.html:94 +#: ldt_utils/templates/front/front_search_results.html:76 #, python-format msgid "%(nb)s annotation on this media" msgid_plural "%(nb)s annotations on this media" msgstr[0] "%(nb)s annotation sur ce média" msgstr[1] "%(nb)s annotations sur ce média" -#: ldt_utils/templates/front/front_all_contents.html:116 -#: ldt_utils/templates/front/front_group.html:79 -#: ldt_utils/templates/front/front_group.html:95 -#: ldt_utils/templates/front/front_home.html:74 -#: ldt_utils/templates/front/front_home.html:100 +#: ldt_utils/templates/front/front_all_contents.html:112 +#: ldt_utils/templates/front/front_group.html:78 +#: ldt_utils/templates/front/front_group.html:94 +#: ldt_utils/templates/front/front_home.html:70 +#: ldt_utils/templates/front/front_home.html:96 +#: ldt_utils/templates/front/front_search_results.html:78 msgid "by" msgstr "par" @@ -358,52 +357,52 @@ msgid "about" msgstr "A propos" -#: ldt_utils/templates/front/front_group.html:36 +#: ldt_utils/templates/front/front_group.html:35 msgid "Projects shared by the group" msgstr "Projets partagés par le groupe" -#: ldt_utils/templates/front/front_group.html:37 +#: ldt_utils/templates/front/front_group.html:36 #: templates/admin/cms_change_list.html:110 #: templates/admin/page_change_list.html:65 msgid "Filter" msgstr "Filtre" -#: ldt_utils/templates/front/front_group.html:41 +#: ldt_utils/templates/front/front_group.html:40 msgid "Search in the projects title" msgstr "Chercher dans le titre des projets" +#: ldt_utils/templates/front/front_group.html:76 #: ldt_utils/templates/front/front_group.html:77 -#: ldt_utils/templates/front/front_group.html:78 msgid "open this project" msgstr "Ouvrir ce projet" -#: ldt_utils/templates/front/front_group.html:84 -#: ldt_utils/templates/front/front_group.html:119 +#: ldt_utils/templates/front/front_group.html:83 +#: ldt_utils/templates/front/front_group.html:118 msgid "See all the group's medias" msgstr "Voir tous les médias du groupe" -#: ldt_utils/templates/front/front_group.html:88 +#: ldt_utils/templates/front/front_group.html:87 msgid "Medias annotated by the group" msgstr "Médias annotés par le groupe" -#: ldt_utils/templates/front/front_group.html:99 -#: ldt_utils/templates/front/front_group.html:121 +#: ldt_utils/templates/front/front_group.html:98 +#: ldt_utils/templates/front/front_group.html:120 msgid "See all the group's projects" msgstr "Voir tous les projets du groupe" -#: ldt_utils/templates/front/front_group.html:103 +#: ldt_utils/templates/front/front_group.html:102 msgid "Back to the group list" msgstr "Retour à la liste des groupes" -#: ldt_utils/templates/front/front_group.html:111 +#: ldt_utils/templates/front/front_group.html:110 msgid "About the group" msgstr "A propos du groupe" -#: ldt_utils/templates/front/front_group.html:126 +#: ldt_utils/templates/front/front_group.html:125 msgid "Members" msgstr "liste des membres" -#: ldt_utils/templates/front/front_group.html:133 +#: ldt_utils/templates/front/front_group.html:132 msgid "active since" msgstr "actif depuis" @@ -428,31 +427,35 @@ msgid "view all medias" msgstr "Voir tous les médias" -#: ldt_utils/templates/front/front_home.html:83 +#: ldt_utils/templates/front/front_home.html:79 msgid "Most annotated medias" msgstr "Médias les plus annotés" -#: ldt_utils/templates/front/front_home.html:107 +#: ldt_utils/templates/front/front_home.html:103 msgid "Active groups" msgstr "Groupes actifs" -#: ldt_utils/templates/front/front_home.html:112 +#: ldt_utils/templates/front/front_home.html:108 msgid "group picture" msgstr "image du groupe" +#: ldt_utils/templates/front/front_home.html:108 #: ldt_utils/templates/front/front_home.html:112 -#: ldt_utils/templates/front/front_home.html:116 msgid "view more infos on this group" msgstr "Voir plus d'informations sur ce groupe" -#: ldt_utils/templates/front/front_home.html:115 +#: ldt_utils/templates/front/front_home.html:111 #, python-format msgid "%(nb)s user in this group" msgid_plural "%(nb)s users in this group" msgstr[0] "%(nb)s utilisateur dans ce groupe" msgstr[1] "%(nb)s utilisateurs dans ce groupe" -#: ldt_utils/templates/front/front_player.html:49 +#: ldt_utils/templates/front/front_player.html:52 +msgid "Afficher/Masquer les annotations" +msgstr "" + +#: ldt_utils/templates/front/front_player.html:62 msgid "All annotations on the media" msgstr "Toutes les annotations sur le média" @@ -487,40 +490,48 @@ msgid " No results for %(search)s." msgstr "Aucun résultat pour %(search)s." -#: ldt_utils/templates/front/front_search_results.html:73 -#: ldt_utils/templates/front/front_search_results.html:75 -msgid "Search results for " -msgstr "Résultats de recherche pour " +#: ldt_utils/templates/front/front_search_results.html:63 +msgid "Results in medias for" +msgstr "Résultats dans les médias pour" -#: ldt_utils/templates/front/front_search_results.html:80 +#: ldt_utils/templates/front/front_search_results.html:63 +msgid "See all medias" +msgstr "Voir pour tous les médias" + +#: ldt_utils/templates/front/front_search_results.html:95 +#: ldt_utils/templates/front/front_search_results.html:97 +msgid "Results in annotations for" +msgstr "Résultats dans les annotations pour" + +#: ldt_utils/templates/front/front_search_results.html:102 #: ldt_utils/templates/ldt/ldt_utils/search_results.html:62 msgid "Result" msgstr "Résultat" -#: ldt_utils/templates/front/front_search_results.html:81 +#: ldt_utils/templates/front/front_search_results.html:103 msgid "Segment" msgstr "Segment" -#: ldt_utils/templates/front/front_search_results.html:100 +#: ldt_utils/templates/front/front_search_results.html:122 msgid "annotation distribution" msgstr "Répartition des annotations" -#: ldt_utils/templates/front/front_search_results.html:114 -#: ldt_utils/templates/front/front_search_results.html:119 +#: ldt_utils/templates/front/front_search_results.html:136 +#: ldt_utils/templates/front/front_search_results.html:141 msgid "view this annotation in the player" msgstr "Visionner cette annotation" -#: ldt_utils/templates/front/front_search_results.html:115 -#: ldt_utils/templates/front/front_search_results.html:120 +#: ldt_utils/templates/front/front_search_results.html:137 +#: ldt_utils/templates/front/front_search_results.html:142 #: ldt_utils/templates/ldt/ldt_utils/search_results.html:84 msgid "No title" msgstr "Sans titre" -#: ldt_utils/templates/front/front_search_results.html:116 +#: ldt_utils/templates/front/front_search_results.html:138 msgid "Begin" msgstr "Début" -#: ldt_utils/templates/front/front_search_results.html:116 +#: ldt_utils/templates/front/front_search_results.html:138 msgid "duration" msgstr "durée" @@ -1288,25 +1299,25 @@ msgid "confirm deletion" msgstr "Confirmation effacement contenu" -#: ldt_utils/views/workspace.py:119 +#: ldt_utils/views/workspace.py:121 msgid "" "The content does not exists or you are not allowed to access this content" msgstr "Le contenu n'existe pas ou bien vous n'êtes pas autorisé à y accéder" -#: ldt_utils/views/workspace.py:123 +#: ldt_utils/views/workspace.py:125 msgid "Parameters project_id or content_id must be given in the url" msgstr "" "Les paramètres project_id ou content_id doivent être indiqués dans l'url" -#: ldt_utils/views/workspace.py:415 +#: ldt_utils/views/workspace.py:417 msgid "Annotation not found in the xml" msgstr "Annotation non trouvée dans le xml" -#: ldt_utils/views/workspace.py:426 +#: ldt_utils/views/workspace.py:428 msgid "Annotation not found" msgstr "Annotation non trouvée" -#: ldt_utils/views/workspace.py:428 ldt_utils/views/workspace.py:430 +#: ldt_utils/views/workspace.py:430 ldt_utils/views/workspace.py:432 msgid "Project not found" msgstr "Projet non trouvé" @@ -1478,7 +1489,6 @@ msgstr "Aucune disponible" #: templates/admin/index.html:91 templates/admin/page_index.html:72 -#, fuzzy msgid "Unknown content" msgstr "Contenu inconnu" @@ -1591,32 +1601,26 @@ msgstr "texte" #: text/models.py:20 -#, fuzzy msgid "annotation.color" msgstr "couleur" #: text/models.py:21 -#, fuzzy msgid "creator.title" msgstr "titre" #: text/models.py:22 -#, fuzzy msgid "contributor.title" msgstr "titre" #: text/models.py:23 -#, fuzzy msgid "annotation.creation_date" msgstr "date de création" #: text/models.py:24 -#, fuzzy msgid "annotation.update_date" msgstr "Date de maj" #: user/admin.py:20 -#, fuzzy msgid "profile" msgstr "Profils" @@ -1665,9 +1669,8 @@ #: user/templates/ldt/user/change_password.html:50 #: user/templates/ldt/user/change_profile.html:131 -#, fuzzy msgid "New password confirmation" -msgstr "Confirmation de base" +msgstr "Confirmation du mot de passe" #: user/templates/ldt/user/change_password.html:57 #: user/templates/ldt/user/change_profile.html:144 @@ -1725,7 +1728,6 @@ msgstr "Ce champs est obligatoire" #: user/templates/ldt/user/login_form.html:68 -#, fuzzy msgid "reset password" msgstr "Réinitialiser le mot de passe" @@ -1900,7 +1902,6 @@ "les instructions pour en entrer un nouveau." #: user/templates/registration/password_reset_form.html:27 -#, fuzzy msgid "Adresse émail" msgstr "Adresse émail" @@ -1914,7 +1915,6 @@ msgstr "Activer le compte" #: user/templates/registration/registration_active.html:9 -#, fuzzy msgid "" "Vous avez bien activé votre compte, vous pouvez accedez à votre espace " "personnel." @@ -1923,7 +1923,6 @@ "personnel." #: user/templates/registration/registration_active.html:10 -#, fuzzy msgid "retourner à la page de connexion" msgstr "retourner à la page de connexion" @@ -1940,6 +1939,12 @@ "Nous vous avons envoyé par courriel les instructions pour activer le compte " "à l'adresse que vous avez indiquée. Vous devriez le recevoir rapidement." +#~ msgid "Search in the medias title" +#~ msgstr "Chercher dans le titre des médias" + +#~ msgid "Search results for " +#~ msgstr "Résultats de recherche pour " + #~ msgid "Cancel upload" #~ msgstr "Annuler le téléversement" diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/settings.py --- a/src/ldt/ldt/settings.py Thu Jan 02 17:47:16 2014 +0100 +++ b/src/ldt/ldt/settings.py Fri Jan 03 11:55:31 2014 +0100 @@ -87,6 +87,7 @@ LDT_MAX_PROJECTS_PER_PAGE = getattr(settings, 'LDT_MAX_PROJECTS_PER_PAGE', 10) LDT_FRONT_MEDIA_PER_PAGE = getattr(settings, 'LDT_FRONT_MEDIA_PER_PAGE', 9) LDT_FRONT_PROJECTS_PER_PAGE = getattr(settings, 'LDT_FRONT_PROJECTS_PER_PAGE', 12) +LDT_MEDIA_IN_RESULTS_PAGE = getattr(settings, 'LDT_MEDIA_IN_RESULTS_PAGE', 6) AUTO_INDEX_AFTER_SAVE = getattr(settings, 'AUTO_INDEX_AFTER_SAVE', True) LDT_INDEXATION_INSERT_BATCH_SIZE = getattr(settings, 'LDT_INDEXATION_INSERT_BATCH_SIZE', 5000) diff -r 622989468114 -r 9431920e7c98 src/ldt/ldt/static/ldt/css/front_search.css --- a/src/ldt/ldt/static/ldt/css/front_search.css Thu Jan 02 17:47:16 2014 +0100 +++ b/src/ldt/ldt/static/ldt/css/front_search.css Fri Jan 03 11:55:31 2014 +0100 @@ -22,7 +22,7 @@ } #title_resultats h2 { - font-size: 19px; + font-size: 21px; } #li_nb_resultats { @@ -131,4 +131,17 @@ #tl_position { width: 300px; margin: 10px 0; height: 16px; border-bottom: 1px solid #909090; +} + +/* content search */ +#search_contents { + width: 960px; margin: 5px 0; +} + +#search_contents .li_h2 { + width: 960px; margin-right: 10px; +} + +#search_contents .li_media { + width: 140px; } \ No newline at end of file