Ajout formulaire, liens pour login
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage_django / templates / savoirs / recherche.html
CommitLineData
d15017b2
CR
1{% extends "container_base.html" %}
2
3{% block contenu %}
4<script>
5 function urlencode(str) {
6 return escape(str).replace(/\+/g,'%2B').replace(
7 /%20/g, '+').replace(/\*/g, '%2A').replace(
8 /\//g, '%2F').replace(/@/g, '%40');
9 }
10 function makeLink (page) {
11 return "?page=" + page +
12 "&q=" + urlencode ("{{ q }}");
13 }
14
15 $(document).ready(function(){
16 var currentPage = {{ page }};
17 var lastPage = {{ data.last_page }};
18 var more = '{{ data.more_link }}';
19
20 var span = $("#pageLinks");
21 // Premiere page
22 if (currentPage == 0)
23 span.append ('<span class="lien-texte">&lt;&lt;</span>&nbsp;&nbsp;');
24 else
25 span.append ('<a href="' + makeLink(0) +
26 '"><span class="lien-texte">&lt;&lt;</span></a>&nbsp;&nbsp;');
27
28 // Boucle
29 var f = currentPage - 4;
30 var t = 0;
31 if (f < 0) { t = -f; f = 0; }
32 t += currentPage + 4;
33 if (t > lastPage) t = lastPage;
34
35 for (var i = f; i <= t; i++) {
36 var display = i + 1;
37 if (i == currentPage)
38 span.append ("<span>" + display + "</span>&nbsp;&nbsp;");
39 else
40 span.append ('<a href="' + makeLink(i) + '"><span>' +
41 display + '</span></a>&nbsp;&nbsp;');
42 }
43
44 // Derniere page
45 if (currentPage == lastPage)
46 span.append ('<span class="lien-texte">&gt;&gt;</span>');
47 else
48 span.append ('<a href="' + makeLink(lastPage) +
49 '"><span class="lien-texte">&gt;&gt;</span></a>');
50
51 if (more.length > 0)
52 span.append ('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +
53 '<a href="'+more+'"><span class="lien-texte">Plus de résultats</span></a>');
d15017b2
CR
54 });
55
5ecd5424
CR
56 {% if user.is_authenticated %}
57 function showEditModal (uri) {
58 $('#jsonsource').load ('{% url savoirs.views.json_get %}?uri='+uri,
59 function() {
60 __jf = new JSONForm ('schema', 'mainform', 'jsonsource');
61 __jf.setup ();
62 $('#edit-form').dialog({height: 400, width: 650, modal: true});
63 });
64 }
65 {% endif %}
66
d15017b2
CR
67
68 </script>
69
70 <h4>Résultats de recherche pour « {{ q }} » :</h4>
71
72 <div class="zone-texte">
73 {% for r in data.results %}
74 <div class="resultatRecherche">
75 <a class="le-titre" href="{{ r.uri }}">{{ r.title|safe }}</a>
76 <div class="resultatResume">{{ r.content|safe }}</div>
77 <a class="ligne-url" href="{{ r.uri }}">{{ r.uri }}</a>
5ecd5424
CR
78 {% if user.is_authenticated %}
79 <a href="#" onclick="showEditModal('{{ r.id }}'); return false;">EDIT</a>
80 {% endif %}
81 </div>
82 {% empty %}
83 <div class="resultatRecherche">
84 <h2>Aucun résultat trouvé</h2>
d15017b2
CR
85 </div>
86 {% endfor %}
87 </div>
88 <div class="resultatPages">
89 <span id="pageLinks">
90 </span>
91 </div>
92
5ecd5424
CR
93 {% if user.is_authenticated %}
94 {% include "savoirs/editor.html" %}
95 {% endif %}
96
d15017b2 97 {% endblock %}