create iri and serialize
authorymh <ymh.work@gmail.com>
Thu, 10 Jun 2010 04:14:44 +0200
changeset 7 881514514df1
parent 6 7256b057c180
child 8 d0a1c6d22b0e
create iri and serialize
web/eulalie/templates/base.html
web/eulalie/templates/eulalie/workspace.html
web/eulalie/templates/ldt/user/login_form.html
web/eulalie/templates/registration/login.html
web/ldt/ldt_utils/admin.py
web/ldt/ldt_utils/models.py
web/ldt/ldt_utils/templates/admin/ldt/app_action.html
web/ldt/ldt_utils/templates/admin/ldt/app_index.html
web/ldt/ldt_utils/templates/admin/ldt/content/reindex_form.html
web/ldt/ldt_utils/templates/admin/ldt/content/search_form.html
web/ldt/ldt_utils/templates/admin/ldt/content/upload_form.html
web/ldt/ldt_utils/templates/admin/ldt_utils/app_action.html
web/ldt/ldt_utils/templates/admin/ldt_utils/app_index.html
web/ldt/ldt_utils/templates/admin/ldt_utils/content/reindex_form.html
web/ldt/ldt_utils/templates/admin/ldt_utils/content/upload_form.html
web/ldt/ldt_utils/templates/ldt/ldt/copy_ldt.html
web/ldt/ldt_utils/templates/ldt/ldt/create_ldt.html
web/ldt/ldt_utils/templates/ldt/ldt/init_ldt.html
web/ldt/ldt_utils/templates/ldt/ldt/ldt_list.html
web/ldt/ldt_utils/templates/ldt/ldt/loading.html
web/ldt/ldt_utils/templates/ldt/ldt/save_done.html
web/ldt/ldt_utils/templates/ldt/ldt_utils/copy_ldt.html
web/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html
web/ldt/ldt_utils/templates/ldt/ldt_utils/init_ldt.html
web/ldt/ldt_utils/templates/ldt/ldt_utils/ldt_list.html
web/ldt/ldt_utils/templates/ldt/ldt_utils/loading.html
web/ldt/ldt_utils/templates/ldt/ldt_utils/save_done.html
web/ldt/ldt_utils/templates/ldt/ldt_utils/search_form.html
web/ldt/ldt_utils/urls.py
web/ldt/ldt_utils/utils.py
web/ldt/ldt_utils/views.py
web/ldt/media/css/dashboard.css
web/ldt/templatetags/iriusermedia.py
web/ldt/templatetags/ldtmedia.py
web/ldt/user/templates/registration/registration_form.html
web/static/ldt/css/dashboard.css
--- 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 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{{LANGUAGE_CODE}}" lang="{{LANGUAGE_CODE}}">
 <head>
     <meta http-equiv="content-language" content="{{LANGUAGE_CODE}}" />
-    <title>{% block title %}Tic-Tac{% endblock %}</title>
+    <title>{% block title %}Eulalie{% endblock %}</title>
     {% block js_import %}
     <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.min.js"></script>
     <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.nyroModal.min.js"></script>
-    <script type="text/javascript" src="{{IRIUSER_MEDIA_PREFIX}}js/jquery.validate.js" ></script>
+    <script type="text/javascript" src="{{LDT_MEDIA_PREFIX}}js/jquery.validate.js" ></script>
     {% endblock %}
     {% block css_import %}
     <link rel="stylesheet" href="{{BASE_URL}}static/css/blueprint/screen.css" type="text/css" media="screen, projection" />
@@ -20,8 +20,8 @@
     <![endif]-->
     <link rel="stylesheet" href="{{BASE_URL}}static/css/style.css" type="text/css"/>
     <link rel="stylesheet" href="{{BASE_URL}}static/css/nyroModal.css" type="text/css"/>
-    <link rel="stylesheet" href="{{IRIUSER_MEDIA_PREFIX}}/css/style.css" type="text/css"/>
-    <link rel="stylesheet" href="{{IRIUSER_MEDIA_PREFIX}}/js/login_ajax/login_ajax.css" type="text/css"/>
+    <link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}/css/style.css" type="text/css"/>
+    <link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}/js/login_ajax/login_ajax.css" type="text/css"/>
     {% endblock %}
     
     {% block js_declaration %}
@@ -33,7 +33,7 @@
 	<div id="header" class="span-24 last">      
 		{% block header %}
 		<div id="header_left">
