Commit 924a77b6 authored by Alexandre Leray's avatar Alexandre Leray
Browse files

Added audacity export view

parent 012c4928
{% load aamarkup %}{% for section in sections %}{% if section.start != None %}{{section.start}} {%if section.end != None%}{{section.end}}{%endif%}{%endif%} {{section.obj.source|tosingleline|safe}}
{% endfor %}
......@@ -119,6 +119,20 @@ def secs2srttimecode (value, autoescape=None):
register.filter('secs2srttimecode', secs2srttimecode)
@stringfilter
def tosingleline(value, autoescape=None):
"""Escapes newlines"""
return value.replace('\n', '\\n')
register.filter('tosingleline', tosingleline)
@stringfilter
def tomultilines(value, autoescape=None):
"""Unescapes newlines"""
return value.replace('\\n', '\n')
register.filter('tomultilines', tomultilines)
@stringfilter
def aalinks (value, autoescape=None):
......
......@@ -30,7 +30,9 @@ urlpatterns = patterns('aabrowser.views',
url(r'^annotations/(?P<id>\d+)/position/$', 'annotation_position', {}, name='aa-annotation-position'),
url(r'^annotations/(?P<id>\d+)/size/$', 'annotation_size', {}, name='aa-annotation-size'),
url(r'^annotations/(?P<id>\d+)/delete/$', 'annotation_delete', {}, name='aa-annotation-delete'),
url(r'^annotations/(?P<id>\d+)/export/$', 'annotation_export', {}, name='aa-annotation-export'),
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'^linktool/$', 'linktool', {}, name='aa-linktool'),
url(r'^linktool/search/$', 'linktool_search', {}, name='aa-linktool-search'),
......
......@@ -334,7 +334,7 @@ def annotation_delete (request, id):
else:
return HttpResponseNotAllowed("post only")
def annotation_export (request, id):
def annotation_export (request, id, template="annotation.srt"):
context = {}
annotation = get_object_or_404(Annotation, pk=id)
context['annotation'] = annotation
......@@ -354,7 +354,8 @@ def annotation_export (request, id):
aobj['end'] = aobj['start'] + 10
wsections.append(aobj)
context['sections'] = wsections
return render_to_response("annotation.srt", context, context_instance = RequestContext(request), mimetype="text/plain")
return render_to_response(template, context, context_instance = RequestContext(request), mimetype="text/plain;charset=utf-8")
class TagForm(ModelForm):
class Meta:
......@@ -362,6 +363,7 @@ class TagForm(ModelForm):
fields = ('parent', 'text')
# exclude = ('name')
def tag (request, name):
name = name_urlunescape(name.strip())
tag = get_object_or_404(Tag, name=name)
......
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