# HG changeset patch # User ymh # Date 1276136084 -7200 # Node ID 881514514df177ddc36bb38599ae3ec9377a52b3 # Parent 7256b057c1802bfad38cf30be2ac1245751ffa75 create iri and serialize diff -r 7256b057c180 -r 881514514df1 web/eulalie/templates/base.html --- a/web/eulalie/templates/base.html Tue Jun 08 15:51:07 2010 +0200 +++ b/web/eulalie/templates/base.html Thu Jun 10 04:14:44 2010 +0200 @@ -6,11 +6,11 @@ - {% block title %}Tic-Tac{% endblock %} + {% block title %}Eulalie{% endblock %} {% block js_import %} - + {% endblock %} {% block css_import %} @@ -20,8 +20,8 @@ - - + + {% endblock %} {% block js_declaration %} @@ -33,7 +33,7 @@ diff -r 7256b057c180 -r 881514514df1 web/eulalie/templates/eulalie/workspace.html --- a/web/eulalie/templates/eulalie/workspace.html Tue Jun 08 15:51:07 2010 +0200 +++ b/web/eulalie/templates/eulalie/workspace.html Thu Jun 10 04:14:44 2010 +0200 @@ -55,8 +55,8 @@ {% for content in contents %} {{ content.title }} - {% trans "open ldt" %} - {% trans "create project" %} + {% trans "open ldt" %} + {% trans "create project" %} {% endfor %} @@ -68,8 +68,8 @@ {% for project in projects %} {{ project.title }} - {% trans "open ldt" %} - {% trans "copy project" %} + {% trans "open ldt" %} + {% trans "copy project" %} {% endfor %} diff -r 7256b057c180 -r 881514514df1 web/eulalie/templates/ldt/user/login_form.html --- a/web/eulalie/templates/ldt/user/login_form.html Tue Jun 08 15:51:07 2010 +0200 +++ b/web/eulalie/templates/ldt/user/login_form.html Thu Jun 10 04:14:44 2010 +0200 @@ -4,7 +4,7 @@ {{block.super}} - - - - - -
 
- - - diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt/ldt_list.html --- a/web/ldt/ldt_utils/templates/ldt/ldt/ldt_list.html Tue Jun 08 15:51:07 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -{% extends "ldt/user/user_base.html" %} {# list of projects ldt #} {% -load i18n %} {% block js_import %}{{ block.super }} - - -{% endblock %} {% block css_import %} {{ block.super }} - -{% endblock %} {% block breadcrumb %} -
  • -
  • {% trans -"Space" %}
  • -
  • {% trans "Ldt Project" %}
  • -{% endblock %} {% block content_title %}{% trans "Ldt Project" %}{% -endblock %} {% block iricontent %} -
    {% -trans 'Create new project'%} - - - - - - - - - - {% for ldt in ldtProjects %} - - - {% ifequal ldt.state 2%} - - {% else %} - - {% endifequal %} - - {% endfor %} - -
    {% trans "Project" %}
    {% trans "title" %}{% trans " published" %}
    {{ ldt.title }}TrueFalse
    -
    -{% endblock %} - diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt/loading.html --- a/web/ldt/ldt_utils/templates/ldt/ldt/loading.html Tue Jun 08 15:51:07 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ - - - - - - - -
    -
    loading
    -
    - - diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt/save_done.html --- a/web/ldt/ldt_utils/templates/ldt/ldt/save_done.html Tue Jun 08 15:51:07 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -

    done

    -

    {{ldt}} -

    -

    {{id}}

    -

    title:{{title}}

    \ No newline at end of file diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt_utils/copy_ldt.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/copy_ldt.html Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,18 @@ +{% load i18n %} {# form of copy of project ldt #} + + + + + + + +
    +
    {% trans "Copy your project" %}
    +
    {% csrf_token %}
    +
    + + diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,28 @@ +{% load i18n %} {# form of creation of project ldt #} + + + + + + + +
    +
    {% trans "Create your project" %}
    +
    {% csrf_token %} + +
    {% trans "List of contents" %}
    +
      + {% for content in contents %} +
    • {{content.iri_id}}
    • + {% endfor %} +
    + +
    +
    + + diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt_utils/init_ldt.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/init_ldt.html Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,51 @@ + + + + + + + +Ligne de Temps - IRI + + + + + + +
     
    + + + diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt_utils/ldt_list.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/ldt_list.html Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,80 @@ +{% extends "ldt/user/user_base.html" %} {# list of projects ldt #} {% +load i18n %} {% block js_import %}{{ block.super }} + + +{% endblock %} {% block css_import %} {{ block.super }} + +{% endblock %} {% block breadcrumb %} +
  • +
  • {% trans +"Space" %}
  • +
  • {% trans "Ldt Project" %}
  • +{% endblock %} {% block content_title %}{% trans "Ldt Project" %}{% +endblock %} {% block iricontent %} +
    {% +trans 'Create new project'%} + + + + + + + + + + {% for ldt in ldtProjects %} + + + {% ifequal ldt.state 2%} + + {% else %} + + {% endifequal %} + + {% endfor %} + +
    {% trans "Project" %}
    {% trans "title" %}{% trans " published" %}
    {{ ldt.title }}TrueFalse
    +
    +{% endblock %} + diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt_utils/loading.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/loading.html Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,26 @@ + + + + + + + +
    +
    loading
    +
    + + diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt_utils/save_done.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/save_done.html Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,5 @@ +

    done

    +

    {{ldt}} +

    +

    {{id}}

    +

    title:{{title}}

    \ No newline at end of file diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/templates/ldt/ldt_utils/search_form.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/search_form.html Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,13 @@ +{% extends "base.html" %} {% block content %} + +
    + + + {{ form.as_table }} +
    +
    + + +{% endblock %} diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/urls.py --- a/web/ldt/ldt_utils/urls.py Tue Jun 08 15:51:07 2010 +0200 +++ b/web/ldt/ldt_utils/urls.py Thu Jun 10 04:14:44 2010 +0200 @@ -18,6 +18,8 @@ url(r'^search/loading/$', 'views.loading'), url(r'^create/(?P.*)$', 'views.create_project'), url(r'^copy/(?P.*)$', 'views.copy_project'), + url(r'^cljson/id/(?P.*)$', 'views.project_json_id'), + url(r'^cljson/externalid/(?P.*)$', 'views.project_json_externalid'), ) if test_ldt(): diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/utils.py --- a/web/ldt/ldt_utils/utils.py Tue Jun 08 15:51:07 2010 +0200 +++ b/web/ldt/ldt_utils/utils.py Thu Jun 10 04:14:44 2010 +0200 @@ -12,6 +12,7 @@ import xml.xpath import os import os.path +import datetime class LdtSearch(object): @@ -264,4 +265,81 @@ new_project.ldt = dom.documentElement.toprettyxml() #save Project new_project.save() - return new_project + return new_project + +def create_iri(file, content, username): + + writer = MarkupWriter(file, indent = u"yes") + writer.startDocument() + writer.startElement(u"iri") + + writer.startElement(u"head") + + writer.simpleElement(u'meta', attributes={'name':'id', 'content':content.iri_id}) + writer.simpleElement(u'meta', attributes={'name':'title', 'content':content.title}) + writer.simpleElement(u'meta', attributes={'name':'author', 'content':username}) + writer.simpleElement(u'meta', attributes={'name':'contributor', 'content':username}) + writer.simpleElement(u'meta', attributes={'name':'date', 'content':datetime.date.utcnow().isoformat()}) + writer.simpleElement(u'meta', attributes={'name':'copyright', 'content':'IRI'}) + writer.simpleElement(u'meta', attributes={'name':'type', 'content':'video'}) + + writer.endElement(u"head") + + writer.startElement(u"body") + + writer.startElement(u"ensembles") + ensemble_id = unicode(uuid.uuid1()) + writer.startElement(u"ensemble", + attributes = { + 'label':'undefined', + 'date':datetime.date.utcnow().isoformat(), + 'title':'autogenerated', + 'abstract':'auto generated', + 'id':ensemble_id, + 'author':username + }) + decoupage_id = unicode(uuid.uuid1()) + writer.startElement(u"decoupage", + attributes = { + 'height' : '10', + 'dur':content.duration, + 'type':'regular', + 'date':datetime.date.utcnow().isoformat(), + 'id':decoupage_id, + 'author':username + }) + + writer.startElement(u"title") + writer.text(u'autogenerated') + writer.endElement(u"title") + writer.startElement(u"abstract") + writer.text(u'autogenerated') + writer.endElement(u"abstract") + + writer.endElement(u"decoupage") + writer.endElement(u"ensemble") + writer.endElement(u"ensembles") + + writer.simpleElement('links') + writer.startElement(u"medias") + + writer.startElement(u"media", attributes={'id':'video'}) + writer.simpleElement(u'video', attributes={'src':content.videopath,'id':uuid.uuid1(),'dur':content.duration,'begin':0}) + writer.endElement(u"media") + + writer.startElement(u"media", attributes={'id':'tool'}) + writer.simpleElement('tool') + writer.endElement(u"media") + + writer.endElement(u"medias") + + writer.startElement('display') + writer.simpleElement('decoupage', attributes={'position':'1', 'id':decoupage_id, 'idensemble':ensemble_id}) + writer.endElement('display') + + writer.endElement(u"body") + + + writer.endElement(u"iri") + writer.endDocument() + diff -r 7256b057c180 -r 881514514df1 web/ldt/ldt_utils/views.py --- a/web/ldt/ldt_utils/views.py Tue Jun 08 15:51:07 2010 +0200 +++ b/web/ldt/ldt_utils/views.py Thu Jun 10 04:14:44 2010 +0200 @@ -11,6 +11,7 @@ from models import * from utils import * from contentindexer import * +from projectserializer import * from string import Template from Ft.Xml import MarkupWriter import cgi @@ -25,7 +26,7 @@ def searchForm(request): form = SearchForm() - return render_to_response('ldt/ldt/search_form.html',{'form': form} , context_instance=RequestContext(request)) + return render_to_response('ldt/ldt_utils/search_form.html',{'form': form} , context_instance=RequestContext(request)) def searchIndex(request): @@ -182,6 +183,36 @@ resp.write(project.ldt) return resp + +def project_json_id(request, id): + + project = Project.objects.get(ldt_id=id) + + return project_json(request, project) + +def project_json_externalid(request, id): + + project = Project.objects.get(external_id=id) + + return project_json(request, project) + + + +def project_json(request, project): + + resp = HttpResponse(mimetype="application/json; charset=utf-8") + resp['Cache-Control']='no-cache, must-revalidate' + resp['Pragma']='no-cache' + + ps = ProjectSerializer(project) + project_dict = ps.serialize_to_cinelab() + + json_serializer = serializers.get_serializer("json")() + json_serializer.serialize(project_array, ensure_ascii=False, stream=resp) + + return resp + + def save_ldtProject(request): if request.method=="POST": ldt = request.POST['ldt'] diff -r 7256b057c180 -r 881514514df1 web/ldt/media/css/dashboard.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/media/css/dashboard.css Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,5 @@ + +#content-main-app-ldt-utils { + float: left; + width: 100%; +} \ No newline at end of file diff -r 7256b057c180 -r 881514514df1 web/ldt/templatetags/iriusermedia.py --- a/web/ldt/templatetags/iriusermedia.py Tue Jun 08 15:51:07 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -from django.template import Library - -register = Library() - -def ldt_media_prefix(): - """ - Returns the string contained in the setting LDT_MEDIA_PREFIX. - """ - try: - from django.conf import settings - except ImportError: - return '' - return settings.LDT_MEDIA_PREFIX -ldt_media_prefix = register.simple_tag(ldt_media_prefix) diff -r 7256b057c180 -r 881514514df1 web/ldt/templatetags/ldtmedia.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/ldt/templatetags/ldtmedia.py Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,14 @@ +from django.template import Library + +register = Library() + +def ldt_media_prefix(): + """ + Returns the string contained in the setting LDT_MEDIA_PREFIX. + """ + try: + from django.conf import settings + except ImportError: + return '' + return settings.LDT_MEDIA_PREFIX +ldt_media_prefix = register.simple_tag(ldt_media_prefix) diff -r 7256b057c180 -r 881514514df1 web/ldt/user/templates/registration/registration_form.html --- a/web/ldt/user/templates/registration/registration_form.html Tue Jun 08 15:51:07 2010 +0200 +++ b/web/ldt/user/templates/registration/registration_form.html Thu Jun 10 04:14:44 2010 +0200 @@ -12,7 +12,7 @@ {% block iricontent%}
    {% csrf_token %}
      -{{form.as_ul}} + {{form.as_ul}}
    diff -r 7256b057c180 -r 881514514df1 web/static/ldt/css/dashboard.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/static/ldt/css/dashboard.css Thu Jun 10 04:14:44 2010 +0200 @@ -0,0 +1,5 @@ + +#content-main-app-ldt-utils { + float: left; + width: 100%; +} \ No newline at end of file