-                   <a href="{% url eulalie.views.workspace %}">TIC-TAC</a>
+                   <a href="{% url eulalie.views.workspace %}">Eulalie</a>
 		</div>
 		{% endblock %}
 	</div>
--- 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 %}
     <tr>
         <td>{{ content.title }}</td>
-        <td><a href="{% url iriuser.ldt.views.index content.iri_id %}" class="ldt_link">{% trans "open ldt" %}</a></td>
-        <td><a href="{% url iriuser.ldt.views.create_project content.iri_id %}" class="ldt_link_create">{% trans "create project" %}</a></td>
+        <td><a href="{% url ldt.ldt_utils.views.index content.iri_id %}" class="ldt_link">{% trans "open ldt" %}</a></td>
+        <td><a href="{% url ldt.ldt_utils.views.create_project content.iri_id %}" class="ldt_link_create">{% trans "create project" %}</a></td>
     </tr>
 {% endfor %}
 </table>
@@ -68,8 +68,8 @@
 {% for project in projects %}
     <tr>
         <td>{{ project.title }}</td>
-        <td><a href="{% url iriuser.ldt.views.indexProject project.ldt_id %}" class="ldt_link">{% trans "open ldt" %}</a></td>
-        <td><a href="{% url iriuser.ldt.views.copy_project project.ldt_id %}" class="ldt_link_create">{% trans "copy project" %}</a></td>
+        <td><a href="{% url ldt.ldt_utils.views.indexProject project.ldt_id %}" class="ldt_link">{% trans "open ldt" %}</a></td>
+        <td><a href="{% url ldt.ldt_utils.views.copy_project project.ldt_id %}" class="ldt_link_create">{% trans "copy project" %}</a></td>
     </tr>
 {% endfor %}
 </table>
--- 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}}
 
     <script language="javascript">
-    var url_login_ajax='{{WEB_URL}}{% url iriuser.user.views.loginAjax %}';
+    var url_login_ajax='{{WEB_URL}}{% url ldt.user.views.loginAjax %}';
     {% if reload %}    
         var reload=true;    
     {% else %}
@@ -29,12 +29,12 @@
     <ul class="usertool">
         {% if user.is_authenticated %}    
             <li id="user">{{user.username}}</li>
-            <li><a href="{% url iriuser.user.views.profile  %}" >{% trans "Profiles" %}</a> </li>
-            <li><a href="{% url iriuser.user.views.space %}">{% trans "Space" %}</a></li>
+            <li><a href="{% url ldt.user.views.profile  %}" >{% trans "Profiles" %}</a> </li>
+            <li><a href="{% url ldt.user.views.space %}">{% trans "Space" %}</a></li>
             {% if user.is_superuser %}
             <li><a href="{% url registration.views.register  %}" >{% trans "Create an account" %}</a></li>
             {% endif %}
-            <li><a href="{% url iriuser.user.views.logout_view %}" >{% trans "Log out" %}</a></li>  
+            <li><a href="{% url ldt.user.views.logout_view %}" >{% trans "Log out" %}</a></li>  
         
         {% else %}     
             <li><a href="#inlineContent" class="login_link">{% trans "Log in" %}</li>
--- a/web/eulalie/templates/registration/login.html	Tue Jun 08 15:51:07 2010 +0200
+++ b/web/eulalie/templates/registration/login.html	Thu Jun 10 04:14:44 2010 +0200
@@ -19,7 +19,7 @@
 
         <form action="" method='post' id="login-form">
             {% csrf_token %}
-            <input type="hidden" name="next" value="{% url iriuser.user.views.profile%}" />            
+            <input type="hidden" name="next" value="{% url ldt.user.views.profile%}" />            
         <ul id="login_fields_list">
         {{form.as_ul}}
         <li><input class="button"type="submit" value="{% trans "login" %}" /></li>
--- a/web/ldt/ldt_utils/admin.py	Tue Jun 08 15:51:07 2010 +0200
+++ b/web/ldt/ldt_utils/admin.py	Thu Jun 10 04:14:44 2010 +0200
@@ -41,7 +41,7 @@
         else:
             form = LdtImportForm()
             args = {'form': form, 'current_app': self.admin_site.name, 'current_action' : 'import_file'}
-        return render_to_response('admin/ldt/content/upload_form.html', args, context_instance=RequestContext(request))
+        return render_to_response('admin/ldt_utils/content/upload_form.html', args, context_instance=RequestContext(request))
 
     def reindex(self, request):
         message = None
