--- a/src/spel/management/commands/generate_demonstrateur_data.py Mon Nov 03 17:53:20 2014 +0100
+++ b/src/spel/management/commands/generate_demonstrateur_data.py Tue Nov 04 15:03:00 2014 +0100
@@ -80,7 +80,6 @@
reader = csv.reader(datafile)
lines = list(reader)
last_content_id = ""
- last_content_title = ""
count_content = 0
admin = User.objects.filter(is_superuser=True)[0]
@@ -88,6 +87,13 @@
for line in lines:
# Test content id and main annotation id
+ if line[0]!="":
+ content_title = unicode(line[1].decode('utf-8'))
+ prefix = "[demo] "
+ if line[0]=="Duo Brick et Maggy en introduction\n[7-1 à 9-5]":
+ prefix = "[demo1] "
+ elif line[0]=="51-13 à 56.15":
+ prefix = "[demo2] "
content_id = line[1]
pre_annot_id = line[2]
pre_annot_tcin_hms = line[3]
@@ -126,7 +132,6 @@
ps = ProjectJsonSerializer(ctt_source.front_project)
print "project ldt_id = " + ctt_source.front_project.ldt_id
project_source_data = ps.serialize_to_cinelab()
-
if annot_id != "" and project_source_data:
count_content += 1
@@ -140,7 +145,7 @@
# tc_end = post_annot_tcout_ms
# data to create new data
- ctt_title = content_id + (u" 0" if count_content<10 else u" ") + unicode(count_content)
+ ctt_title = prefix + content_title + (u" 0" if count_content<10 else u" ") + unicode(count_content)
media_src = "/data/demonstrateur/"+content_id+"/" + created_ctt_id + ".mp4"
if hasattr(settings, "DEMONSTRATEUR_DOMAIN") and len(settings.DEMONSTRATEUR_DOMAIN)>0:
media_src = settings.DEMONSTRATEUR_DOMAIN + media_src
@@ -153,6 +158,7 @@
duration = created_ctt_dur)
content.is_public = True
update_stat_content(content)
+ content.tags.add("demo_theatre")
# Get content front projet
proj = content.front_project
ps = ProjectJsonSerializer(proj)
@@ -200,165 +206,6 @@
else:
print "Nope"
-
- """
- # Continue
- if do_import:
- print("Parsing folder %s ..." % path)
- for dirpath, dirnames, filenames in os.walk(path):
- #print("Parsing walk %s, %s, %s" % (dirpath, dirnames, filenames))
- for filename in filenames:
- if filename == "cinelab_iri.json":
- ctt_id = os.path.basename(dirpath)
- # dirname is like "acte-1-stuff-thing_1234" and we want "Acte 1 stuff thing"
- content_title = ctt_id.split("_")[0].replace("-"," ").capitalize()
- json_path = os.path.join(dirpath, filename)
- print("Parsing json file %s ..." % json_path)
- json_data = False
- try:
- file_data = open(json_path)
- json_data = json.load(file_data)
- file_data.close()
- except:
- print("Error while parsing json file.")
- if json_data:
- dur = int(json_data["medias"][0]["meta"]["duration"])
- # Save media and content
- media, _ = Media.objects.get_or_create(src="/data/opera/"+ctt_id+"/720p.mp4", duration=dur)
- media.is_public = True
- content = Content.objects.create(iri_id=ctt_id,
- iriurl=ctt_id+u"/"+ctt_id+u".iri",
- media_obj=media,
- title=content_title,
- duration=dur,
- content_creation_date = json_data["meta"]["dc:created"])
- content.is_public = True
- content.tags.add("content_opera")
- # Get content front projet
- proj = content.front_project
- username = proj.owner.username
- now = datetime.utcnow().isoformat()
- # Start data to send to api
- proj_data = {}
- proj_data["meta"] = {}
- proj_data["meta"]["id"] = proj.ldt_id
- proj_data["meta"]["dc:title"] = proj.title
- proj_data["meta"]["dc:creator"] = username
- proj_data["meta"]["dc:description"] = "description added"
- proj_data["meta"]["dc:created"] = json_data["meta"]["dc:created"]
- proj_data["meta"]["dc:modified"] = json_data["meta"]["dc:modified"]
- proj_data["meta"]["dc:contributor"] = username
- proj_data["medias"] = []
- proj_data["medias"].append({"id": content.iri_id})
- # The tags and annotations (main part)
- proj_data["tags"] = []
- proj_data["annotations"] = []
- tags_id_label = {}
- tags_label_id = {}
- for a in json_data["annotations"]:
- # "content": { "data": { "modalites_sceniques": "costumes,décors",... } }
- # Opera management :
- # tag "modalites_sceniques" becomes "opera_modalites_sceniques"
- # tag "mesure" becomes "opera_mesure"
- # tag "personnages" becomes "opera_personnages"
- # tag "scene" becomes "opera_scene"
- # tag "type_travail" becomes "opera_type_travail"
- # tag "acte" becomes "opera_acte"
- if "content" in a and "data" in a["content"] and type(a["content"]["data"]) == type(dict()):
- annot_tags = []
- desc = ""
- title = ""
- # Build tags
- for k,v in a["content"]["data"].iteritems():
- if k!="commentaire" and k!="description" and k!="titre":
- if k=="acte" or k=="scene":
- v = int(v)
- k = "opera_" + k
- v = unicode(v).split(",")
- for val in v:
- val = val.strip()
- tag_label = k + u": " + val
- if val!="":
- if not tag_label in tags_label_id:
- tags_label_id[tag_label] = generate_uuid()
- tags_id_label[tags_label_id[tag_label]] = tag_label
- #logger.debug("CREATED")
- #logger.debug(tags_label_id[tag_label] + " = " + tags_id_label[tags_label_id[tag_label]])
- proj_data["tags"].append({"meta": { "dc:title": tag_label }, "id": tags_label_id[tag_label] })
- annot_tags.append({"id-ref": tags_label_id[tag_label] })
- elif k=="commentaire" or k=="description":
- desc = v
- elif k=="titre":
- title = v
- # Build annotation with needed fields
- proj_data["annotations"].append({
- "content": {
- "mimetype": "application/x-ldt-structured",
- "description": desc,
- # "img": {
- # "src": ""
- # },
- "title": title,
- # "polemics": [ ],
- },
- "begin": a["begin"],
- "meta": {
- # "dc:contributor": "admin",
- "id-ref": a["type"],
- "dc:created": now,
- # "dc:modified": "2014-03-04T16:40:23.609971",
- "dc:creator": username
- },
- "end": a["end"],
- "tags": annot_tags,
- "color": "16763904",
- "media": ctt_id,
- "id": a["id"]
- })
-
- # The annotation-types
- proj_data["annotation-types"] = []
- at_ids = []
- for at in json_data["annotation_types"]:
- proj_data["annotation-types"].append({
- # dc:contributor: "admin",
- "dc:creator": username,
- "dc:title": at["id"],
- "id": at["id"],
- # dc:created: "2014-03-04T14:51:13.907674",
- "dc:description": ""
- # dc:modified: "2014-03-04T14:51:13.907674"
- })
- at_ids.append({ "id-ref": at["id"] })
- # The list of annotation-types
- list_id = generate_uuid()
- proj_data["lists"] = [{
- "items": at_ids,
- "meta": {
- "dc:creator": username,
- "id-ref": ctt_id,
- "dc:title": "SPEL",
- "dc:description": ""
- },
- "id": list_id
- }]
- # The views for default display
- proj_data["views"] = [{
- "id": generate_uuid(),
- "contents": [ ctt_id ],
- "annotation_types": [atid["id-ref"] for atid in at_ids]
- }]
-
- serializr = CinelabSerializer()
- serializr.validate_cinelab_json(proj_data)
- ldt_xml = serializr.cinelab_to_ldt(proj_data)
- proj.ldt = lxml.etree.tostring(ldt_xml, pretty_print=True)
- #logger.debug(proj.ldt)
- proj.save()
- update_stat_content(content)
- else:
- print("Ignoring or not exist.")
- """
# This is the end
print("This is the end.")
\ No newline at end of file
--- a/src/spel/templates/spel_base.html Mon Nov 03 17:53:20 2014 +0100
+++ b/src/spel/templates/spel_base.html Tue Nov 04 15:03:00 2014 +0100
@@ -32,6 +32,8 @@
<li{% if request.path == url %} class="active"{% endif %}><a href="{{ url }}">Opéra</a></li>
{% url 'spel_corpus' as url %}
<li{% if request.path == url %} class="active"{% endif %}><a href="{{ url }}">Corpus</a></li>
+ {% url 'spel_demonstrateur' as url %}
+ <li{% if request.path == url %} class="active"{% endif %}><a href="{{ url }}">Démonstrateur</a></li>
</ul>
</div>
</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/spel/templates/spel_demonstrateur.html Tue Nov 04 15:03:00 2014 +0100
@@ -0,0 +1,183 @@
+{% extends "spel_base.html" %}
+{% load static %}
+
+{% block page_title %}Corpus{% endblock %}
+
+{% block spel_content %}
+ <section style="width: 1070px; margin: 0 auto">
+ <h1>Démonstrateur</h1>
+ <select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
+ <option value="">Sélectionner...</option>
+ {% for c in contents %}
+ <option value="?p={{ c.front_project.ldt_id }}">{{ c.title }}</option>
+ {% endfor %}
+ </select>
+ <ul>
+ </ul>
+ <div id="LdtPlayer"></div>
+ <div id="AnnotationsListContainer"></div>
+ </section>
+ <script type="text/javascript" src="{% static 'spel/lib/jquery.min.js' %}"></script>
+ <script type="text/javascript" src="{% static 'spel/lib/jquery-ui.min.js' %}"></script>
+ <script type="text/javascript" src="{% static 'spel/metadataplayer/LdtPlayer-core.js' %}"></script>
+ <!--script type="text/javascript" src="{% static 'spel/metadataplayer/spel-serializer.js' %}"></script-->
+ <script type="text/javascript">
+ function getURLParameter(name) {
+ return decodeURI(
+ (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
+ );
+ }
+ $(document).ready(function(){
+ // Get group array number
+ var g = getURLParameter("g");
+ var d = getURLParameter("d");
+ var f = getURLParameter("f");
+ var p = getURLParameter("p");// project id
+ if(typeof g=="string"){
+
+ IriSP.libFiles.defaultDir = "{% static 'spel/lib' %}";
+ IriSP.widgetsDir = "{% static 'spel/metadataplayer' %}";
+ var _metadata = {
+ //url: "/data/" + d + "/" + g + "/cinelab" + ( (d!="opera") ? "_iri" : "" ) + ".json",
+ url: "{% url 'projectjson_id' id='' %}" + p,
+ //format: 'spel'
+ format: 'ldt'
+ };
+ var _config = {
+ width : 550,
+ container : 'LdtPlayer',
+ default_options: {
+ metadata: _metadata
+ },
+ css : "{% static 'spel/metadataplayer/LdtPlayer-core.css' %}",
+ widgets: [
+ /*{
+ type: "Title"
+ },*/
+ {
+ type: "HtmlPlayer", /*ou HtmlPlayer si HTML5*/
+ //video: "/data/" + d + "/" + g + "/" + f,
+ height: 320
+ },
+ { type: "Slider" },
+ { type: "Controller" },
+ {
+ type: "MultiSegments",
+ //annotation_type: ["performance","discussion"]
+ },
+ /*{
+ type: "Annotation",
+ show_social: false,
+ show_annotation_type: true,
+ annotation_type: ["performance","discussion"]
+ },*/
+ {
+ type: "Polemic",
+ annotation_type: "interpretation",
+ only_allow_zero_duration_annotations: false,
+ polemics: [
+ {
+ keywords: [ "type_inter: type_inter: performance d'un(e) comédien(ne)" ],
+ color: "#c00000"
+ },
+ {
+ keywords: [ "type_inter: Interpétation alternative de mise en scène" ],
+ color: "#008000"
+ },
+ {
+ keywords: [ "type_inter: Intervention de la technique" ],
+ color: "#0000f0"
+ },
+ {
+ keywords: [ "type_inter: intervention MES" ],
+ color: "#a6cee3"
+ },
+ {
+ keywords: [ "type_inter: Adaptation du texte" ],
+ color: "#1f78b4"
+ },
+ {
+ keywords: [ "type_inter: scène reprise" ],
+ color: "#b2df8a"
+ },
+ {
+ keywords: [ "type_inter: Identification d'un problème" ],
+ color: "#33a02c"
+ },
+ {
+ keywords: [ "type_inter: Improvisation" ],
+ color: "#fb9a99"
+ },
+ {
+ keywords: [ "type_inter: Décision" ],
+ color: "#e31a1c"
+ },
+ {
+ keywords: [ "type_inter: Allemande de la scène" ],
+ color: "#fdbf6f"
+ },
+ {
+ keywords: [ "type_inter: Filage de la scène" ],
+ color: "#ff7f00"
+ },
+ {
+ keywords: [ "type_inter: Question d'espace" ],
+ color: "#cab2d6"
+ },
+ {
+ keywords: [ "type_inter: Conflit" ],
+ color: "#6a3d9a"
+ },
+ {
+ keywords: [ "type_inter: Référence au réel" ],
+ color: "#ffff99"
+ },
+ {
+ keywords: [ "type_inter: Adaptation du texte" ],
+ color: "#b15928"
+ },
+ {
+ keywords: [ "type_inter: Parole à l'acteur/acrtrice" ],
+ color: "#8e0152"
+ },
+ {
+ keywords: [ "type_inter: Demande d'un(e) comédien(ne)" ],
+ color: "#7f3b08"
+ },
+ {
+ keywords: [ "type_inter: Doutes" ],
+ color: "#80cdc1"
+ },
+ {
+ keywords: [ "type_inter: Intervention assistant metteur en scène" ],
+ color: "#ffffcc"
+ },
+ {
+ keywords: [ "type_inter: Remise en cause" ],
+ color: "#0000f0"
+ },
+ ]
+ },/*
+ {
+ type: "Annotation",
+ annotation_type: "interpretation",
+ show_social: false,
+ arrow_position: 0
+ },*/
+ {
+ type: "SpelSyncHtml",
+ container: "AnnotationsListContainer",
+ height: 600,
+ width: 500,
+ src: ( (d!="opera") ? "{% url 'spel_ctb' %}" : "")
+ },
+ {
+ type: "Mediafragment"
+ }
+ ]
+ };
+ _myPlayer = new IriSP.Metadataplayer(_config);
+ }
+ });
+ </script>
+{% endblock %}
\ No newline at end of file
--- a/src/spel/templates/spel_home.html Mon Nov 03 17:53:20 2014 +0100
+++ b/src/spel/templates/spel_home.html Tue Nov 04 15:03:00 2014 +0100
@@ -6,4 +6,6 @@
{% block spel_content %}
<p><a href="{% url 'spel_theatre' %}">Théâtre</a></p>
<p><a href="{% url 'spel_opera' %}">Opéra</a></p>
+ <p><a href="{% url 'spel_corpus' %}">Corpus</a></p>
+ <p><a href="{% url 'spel_demonstrateur' %}">Démonstrateur</a></p>
{% endblock %}
--- a/src/spel/urls.py Mon Nov 03 17:53:20 2014 +0100
+++ b/src/spel/urls.py Tue Nov 04 15:03:00 2014 +0100
@@ -6,7 +6,7 @@
from django.views.generic import RedirectView, TemplateView
from ldt.auth.views import login as pf_login
from ldt.text import VERSION_STR
-from .views import AnnotationRequest, ChapterRequest, Theatre, Opera, OperaRequest, JsonRdfExport
+from .views import AnnotationRequest, ChapterRequest, Theatre, Opera, OperaRequest, JsonRdfExport, Demonstrateur
#from django.conf import settings
@@ -53,6 +53,7 @@
url(r'^player', TemplateView.as_view(template_name="spel_player.html"), name='spel_player'),
url(r'^opera$', Opera.as_view(), name='spel_opera'),
url(r'^operaannotations$', OperaRequest.as_view(), name='spel_opera_annotations'),
+ url(r'^demonstrateur$', Demonstrateur.as_view(), name='spel_demonstrateur'),
)
urlpatterns += staticfiles_urlpatterns()
--- a/src/spel/views.py Mon Nov 03 17:53:20 2014 +0100
+++ b/src/spel/views.py Tue Nov 04 15:03:00 2014 +0100
@@ -516,4 +516,14 @@
return resp
return project_json_id(request, id)
+
+
+class Demonstrateur(TemplateView):
+ template_name = "spel_demonstrateur.html"
+ def get(self, request):
+ # Get start and end for date bounds (earliest is available only on django 1.6)
+ contents = Content.objects.filter(tags__name__in=["demo_theatre"]).select_related("front_project__ldt_id").order_by("creation_date")
+ context = { "contents": contents }
+ return self.render_to_response(context)
+
\ No newline at end of file