--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/metadatacomposer/forms.py Tue May 21 17:41:31 2013 +0200
@@ -0,0 +1,9 @@
+# forms.py
+from django import forms
+from metadatacomposer.models import Image
+
+class ImageUploadModelForm(forms.ModelForm):
+
+ class Meta:
+ model = Image
+ fields = ['image_file', 'title', 'description']
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/metadatacomposer/migrations/0001_initial.py Tue May 21 17:41:31 2013 +0200
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding model 'Image'
+ db.create_table('metadatacomposer_image', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('image_file', self.gf('django.db.models.fields.files.ImageField')(max_length=2048)),
+ ('width', self.gf('django.db.models.fields.IntegerField')()),
+ ('height', self.gf('django.db.models.fields.IntegerField')()),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=1024, null=True, blank=True)),
+ ('description', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
+ ('creation_date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+ ('modification_date', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
+ ))
+ db.send_create_signal('metadatacomposer', ['Image'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'Image'
+ db.delete_table('metadatacomposer_image')
+
+
+ models = {
+ 'metadatacomposer.image': {
+ 'Meta': {'object_name': 'Image'},
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'height': ('django.db.models.fields.IntegerField', [], {}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'image_file': ('django.db.models.fields.files.ImageField', [], {'max_length': '2048'}),
+ 'modification_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
+ 'width': ('django.db.models.fields.IntegerField', [], {})
+ }
+ }
+
+ complete_apps = ['metadatacomposer']
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/metadatacomposer/models.py Tue May 21 17:41:31 2013 +0200
@@ -0,0 +1,24 @@
+from django.db import models
+import os
+import time
+
+
+def image_file_name(instance, filename):
+ now = time.time()
+ milliseconds = '%03d' % int((now - int(now)) * 1000)
+ localtime = time.localtime()
+ _, ext = os.path.splitext(filename)
+ filename = time.strftime('%Y%m%d%H%M%S', localtime) + milliseconds
+ return 'metadatacomposer/images/' + filename + ext
+
+
+class Image(models.Model):
+
+ image_file = models.ImageField(width_field="width", height_field="height", upload_to=image_file_name, max_length=2048)
+ width = models.IntegerField(null=False, blank=False)
+ height = models.IntegerField(null=False, blank=False)
+ title = models.CharField(null=True, blank=True, max_length=1024)
+ description = models.TextField(null=True, blank=True)
+ creation_date = models.DateTimeField(auto_now_add=True)
+ modification_date = models.DateTimeField(auto_now=True)
+
\ No newline at end of file
--- a/src/metadatacomposer/static/metadatacomposer/js/edition.js Tue May 21 17:41:10 2013 +0200
+++ b/src/metadatacomposer/static/metadatacomposer/js/edition.js Tue May 21 17:41:31 2013 +0200
@@ -3,7 +3,46 @@
var global = {
diaporama : null,
idAnnotation : null
-};
+},
+chapitres = [],
+annotations = [];
+
+myProject.onLoad(function() {
+
+ $(".project-title").text(myProject.title);
+
+ myMedia = myProject.getCurrentMedia();
+
+ IriSP.htmlPlayer(
+ myMedia,
+ $(".main-video"),
+ {
+ width: 460,
+ height: 345,
+ controls: true,
+ autostart: true
+ }
+ );
+
+ myMedia.on("timeupdate", function(t) {
+
+ //curseur chapitre
+ var pos = $(".chapitre-cut-wrap").width() * t / myMedia.duration,
+ wContainer = $('.chapitre-cut-wrap').width(),
+ btnCutChapter = $('.btn-cut-chapter'),
+ wBtnCutChapter = btnCutChapter.outerWidth();
+
+ $(".indicateur-chapter").css("left",pos);
+ if(pos+wBtnCutChapter>wContainer){
+ btnCutChapter.css("left",(pos - wBtnCutChapter));
+ }else{
+ btnCutChapter.css("left",pos);
+ }
+
+ });//timeupdate
+
+});//myProject.onLoad
+
//modal
$(document).on('click', 'a.open-modal', function(e){
@@ -91,7 +130,7 @@
$('.project-title').html($(this).val());
});
-//chapter
+//--chapter
$('.list-chapter-wrap').on('click', '.edit-chapter', function(e){
e.preventDefault();
var viewChapter = {
@@ -109,6 +148,7 @@
//nouveau chapitre
$('.chapter-widget').on('click', '.btn-cut-chapter', function(e){
e.preventDefault();
+
var uniqId = 'id' + (new Date()).getTime();
$.get('template.html', function(templates){
var viewChapterRow = {
@@ -120,6 +160,9 @@
});
});
+ function addChapter(data){
+
+ }
//edit annotation
$('#list-annotations').on('click', 'a.btn-edit-annotation', function(e){
@@ -261,11 +304,7 @@
});
//annotation > diaporama (spin)
-var spinParam = {
- imageBasePath :'lib/spin/img/',
- max:60,
- min:0
-};
+
//config
//CLEditor annotation > text (wysiwyg)
@@ -371,4 +410,4 @@
$('#annotation-tab a:last-child').tab('show');
-});
\ No newline at end of file
+});//ready
\ No newline at end of file
--- a/src/metadatacomposer/static/metadatacomposer/js/projet.js Tue May 21 17:41:10 2013 +0200
+++ b/src/metadatacomposer/static/metadatacomposer/js/projet.js Tue May 21 17:41:31 2013 +0200
@@ -6,7 +6,7 @@
//ZeroClipboard (fonctionne sous localhost)
var clip = new ZeroClipboard( $('.clipboard'), {
- moviePath: "lib/ZeroClipboard/ZeroClipboard.swf"
+ moviePath: ZeroClipboardMoviePath
});
clip.on( 'complete', function(client, args) {
alert("Copied text to clipboard: " + args.text );
--- a/src/metadatacomposer/templates/metadatacomposer_home.html Tue May 21 17:41:10 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_home.html Tue May 21 17:41:31 2013 +0200
@@ -46,7 +46,7 @@
<!-- block containers -->
<article class="container">
<div class="row article-title">
- <h3 class="span8"><i class="icon-file"></i>Derniers projets</h3>
+ <h3 class="span8"><i class="icon-file"></i> Derniers projets</h3>
<div class="span4 wrap-btn-add"><a class="btn btn-success" href="#">Ajouter un projet <i class="icon-plus-sign"></i></a></div>
</div>
<div class="row">
@@ -64,30 +64,12 @@
<div class="span4 wrap-btn-add"><a class="btn btn-success" href="#">Ajouter une image <i class="icon-plus-sign"></i></a></div>
</div>
<div class="row">
- <div class="span2">
- <a href=""><img src="{% static 'metadatacomposer/img/140x140.gif' %}" alt=""></a>
- <h4><a href="">Titre de l'image</a></h4>
- </div>
+ {% for i in images %}
<div class="span2">
- <a href=""><img src="{% static 'metadatacomposer/img/140x140.gif' %}" alt=""></a>
- <h4><a href="">Titre de l'image</a></h4>
- </div>
- <div class="span2">
- <a href=""><img src="{% static 'metadatacomposer/img/140x140.gif' %}" alt=""></a>
- <h4><a href="">Titre de l'image</a></h4>
+ <a href="">{% thumbnail i.image_file "140x140" crop="center" format="PNG" as im %}<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />{% empty %}<img src="{% static 'metadatacomposer/img/140x140.gif' %}" width="140px" height="140px" />{% endthumbnail %}
+ <h4>{{ i.title }}</h4></a>
</div>
- <div class="span2">
- <a href=""><img src="{% static 'metadatacomposer/img/140x140.gif' %}" alt=""></a>
- <h4><a href="">Titre de l'image</a></h4>
- </div>
- <div class="span2">
- <a href=""><img src="{% static 'metadatacomposer/img/140x140.gif' %}" alt=""></a>
- <h4><a href="">Titre de l'image</a></h4>
- </div>
- <div class="span2">
- <a href=""><img src="{% static 'metadatacomposer/img/140x140.gif' %}" alt=""></a>
- <h4><a href="">Titre de l'image</a></h4>
- </div>
+ {% endfor %}
</div>
</article>
<article class="container">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/metadatacomposer/templates/metadatacomposer_modal_image.html Tue May 21 17:41:31 2013 +0200
@@ -0,0 +1,62 @@
+{% load static %}
+<div class="row">
+ <div class="span3">
+ <ul class="modal-menu">
+ <li class="bibliotheque-link"><a data-type-media="image" data-title="Bibliothèque" class="btn open-modal" href="modal-bibliotheque-image.html"><i class="icon-folder-open"></i> Bibliothèque</a></li>
+ <li><a class="btn active" tabindex="-1" href="#"><i class="icon-plus-sign"></i> Ajouter une image</a></li>
+ </ul>
+ </div>
+ <div class="span8 offset1 popup-content">
+ <h4>Informations et source de l'image</h4>
+ <form class="form-horizontal" action="{% url composer_modal_image branding=branding %}" enctype="multipart/form-data" method="post">{% csrf_token %}
+ {% for error in form.errors.name %}
+ <span class="error">{{ error }}</span>
+ {% endfor %}
+ <div class="control-group">
+ <label class="control-label" for="media-title">Titre :</label>
+ <div class="controls">
+ <input type="text" name="title" id="id_title" placeholder="Titre de l'image.." maxlength="1024"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="media-description">Description :</label>
+ <div class="controls">
+ <textarea name="description" id="id_description"></textarea>
+ </div>
+ </div>
+ <!--div class="control-group">
+ <label class="control-label" for="media-type-select">Type de la source :</label>
+ <div class="controls">
+ <select name="" id="media-type-select">
+ <option value="url">URL</option>
+ <option value="upload" selected>Upload</option>
+ </select>
+ </div>
+ </div>
+ <div class="control-group input-image-url">
+ <label class="control-label" for="media-url-link">URL de l'image :</label>
+ <div class="controls">
+ <input type="text" name="title-media" id="media-url-link" placeholder="Titre de l'image..">
+ <a href="#" class="btn btn-previsualisation" class="btn"><i class="icon-eye-open"></i> Prévisualiser</a>
+ </div>
+ </div-->
+ <div class="control-group input-image-upload">
+ <label class="control-label" for="media-url-link">Fichier de l'image :</label>
+ <div class="controls">
+ <input type="file" name="image_file" id="id_image_file"/>
+ <a href="#" class="btn btn-previsualisation" class="btn"><i class="icon-eye-open"></i> Prévisualiser</a>
+ </div>
+ </div>
+ <div class="control-group">
+ <div class="controls previsualisation">
+ </div>
+ </div>
+ <div class="control-group">
+ <div class="controls">
+ <a href="#" class="btn-cancel btn btn-inverse"><i class="icon-reply" data-dismiss="modal" aria-hidden="true"></i> Annuler</a>
+ <button type="submit" class="btn btn-success"><i class="icon-save"></i> Sauvegarder</button>
+ </div>
+ </div>
+ </form>
+ </div>
+</div>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/metadatacomposer/templates/metadatacomposer_modal_video.html Tue May 21 17:41:31 2013 +0200
@@ -0,0 +1,53 @@
+{% load static %}
+<div class="row">
+ <div class="span3">
+ <ul class="modal-menu">
+ <li class="bibliotheque-link"><a data-type-media="video" data-title="Bibliothèque" class="btn open-modal" href="modal-bibliotheque-video.html"><i class="icon-folder-open"></i> Bibliothèque</a></li>
+ <li><a class="btn active" tabindex="-1" href="#"><i class="icon-plus-sign"></i> Ajouter une video</a></li>
+ </ul>
+ </div>
+ <div class="span8 offset1 popup-content">
+
+ <form class="row" action="#" method="post">
+ <h4 class="span8">Informations sur la vidéo</h4>
+ <div class="span4">
+
+ <label for="title-media-video">Titre :</label>
+ <input type="text" id="title-media-video" name="">
+ <label for="description-title-media">Description :</label>
+ <textarea name="" id="description-title-media"></textarea>
+ </div>
+ <div class="span4">
+ <label for="">Durée de la vidéo :</label>
+ <div class="select-duration">
+ <input pattern="[0-9]*" name="" type="text" id="video-hour" class="number-spin span1" value="1">
+ <label for="video-hour">H</label>
+ <input pattern="[0-9]*" name="" type="text" id="video-minute" class="number-spin span1" value="1">
+ <label for="video-minute">M</label>
+ <input pattern="[0-9]*" name="" type="text" id="video-seconde" class="number-spin span1" value="1">
+ <label for="video-seconde">S</label>
+ </div>
+ <label for="">Vignette de la vidéo :</label>
+ <input type="file">
+ </div>
+ <div class="span8">
+ <h4>Source de la vidéo</h4>
+ <label for="">URL de la vidéo :</label>
+ <input type="text" class="input-xxlarge" placeholder="http://youtu.be">
+ <div class="control-group">
+ <div class="controls">
+ <a href="#" class="btn-cancel btn btn-inverse"><i class="icon-reply" data-dismiss="modal" aria-hidden="true"></i> Annuler</a>
+ <button type="submit" class="btn btn-success"><i class="icon-save"></i> Sauvegarder</button>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+</div>
+<script type="text/javascript">
+$('.select-duration .number-spin').spin({
+ imageBasePath :"{% static 'metadatacomposer/lib/spin/img/' %}",
+ max:60,
+ min:0
+});
+</script>
\ No newline at end of file
--- a/src/metadatacomposer/templates/metadatacomposer_project_list.html Tue May 21 17:41:10 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_project_list.html Tue May 21 17:41:31 2013 +0200
@@ -87,4 +87,7 @@
{% block js_page %}
<script src="{% static 'metadatacomposer/lib/ZeroClipboard/ZeroClipboard.min.js' %}"></script>
<script src="{% static 'metadatacomposer/js/projet.js' %}"></script>
+ <script>
+ var ZeroClipboardMoviePath = "{% static 'metadatacomposer/lib/ZeroClipboard/ZeroClipboard.swf' %}";
+ </script>
{% endblock %}
--- a/src/metadatacomposer/templates/metadatacomposer_resource_list.html Tue May 21 17:41:10 2013 +0200
+++ b/src/metadatacomposer/templates/metadatacomposer_resource_list.html Tue May 21 17:41:31 2013 +0200
@@ -19,7 +19,7 @@
<div class="row article-title">
<h3 class="span8"><i class="icon-picture"></i> Liste des images</h3>
<div class="span4 wrap-btn-add">
- <a data-type-media="image" data-title="Ajouter une image" class="btn btn-success open-modal" href="modal-image.html">
+ <a data-type-media="image" data-title="Ajouter une image" class="btn btn-success open-modal" href="{% url composer_modal_image branding=branding %}">
Ajouter une image <i class="icon-plus-sign"></i>
</a>
</div>
@@ -48,7 +48,7 @@
</td>
<td>14/03/2014</td>
<td>
- <a data-type-media="image" data-title="Modifier une image" class="btn open-modal" href="modal-image.html"><i class="icon-pencil"></i></a>
+ <a data-type-media="image" data-title="Modifier une image" class="btn open-modal" href="{% url composer_modal_image branding=branding %}"><i class="icon-pencil"></i></a>
<a class="btn btn-delete" data-title="Titre du média" href="#row-list-ressources-image-id1">
<i class="icon-remove"></i>
</a>
@@ -66,7 +66,7 @@
</td>
<td>14/03/2014</td>
<td>
- <a data-type-media="image" data-title="Modifier une image" class="btn open-modal" href="modal-image.html"><i class="icon-pencil"></i></a>
+ <a data-type-media="image" data-title="Modifier une image" class="btn open-modal" href="{% url composer_modal_image branding=branding %}"><i class="icon-pencil"></i></a>
<a class="btn btn-delete" data-title="Titre du média" href="#row-list-ressources-image-id2">
<i class="icon-remove"></i>
</a>
@@ -92,7 +92,7 @@
<div class="row article-title">
<h3 class="span8"><i class="icon-film"></i> Liste des vidéos</h3>
<div class="span4 wrap-btn-add">
- <a data-type-media="video" data-title="Ajouter une vidéo" class="btn btn-success open-modal" href="modal-video.html">
+ <a data-type-media="video" data-title="Ajouter une vidéo" class="btn btn-success open-modal" href="{% url composer_modal_video branding=branding %}">
Ajouter une vidéo <i class="icon-plus-sign"></i>
</a>
</div>
--- a/src/metadatacomposer/templates/partial/resource_content_list.html Tue May 21 17:41:10 2013 +0200
+++ b/src/metadatacomposer/templates/partial/resource_content_list.html Tue May 21 17:41:31 2013 +0200
@@ -26,7 +26,7 @@
</td>
<td>{{ res.content.update_date|date:"Y/m/d" }}</td>
<td>
- <a data-type-media="video" data-title="Modifier une vidéo" class="btn open-modal" href="modal-video.html"><i class="icon-pencil"></i></a>
+ <a data-type-media="video" data-title="Modifier une vidéo" class="btn open-modal" href="{% url composer_modal_video branding=branding %}"><i class="icon-pencil"></i></a>
<a class="btn btn-delete" data-title="Titre du média" href="#row-list-ressources-video-id1">
<i class="icon-remove"></i>
</a>
--- a/src/metadatacomposer/urls.py Tue May 21 17:41:10 2013 +0200
+++ b/src/metadatacomposer/urls.py Tue May 21 17:41:31 2013 +0200
@@ -1,12 +1,15 @@
from django.conf.urls.defaults import patterns, url
from metadatacomposer.views import MetadataComposerHome, MetadataComposerProjectList,\
- MetadataComposerResourceList, MetadataComposerContentPagination
+ MetadataComposerResourceList, MetadataComposerContentPagination,\
+ MetadataComposerModalVideo, MetadataComposerModalImage
urlpatterns = patterns('',
url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog', name='jsi18n'),
url(r'^(?P<branding>.*)/projectlist/$', MetadataComposerProjectList.as_view(), name="composer_project_list"),
url(r'^(?P<branding>.*)/resourcelist/$', MetadataComposerResourceList.as_view(), name="composer_resource_list"),
url(r'^(?P<branding>.*)/contentpage/$', MetadataComposerContentPagination.as_view(), name="composer_content_page"),
+ url(r'^(?P<branding>.*)/modalvideo/$', MetadataComposerModalVideo.as_view(), name="composer_modal_video"),
+ url(r'^(?P<branding>.*)/modalimage/$', MetadataComposerModalImage.as_view(), name="composer_modal_image"),
url(r'^(?P<branding>.*)/$', MetadataComposerHome.as_view(), name="composer_home"),
url(r'^$', MetadataComposerHome.as_view(), name="composer_home"),
)
--- a/src/metadatacomposer/views.py Tue May 21 17:41:10 2013 +0200
+++ b/src/metadatacomposer/views.py Tue May 21 17:41:31 2013 +0200
@@ -1,13 +1,13 @@
from django.conf import settings
-from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
-from django.core.exceptions import ObjectDoesNotExist
from django.core.paginator import Paginator, InvalidPage, EmptyPage
-from django.http import HttpResponseNotFound, HttpResponse
from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.views.generic.base import View, TemplateResponseMixin
+from django.views.generic.edit import FormView
from ldt.ldt_utils.models import Project, Content
+from metadatacomposer.forms import ImageUploadModelForm
+from metadatacomposer.models import Image
import logging #@UnresolvedImport
@@ -39,10 +39,12 @@
self.branding = branding
projects = Project.safe_objects.filter(owner=request.user).order_by('-modification_date')[:6]
+ images = Image.objects.order_by('-modification_date')[:6]
+ logger.debug(images)
contents = Content.safe_objects.order_by('-update_date')[:6]
context = self.get_context_dict(request)
- context.update({"projects":projects, "contents": contents})
+ context.update({"projects":projects, "images": images, "contents": contents})
return self.render_to_response(context)
@@ -143,4 +145,63 @@
results.object_list = results_object_list
return results
-
\ No newline at end of file
+
+
+
+class MetadataComposerModalVideo(TemplateResponseMixin, MetadataComposerContextView):
+
+ def get_template_names(self):
+ return "metadatacomposer_modal_video.html"
+
+ @method_decorator(login_required)
+ def dispatch(self, *args, **kwargs):
+ return super(MetadataComposerModalVideo, self).dispatch(*args, **kwargs)
+
+ def get(self, request, branding="iri", **kwargs):
+ self.branding = branding
+ context = self.get_context_dict(request)
+ return self.render_to_response(context)
+
+
+
+class MetadataComposerModalImage(TemplateResponseMixin, MetadataComposerContextView):
+
+ def get_template_names(self):
+ return "metadatacomposer_modal_image.html"
+
+ @method_decorator(login_required)
+ def dispatch(self, *args, **kwargs):
+ return super(MetadataComposerModalImage, self).dispatch(*args, **kwargs)
+
+ def get(self, request, branding="iri", **kwargs):
+ self.branding = branding
+
+ # Add form
+ form = ImageUploadModelForm()
+
+ context = self.get_context_dict(request)
+ context.update({"form":form})
+ return self.render_to_response(context)
+
+ def post(self, request, branding="iri", **kwargs):
+ self.branding = branding
+
+ # Check form
+ form = ImageUploadModelForm(request.POST, request.FILES)
+ logger.debug("COUCOU 1")
+ logger.debug(form)
+ logger.debug(form.is_valid())
+ if form.is_valid():
+ logger.debug("COUCOU 2")
+ # If an image id was in the form, we update the existing image
+ if 'image_pk' in request.POST:
+ form = ImageUploadModelForm(request.POST, request.FILES, instance=Image.objects.get(pk=request.POST['image_pk']))
+ form.save()
+ else:
+ logger.debug("COUCOU 3")
+ context = self.get_context_dict(request)
+ context.update({"form":form})
+ return redirect(request.META['HTTP_REFERER'])
+
+
+