@@ -65,7 +65,7 @@
         else:
             form = ReindexForm()
     
-        return render_to_response('admin/ldt/content/reindex_form.html', {'form': form, 'message':message, 'current_app': self.admin_site.name, 'current_action' : 'reindex' }, context_instance=RequestContext(request))
+        return render_to_response('admin/ldt_utils/content/reindex_form.html', {'form': form, 'message':message, 'current_app': self.admin_site.name, 'current_action' : 'reindex' }, context_instance=RequestContext(request))
 
     def get_urls(self):
         urls = super(ContentAdmin, self).get_urls()
--- a/web/ldt/ldt_utils/models.py	Tue Jun 08 15:51:07 2010 +0200
+++ b/web/ldt/ldt_utils/models.py	Thu Jun 10 04:14:44 2010 +0200
@@ -2,7 +2,9 @@
 from django.conf import settings
 from ldt.core.models import Document, Owner
 from django.utils.translation import ugettext_lazy as _
-from utils import create_ldt, copy_ldt
+from utils import create_ldt, copy_ldt, create_iri
+import os
+import os.path
 import uuid
 
 class Author(models.Model):
@@ -42,7 +44,19 @@
         super(Content, self).delete()
         writer = lucene.IndexWriter(STORE, ANALYZER, True, lucene.IndexWriter.MaxFieldLength.UNLIMITED)
         writer.deleteDocuments(lucene.Term("iri_id", self.iri_id))
-        writer.commit() 
+        writer.commit()
+        
+    def save(self):
+        # create iri file if needed
+        iri_file_path = self.iri_file_path()
+        if not os.path.exists(iri_file_path):
+            dir = os.path.dirname(iri_file_path)
+            if not os.path.exists(dir):
+                os.makedirs(dir)
+            file = open(iri_file_path,"w")
+            create_iri(file, self, "IRI")
+        # update it 
+        super(Content, self).save()
     
     def __unicode__(self):
         return str(self.id) + ": " + self.iri_id
@@ -52,6 +66,12 @@
             return self.iriurl
         else:
             return unicode(web_url) + unicode(settings.MEDIA_URL)+u"media/ldt/"+unicode(self.iriurl)
+    
+    def iri_file_path(self):
+        return os.path.join(os.path.join(os.path.join(os.path.join(settings.MEDIA_ROOT, "media"), "ldt"), self.iri_id), os.path.basename(self.iri.path))
+
+    def iri_url_template(self):
+        return "${web_url}${media_url}media/ldt/" + unicode(self.iri_id) + "/" + os.path.basename(self.iri.path)
         
         
 class Project(Document):  
@@ -74,6 +94,20 @@
     
     def __unicode__(self):
         return unicode(self.id) + u": " + unicode(self.ldt_id)
+    
+    def get_description(self, doc=None):
+        
+        if doc is None:
+            doc = xml.dom.minidom.parseString(self.ldt)
+            doc = Ft.Xml.Domlette.ConvertDocument(doc)        
+        
+        con = xml.xpath.Context.Context(doc, 1, 1, None)
+        res = xml.xpath.Evaluate("/iri/project", context=con)
+        if len(res) > 0:
+            return res[0].getAttributeNS(None, 'abstract')
+        else:
+            return None
+        
 
     @staticmethod
     def create_project(user, title, contents):
