Prepare url, front.py, js and template to load annotation preview.
--- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Tue Jan 24 14:55:05 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Tue Jan 24 16:03:14 2012 +0100
@@ -33,6 +33,9 @@
"stats" : [{{ res.content.stat_annotation }}],
},{% endfor %}
];
+
+ var global_csrf_token = "{{ csrf_token }}";
+ var annot_preview_url = "{% url ldt.ldt_utils.views.front.annotation_preview content_iri_id='__CONTENT_IRI_ID__' project_id='__PROJECT_ID__' cutting_id='__CUTTING_ID__' annot_id='__ANNOT_ID__' %}";
</script>
<script src="{{LDT_MEDIA_PREFIX}}js/Ldt_front_search_results.js" type="text/javascript"></script>
--- a/src/ldt/ldt/ldt_utils/urls.py Tue Jan 24 14:55:05 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/urls.py Tue Jan 24 16:03:14 2012 +0100
@@ -48,6 +48,7 @@
url(r'^front/search/$', 'views.front.search_index'),
url(r'^front/searchListing', 'views.front.search_listing'),
url(r'^front/medias', 'views.front.all_contents'),
+ url(r'^annotpreview/(?P<content_iri_id>.*)/(?P<project_id>.*)/(?P<cutting_id>.*)/(?P<annot_id>.*)$', 'views.front.annotation_preview'),
)
urlpatterns += patterns('',
--- a/src/ldt/ldt/ldt_utils/views/front.py Tue Jan 24 14:55:05 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/views/front.py Tue Jan 24 16:03:14 2012 +0100
@@ -2,7 +2,7 @@
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import Group, User
from django.core.urlresolvers import reverse
-from django.http import HttpResponseServerError
+from django.http import HttpResponse, HttpResponseServerError
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from guardian.shortcuts import get_objects_for_group
@@ -129,4 +129,11 @@
return Tag.objects.cloud_for_model(Content, steps=steps)[:limit]
+def annotation_preview(request, content_iri_id, project_id, cutting_id, annot_id):
+ return HttpResponse("coucou<br/>content_iri_id = " + content_iri_id +
+ "<br/>project_id = " + project_id +
+ "<br/>cutting_id = " + cutting_id +
+ "<br/>annot_id = " + annot_id)
+
+
--- a/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Tue Jan 24 14:55:05 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Tue Jan 24 16:03:14 2012 +0100
@@ -71,5 +71,20 @@
}).css({
"opacity" : ".5",
});
+ }).click(function() {
+ var url = annot_preview_url.replace('__CONTENT_IRI_ID__', "ctt_iri_id");
+ url = url.replace('__PROJECT_ID__', "project_id");
+ url = url.replace('__CUTTING_ID__', "cutting_id");
+ url = url.replace('__ANNOT_ID__', "annot_id");
+ $.ajax({
+ url: url,
+ type: 'GET',
+ data: {csrfmiddlewaretoken:global_csrf_token},
+ // bug with jquery >= 1.5, "json" adds a callback so we don't specify dataType
+ //dataType: 'json',
+ success: function(data, status, request) {
+ $("#result_preview").html(data);
+ }
+ });
});
});
\ No newline at end of file