--- a/src/ldt/ldt/ldt_utils/migrations/0005_add_permissions.py Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/migrations/0005_add_permissions.py Thu Jan 26 17:27:27 2012 +0100
@@ -20,10 +20,8 @@
for model in ["project", "content", "segment", "author", "media"]:
self.add_perm(orm, model)
-
-
- set_default_permissions(is_migration=True, orm=orm)
-
+
+ # Run command ./manage.py assignpermissions after this migration
def add_perm(self, orm, model_name):
--- a/src/ldt/ldt/ldt_utils/migrations/0007_auto__add_field_content_image__del_field_media_image.py Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/migrations/0007_auto__add_field_content_image__del_field_media_image.py Thu Jan 26 17:27:27 2012 +0100
@@ -1,5 +1,6 @@
# encoding: utf-8
import datetime
+from django.conf import settings
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
@@ -9,7 +10,7 @@
def forwards(self, orm):
# Adding field 'Content.image'
- db.add_column('ldt_utils_content', 'image', self.gf('sorl.thumbnail.fields.ImageField')(default='thumbnails/contents/drive.jpg', max_length=100), keep_default=False)
+ db.add_column('ldt_utils_content', 'image', self.gf('sorl.thumbnail.fields.ImageField')(default=settings.DEFAULT_CONTENT_ICON, max_length=100), keep_default=False)
# Deleting field 'Media.image'
db.delete_column('ldt_utils_media', 'image')
--- a/src/ldt/ldt/ldt_utils/migrations/0011_gen_stat_annotation.py Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/migrations/0011_gen_stat_annotation.py Thu Jan 26 17:27:27 2012 +0100
@@ -11,19 +11,13 @@
def forwards(self, orm):
"Write your forwards methods here."
-
- for proj in orm.Project.objects.all():
- update_stat_project(proj)
-
- # Sets fields nb_annotation and stat_annotation to 0 and 0,0,...,0
- # for contents that do not have annotations
- for content in orm.Content.objects.all():
- if not content.stat_annotation:
- update_stat_content(content)
+ pass
+ # use command ./manage.py statannotation after this migration
def backwards(self, orm):
"Write your backwards methods here."
+ pass
models = {
--- a/src/ldt/ldt/ldt_utils/models.py Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/models.py Thu Jan 26 17:27:27 2012 +0100
@@ -346,11 +346,11 @@
if self.pk:
everyone = Group.objects.get(name=settings.PUBLIC_GROUP_NAME)
if value:
- assign('view_content', everyone, self)
- assign('view_media', everyone, self.media_obj)
+ assign('ldt_utils.view_content', everyone, self)
+ assign('ldt_utils.view_media', everyone, self.media_obj)
else:
- remove_perm('view_content', everyone, self)
- remove_perm('view_media', everyone, self.media_obj)
+ remove_perm('ldt_utils.view_content', everyone, self)
+ remove_perm('ldt_utils.view_media', everyone, self.media_obj)
return locals()
@@ -375,6 +375,7 @@
# Tag management
def get_tags(self):
return Tag.objects.get_for_object(self)
+
@@ -502,7 +503,13 @@
default_image = os.path.basename(settings.DEFAULT_CONTENT_ICON)
for content in self.contents.all():
- if os.path.basename(content.image.file.name) != default_image:
+ add_image = False
+ try:
+ current_image = content.image.file.name
+ except IOError:
+ add_image = True
+
+ if add_image or current_image != default_image:
self.image = content.image
return True
--- a/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_all_contents.html Thu Jan 26 17:27:27 2012 +0100
@@ -9,6 +9,7 @@
{{block.super}}
<script src="{{LDT_MEDIA_PREFIX}}js/jquery.min.js" type="text/javascript"/></script>
<script src="{{LDT_MEDIA_PREFIX}}js/raphael.js" type="text/javascript"/></script>
+<script src="{{LDT_MEDIA_PREFIX}}js/Ldt_front_sparkline.js" type="text/javascript"/></script>
{% endblock %}
{% block css_import %}
@@ -16,50 +17,6 @@
<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/front_home.css" type="text/css"/>
{% endblock %}
-{% block js_declaration %}
-{{block.super}}
-<script type="text/javascript">
- var _width = 293,
- _height = 20;
- var _medias = [ {% for content in content_list %}
- {
- "iri_id" : '{{ content.iri_id }}',
- "stats" : [{{ content.stat_annotation }}],
- },{% endfor %}
- ];
- $(document).ready(function () {
- $('.graph_annotation').each(function(_i) {
- var _values = _medias[_i].stats,
- _nb = _values.length,
- _max = _values.reduce(function(_a,_b) {
- return Math.max(_a,_b);
- }, 1),
- _x = function(_p) {
- return _p * _width / _nb;
- },
- _y = function(_p) {
- return _height * ( 1 - _p / _max );
- },
- _d = _values.map(function(_v,_k) {
- return ( _k == 0 ?
- "M" + _x(_k) + " " + _y(_v) :
- "C" + _x(_k-.5) + " " + _y(_values[_k - 1])
- + " " + + _x(_k-.5) + " " + _y(_v)
- + " " + + _x(_k) + " " + _y(_v)
- ) ;
- }).join("") + "L" + _width + " " + _height + "L0 " + _height;
- this.innerHTML = '';
- var _paper = new Raphael(this,_width,_height);
- _paper.path(_d).attr({
- "fill" : "#adadad",
- "stroke" : "#808080"
- });
- });
- });
-</script>
-
-{% endblock %}
-
{% block body %}
{{block.super}}
<!-- Last annotated contents -->
@@ -71,8 +28,18 @@
</li>
{% for content in content_list %}
<li class="li_media">
- <a href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}">{% thumbnail content.image "294x165" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}" alt="{% trans 'open this media' %}" title="{% trans 'open this media' %}">{% endthumbnail %}
- <span class="graph_annotation"></span></a>
+ <a class="img_and_overlay" href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}">
+ {% thumbnail content.image "294x165" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}" alt="{% trans 'open this media' %}" title="{% trans 'open this media' %}">{% endthumbnail %}
+ <div class="overlay">
+ <ul class="polemics">
+ <li class="pol-negative" style="width:0%">0%</li>
+ <li class="pol-positive" style="width:0%">0%</li>
+ <li class="pol-reference" style="width:0%">0%</li>
+ <li class="pol-question" style="width:0%">0%</li>
+ </ul>
+ <span class="graph_annotation" id="sp_{{ content.iri_id }}">{{ content.stat_annotation }}</span>
+ </div>
+ </a>
<div class="bulle_annot" title="{% blocktrans count nb=content.nb_annotation %}{{nb}} annotation on this media{% plural %}{{nb}} annotations on this media{% endblocktrans %}">{{ content.nb_annotation }}</div>
<p><a href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}"><b>{% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}</b></a></p>
<p>{% trans 'by' %} IRI | {{content.duration|str_duration:"h"}}</p>
--- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Jan 26 17:27:27 2012 +0100
@@ -6,6 +6,13 @@
{% block title %}{% trans "front.home" %}{% endblock %}
+{% block js_import %}
+{{block.super}}
+<script src="{{LDT_MEDIA_PREFIX}}js/jquery.min.js" type="text/javascript"/></script>
+<script src="{{LDT_MEDIA_PREFIX}}js/raphael.js" type="text/javascript"/></script>
+<script src="{{LDT_MEDIA_PREFIX}}js/Ldt_front_sparkline.js" type="text/javascript"/></script>
+{% endblock %}
+
{% block css_import %}
{{block.super}}
<link rel="stylesheet" href="{{LDT_MEDIA_PREFIX}}css/front_home.css" type="text/css"/>
@@ -26,7 +33,17 @@
</li>
{% for content in last_contents %}
<li class="li_media">
- <a href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}">{% thumbnail content.image "294x165" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}" alt="{% trans 'open this media' %}" title="{% trans 'open this media' %}">{% endthumbnail %}</a>
+ <a class="img_and_overlay" href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}">{% thumbnail content.image "294x165" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}" alt="{% trans 'open this media' %}" title="{% trans 'open this media' %}">{% endthumbnail %}
+ <div class="overlay">
+ <ul class="polemics">
+ <li class="pol-negative" style="width:0%">0%</li>
+ <li class="pol-positive" style="width:0%">0%</li>
+ <li class="pol-reference" style="width:0%">0%</li>
+ <li class="pol-question" style="width:0%">0%</li>
+ </ul>
+ <span class="graph_annotation" id="sp_{{ content.iri_id }}">{{ content.stat_annotation }}</span>
+ </div>
+ </a>
<div class="bulle_annot" title="{% blocktrans count nb=content.nb_annotation %}{{nb}} annotation on this media{% plural %}{{nb}} annotations on this media{% endblocktrans %}">{{ content.nb_annotation }}</div>
<p><a href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}" title="{% trans 'open this media' %}"><b>{{content.title}}</b></a></p>
<p>{% trans 'by' %} IRI | {{content.duration|str_duration:"h"}}</p>
@@ -46,14 +63,16 @@
</li>
{% for content in most_contents %}
<li class="li_media">
- <a class="img_and_polemic" href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}">
+ <a class="img_and_overlay" href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}">
{% thumbnail content.image "134x75" format="PNG" crop="center" as im %}<img src="{{ im.url }}" class="img_media" width="{{ im.width }}" height="{{ im.height }}" alt="{% trans 'open this media' %}" title="{% trans 'open this media' %}">{% endthumbnail %}
- <ul class="polemics">
- <li class="pol-negative" style="width:0%">0%</li>
- <li class="pol-positive" style="width:0%">0%</li>
- <li class="pol-reference" style="width:0%">0%</li>
- <li class="pol-question" style="width:0%">0%</li>
- </ul>
+ <div class="overlay">
+ <ul class="polemics">
+ <li class="pol-negative" style="width:0%">0%</li>
+ <li class="pol-positive" style="width:0%">0%</li>
+ <li class="pol-reference" style="width:0%">0%</li>
+ <li class="pol-question" style="width:0%">0%</li>
+ </ul>
+ </div>
</a>
<div class="bulle_annot" title="{% blocktrans count nb=content.nb_annotation %}{{nb}} annotation on this media{% plural %}{{nb}} annotations on this media{% endblocktrans %}">{{ content.nb_annotation }}</div>
<p><a href="{% url ldt.ldt_utils.views.front.annot_content content.iri_id %}" title="{% trans 'open this media' %}"><b>{% if content.title|length > 69 %}{{content.title|slice:":69"}}...{% else %}{{content.title}}{% endif %}</b></a></p>
--- a/src/ldt/ldt/management/commands/statannotation.py Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/management/commands/statannotation.py Thu Jan 26 17:27:27 2012 +0100
@@ -1,37 +1,23 @@
from django.core.management.base import BaseCommand
-from ldt.ldt_utils.models import Content
-from ldt.ldt_utils.stat import update_stat_content
-from optparse import make_option
+from ldt.ldt_utils.models import Content, Project
+from ldt.ldt_utils.stat import update_stat_content, update_stat_project
class Command(BaseCommand):
- help = 'Computes annotation volume for a given content'
+ help = 'Computes annotation for all contents and all projects'
- option_list = BaseCommand.option_list + (
- make_option("-c", "--content",
- dest="content",
- action="store",
- help="The id of the content we want to compute annotation volume on"),
- )
- def handle(self, *args, **options):
- parser = self.create_parser("statannotation", "")
- options, args = parser.parse_args()
-
- verbose = (options.verbosity == "2")
+ def handle(self, *args, **options):
- id_content = options.content
- if id_content:
- contents = Content.objects.filter(iri_id=id_content)
- if not len(contents):
- print "No content found with iri_id %s" % id_content
- return None
- else:
- contents = Content.objects.all()
- print "analysing all contents"
+ for proj in Project.objects.all():
+ print "Stat for project %s" % proj
+ update_stat_project(proj)
-
- for content in contents:
- update_stat_content(content)
+ # Sets fields nb_annotation and stat_annotation to 0 and 0,0,...,0
+ # for contents that do not have annotations
+ for content in Content.objects.all():
+ if not content.stat_annotation:
+ print "Stat for content %s" % content
+ update_stat_content(content)
return None
\ No newline at end of file
--- a/src/ldt/ldt/static/ldt/css/front_common.css Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/static/ldt/css/front_common.css Thu Jan 26 17:27:27 2012 +0100
@@ -132,17 +132,25 @@
.img_media {
background: #000000; border: 2px solid #ffffff; padding: 1px;
}
-.img_and_polemic {
+.img_and_overlay {
float: left; position: relative;
}
+.overlay {
+ position: absolute; bottom: 7px; width: 100%;
+}
+
+.graph_annotation {
+ float: left; height: 20px; margin: 0 4px;
+}
+
.polemics {
- position: absolute; bottom: 8px; list-style: none; z-index: 2;
+ float: left; margin-bottom: 2px; list-style: none; z-index: 2;
width: 95%; font-size: 9px; color: #ffffff;
}
.polemics li {
- text-align: left; overflow: hidden; padding: 0 0 0 3px; margin: 2px 0; clear: both;
+ float: left; text-align: left; overflow: hidden; padding: 0 0 0 3px; margin: 2px 0; clear: both;
width: 100%; box-shadow: 2px 2px 2px #000000;
}
--- a/src/ldt/ldt/static/ldt/css/front_home.css Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/static/ldt/css/front_home.css Thu Jan 26 17:27:27 2012 +0100
@@ -22,10 +22,6 @@
.title_ul {
list-style: none;
}
-.graph_annotation {
- background: url(./imgs/whitealpha.png); position:absolute;
- z-index: 2; width: 294px; height: 20px; left: 3px; top: 148px;
-}
/* Plus annotés */
--- a/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Thu Jan 26 17:23:18 2012 +0100
+++ b/src/ldt/ldt/static/ldt/js/Ldt_front_search_results.js Thu Jan 26 17:27:27 2012 +0100
@@ -61,7 +61,9 @@
});
$("li.li_segment").removeClass("selected");
$("#li_" + _id).addClass("selected");
- $("#result_preview").show().html($("#li_" + _id + " div.hidden_preview").html());
+ $("#result_preview")
+ .show()
+ .html($("#li_" + _id + " div.hidden_preview").html());
$("#result_preview .result_taglist")
.html(
$("#result_preview .result_taglist").html()
@@ -82,4 +84,9 @@
"opacity" : ".5",
});
});
+ $(document).scroll(function() {
+ $("#result_preview").css({
+ "padding-top": Math.max(30,$(document).scrollTop()-20) + 'px',
+ })
+ })
});
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/static/ldt/js/Ldt_front_sparkline.js Thu Jan 26 17:27:27 2012 +0100
@@ -0,0 +1,36 @@
+$(document).ready(function () {
+ $('.graph_annotation').each(function(_i) {
+ var _values = this.innerHTML.split(','),
+ _nb = _values.length,
+ _width = $(this).parent().parent().parent().width() - 8,
+ _height = $(this).height(),
+ _max = _values.reduce(function(_a,_b) {
+ return Math.max(_a,_b);
+ }, 1),
+ _x = function(_p) {
+ return _p * _width / _nb;
+ },
+ _y = function(_p) {
+ return _height * ( 1 - _p / _max );
+ },
+ _d = _values.map(function(_v,_k) {
+ return ( _k == 0 ?
+ "M" + _x(_k) + " " + _y(_v) :
+ "C" + _x(_k-.5) + " " + _y(_values[_k - 1])
+ + " " + + _x(_k-.5) + " " + _y(_v)
+ + " " + + _x(_k) + " " + _y(_v)
+ ) ;
+ }).join("") + "L" + _width + " " + _height + "L0 " + _height;
+ this.innerHTML = '';
+ var _paper = new Raphael(this,_width,_height);
+ _paper.rect(0,0,_width,_height).attr({
+ "stroke" : "none",
+ "fill" : "#ffffff",
+ "opacity" : .8,
+ });
+ _paper.path(_d).attr({
+ "fill" : "#adadad",
+ "stroke" : "#808080"
+ });
+ });
+});
\ No newline at end of file