--- a/web/ldt/ldt_utils/templates/admin/ldt/app_action.html	Tue Jun 08 15:51:07 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-{% extends "admin/base_site.html" %} {% load i18n %} {% block
-breadcrumbs %}
-<div class="breadcrumbs"><a href="{% url admin:index %}"> {%
-trans "Home" %}</a> &rsaquo; <a href="{% url admin:app_list 'ldt' %}">
-ldt</a> &rsaquo; {{ current_action }}</div>
-{% endblock %}
-
--- a/web/ldt/ldt_utils/templates/admin/ldt/app_index.html	Tue Jun 08 15:51:07 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-{% extends "admin/app_index.html" %} {% load i18n %} {% block content %}
-{{ block.super }}
-
-<div class="module">
-<table summary="Import">
-	<caption>Import</caption>
-	<tr>
-		<th><a href="{{WEB_URL}}{% url admin:ldt_content_import_file %}">Import
-		an ldt</a></th>
-		<td>&nbsp;</td>
-		<!--tr>
-                    <th>            
-                        <a href="content/export/form">Generate ldt</a>
-                    </th>
-                    <td>&nbsp;</td>
-                </tr-->
-		<tr>
-			<th><a href="{{WEB_URL}}{% url admin:ldt_content_reindex %}">Reindex</a>
-			</th>
-			<td>&nbsp;</td>
-		</tr>
-</table>
-</div>
-
-{% endblock %}
--- a/web/ldt/ldt_utils/templates/admin/ldt/content/reindex_form.html	Tue Jun 08 15:51:07 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-{% extends "admin/ldt/app_action.html" %} {% load i18n %} {# reindex
-contents #} {% block content %} {% if message %}
-<div>
-<p>{{ message }}</p>
-</div>
-{% endif %} {% if form. %}
-<div></div>
-{% endif %}
-<div>
-<form method="post"
-	action="{{WEB_URL}}{% url admin:ldt_content_reindex %}">{%
-csrf_token %}
-<table>
-	{{ form.as_table }}
-</table>
-<input type="submit" /></form>
-</div>
-
-<a href="{{WEB_URL}}{% url admin:app_list 'ldt' %}">Back to
-administration page</a>
-
-{% endblock %}
--- a/web/ldt/ldt_utils/templates/admin/ldt/content/search_form.html	Tue Jun 08 15:51:07 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-{% extends "base.html" %} {% block content %}
-
-<form method="post"
-	action="{{WEB_URL}}{% url ldt.ldt.views.searchIndex %}"
-	accept-charset="utf-8">
-
-<table>
-	{{ form.as_table }}
-</table>
-<input type="submit" /></form>
-
-
-{% endblock %}
--- a/web/ldt/ldt_utils/templates/admin/ldt/content/upload_form.html	Tue Jun 08 15:51:07 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-{% extends "admin/ldt/app_action.html" %} {# import an ldt #} {% block
-content %}
-<p>Vous pouvez importer un fichier ldt ou un zip qui compresse un
-fichier .ldt et plusieurs fichiers .iri.</p>
-<p>Bien verifiez vous que le chemin de source est absolute pour un
-fichier ldt lors qu'il est tout seul, alors qu'il est relatif s'il est
-dans le zip</p>
-<p>Vous pouvez indiquer le chemin de video si vous avez besoin</p>
-{% if message %}
-<div>
-<p>{{ message }}</p>
-</div>
-{% endif %} {% if form %}
-
-<form method="post" enctype="multipart/form-data" action="">{%
-csrf_token %}
-<table>
-	{{ form.as_table }}
-</table>
-<input type="submit" /></form>
-{% endif %}
-
-<a href="{% url admin:app_list 'ldt' %}">Back to administration
-page</a>
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/ldt/ldt_utils/templates/admin/ldt_utils/app_action.html	Thu Jun 10 04:14:44 2010 +0200
@@ -0,0 +1,6 @@
+{% extends "admin/base_site.html" %}
+{% load i18n %}
+{% block breadcrumbs %}
+<div class="breadcrumbs"><a href="{% url admin:index %}"> {% trans "Home" %}</a> &rsaquo; <a href="{% url admin:app_list 'ldt' %}">ldt</a> &rsaquo; {{ current_action }}</div>
+{% endblock %}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/ldt/ldt_utils/templates/admin/ldt_utils/app_index.html	Thu Jun 10 04:14:44 2010 +0200
@@ -0,0 +1,32 @@
+{% extends "admin/app_index.html" %}
+{% block extrastyle %}
+    {{ block.super }}
+    <link rel="stylesheet" type="text/css" href="{% load ldtmedia %}{% ldt_media_prefix %}css/dashboard.css" />
+{% endblock %}
+{% load i18n %}
+{% block content %}
+{{ block.super }}
+<div id="content-main-app-ldt-utils">
+	<div class="module">
+	<table summary="Import">
+		<caption>Import</caption>
+		<tr>
+			<th><a href="{{WEB_URL}}{% url admin:ldt_content_import_file %}">Import
+			an ldt</a></th>
+			<td>&nbsp;</td>
+			<!--tr>
+	                    <th>            
+	                        <a href="content/export/form">Generate ldt</a>
+	                    </th>
+	                    <td>&nbsp;</td>
+	                </tr-->
+			<tr>
+				<th><a href="{{WEB_URL}}{% url admin:ldt_content_reindex %}">Reindex</a>
+				</th>
+				<td>&nbsp;</td>
+			</tr>
+	</table>
+	</div>
+</div>
+
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/ldt/ldt_utils/templates/admin/ldt_utils/content/reindex_form.html	Thu Jun 10 04:14:44 2010 +0200
@@ -0,0 +1,23 @@
+{% extends "admin/ldt_utils/app_action.html" %}
+{% load i18n %}
+{# reindex contents #}
+{% block content %}
+{% if message %}
+<div>
+<p>{{ message }}</p>
+</div>
+{% endif %} {% if form. %}
+<div></div>
+{% endif %}
+<div>
+<form method="post"
+	action="{{WEB_URL}}{% url admin:ldt_content_reindex %}">{% csrf_token %}
+<table>
+	{{ form.as_table }}
+</table>
+<input type="submit" /></form>
+</div>
+
+<a href="{{WEB_URL}}{% url admin:app_list 'ldt_utils' %}">Back to administration page</a>
+
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/ldt/ldt_utils/templates/admin/ldt_utils/content/upload_form.html	Thu Jun 10 04:14:44 2010 +0200
@@ -0,0 +1,24 @@
+{% extends "admin/ldt_utils/app_action.html" %} {# import an ldt #}
+{% block content %}
+<p>Vous pouvez importer un fichier ldt ou un zip qui compresse un
+fichier .ldt et plusieurs fichiers .iri.</p>
+<p>Bien verifiez vous que le chemin de source est absolute pour un
+fichier ldt lors qu'il est tout seul, alors qu'il est relatif s'il est
+dans le zip</p>
+<p>Vous pouvez indiquer le chemin de video si vous avez besoin</p>
+{% if message %}
+<div>
+<p>{{ message }}</p>
+</div>
+{% endif %} {% if form %}
+
+<form method="post" enctype="multipart/form-data" action="">{% csrf_token %}
+<table>
+	{{ form.as_table }}
+</table>
+<input type="submit" /></form>
+{% endif %}
+
+<a href="{% url admin:app_list 'ldt_utils' %}">Back to administration page</a>
+
+{% endblock %}
--- a/web/ldt/ldt_utils/templates/ldt/ldt/copy_ldt.html	Tue Jun 08 15:51:07 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-{% load i18n %} {# form of copy of project ldt #}
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<?xml version="1.0" encoding="UTF-8"?>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<link rel="stylesheet" href="{{BASE_URL}}static/ldt/css/ldt.css" />
-</head>
-<body>
-<div id="add_contribution">
-<div class="title">{% trans "Copy your project" %}</div>
-<form action="" method="POST">{% csrf_token %} <label for="title">{%
-trans "Title" %}:</label> <input class="inputbox required" type="text"
-	name="title" size="80" ; value="" id="title" /> <input class="button"
-	id="ldt_submit" type="submit" value="{% trans 'Copy' %}" /></form>
-</div>
-</body>
-</html>
--- a/web/ldt/ldt_utils/templates/ldt/ldt/create_ldt.html	Tue Jun 08 15:51:07 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-{% load i18n %} {# form of creation of project ldt #}
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<?xml version="1.0" encoding="UTF-8"?>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<link rel="stylesheet" href="{{BASE_URL}}static/ldt/css/ldt.css" />
-</head>
-<body>
-<div id="add_contribution">
-<div class="title">{% trans "Create your project" %}</div>
-<form action="{{create_project_action}}" method="POST">{%
-csrf_token %} <label for="title">{% trans "Title" %}:</label> <input
-	class="inputbox required" type="text" name="title" size="80" ; value=""
-	id="title" />
-
-<div class="title">{% trans "List of contents" %}</div>
-<ul class='contentlist'>
-	{% for content in contents %}
-	<li><input type="checkbox" name="contents" value="{{ content.id}}"
-		checked="true" />{{content.iri_id}}</li>
-	{% endfor %}
-</ul>
-
-<input class="button" id="ldt_submit" type="submit"
-	value="{% trans 'Create' %}" /></form>
-</div>
-</body>
-</html>
--- a/web/ldt/ldt_utils/templates/ldt/ldt/init_ldt.html	Tue Jun 08 15:51:07 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
-<meta http-equiv="Pragma" content="no-cache" />
-<meta http-equiv="Cache" content="no store" />
-<meta http-equiv="Expires" content="-1" />
-<title>Ligne de Temps - IRI</title>
-<script type="text/javascript" src="{{MEDIA_URL}}js/swfobject.js"></script>
-<script type="text/javascript">
-	    
-	</script>
-</head>
-
-<body id="init_ldt_view">
-
-<div id="ldtInit" style="width: 1001px; height: 631px;">&nbsp;</div>
-<script language="JavaScript" type="text/javascript">
-
-        var params = {
-            quality:"high",
-            allowFullScreen:"true",
-            wmode:"transparent",
-            allowScriptAccess:"always"
-        };
-    
-        var flashvars = {
-            colorUrl:'{{colorurl}}',
-            i18nUrl: '{{i18nurl}}',
-            language: '{{language}}',
-            {% if url %}
-            urlBase:'{{baseurl}}',
-            initUrl:'{{url}}',
-            {% endif %}
-            {% ifequal readonly 'false' %}
-            readOnly: '{{readonly}}',
-            postUrl:'{{posturl}}',
-            postVars: encodeURIComponent('id={{id}}&csrfmiddlewaretoken={{csrf_token}}'),
-            {% else %}
-            readOnly:'true',
-            {% endifequal %}
-            startTime:'100'     
-        };
-
-        var attributes = {  id: "ldtInitSwf",  name: "ldtInitSwf"};
-
-        swfobject.embedSWF("{{ MEDIA_URL }}swf/ldt/LignesDeTempsFlex.swf", "ldtInit", "1001", "631", "9.0.0", "{{ MEDIA_URL }}swf/expressInstall.swf", flashvars, params, attributes);
-
-    </script>
-</body>
-</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 }}
-<script type="text/javascript"
-	src="{{ BASE_URL }}static/js/jquery.DOMwindow.js"></script>
-<script type="text/javascript">           
-        $(document).ready(function(){
-        	$('.ldt_link').nyroModal({
-        		height:662, 
-        		width:1022, 
-        		type:'iframe',
-        		forceType:'iframe',
-        		padding:5,
-        		bgColor: 'rgb(239, 239, 239)',
-                titleFromIframe: false,
-                beforeHideContent: function(elts, settings, callback){
-                    try {                       
-                        var res = $('#ldtInitSwf',$('#nyroModalIframe').contents());
-                        if(res.length > 0)
-                        {
-                            var swfobj = res.get(0);
-                            if(swfobj && swfobj.forceSave != undefined)          
-                                swfobj.forceSave();
-                        }
-                    }
-                    catch(err)
-                    {
-                        // do nothing
-                    }                   
-                    callback();
-                }        		
-            	});
-            $('.create_ldt_link').nyroModal({
-        		height:662, 
-        		width:1022, 
-        		type:'ajax', 
-        		padding:5,
-        		bgColor: 'rgb(239, 239, 239)',
-            	});       
-        });        	        
-</script>
-{% endblock %} {% block css_import %} {{ block.super }}
-<link rel="stylesheet" type="text/css"
-	href="{{ BASE_URL }}static/ldt/css/ldt.css" />
-{% endblock %} {% block breadcrumb %}
-<li></li>
-<li><a href="{% url ldt.userpanel.views.space %}">{% trans
-"Space" %}</a></li>
-<li>{% trans "Ldt Project" %}</li>
-{% endblock %} {% block content_title %}{% trans "Ldt Project" %}{%
-endblock %} {% block iricontent %}
-<div id='ldtlist'><a
-	href="{% url ldt.ldt.views.create_ldt_view %}" class="create_ldt_link">{%
-trans 'Create new project'%}</a>
-<table>
-	<caption>{% trans "Project" %}</caption>
-	<thead>
-		<tr>
-			<th width="170">{% trans "title" %}</th>
-			<th width="20">{% trans " published" %}</th>
-		</tr>
-	</thead>
-	<tbody>
-		{% for ldt in ldtProjects %}
-		<tr>
-			<th><a href="{% url ldt.ldt.views.indexProject ldt.ldt_id %}"
-				class="ldt_link">{{ ldt.title }}</a></th>
-			{% ifequal ldt.state 2%}
-			<td><a href="{% url ldt.ldt.views.unpublish ldt.ldt_id%}"><img
-				alt="True" src="{{BASE_URL}}static/admin/img/admin/icon-yes.gif" /></td>
-			{% else %}
-			<td><a href="{% url ldt.ldt.views.publish ldt.ldt_id %}"><img
-				alt="False" src="{{BASE_URL}}static/admin/img/admin/icon-no.gif" /></td>
-			{% endifequal %}
-		</tr>
-		{% endfor %}
-	</tbody>
-</table>
-</div>
-{% endblock %}
-
--- 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 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<?xml version="1.0" encoding="UTF-8"?>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<style type="text/css">
-.center {
-	position: absolute;
-	top: 50%;
-	left: 50%;
-}
-
-.center div {
-	position: relative;
-	top: -7px;
-	left: -104px;
-}
-</style>
-</head>
-<body>
-<div class="center">
-<div><img alt="loading"
-	src="{{MEDIA_URL}}img/loadingAnimation.gif" /></div>
-</div>
-</body>
-</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 @@
-<p>done</p>
-<p>{{ldt}}
-<p>
-<p>{{id}}</p>
-<p>title:{{title}}</p>
\ No newline at end of file
--- /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 #}
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<link rel="stylesheet" href="{{BASE_URL}}static/ldt/css/ldt.css" />
+</head>
+<body>
+<div id="add_contribution">
+<div class="title">{% trans "Copy your project" %}</div>
+<form action="" method="POST">{% csrf_token %} <label for="title">{%
+trans "Title" %}:</label> <input class="inputbox required" type="text"
+	name="title" size="80" ; value="" id="title" /> <input class="button"
+	id="ldt_submit" type="submit" value="{% trans 'Copy' %}" /></form>
+</div>
+</body>
+</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 #}
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<link rel="stylesheet" href="{{BASE_URL}}static/ldt/css/ldt.css" />
+</head>
+<body>
+<div id="add_contribution">
+<div class="title">{% trans "Create your project" %}</div>
+<form action="{{create_project_action}}" method="POST">{% csrf_token %} <label for="title">{% trans "Title" %}:</label> <input
+	class="inputbox required" type="text" name="title" size="80" ; value=""
+	id="title" />
+
+<div class="title">{% trans "List of contents" %}</div>
+<ul class='contentlist'>
+	{% for content in contents %}
+	<li><input type="checkbox" name="contents" value="{{ content.id}}"
+		checked="true" />{{content.iri_id}}</li>
+	{% endfor %}
+</ul>
+
+<input class="button" id="ldt_submit" type="submit"
+	value="{% trans 'Create' %}" /></form>
+</div>
+</body>
+</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 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
+<meta http-equiv="Pragma" content="no-cache" />
+<meta http-equiv="Cache" content="no store" />
+<meta http-equiv="Expires" content="-1" />
+<title>Ligne de Temps - IRI</title>
+<script type="text/javascript" src="{{MEDIA_URL}}js/swfobject.js"></script>
+<script type="text/javascript">
+	    
+	</script>
+</head>
+
+<body id="init_ldt_view">
+
+<div id="ldtInit" style="width: 1001px; height: 631px;">&nbsp;</div>
+<script language="JavaScript" type="text/javascript">
+
+        var params = {
+            quality:"high",
+            allowFullScreen:"true",
+            wmode:"transparent",
+            allowScriptAccess:"always"
+        };
+    
+        var flashvars = {
+            colorUrl:'{{colorurl}}',
+            i18nUrl: '{{i18nurl}}',
+            language: '{{language}}',
+            {% if url %}
+            urlBase:'{{baseurl}}',
+            initUrl:'{{url}}',
+            {% endif %}
+            {% ifequal readonly 'false' %}
+            readOnly: '{{readonly}}',
+            postUrl:'{{posturl}}',
+            postVars: encodeURIComponent('id={{id}}&csrfmiddlewaretoken={{csrf_token}}'),
+            {% else %}
+            readOnly:'true',
+            {% endifequal %}
+            startTime:'100'     
+        };
+
+        var attributes = {  id: "ldtInitSwf",  name: "ldtInitSwf"};
+
+        swfobject.embedSWF("{{ MEDIA_URL }}swf/ldt/LignesDeTempsFlex.swf", "ldtInit", "1001", "631", "9.0.0", "{{ MEDIA_URL }}swf/expressInstall.swf", flashvars, params, attributes);
+
+    </script>
+</body>
+</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 }}
+<script type="text/javascript"
+	src="{{ BASE_URL }}static/js/jquery.DOMwindow.js"></script>
+<script type="text/javascript">           
+        $(document).ready(function(){
+        	$('.ldt_link').nyroModal({
+        		height:662, 
+        		width:1022, 
+        		type:'iframe',
+        		forceType:'iframe',
+        		padding:5,
+        		bgColor: 'rgb(239, 239, 239)',
+                titleFromIframe: false,
+                beforeHideContent: function(elts, settings, callback){
+                    try {                       
+                        var res = $('#ldtInitSwf',$('#nyroModalIframe').contents());
+                        if(res.length > 0)
+                        {
+                            var swfobj = res.get(0);
+                            if(swfobj && swfobj.forceSave != undefined)          
+                                swfobj.forceSave();
+                        }
+                    }
+                    catch(err)
+                    {
+                        // do nothing
+                    }                   
+                    callback();
+                }        		
+            	});
+            $('.create_ldt_link').nyroModal({
+        		height:662, 
+        		width:1022, 
+        		type:'ajax', 
+        		padding:5,
+        		bgColor: 'rgb(239, 239, 239)',
+            	});       
+        });        	        
+</script>
+{% endblock %} {% block css_import %} {{ block.super }}
+<link rel="stylesheet" type="text/css"
+	href="{{ BASE_URL }}static/ldt/css/ldt.css" />
+{% endblock %} {% block breadcrumb %}
+<li></li>
+<li><a href="{% url ldt.userpanel.views.space %}">{% trans
+"Space" %}</a></li>
+<li>{% trans "Ldt Project" %}</li>
+{% endblock %} {% block content_title %}{% trans "Ldt Project" %}{%
+endblock %} {% block iricontent %}
+<div id='ldtlist'><a
+	href="{% url ldt.ldt.views.create_ldt_view %}" class="create_ldt_link">{%
+trans 'Create new project'%}</a>
+<table>
+	<caption>{% trans "Project" %}</caption>
+	<thead>
+		<tr>
+			<th width="170">{% trans "title" %}</th>
+			<th width="20">{% trans " published" %}</th>
+		</tr>
+	</thead>
+	<tbody>
+		{% for ldt in ldtProjects %}
+		<tr>
+			<th><a href="{% url ldt.ldt.views.indexProject ldt.ldt_id %}"
+				class="ldt_link">{{ ldt.title }}</a></th>
+			{% ifequal ldt.state 2%}
+			<td><a href="{% url ldt.ldt.views.unpublish ldt.ldt_id%}"><img
+				alt="True" src="{{BASE_URL}}static/admin/img/admin/icon-yes.gif" /></td>
+			{% else %}
+			<td><a href="{% url ldt.ldt.views.publish ldt.ldt_id %}"><img
+				alt="False" src="{{BASE_URL}}static/admin/img/admin/icon-no.gif" /></td>
+			{% endifequal %}
+		</tr>
+		{% endfor %}
+	</tbody>
+</table>
+</div>
+{% endblock %}
+
--- /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 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<style type="text/css">
+.center {
+	position: absolute;
+	top: 50%;
+	left: 50%;
+}
+
+.center div {
+	position: relative;
+	top: -7px;
+	left: -104px;
+}
+</style>
+</head>
+<body>
+<div class="center">
+<div><img alt="loading"
+	src="{{MEDIA_URL}}img/loadingAnimation.gif" /></div>
+</div>
+</body>
+</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 @@
+<p>done</p>
+<p>{{ldt}}
+<p>
+<p>{{id}}</p>
+<p>title:{{title}}</p>
\ No newline at end of file
--- /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 method="post"
+	action="{{WEB_URL}}{% url ldt.ldt.views.searchIndex %}"
+	accept-charset="utf-8">
+
+<table>
+	{{ form.as_table }}
+</table>
+<input type="submit" /></form>
+
+
+{% endblock %}
--- 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<iri_id>.*)$', 'views.create_project'),
     url(r'^copy/(?P<ldt_id>.*)$', 'views.copy_project'),
+    url(r'^cljson/id/(?P<id>.*)$', 'views.project_json_id'),
+    url(r'^cljson/externalid/(?P<id>.*)$', 'views.project_json_externalid'),
 )
 
 if test_ldt():
--- 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()
+    
--- 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']
--- /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
--- 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)
--- /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)
--- 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%}
 <form class="signupform" id="signup_form" method="post" action=""> {% csrf_token %}
                 <ul>
-{{form.as_ul}}
+				{{form.as_ul}}
                 <li><input class="button" type="submit" value="{% trans 'Save' %} "/></li>
                 </ul>
 </form>
--- /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