Commit 10fd5e2a authored by Michael Murtaugh's avatar Michael Murtaugh
Browse files

Merge branch 'master' of git.constantvzw.org:aa.aabrowser

parents 1eb84fb0 0dcae6f1
......@@ -7,5 +7,6 @@
*.orig
venv
*.db
*.swp
run/static/cache
......@@ -39,6 +39,7 @@ $.widget("aa.playlist", {
size_url: "",
srt_url: "",
export_audacity_url: "",
import_audacity_url: "",
position_url: "",
updatePositionURL: "",
drop_on_cancel: false,
......
......@@ -6,6 +6,7 @@
{%block extrahead %}
<script type="text/javascript" charset="utf-8">
var RESOURCE_INFO_URL = "{% url aabrowser.views.resource_info %}";
var RESOURCE_VIEW_URL = "{% url aabrowser.views.resource resource.id %}";
var ANNOTATION_URL_TEMPLATE = "{% url aabrowser.views.annotation 0 %}";
......@@ -66,7 +67,18 @@ function play (url, start, end, endedcallback) {
end: end,
delegate: info.delegate,
autoplay: true,
controls: true,
controls: {
autoHide: true,
height: 24,
backgroundColor: "#FFFFFF",
buttonColor: "#000000",
buttonOverColor: "#999999",
timeFontSize: 9,
timeColor: "#000000",
timeSeparator: "/",
durationColor: "#000000",
fullscreen: false,
},
ended: endedcallback,
timeupdate: function (evt, params) {
$(".aa-playlist").playlist("doTimeUpdate", params.time, url);
......@@ -136,6 +148,21 @@ $("a#textile-help-show").click(function(){ $('div#textile-help').toggle('fast');
})(jQuery);
$(document).ready(function () {
// SARMA
// Calculate column width according to number of annotations
box_nb = $("div.aa-playlist").length;
width = 100/box_nb;
$("div.aa-playlist").css("width", width + "%");
// Header fades out when mouse doesn't move for X sec.
$(window).mousemove(function(){
$("#header, #resource_header").stop().show().css('opacity',1).animate({
opacity: 0
}, 2000);
});
// SARMA END
// COLLAPSE THE SIDEBAR
$("#sidebar_content").hide();
// console.log("scrolling");
......
......@@ -33,7 +33,8 @@ urlpatterns = patterns('aabrowser.views',
url(r'^annotations/(?P<id>\d+)/export/srt/$', 'annotation_export', {}, name='aa-annotation-export-srt'),
url(r'^annotations/(?P<id>\d+)/export/audacity/$', 'annotation_export', \
{'template':'annotation.audacity.txt'}, name='aa-annotation-export-audacity'),
url(r'^annotations/(?P<id>\d+)/import/audacity/$', 'annotation_import_audacity', {}, name='aa-annotation-import-audacity'),
url(r'^annotations/(?P<id>\d+)/import/audacity/$', 'annotation_import_audacity', \
{}, name='aa-annotation-import-audacity'),
url(r'^linktool/$', 'linktool', {}, name='aa-linktool'),
url(r'^linktool/search/$', 'linktool_search', {}, name='aa-linktool-search'),
......
from .timecode import timecode_fromsecs
def audacity2srt(data):
"""docstring for audacity2srt"""
srt = ""
for line in data.splitlines():
chunks = line.split(' ')
start = timecode_fromsecs(float(chunks[0].replace(',', '.')), alwaysfract=True, \
alwayshours=True, fractdelim = '.')
end = timecode_fromsecs(float(chunks[1].replace(',', '.')), alwaysfract=True, \
alwayshours=True, fractdelim = '.')
chunks[0] = start
chunks[1] = end
srt += chunks[0] + "-->" + chunks[1] + "\n" + " ".join(chunks[2:]) + "\n"
srt = srt.replace('\\n', '\n')
return srt
......@@ -30,6 +30,7 @@ from LinkForm import Link_parseText, name_normalize, name_urlunescape
from models import *
import urllib, re
import django.forms
from .utils import audacity2srt
try: import simplejson as json
except ImportError: import json
......@@ -378,12 +379,17 @@ def annotation_import_audacity (request, id):
data = ""
for chunk in f.chunks():
data += chunk
# removes current sections
for section in a.sections.all():
section.delete()
# updates with the new content
a.update_from_text(audacity2srt(data))
return HttpResponse("Import complete, close this window and reload the page")
else:
# display the form
form = ImportForm()
context['form'] = form
return render_to_response("annotation_import.html", context, context_instance = RequestContext(request))
return render_to_response("annotation_import.html", context, context_instance=RequestContext(request))
class TagForm(ModelForm):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment