--- a/.hgignore Wed Sep 15 15:20:26 2010 +0200
+++ b/.hgignore Tue Sep 21 04:27:08 2010 +0200
@@ -9,4 +9,6 @@
^sbin/virtualenv/distribute.*\.tar\.gz$
syntax: regexp
-^web/franceculture/modwsgi\.wsgi$
\ No newline at end of file
+^web/franceculture/modwsgi\.wsgi$
+syntax: regexp
+^web/log/log\.txt$
\ No newline at end of file
--- a/sbin/virtualenv/create_python_env.py Wed Sep 15 15:20:26 2010 +0200
+++ b/sbin/virtualenv/create_python_env.py Tue Sep 21 04:27:08 2010 +0200
@@ -47,6 +47,7 @@
EXTRA_TEXT += " 'PIL' : { 'setup': 'pil', 'url': 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz', 'local': '"+ os.path.abspath(os.path.join(src_base,"Imaging-1.1.7.tar.gz"))+"'},\n"
EXTRA_TEXT += " 'PYXML' : { 'setup': 'http://sourceforge.net/projects/pyxml/files/pyxml/0.8.4/PyXML-0.8.4.tar.gz/download', 'url': 'http://sourceforge.net/projects/pyxml/files/pyxml/0.8.4/PyXML-0.8.4.tar.gz/download', 'local': '"+ os.path.abspath(os.path.join(src_base,"PyXML-0.8.4.tar.gz"))+"', 'patch': '"+os.path.join(patch_path,"pyxml.patch")+"'},\n"
EXTRA_TEXT += " 'DJANGO' : { 'setup': 'django', 'url': 'http://www.djangoproject.com/download/1.2.3/tarball/', 'local': '"+ os.path.abspath(os.path.join(src_base,"Django-1.2.3.tar.gz"))+"'},\n"
+EXTRA_TEXT += " 'JOGGING' : { 'setup': 'jogging', 'url': 'http://github.com/zain/jogging/tarball/v0.2.2', 'local': '"+ os.path.abspath(os.path.join(src_base,"jogging-0.2.2.tar.gz"))+"'},\n"
EXTRA_TEXT += " 'DJANGO-EXTENSIONS' : { 'setup': 'django-extensions', 'url':'http://django-command-extensions.googlecode.com/files/django-extensions-0.4.1.tar.gz', 'local':'"+ os.path.abspath(os.path.join(src_base,"django-extensions-0.4.1.tar.gz"))+"' },\n"
EXTRA_TEXT += " 'DJANGO-REGISTRATION' : { 'setup': 'django-registration', 'url':'http://bitbucket.org/ubernostrum/django-registration/get/tip.tar.gz', 'local':'"+ os.path.abspath(os.path.join(src_base,"django-registration.tar.gz"))+"' },\n"
EXTRA_TEXT += " 'DJANGO-TAGGING' : { 'setup': 'django-tagging', 'url':'http://django-tagging.googlecode.com/files/django-tagging-0.3.1.tar.gz', 'local':'"+ os.path.abspath(os.path.join(src_base,"django-tagging-0.3.1.tar.gz"))+"' },\n"
@@ -241,6 +242,7 @@
('PIL', 'pip', None, None),
('FOURSUITE_XML','easy_install', None, None),
('DJANGO','pip', None, None),
+ ('JOGGING','pip', None, None),
('DJANGO-EXTENSIONS', 'pip', None, None),
('DJANGO-REGISTRATION', 'easy_install', '-Z', None),
('DJANGO-TAGGING', 'pip', None, None),
Binary file sbin/virtualenv/res/src/jogging-0.2.2.tar.gz has changed
--- a/sql/update_db_0_13_to_0_16.sql Wed Sep 15 15:20:26 2010 +0200
+++ b/sql/update_db_0_13_to_0_16.sql Tue Sep 21 04:27:08 2010 +0200
@@ -3,6 +3,7 @@
ALTER TABLE ldt_utils_content DROP COLUMN videopath;
ALTER TABLE ldt_utils_content DROP COLUMN external_id;
+ALTER TABLE ldt_utils_content DROP COLUMN src;
-ALTER TABLE ldt_utils_content ADD COLUMN "media_id" integer REFERENCES "ldt_utils_media" ("id") DEFERRABLE INITIALLY DEFERRED;
-CREATE INDEX "ldt_utils_content_media_id" ON "ldt_utils_content" ("media_id");
+ALTER TABLE ldt_utils_content ADD COLUMN "media_obj_id" integer REFERENCES "ldt_utils_media" ("id") DEFERRABLE INITIALLY DEFERRED;
+CREATE INDEX "ldt_utils_content_media_obj_id" ON "ldt_utils_content" ("media_obj_id");
--- a/web/franceculture/config.py.tmpl Wed Sep 15 15:20:26 2010 +0200
+++ b/web/franceculture/config.py.tmpl Tue Sep 21 04:27:08 2010 +0200
@@ -8,10 +8,15 @@
MEDIA_BASE_URL = BASE_URL + 'static/'
STREAM_URL = MEDIA_BASE_URL + "/content/"
+STREAM_SRC_PREFIX = ""
+
+
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.abspath(BASE_DIR + "../static/")
+
+
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
@@ -19,6 +24,8 @@
CONTENT_ROOT = MEDIA_ROOT + "media/content/"
+STREAM_PATH = CONTENT_ROOT
+
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
--- a/web/franceculture/settings.py Wed Sep 15 15:20:26 2010 +0200
+++ b/web/franceculture/settings.py Tue Sep 21 04:27:08 2010 +0200
@@ -79,6 +79,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
+ 'jogging.middleware.LoggingMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
@@ -104,6 +105,7 @@
)
INSTALLED_APPS = (
+ 'jogging',
'django_extensions',
'django.contrib.auth',
'django.contrib.contenttypes',
@@ -141,4 +143,6 @@
LOGOUT_URL = BASE_URL + 'franceculture'
LOGIN_REDIRECT_URL = BASE_URL + 'franceculture'
+GLOBAL_LOG_LEVEL = LOG_LEVEL
+GLOBAL_LOG_HANDLERS = [logging.FileHandler(LOG_FILE)]
--- a/web/franceculture/templates/franceculture/workspace.html Wed Sep 15 15:20:26 2010 +0200
+++ b/web/franceculture/templates/franceculture/workspace.html Tue Sep 21 04:27:08 2010 +0200
@@ -48,7 +48,7 @@
<div class="span-12 last titlediv" >
<div class="span-8 projectscontentstitle">{% trans "content list" %}</div>
<div class="span-4 last searchfielddiv" >
- <div class="searchfield rounded"><input id="searchcontentsinput" class="searchfieldinput searchfieldinputbase" value="{% trans 'search' %}" type="text" /><img id="contentsajaxloader" class="searchajaxloader" src="{{MEDIA_URL}}/img/ajax-loader-16x16.gif" alt="loader"/></div>
+ <div class="searchfield rounded"><input id="searchcontentsinput" class="searchfieldinput searchfieldinputbase" value="{% trans 'search' %}" type="text" /><img id="contentsajaxloader" class="searchajaxloader" src="{{MEDIA_URL}}/img/ajax-loader-16x16.gif" alt="loader"/><img id="contentsclear" class="searchclear" src="{{MEDIA_URL}}img/clear-left.png"/></div>
</div>
</div>
<div class="span-12 last projectscontentsdiv" id="contentslistcontainer">
@@ -59,7 +59,7 @@
<div class="span-12 last titlediv" >
<div class="span-8 projectscontentstitle" >{% trans "project list" %}</div>
<div class="span-4 last searchfielddiv" >
- <div class="searchfield rounded"><input id="searchprojectsinput" class="searchfieldinput searchfieldinputbase" value="{% trans 'search' %}" type="text" /><img id="projectsajaxloader" class="searchajaxloader" src="{{MEDIA_URL}}/img/ajax-loader-16x16.gif" alt="loader"/></div>
+ <div class="searchfield rounded"><input id="searchprojectsinput" class="searchfieldinput searchfieldinputbase" value="{% trans 'search' %}" type="text" /><img id="projectsajaxloader" class="searchajaxloader" src="{{MEDIA_URL}}/img/ajax-loader-16x16.gif" alt="loader"/><img id="projecsclear" class="searchclear" src="{{MEDIA_URL}}img/clear-left.png"/></div>
</div>
</div>
<div class="span-12 last projectscontentsdiv" id="projectslistcontainer">
--- a/web/franceculture/templates/ldt/ldt_utils/content_list.html Wed Sep 15 15:20:26 2010 +0200
+++ b/web/franceculture/templates/ldt/ldt_utils/content_list.html Tue Sep 21 04:27:08 2010 +0200
@@ -49,7 +49,7 @@
<div class="span-12 last titlediv" >
<div class="span-8 projectscontentstitle">{% trans "content list" %}</div>
<div class="span-4 last searchfielddiv" >
- <div class="searchfield rounded"><input id="searchcontentsinput" class="searchfieldinput searchfieldinputbase" value="{% trans 'search' %}" type="text" /><img id="contentsajaxloader" class="searchajaxloader" src="{{MEDIA_URL}}/img/ajax-loader-16x16.gif" alt="loader"/></div>
+ <div class="searchfield rounded"><input id="searchcontentsinput" class="searchfieldinput searchfieldinputbase" value="{% trans 'search' %}" type="text" /><img id="contentsajaxloader" class="searchajaxloader" src="{{MEDIA_URL}}/img/ajax-loader-16x16.gif" alt="loader"/><img id="contentsclear" class="searchclear" src="{{MEDIA_URL}}/img/clear-left.png"/></div>
</div>
</div>
<div class="span-12 last projectscontentsdiv" id="contentslistcontainer">
--- a/web/franceculture/templates/ldt/ldt_utils/create_content.html Wed Sep 15 15:20:26 2010 +0200
+++ b/web/franceculture/templates/ldt/ldt_utils/create_content.html Tue Sep 21 04:27:08 2010 +0200
@@ -6,7 +6,7 @@
{% block js_import %}
{{ block.super }}
<script type="text/javascript" src="{{MEDIA_URL}}admin/js/core.js" ></script>
- <script type="text/javascript" src="{% url jsi18n %}" } ></script>
+ <script type="text/javascript" src="{% url jsi18n %}" ></script>
<script type="text/javascript" src="{{MEDIA_URL}}js/jquery.nyroModal.min.js"></script>
{{ content_form.media.js }}
{% endblock %}
@@ -22,14 +22,44 @@
{% block js_declaration %}
<script type="text/javascript">
window.__admin_media_prefix__ = "{% filter escapejs %}{% admin_media_prefix %}{% endfilter %}";
+ $(document).ready(function() {
+ $(".media_fields").hide();
+ $("#media_field_"+$("#id_content-media_input_type").val()).show();
+ $("#id_content-media_input_type").change(function(e) {
+ $(".media_fields").hide();
+ $("#media_field_"+$(e.target).val()).show();
+ });
+ });
</script>
{% endblock %}
{% block body %}
+ {% if content_form.errors %}
+ <div id="content-form-error">
+ <p>{% trans "The operation could not be performed because one or more error(s) occurred.<br />Please resubmit the content form after making the following changes:" %}</p>
+ <ul>
+ {% for field in content_form %}
+ {% if field.errors%}<li>{{field.name}} : {{ field.errors|striptags }}</li>{% endif %}
+ {% endfor %}
+ </ul>
+ </div>
+ {% endif %}
+
+ {% if media_form.errors %}
+ <div id="media-form-error">
+ <p>{% trans "The operation could not be performed because one or more error(s) occurred.<br />Please resubmit the media form after making the following changes:" %}</p>
+ <ul>
+ {% for field in media_form %}
+ {% if field.errors%}<li>{{field.name}} : {{ field.errors|striptags }}</li>{% endif %}
+ {% endfor %}
+ </ul>
+ </div>
+ {% endif %}
+
<div id="add_content" class="span-18 last">
<div class="projectscontentstitle">{% trans "Create content" %}</div>
- <form action="{{create_content_action}}" method="POST">
+ <form action="{{create_content_action}}" method="POST" enctype="multipart/form-data" >
<div id="contentformhidden">
{% csrf_token %}
<input type="hidden" name="form_status" value="{{form_status}}" id="content_form_status" />
@@ -50,6 +80,14 @@
<div>{{ content_form.duration.errors }}{{ content_form.duration.label_tag }}{{content_form.duration}}</div>
<div>{{ content_form.content_creation_date.errors }}{{ content_form.content_creation_date.label_tag }}{{content_form.content_creation_date}}</div>
<div>{{ content_form.tags.errors }}{{ content_form.tags.label_tag }}{{content_form.tags}}</div>
+ <div>{{ content_form.media_input_type.errors }}{{ content_form.media_input_type.label_tag }}{{content_form.media_input_type}}</div>
+ <div id="media_fields_div">
+ <div id="media_field_link" class="media_fields">{{ content_form.media_obj.errors }}{{ content_form.media_obj.label_tag }}{{content_form.media_obj}}</div>
+ <div id="media_field_upload" class="media_fields">{{ media_form.media_file.errors }}{{ media_form.media_file.label_tag }}{{media_form.media_file}}</div>
+ <div id="media_field_url" class="media_fields">{{ media_form.external_src_url.errors }}{{ media_form.external_src_url.label_tag }}{{ media_form.external_src_url }}</div>
+ <div id="media_field_create" class="media_fields">{{ media_form.src.errors }}{{ media_form.src.label_tag }}{{ media_form.src }}</div>
+ </div>
+
</div>
</div>
<div id="submitcontent" class="span-18 last">
--- a/web/franceculture/templates/ldt/ldt_utils/ldt_list.html Wed Sep 15 15:20:26 2010 +0200
+++ b/web/franceculture/templates/ldt/ldt_utils/ldt_list.html Tue Sep 21 04:27:08 2010 +0200
@@ -76,7 +76,7 @@
<div class="span-12 last titlediv" >
<div class="span-8 projectscontentstitle" >{% trans "project list" %}</div>
<div class="span-4 last searchfielddiv" >
- <div class="searchfield rounded"><input id="searchprojectsinput" class="searchfieldinput searchfieldinputbase" value="{% trans 'search' %}" type="text" /><img id="projectsajaxloader" class="searchajaxloader" src="{{MEDIA_URL}}/img/ajax-loader-16x16.gif"/></div>
+ <div class="searchfield rounded"><input id="searchprojectsinput" class="searchfieldinput searchfieldinputbase" value="{% trans 'search' %}" type="text" /><img id="projectsajaxloader" class="searchajaxloader" src="{{MEDIA_URL}}/img/ajax-loader-16x16.gif"/><img id="projectsclear" class="searchclear" src="{{MEDIA_URL}}/img/clear-left.png"/></div>
</div>
</div>
<div class="span-12 last projectscontentsdiv" id="projectslistcontainer">
--- a/web/ldt/ldt_utils/contentindexer.py Wed Sep 15 15:20:26 2010 +0200
+++ b/web/ldt/ldt_utils/contentindexer.py Tue Sep 21 04:27:08 2010 +0200
@@ -4,7 +4,6 @@
import shutil
from ldt.utils import zipfileext
import urllib
-# import ldt.utils.log
import ldt.utils.xml
from django.conf import settings
from models import Content
@@ -160,7 +159,6 @@
def index_project(self, project):
- # pocketfilms.utils.log.debug("Indexing project : "+str(project.iri_id))
doc = xml.dom.minidom.parseString(project.ldt)
doc = Ft.Xml.Domlette.ConvertDocument(doc)
@@ -175,7 +173,6 @@
ensembleId = "ens_perso"
for decoupageNode in content.childNodes:
- # pocketfilms.utils.log.debug("Indexing content decoupage : "+ repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist))
if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage" or decoupageNode.getAttributeNS(None,"id") in self.decoupage_blacklist:
continue
--- a/web/ldt/ldt_utils/fileimport.py Wed Sep 15 15:20:26 2010 +0200
+++ b/web/ldt/ldt_utils/fileimport.py Tue Sep 21 04:27:08 2010 +0200
@@ -328,12 +328,10 @@
#get annotation of file ldt
- #result = xml.xpath.Evaluate("/iri/annotations/content", context=con)
result = doc.xpath("/iri/annotations/content")
for contentnode in result:
id = contentnode.attrib['id']
- # pocketfilms.utils.log.debug("ID : " + str(id))
if contents.has_key(id):
if self.author:
contentnode.set("author", unicode(self.author))
@@ -372,17 +370,14 @@
#load ldt
foldersToProcess = [self.__tempdir]
while len(foldersToProcess):
- # pocketfilms.utils.log.debug("folder stack length : "+ str(len(foldersToProcess)))
currentFolder = foldersToProcess.pop()
for entry in os.listdir(currentFolder):
if entry in settings.ZIP_BLACKLIST:
continue
entryPath = os.path.join(currentFolder, entry)
if(os.path.isdir(entryPath)):
- # pocketfilms.utils.log.debug("Push folder : " + entryPath)
foldersToProcess.append(entryPath)
elif fnmatch.fnmatch(entry, "*.ldt"):
- # pocketfilms.utils.log.debug("Process file : " + entryPath)
ldtid = self.processLdt(entryPath)
processedids.append(ldtid)
elif fnmatch.fnmatch(entry, "*.flv"):
--- a/web/ldt/ldt_utils/forms.py Wed Sep 15 15:20:26 2010 +0200
+++ b/web/ldt/ldt_utils/forms.py Tue Sep 21 04:27:08 2010 +0200
@@ -1,12 +1,13 @@
from django import forms
-from models import Project, Content
+from models import Project, Content, Media
import uuid
from utils import generate_uuid
-from django.forms.widgets import Widget
+from django.forms.widgets import Widget, RadioSelect
from django.contrib.admin import widgets as admin_widgets
from django.core.urlresolvers import reverse
from ldt.settings import BASE_URL
from ldt.forms import widgets as ldt_widgets
+from django.utils.translation import ugettext_lazy as _
class LdtImportForm(forms.Form):
importFile = forms.FileField()
@@ -39,7 +40,8 @@
#iri_id = forms.CharField(max_length=1024, widget=forms.HiddenInput, initial=generate_uuid)
iriurl = forms.CharField(max_length=1024, widget=forms.HiddenInput, required=False)
- content_creation_date = forms.SplitDateTimeField(widget=ldt_widgets.LdtSplitDateTime, required=False)
+ content_creation_date = forms.SplitDateTimeField(widget=ldt_widgets.LdtSplitDateTime, required=False, label=_("content.content_creation_date"))
+ media_input_type = forms.ChoiceField(required=False, label=_("content.media_input_type"), choices=(("upload",_("file_upload")),("url",_("url")),("link",_("existing_media")),("create",_("create_media")),("none",_("none_media")) ))
def clean_iri_id(self):
data = self.cleaned_data.get('iri_id')
@@ -65,18 +67,20 @@
class Media:
css = {
- 'all' : ('admin/css/forms.css','admin/css/base.css', 'admin/css/base.css', 'admin/css/widgets.css')
+ 'all' : ('admin/css/forms.css','admin/css/base.css', 'admin/css/widgets.css')
}
class MediaForm(forms.ModelForm):
media_creation_date = forms.SplitDateTimeField(widget=ldt_widgets.LdtSplitDateTime, required=False)
+ media_file = forms.FileField(required=False);
+ src = forms.CharField(required=False, max_length=1024)
class Meta:
- model = Content
+ model = Media
exclude = ("creation_date", "update_date", "creator")
class Media:
css = {
- 'all' : ('admin/css/forms.css','admin/css/base.css', 'admin/css/base.css', 'admin/css/widgets.css')
+ 'all' : ('admin/css/forms.css','admin/css/base.css', 'admin/css/widgets.css')
}
--- a/web/ldt/ldt_utils/models.py Wed Sep 15 15:20:26 2010 +0200
+++ b/web/ldt/ldt_utils/models.py Tue Sep 21 04:27:08 2010 +0200
@@ -21,18 +21,28 @@
class Media(models.Model):
external_id = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('media.external_id'))
- external_permalink = models.URLField(max_length=1024, verbose_name=_('content.external_permalink'))
- external_publication_url = models.URLField(max_length=1024, verbose_name=_('content.external_publication_url'))
- external_src_url = models.URLField(max_length=1024, verbose_name=_('content.external_publication_url'))
+ external_permalink = models.URLField(max_length=1024, null=True, blank=True, verbose_name=_('content.external_permalink'))
+ external_publication_url = models.URLField(max_length=1024, null=True, blank=True, verbose_name=_('content.external_publication_url'))
+ external_src_url = models.URLField(max_length=1024, null=True, blank=True, verbose_name=_('content.external_publication_url'))
creation_date = models.DateTimeField(auto_now_add=True, verbose_name=_('media.creation_date'))
media_creation_date = models.DateTimeField(null=True, blank=True, verbose_name=_('media.media_creation_date'))
update_date = models.DateTimeField(auto_now=True, verbose_name=_('media.update_date'))
videopath = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('media.videopath'))
duration = models.IntegerField(null=True, blank=True, verbose_name=_('media.duration'))
- creator = models.ForeignKey(User, blank=True, verbose_name=_('media.creator'))
+ creator = models.ForeignKey(User, blank=True, null=True, verbose_name=_('media.creator'))
description = models.TextField(null=True, blank=True, verbose_name=_('description'))
title = models.CharField(max_length=1024, null=True, blank=True, verbose_name=_('title'))
src = models.CharField(max_length=1024, unique=True, verbose_name=_('media.src'))
+
+ def __unicode__(self):
+ strings = []
+ if self.title:
+ strings.append(unicode(self.title))
+ else:
+ strings.append(unicode(self.src))
+ if self.external_id:
+ strings.append(unicode(self.external_id))
+ return "|".join(strings)
class Content(models.Model):
iri_id = models.CharField(max_length=1024, unique=True, default=generate_uuid, verbose_name=_('content.iri_id'))
@@ -48,7 +58,7 @@
duration = models.IntegerField(null=True, blank=True, verbose_name=_('content.duration'))
content_creation_date = models.DateTimeField(null=True, blank=True, verbose_name=_('content.content_creation_date'))
tags = tagging.fields.TagField(max_length=2048, null=True, blank=True )
- media = models.ForeignKey('Media', blank=True, null=True )
+ media_obj = models.ForeignKey('Media', blank=True, null=True )
def get_duration(self):
if self.duration is None:
@@ -105,19 +115,32 @@
def iri_url_template(self):
return "${web_url}${media_url}media/ldt/" + unicode(self.iri_id) + "/" + os.path.basename(self.iriurl)
+
+
+ def __get_empty_media(self):
+ if settings.EMPTY_MEDIA_EXTERNALID:
+ empty_media = Media.objects.get(externalid=settings.EMPTY_MEDIA_EXTERNALID)
+ return empty_media
+ else:
+ return None
+
def videopath(): #@NoSelf
doc = """simulate videopath""" #@UnusedVariable
def fget(self):
- if self.media is None:
- return None
+ if self.media_obj is None:
+ empty_media = self.__get_empty_media()
+ if empty_media:
+ return empty_media.videopath
+ else:
+ return None
else:
- return self.media.videopath
+ return self.media_obj.videopath
def fset(self, value):
- if self.media is not None:
- self.media.videopath = value
+ if self.media_obj is not None:
+ self.media_obj.videopath = value
return locals()
@@ -127,39 +150,24 @@
doc = """simulate videopath""" #@UnusedVariable
def fget(self):
- if self.media is None:
- return None
+ if self.media_obj is None:
+ empty_media = self.__get_empty_media()
+ if empty_media:
+ return empty_media.src
+ else:
+ return None
else:
- return self.media.src
+ return self.media_obj.src
def fset(self, value):
- if self.media is None or self.media.src != value:
+ if self.media_obj is None or self.media_obj.src != value:
media, created = Media.objects.get_or_create(src=value, defaults={'src':value})
- self.media = media
+ self.media_obj = media
self.save()
return locals()
src = property(**src())
-
- def videopath(): #@NoSelf
- doc = """simulate videopath""" #@UnusedVariable
-
- def fget(self):
- if self.media is None:
- return None
- else:
- return self.media.videopath
-
- def fset(self, value):
- if self.media is not None:
- self.media.videopath = value
-
- return locals()
-
- videopath = property(**videopath())
-
-
class Project(Document):
--- a/web/ldt/ldt_utils/projectindexer.py Wed Sep 15 15:20:26 2010 +0200
+++ b/web/ldt/ldt_utils/projectindexer.py Tue Sep 21 04:27:08 2010 +0200
@@ -44,7 +44,6 @@
self.index_project(project)
def index_project(self, project):
- # ldt.utils.log.debug("Indexing project : "+str(project.ldt_id))
ldt=project.ldt
doc = xml.dom.minidom.parseString(ldt.encode( "utf-8" ))
@@ -61,7 +60,6 @@
ensembleId = ensemble.getAttribute("id")
for decoupageNode in ensemble.childNodes:
- # ldt.utils.log.debug("Indexing project decoupage : "+ repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist))
if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage" or decoupageNode.getAttribute("id") in self.decoupage_blacklist:
continue
--- a/web/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Wed Sep 15 15:20:26 2010 +0200
+++ b/web/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html Tue Sep 21 04:27:08 2010 +0200
@@ -20,12 +20,34 @@
<body>
<div id="add_content">
<div class="title">{% trans "Create content" %}</div>
-<form action="{{create_content_action}}" method="POST">
+<form action="{{create_content_action}}" method="POST" enctype="multipart/form-data" >
{% csrf_token %}
{{ content_form.as_ul }}
+{{ media_form.as_ul }}
<input type="hidden" name="form_status" value="{{form_status}}" id="content_form_status" />
<input type="submit"/>
</form>
</div>
+{% if content_form.errors %}
+<div id="content-form-error">
+ <p>The operation could not be performed because one or more error(s) occurred.<br />Please resubmit the form after making the following changes:</p>
+ <ul>
+ {% for field in content_form %}
+ {% if field.errors%}<li>{{ field.errors|striptags }}</li>{% endif %}
+ {% endfor %}
+ </ul>
+</div>
+{% endif %}
+{% if media_form.errors %}
+<div id="media-form-error">
+ <p>The operation could not be performed because one or more error(s) occurred.<br />Please resubmit the form after making the following changes:</p>
+ <ul>
+ {% for field in media_form %}
+ {% if field.errors%}<li>{{ field.errors|striptags }}</li>{% endif %}
+ {% endfor %}
+ </ul>
+</div>
+{% endif %}
+
</body>
</html>
--- a/web/ldt/ldt_utils/utils.py Wed Sep 15 15:20:26 2010 +0200
+++ b/web/ldt/ldt_utils/utils.py Tue Sep 21 04:27:08 2010 +0200
@@ -338,7 +338,7 @@
# open xml
doc = lxml.etree.parse(filepath)
- res = doc.xpath("/iri/heqd/meta")
+ res = doc.xpath("/iri/head/meta")
# update meta
for meta_node in res:
--- a/web/ldt/ldt_utils/views.py Wed Sep 15 15:20:26 2010 +0200
+++ b/web/ldt/ldt_utils/views.py Tue Sep 21 04:27:08 2010 +0200
@@ -9,7 +9,7 @@
from django.utils import simplejson
from django.utils.html import escape
from fileimport import *
-from forms import LdtImportForm, LdtAddForm, SearchForm, AddProjectForm, CopyProjectForm, ContentForm
+from forms import LdtImportForm, LdtAddForm, SearchForm, AddProjectForm, CopyProjectForm, ContentForm, MediaForm
from ldt.core.models import Owner
from models import *
from utils import *
@@ -24,6 +24,10 @@
import xml.dom
import xml.dom.ext
import xml.dom.minidom
+import tempfile
+import urllib2
+from urllib2 import urlparse
+from jogging import logging
@@ -367,29 +371,114 @@
def write_content_base(request):
+ logging.debug("write_content_base")
form_status= 'none'
if request.method =="POST":
+ logging.debug("write_content_base : POST")
content_form = ContentForm(request.POST, prefix="content")
- media_form = MediaForm(request.POST, prefix="media")
+ media_form = MediaForm(request.POST, request.FILES, prefix="media")
media_valid = media_form.is_valid()
content_valid = content_form.is_valid()
if media_valid and content_valid :
- media, created = Media.objects.get_or_create(src=media_form.cleaned_data['src'], defaults=media_form.cleaned_data)
- if not created:
- for attribute in ('external_id', 'external_permalink', 'external_publication_url', 'external_src_url', 'media_creation_date', 'videopath', 'duration', 'description', 'title'):
- setattr(media, attribute, media_form.cleaned_data.get(attribute))
- media.save()
+
+ # see if media must be created
+ cleaned_data = {}
+ cleaned_data.update(media_form.cleaned_data)
+
+ media_input_type = content_form.cleaned_data["media_input_type"]
+
+ logging.debug("write_content_base : POST media_input_type:" + media_input_type)
- content_defaults = {'media': media }
- content_defaults.update(content_form.cleaned_data)
- content, created = Content.objects.get_or_create(iri_id = content_form.cleaned_data['iri_id'], defaults = content_defaults)
- if not created:
- for attribute in ('iriurl', 'title', 'description', 'duration', 'content_creation_date', 'tags', 'media'):
- setattr(content, attribute, content_defaults[attribute])
- content.save()
- form_status = 'saved'
- media_form = MediaForm(instance=media, prefix="media")
- content_form = ContentForm(instance=content, prefix="content")
+ if media_input_type == "none":
+ media = None
+ elif media_input_type == "link":
+ media = content_form.cleaned_data["media_obj"]
+ elif media_input_type == "url" or media_input_type == "upload" or media_input_type == "create":
+ # copy file
+ #complet src
+ destination_file = None
+ source_file = None
+ destination_file_path = None
+ if media_input_type != "create":
+ try:
+ if media_input_type == "url":
+ url = cleaned_data["external_src_url"]
+ source_file = urllib2.urlopen(url)
+ source_filename = source_file.info().get('Content-Disposition', None)
+ if not source_filename:
+ source_filename = urlparse.urlparse(url).path.rstrip("/").split('/')[-1]
+ elif media_input_type == "upload":
+ source_file = request.FILES['media-media_file']
+ source_filename = source_file.name
+
+
+ destination_filepath = os.path.join(settings.STREAM_PATH, source_filename)
+ base_source_filename = source_filename
+ i = 0
+ while os.path.exists(destination_filepath):
+ base_source_filename = source_filename+"(%d)" % (i)
+ destination_filepath = os.path.join(settings.STREAM_PATH, base_source_filename)
+ i += 1
+
+ destination_file = open(destination_filepath, "w")
+ src_prefix = settings.STREAM_SRC_PREFIX.rstrip("/")
+ if len(src_prefix) > 0:
+ cleaned_data["src"] = src_prefix + "/" + base_source_filename
+ else:
+ cleaned_data["src"] = base_source_filename
+
+ chunck = source_file.read(2048)
+ while chunck:
+ destination_file.write(chunck)
+ chunck = source_file.read(2048)
+
+ except Exception as inst:
+ logging.debug("write_content_base : POST error when processing file:" + str(inst))
+ form_status = "error"
+ finally:
+ if destination_file:
+ destination_file.close()
+ if source_file:
+ source_file.close()
+
+ if form_status != "error":
+ #try:
+ del cleaned_data["media_file"]
+ if not cleaned_data['videopath']:
+ cleaned_data['videopath'] = settings.STREAM_URL
+ media, created = Media.objects.get_or_create(src=cleaned_data['src'], defaults=cleaned_data)
+ if not created:
+ for attribute in ('external_id', 'external_permalink', 'external_publication_url', 'external_src_url', 'media_creation_date', 'videopath', 'duration', 'description', 'title'):
+ setattr(media, attribute, cleaned_data.get(attribute))
+ media.save()
+ #except Exception as inst:
+# logging.debug("write_content_base : POST error when saving media:" + str(inst))
+ # form_status = "error"
+ #TODO: set error message
+ #media_form.errors = _("Error when saving the media : " + e.message)
+
+ #if needed preparetemp file and copy temp file to destination
+
+
+ if form_status != "error":
+ #try:
+ content_defaults = {}
+ content_defaults.update(content_form.cleaned_data)
+ content_defaults['media_obj'] = media
+ del content_defaults["media_input_type"]
+ content, created = Content.objects.get_or_create(iri_id = content_form.cleaned_data['iri_id'], defaults = content_defaults)
+ if not created:
+
+ for attribute in ('iriurl', 'title', 'description', 'duration', 'content_creation_date', 'tags', 'media_obj'):
+ setattr(content, attribute, content_defaults[attribute])
+ content.save()
+ form_status = 'saved'
+ media_form = MediaForm(instance=media, prefix="media")
+ content_form = ContentForm(instance=content, prefix="content")
+ #except:
+ #logging.debug("write_content_base : POST error when saving content:" + str(inst))
+ #form_status = "error"
+ #TODO : set error on content form
else:
form_status = 'error'
else:
--- a/web/ldt/settings.py Wed Sep 15 15:20:26 2010 +0200
+++ b/web/ldt/settings.py Tue Sep 21 04:27:08 2010 +0200
@@ -13,6 +13,7 @@
#SERVER_EMAIL = "admin@domain.com"
INSTALLED_APPS = (
+ 'jogging',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
@@ -28,6 +29,17 @@
'ldt.management',
)
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.middleware.locale.LocaleMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'jogging.middleware.LoggingMiddleware',
+)
+
+
WEB_URL = getattr(settings, 'WEB_URL', '')
BASE_URL = getattr(settings, 'BASE_URL', '')
MEDIA_URL = getattr(settings, 'MEDIA_URL', '')
@@ -39,6 +51,14 @@
LANGUAGES = settings.LANGUAGES
DECOUPAGE_BLACKLIST =getattr(settings, 'DECOUPAGE_BLACKLIST', 'de_PPP')
STREAM_URL = getattr(settings, 'STREAM_URL', '')
+STREAM_PATH = getattr(settings, 'STREAM_PATH', '')
+STREAM_SRC_PREFIX = getattr(settings, 'STREAM_SRC_PREFIX', '')
+LOG_FILE = getattr(settings, 'LOG_FILE', '')
+LOG_LEVEL = getattr(settings, 'LOG_LEVEL', logging.INFO)
+EMPTY_MEDIA_EXTERNALID = getattr(settings, 'EMPTY_MEDIA_EXTERNALID', None)
+
+GLOBAL_LOG_LEVEL = LOG_LEVEL
+GLOBAL_LOG_HANDLERS = [logging.FileHandler(LOG_FILE)]
ACCOUNT_ACTIVATION_DAYS = getattr(settings, 'ACCOUNT_ACTIVATION_DAYS', 7)
--- a/web/static/css/ldtform.css Wed Sep 15 15:20:26 2010 +0200
+++ b/web/static/css/ldtform.css Tue Sep 21 04:27:08 2010 +0200
@@ -105,3 +105,12 @@
padding: 5px 0px 20px 0px;
height: 300px;
}
+
+#media_fields_div {
+ width : 338px;
+ height : 50px;
+ margin-top: 10px 0px;
+ padding-left: 10px;
+ border: 1px solid #DDD;
+}
+
--- a/web/static/css/workspace.css Wed Sep 15 15:20:26 2010 +0200
+++ b/web/static/css/workspace.css Tue Sep 21 04:27:08 2010 +0200
@@ -43,6 +43,10 @@
border: none;
}
+.searchclear {
+ display: none;
+}
+
.searchfieldinputbase {
background: #ffffff url("../img/search.gif") no-repeat left center;
width: 99px;
Binary file web/static/img/clear-left.png has changed
--- a/web/static/js/LdtPlayer.js Wed Sep 15 15:20:26 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,811 +0,0 @@
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- ----------------------------------------------------------------
-
- LDTPlayer is created by http://www.iri.centrepompidou.fr
- 2010-06-14 - version 0.08
-
- init By Samuel Huron < samuel.huron (at) cybunk (dot) com >
- use JQUERY -
- use TOOLTIP FOR JQ -
- use JQUERY UI for theme management -
- use JWPLAYER -
- use HTML5 exeample by Silvia Pfeiffer
- http://annodex.net/~silvia/itext/mediafrag.html
-
-
-
- TODO : ////////////////////////////////////////
-
- ok - afficher une annotation au fil de la lecture
- ok - fermer la zonne d'annotation
- ok - ne pas fermer la zone annotation si pas demander
- ok - réduire la taille du tool tip
- ok - ajouter la gestion de fragments via les ancres
- - ajouter le share annotation
- - ajouter le share embed
-
- ok - bouton next
- - gestion créer une annotation simple
- - bouton graphique design : pause / stop
- - gestion de L'API PLAYER !!!!!!
-
- - creation du mode radio
-
- ----------------------------------------------------------------
-*/
-
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- INIT player LDT */
-
- //LdtShareTool = "<!-- AddThis Button BEGIN -->\n <div class='addthis_toolbox addthis_default_style'> \n<a href='http://www.addthis.com/bookmark.php?v=250&username=xa-4c349bb933426b8c' class='addthis_button_compact'>Share</a><span class='addthis_separator'>|</span> \n <a class='addthis_button_facebook'></a> \n <a class='addthis_button_myspace'></a> \n <a class='addthis_button_google'></a> \n <a class='addthis_button_twitter'></a> \n </div> \n <script type='text/javascript' src='http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c349bb933426b8c'></script>/n<!-- AddThis Button END -->";
-
- LdtShareTool = ""+
- "\n<a onclick=\"LdtApiPlayer.share('delicious');\" title='partager avec delicious'><span class='share shareDelicious'> </span></a>"+
- "\n<a onclick=\"LdtApiPlayer.share('facebook');\" title='partager avec facebook'> <span class='share shareFacebook'> </span></a>"+
- "\n<a onclick=\"LdtApiPlayer.share('twitter');\" title='partager avec twitter'> <span class='share shareTwitter'> </span></a>"+
- "\n<a onclick=\"LdtApiPlayer.share('myspace');\" title='partager avec Myspace'> <span class='share shareMySpace'> </span></a>"+
- "\n<a onclick=\"LdtApiPlayer.share('jamespot');\" title='partager avec JamesPot'> <span class='share shareJamesPot'> </span></a>";
-
-
- function playerLdt (width,height,file,divId,MySwfPath,AudioVideo){
-
- if (AudioVideo==true){
- $jIRI("#"+divId).append("<div id=\"ldt-Show\">\n <div id=\"Ldt-ShowAnnotation\" class=\"demo\" >\n <div id=\"Ldt-SaTitle\"></div>\n <div id=\"Ldt-SaDescription\"></div>\n <div style='text-align:right; float:right;' >\n \n "+LdtShareTool+"\n \n <div onclick=\"$jIRI('#Ldt-ShowAnnotation').slideUp();\" style='color:#ffffff;float:right;padding-right:10px;padding-left:10px;padding-bottom:5px;' >X</div> </div> </div> <div id=\"Ldt-PlaceHolder\">\n <a href=\"http://www.adobe.com/go/getflashplayer\">Get flash</a> to see this player \n </div>\n </div>\n <div id=\"Ldt-controler\" class=\"demo\">\n <div class=\"Ldt-Control1\" >\n <button id=\"ldt-CtrlPlay\" onclick=\"LdtApiPlayer.play()\">Play</button>\n <button id=\"ldt-CtrlNext\" onclick=\"LDTligne.nextAnnotation()\">next</button>\n </div>\n <div id=\"Ldt-Annotations\" class=\"ui-slider\">\n <div id=\"slider-range-min\"></div>\n </div>\n <div class=\"Ldt-Control2\">\n <button id=\"ldt-CtrlLink\" onclick=\"LdtApiPlayer.share()\">Share</button>\n <button id=\"ldt-CtrlSound\" onclick=\"LdtApiPlayer.mute()\">Sound</button>\n </div>\n </div><div class='cleaner'> </div>");
-
- } else {
- $jIRI("#"+divId).append(" <div id=\"Ldt-PlaceHolder\" style=\"visibility:hidden;height:0px;display:none;\">\n <a href=\"http://www.adobe.com/go/getflashplayer\">Get flash</a> to see this player \n </div>\n </div>\n <div id=\"Ldt-controler\" class=\"demo\">\n <div class=\"Ldt-Control1\" >\n <button id=\"ldt-CtrlPlay\" onclick=\"LdtApiPlayer.play()\">Play</button>\n <button id=\"ldt-CtrlNext\" onclick=\"LDTligne.nextAnnotation()\">next</button>\n </div>\n <div id=\"Ldt-Annotations\" class=\"ui-slider\">\n <div id=\"slider-range-min\"></div>\n </div>\n <div class=\"Ldt-Control2\">\n <button id=\"ldt-CtrlLink\" onclick=\"LdtApiPlayer.share()\">Share</button>\n <button id=\"ldt-CtrlSound\" onclick=\"LdtApiPlayer.mute()\">Sound</button>\n </div>\n </div> <div class='cleaner'> </div> <div id=\"ldt-Show\" style=\"margin-top:20px;\">\n <div id=\"Ldt-ShowAnnotation\" class=\"demo\" >\n <div id=\"Ldt-SaTitle\"></div>\n <div id=\"Ldt-SaDescription\"></div>\n <div style='text-align:right; float:right;' >\n \n "+LdtShareTool+"\n \n <div onclick=\"$jIRI('#Ldt-ShowAnnotation').slideUp();\" style='color:#ffffff;float:right;padding-right:10px;padding-left:10px;padding-bottom:5px;' >X</div> </div> </div>");
- }
- loadJson(width,height,file,MySwfPath);
- }
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- LOAD JSON AND PARSE IT */
-
- var MyLdt;
- var Durration;
- var playerLdtWidth;
- var playerLdtHeight;
-
- function loadJson (width,height,urlJson,MySwfPath){
-
- playerLdtWidth=width;
- playerLdtHeight=height;
-
- $jIRI.ajax({
- dataType: 'jsonp',
- url:urlJson,
- success: function(json){
- /* # fonction avec 1 seul media et 1 seul annotation type code a cleaner */
- /* # créer le player */
- $jIRI("<div></div>").appendTo("#output");
- MyMedia = new Media(json.medias[0].id,json.medias[0].href,json.medias[0]["meta"]["dc:duration"],json.medias[0]['dc:title'],json.medias[0]['dc:description']);
- MyMedia.createPlayer(playerLdtWidth,playerLdtHeight,json.medias[0]["meta"]["item"]["value"],MySwfPath);
- /* # créer lignes */
- /*$jIRI.each(json['annotation-types'], function(i,item) {
- });*/
- MyLdt = new Ligne (json['annotation-types'][0].id,json['annotation-types'][0]['dc:title'],json['annotation-types'][0]['dc:description'],json.medias[0]["meta"]["dc:duration"]);
- /* # créer les annotations */
- $jIRI.each(json.annotations, function(i,item) {
-
- MyLdt.addAnnotation(
- item.id,
- item.begin,
- item.end,
- item.media,
- item.content.title,
- item.content.description,
- item.content.color);
-
- });
- $jIRI.each(json.lists, function(i,item) {
- trace("lists","");
- });
- $jIRI.each(json.tags, function(i,item) {
- trace("tags","");
- });
- $jIRI.each(json.views, function(i,item) {
- trace("views","");
- });
- /* END PARSING ----------------------- */
-
-
- }
- ,error: function(data){
- alert("ERROR : "+data);
- }
- });
- }
- function callbackLdts(json){
-
- }
- function trace (msg,value){
- $jIRI("<div>"+msg+" : "+value+"</div>").appendTo("#output");
- }
-
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- Class Media */
-/*
-
- "http://advene.liris.cnrs.fr/ns/frame_of_reference/ms":"o=0",
- "id":"kia_closeup",
- "url":"D:/Thibaut/Outils_techno/IRI-LignesDeTemps/media/video/kia_closeup_BQ.flv",
- "dc:creator":"tcavalie",
- "dc:created":"2010-05-04T00:00:00",
- "dc:contributor":"tcavalie",
- "dc:modified":"2010-05-04T00:00:00",
- "dc:creator.contents":"Abbas Kiarostami",
- "dc:created.contents":"1990",
- "dc:title":"Close Up is a very very long title",
- "dc:description":"Analyse de Close Up",
- "dc:duration":"689266"
- */
- function Media (id,url,duration,title,description){
- this.id = id;
- this.url = url;
- this.title = title;
- this.description = description;
- this.duration = duration;
-
- this.lignes = new Array();
- this.updatePlayer = updatePlayerMedia;
- this.getDuration = getMediaDuration;
- this.createPlayer = createPlayerMedia;
-
- trace("Media ID :",id);
- trace("Media URL :",this.url);
- trace("- content : color",url);
- trace("- content : audio",title);
- }
- function createPlayerMedia(width,height,MyStreamer,MySwfPath){
- LdtApiPlayer = new APIplayer(width,height,this.url,this.duration,MyStreamer,MySwfPath);
- //createPlayer(width,height,this.url,this.duration,MyStreamer,MySwfPath);
- }
- function updatePlayerMedia(){
-
- }
- function getMediaDuration(){
- return (this.duration);
- }
- function getMediaTitle(){
- return (this.title);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- INTERFACE : SLIDER ( CONTROL BAR ) | BUTTON () */
- function createInterface (width,height,duration){
- trace("CREATE INTERFACE ",width+","+height+","+duration+",");
- $jIRI(function() {
-
- $jIRI("#Ldt-Annotations").width(width-(78*2));
- $jIRI("#Ldt-ShowAnnotation").width(width-10);
- $jIRI("#Ldt-controler ").width(width);
- $jIRI("#Ldt-Control").attr("z-index","100");
-
- $jIRI("#Ldt-ShowAnnotation").click(function () {
- //$jIRI(this).slideUp();
- });
-
- var LdtpPlayerY = $jIRI("#Ldt-PlaceHolder").attr("top");
- var LdtpPlayerX = $jIRI("#Ldt-PlaceHolder").attr("left");
-
- $jIRI("#slider-range-min").slider({ //range: "min",
- value: 0,
- min: 1,
- max: duration/1000,//1:54:52.66 = 3600+3240+
- step: 0.1,
- slide: function(event, ui) {
-
- //$jIRI("#amount").val(ui.value+" s");
- //player.sendEvent('SEEK', ui.value)
- LdtApiPlayer.seek(ui.value);
- //changePageUrlOffset(ui.value);
- //player.sendEvent('PAUSE')
- }
- });
- $jIRI("#amount").val($jIRI("#slider-range-min").slider("value")+" s");
-
- $jIRI(".Ldt-Control1 button:first").button({
- icons: {
- primary: 'ui-icon-play'
- },
- text: false
- }).next().button({
- icons: {
- primary: 'ui-icon-seek-next'
- },
- text: false
- });
-
- $jIRI(".Ldt-Control2 button:first").button({
- icons: {
- primary: 'ui-icon-transferthick-e-w'//,
- //secondary: 'ui-icon-volume-off'
- },
- text: false
- }).next().button({
- icons: {
- primary: 'ui-icon-volume-on'
- },
- text: false
- });
-
- });
- }
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- Conversion de couleur Decimal vers HexaDecimal || 000 si fff */
- function DEC_HEXA_COLOR(dec)
- {
- var hexa='0123456789ABCDEF',hex=''
- while (dec>15)
- {
- tmp = dec-(Math.floor(dec/16))*16;
- hex = hexa.charAt(tmp)+hex;
- dec = Math.floor(dec/16);
- }
- hex = hexa.charAt(dec)+hex;
- if (hex == "FFCC00"){ hex="";/* by default color of Ldt annotation */ }
- return(hex);
- }
-
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- API player - work in progress */
- function APIplayer (width,height,url,duration,streamerPath,MySwfPath){
-
- this.player = null;
- this.hashchangeUpdate = null;
-
- this.width = width;
- this.height = height;
- this.url = url;
- this.duration = duration;
- this.streamerPath = streamerPath;
- this.MySwfPath = MySwfPath;
-
- this.pause = APIpPause;
- this.ready = APIpReady;
- this.play = APIpPlay;
- this.seek = APIpSeek;
- this.update = APIpUpdate;
- this.mute = APIpMute;
- this.share = APIpShare;
- MyApiPlayer = this;
-
- createPlayer(width,height,this.url,this.duration,this.streamerPath,this.MySwfPath);
-
- }
-
- function APIpCreate(){
-
- }
- function APIpReady(player){
- //alert("ready");
- createInterface(this.width,this.height,this.duration);
- this.player = player;
-
- // hashchange EVENT
- if (window.addEventListener){
- // pour FIREFOX hashchange EVENT
- window.addEventListener("hashchange", function() {
- var url = location.href;
- var time = retrieveTimeFragment(url);
- trace("hashchange",time);
- if(LdtApiPlayer.hashchangeUpdate==null){
- LdtApiPlayer.seek(time);
- }else{
- LdtApiPlayer.hashchangeUpdate=null;
- }
- }, false);
-
- }
- else if (window.attachEvent){
- // FOR IE hashchange EVENT
- window.attachEvent("onhashchange", function() {
- trace("hashchange",time);
- var url = location.href;
- var time = retrieveTimeFragment(url);
- if(LdtApiPlayer.hashchangeUpdate==null){
- LdtApiPlayer.seek(time);
- }else{
- LdtApiPlayer.hashchangeUpdate=null;
- }
- }, false);
- }
-
- }
- function APIpPause(){
- this.hashchangeUpdate = true;
- this.player.sendEvent('PAUSE');
- }
- function APIpPlay(){
- this.hashchangeUpdate = true;
- this.player.sendEvent('PLAY');
- }
- function APIpMute(){
- this.player.sendEvent('MUTE');
- }
- function APIpShare(network){
-
- MyMessage = "Je regarde :";
- MyURLNow = window.location.href;
- //alert(network+" : "+MyURLNow);
-
- if(network == "facebook"){
-
- //window.title =
-
- shareURL = "http://www.facebook.com/share.php?u=";
- //http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.addthis.com%2F%3Fsms_ss%3Dfacebook
-
- }else if(network == "twitter"){
-
- shareURL = "http://twitter.com/home?status="+MyMessage;
-
- }else if(network == "myspace"){
- shareURL ="http://www.myspace.com/Modules/PostTo/Pages/?u=";
-
- }else if(network == "delicious"){
- shareURL = "http://delicious.com/save?url=";
-
- }else if(network == "JamesPot"){
- alert(network+" non actif pour l'instant : "+MyURLNow);
-
- }
-
- window.location.href = shareURL+encodeURIComponent(MyURLNow);
- }
- function APIpSeek(time){
- this.player.sendEvent('SEEK', time);
- changePageUrlOffset(time);
- }
- function APIpUpdate(time){
- this.hashchangeUpdate = true;
- this.player.sendEvent('SEEK', time);
- }
-
- function changePageUrlOffset(time) {
- trace("changeURL",time);
- // update page url
- location.hash = "#t=" + time;
- //document.displayurl.offseturl.value = location.href;
- window.location.href = location.href;
- }
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- CREER JW PLAYER creation + listener */
-
- var currentPosition = 0;
- var currentVolume = 50;
- var player = null;
- var startPosition = null;
-
- function playerReady(thePlayer) {
-
- player = window.document[thePlayer.id];
- LdtApiPlayer.ready(player);
- trace("PLAYER READY ","");
- var url = location.href;
- var time = retrieveTimeFragment(url);
- trace("PLAYER READY SEEK IF NEEDED",time);
- startPosition = time;
- addListeners();
- }
- function addListeners() {
- if (player) {
- player.addModelListener("TIME", "positionListener");
- player.addControllerListener("VOLUME", "volumeListener");
- player.addModelListener('STATE', 'stateMonitor');
- //http://developer.longtailvideo.com/trac/wiki/Player5Events
- } else {
- setTimeout("addListeners()",100);
- }
-
- // et changer les boutons
- }
- function stateMonitor(obj) {
-
- if(obj.newstate == 'PAUSED')
- {
- trace("PAUSE : ","");
- changePageUrlOffset(currentPosition);
-
- } else if (obj.newstate == 'PLAYING'){
- // une fois la video prete a lire la déplacer au bon timecode
- if(startPosition!=null){
- LdtApiPlayer.update(startPosition);
- startPosition = null;
- }
- } else if (obj.newstate == 'BUFFERING'){
- trace("BUFFERING : ","");
- //changePageUrlOffset(currentPosition);
- }
-
- }
- function positionListener(obj) {
- currentPosition = obj.position;
- var tmp = document.getElementById("posit");
- if (tmp) { tmp.innerHTML = "position: " + currentPosition; }
- $jIRI("#slider-range-min").slider("value", obj.position);
- $jIRI("#amount").val(obj.position+" s");
- // afficher annotation
- MyLdt.checkTime(currentPosition);
- }
- function volumeListener(obj) {
- currentVolume = obj.percentage;
- var tmp = document.getElementById("vol");
- if (tmp) { tmp.innerHTML = "volume: " + currentVolume; }
- }
- function createPlayer(width,height,url,duration,streamerPath,MySwfPath) {
-
- myUrlFragment = url.split(streamerPath);
- file = myUrlFragment[1];
- streamer = streamerPath;
-
- var flashvars = {
- streamer:streamer,
- file:file,
- //live:"true",
- autostart:"true",
- controlbar:"none"
- }
-
- var params = {
- allowfullscreen:"true",
- allowscriptaccess:"always",
- wmode:"transparent"
- }
-
- var attributes = {
- id:"Ldtplayer1",
- name:"Ldtplayer1"
- }
-
- swfobject.embedSWF(MySwfPath, "Ldt-PlaceHolder", width, height, "9.0.115", false, flashvars, params, attributes);
- }
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- MEDIA FRAGMENT FUNCTION*/
-
- // when the hash on the window changes, also do an offset
- // jump to time offset action
- function jumpToTimeoffset(form) {
- var time = form.time.value;
- changePageUrlOffset(time);
- }
-
- // parse the time hash out of the given url
- function retrieveTimeFragment(url) {
- var pageoffset = 0;
- var offsettime = 0;
-
- if (url.split("#")[1] != null) {
- pageoffset = url.split("#")[1];
- if (pageoffset.substring(2) != null) {
- offsettime = pageoffset.substring(2);
- }
- }
- return offsettime;
- }
-
- function ignoreTimeFragment(url){
- if (url.split("#")[1] != null) {
- pageurl= url.split("#")[0];
- }
- return pageurl;
- }
-
-
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- Class Ligne (annotationType) */
-/*
- "id":"dp_1",
- "dc:creator":"tcavalie",
- "dc:created":"2010-04-04T19:09:44",
- "dc:contributor":"perso",
- "dc:modified":"15/2/2008",
- "dc:title":"dqsdkljfh qklsdhf very very very long",
- "dc:description":"sdfg sdfg sdfg sdfg"
- */
-
- var LDTligne = null;
- function Ligne (){
- this.id = id;
- this.title = title;
- this.description = description;
- this.annotations = new Array();
- this.annotationOldRead = "";
- this.addAnnotation = addAnnotationligne;
- this.clickAnnotation= onClickLigneAnnotation;
- this.checkTime = checkTimeLigne;
- this.nextAnnotation = onClickNextAnnotation;
- }
- function Ligne (id,title,description,duration){
- this.id = id;
- this.title = title;
- this.description = description;
- //
- this.annotations = new Array();
- this.addAnnotation = addLigneAnnotation;
- this.checkTime = checkTimeLigne;
- this.nextAnnotation = onClickNextAnnotation;
- this.numAnnotation = numAnnotationTimeLine;
- this.duration = duration;
- LDTligne = this;
- trace("LIGNE ","créer "+LDTligne);
- }
- function addLigneAnnotation(id,begin,end,media,title,description,color){
- var myAnnotation = new Annotation(id,begin,end,media,title,description,color,this.duration);
- this.annotations.push(myAnnotation);
- trace("LIGNE ","add annotation ");
- }
- function onClickLigneAnnotation(id){
- //changePageUrlOffset(currentPosition);
- //player.sendEvent('SEEK', this.start);
- //trace("SEEK",this.start);
- }
- function searchLigneAnnotation(id){
- /*for (){
- }*/
- }
- function listAnnotations (){
-
- }
- function onClickNextAnnotation(){
- var annotationCibleNumber = this.numAnnotation(this.annotationOldRead)+1;
- var annotationCible = this.annotations[annotationCibleNumber];
-
- if(annotationCibleNumber<this.annotations.length-1){
- annotationCible.begin
- player.sendEvent('SEEK', annotationCible.begin/1000);
-trace("LIGNE ","| next = "+annotationCibleNumber+" - "+this.annotations.length+" | seek :"+annotationCible.begin/1000);
- }else{
- player.sendEvent('SEEK', this.annotations[0].begin/1000);
- }
-
-
- }
- function numAnnotationTimeLine(annotationCible){
- for (var i=0; i < this.annotations.length; ++i){
- if(annotationCible == this.annotations[i]){
- return i;
- }
- }
- }
- function checkTimeLigne(time){
- var annotationTempo = -1;
- //trace("LENGTH : ",this.annotations.length);
- for (var i=0; i < this.annotations.length; ++i){
-
- if (time>this.annotations[i].begin/1000 && time<this.annotations[i].end/1000){
- var annotationTempo = this.annotations[i];
- // si différentes de la précédente
- if(annotationTempo!=this.annotationOldRead){
- this.annotationOldRead = annotationTempo;
- trace("Check : ","annotation ici : "+i+" title "+annotationTempo.title);
- $jIRI('#Ldt-ShowAnnotation').slideUp();
-
- $jIRI("#Ldt-SaTitle").delay(100).text(annotationTempo.title);
- $jIRI("#Ldt-SaDescription").delay(100).text(annotationTempo.description);
-
- $jIRI('#Ldt-ShowAnnotation').delay(100).slideDown();
- /*
- a2a_config.linkname = 'Example Page 2';
- a2a_config.linkurl = 'http://www.example.com/page_2.html';
- a2a.init('page');
-*/
- var tempolinkurl = ignoreTimeFragment(window.location.href)+"#t="+(this.annotations[i].begin/1000);
- /*
- a2a_config = {
- linkname: annotationTempo.title,
- linkurl:tempolinkurl
- };*/
-
- //alert(a2a_config.linkurl);
- /*
- a2a_config.linkname = annotationTempo.title;
- a2a_config.linkurl = tempolinkurl;
- a2a_config.show_title =true;
- a2a_config.onclick=true;
- */
- //a2a_config.init('page');
- //a2a.init('page');
-/*
- a2a_config.templates = {
- twitter: "Reading: ${title} ${link} @iri-live"
- };*/
- //alert("ok ? "+ a2a_config.linkurl);
-
- }
- break;
- }
-
- }
- // si il y en a pas : retractation du volet
- if( annotationTempo == -1){
- if(annotationTempo!=this.annotationOldRead){
- trace("Check : ","pas d'annotation ici ");
- $jIRI('#Ldt-ShowAnnotation').slideUp();
- this.annotationOldRead = annotationTempo;
- }
- }
-
- }
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- CLASSE Annotation */
-/*
-
- "begin":"767",
- "end":"785",
- "id":"dp_1_sp_3",
- "media":"kia_closeup",
- "content": {
- "mimetype":"application/x-ldt-structured",
- "title":"mon titre",
- "description":"ma description en <b>gras</b> .",
- "color":"16763904",
- "audio":{"src":"","mimetype":"audio/mp3","href":""}
- },
- "meta":
- {
- "id-ref":"dp_1",
- "dc:creator":"tcavalie",
- "dc:created":"2010-04-04T19:09:44",
- "dc:contributor":"perso",
- "dc:modified":"9/10/2007"
- }
- */
-
- function Annotation (){
- this.id = null;
- this.begin = null;
- this.end = null;
- this.media = null;
- this.description = null;
- this.title = null;
- this.color = null;
- this.onRollOver = onRollOverAnnotation;
- this.onClick = onClickAnnotation;
- this.toolTip = rollOverAnnotation;
- this.draw = drawAnnotation;
- trace("annotation ","réussi")
- }
- function Annotation (id,begin,end,media,title,description,color,duration){
- this.id = id;
- this.begin = begin;
- this.end = end;
- this.media = media;
- this.description = description;
- this.title = title;
- this.color = color;
- this.duration = duration;
- //
- this.onRollOver = onRollOverAnnotation;
- //this.onClick = onClickAnnotation;
- this.toolTip = tootTipAnnotation;
- this.draw = drawAnnotation;
- //this.show = showAnnotationNotice;
- // draw it
- this.draw();
-
- //
- trace("Annotation created : ",id);
- }
- function drawAnnotation (){
- //alert (this.duration);
- startPourcent = timeToPourcent(this.begin,this.duration); // temps du média
- endPourcent = timeToPourcent(this.end,this.duration)-startPourcent;
- $AnnotationTemplate = "<div title='"+this.title+"' id='"+this.id+"' class='ui-slider-range ui-slider-range-min ui-widget-header iri-chapter' width='100%' style=\"left:"+startPourcent+"%; width:"+endPourcent+"%; padding-top:15px; border-left:solid 1px #aaaaaa; border-right:solid 1px #aaaaaa; background:#"+DEC_HEXA_COLOR(this.color)+";\" onclick=\"LdtApiPlayer.seek('"+Math.round(this.begin/1000)+"');$jIRI('#Ldt-ShowAnnotation').slideDown();\" ></div> ";
- //alert(this.color+" : "+DEC_HEXA_COLOR(this.color));
-
- $toolTipTemplate = "<div class='Ldt-tooltip'>"
- +"<div class='title'>"+this.title+"</div>"
- +"<div class='time'>"+this.begin+" : "+this.end+"</div>"
- +"<div class='description'>"+this.description+"</div>"
- +"</div>";
-
-
- $jIRI("<div>"+$AnnotationTemplate+"</div>").appendTo("#Ldt-Annotations");
- $jIRI("#"+this.id).tooltip({ effect: 'slide'});
-
- trace(" ### ","ADD ANOTATION : "+this.begin+" "+this.end+" "+this.title+" | "+startPourcent+" | "+endPourcent+" | duration = "+this.duration);
-
- }
- function tootTipAnnotation() {
- // 1 chercher le div correspondant
- // 2 y mettre les information
- return this.color + ' ' + this.type + ' apple';
- }
- function onRollOverAnnotation(){
- this.tootTip();
- }
- function timeToPourcent(time,timetotal){
- return (parseInt(Math.round(time/timetotal*100)));
- }
-
-
-
-
-
-
-
-/* ----------------------------------------------------------------
- ----------------------------------------------------------------
- Class tracess */
-
- function Tracer (){
-
- }
- function addTrace(){
-
- }
-
-
-
\ No newline at end of file
--- a/web/static/js/projectscontents.js Wed Sep 15 15:20:26 2010 +0200
+++ b/web/static/js/projectscontents.js Tue Sep 21 04:27:08 2010 +0200
@@ -76,7 +76,7 @@
forceType: 'iframe',
titleFromIframe: false,
height:662,
- width:650,
+ width:750,
bgColor: 'rgb(239, 239, 239)',
padding: 5,
url: embed_url+'?json_url='+escape(json_url)+'&player_id='+escape(player_id),
@@ -125,9 +125,11 @@
target.attr('timer',setTimeout(function() {
target.next(".searchajaxloader").show();
+ target.next(".searchclear").hide();
url = url.replace('__FILTER__',escape($(target).realVal()));
$(container_selector).load(url, null, function() {
target.next(".searchajaxloader").hide();
+ target.next(".searchclear").show();
init_events($(container_selector));
target.removeAttr('timer');
});