added video and audio stuff
This commit is contained in:
parent
a9a34564ec
commit
0e6ca63a4a
14
COPYING
Normal file
14
COPYING
Normal file
|
@ -0,0 +1,14 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2010 Sanjay Bhangar <sanjay@camputer.org>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
|
@ -309,18 +309,34 @@ class Page(models.Model):
|
|||
textBoxes = []
|
||||
for t in TextBox.objects.filter(page = self).exclude(is_displayed = False):
|
||||
textBoxes.append(t.to_dict())
|
||||
'''
|
||||
|
||||
videos = []
|
||||
for v in self.videos:
|
||||
for v in self.videos.all():
|
||||
r = {
|
||||
'title' = v.fil.title,
|
||||
'description' = v.fil.description
|
||||
'srts' = []
|
||||
for s in v.srt:
|
||||
'id': v.id,
|
||||
'title': v.fil.title,
|
||||
'description': v.fil.description,
|
||||
'file': v.fil.file.url,
|
||||
'mime': 'video'
|
||||
}
|
||||
videos.append(r)
|
||||
|
||||
audios = []
|
||||
for a in self.audios.all():
|
||||
r = {
|
||||
'id': a.id,
|
||||
'title': a.fil.title,
|
||||
'description': a.fil.description,
|
||||
'file': a.fil.file.url,
|
||||
'mime': 'audio'
|
||||
}
|
||||
audios.append(r)
|
||||
|
||||
|
||||
'''
|
||||
|
||||
#Resources:
|
||||
'''
|
||||
|
||||
resources = []
|
||||
for res in self.resources.all():
|
||||
r = {}
|
||||
|
@ -339,6 +355,8 @@ class Page(models.Model):
|
|||
'id': self.id,
|
||||
'imageBoxes' : imageBoxes,
|
||||
'textBoxes': textBoxes,
|
||||
'videos': videos,
|
||||
'audios': audios
|
||||
# 'resources' : resources
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ def edit_page(request, id):
|
|||
"""
|
||||
send GET request to to /edit/add_media/ with page_id and resource_id .
|
||||
"""
|
||||
@login_required
|
||||
def add_media(request):
|
||||
page_id = request.GET['page_id']
|
||||
file_id = request.GET['resource_id']
|
||||
|
@ -49,13 +50,15 @@ def add_media(request):
|
|||
if typ == 'video':
|
||||
try:
|
||||
video = Video.objects.get(fil__id=file_id)
|
||||
page.videos.append(video)
|
||||
page.videos.add(video)
|
||||
page.save()
|
||||
except:
|
||||
pass
|
||||
elif typ == 'audio':
|
||||
try:
|
||||
audio = Audio.objects.get(fil__id=file_id)
|
||||
page.audios.append(audio)
|
||||
page.audios.add(audio)
|
||||
page.save()
|
||||
except:
|
||||
pass
|
||||
page.save()
|
||||
|
@ -64,6 +67,7 @@ def add_media(request):
|
|||
}
|
||||
return HttpResponse(simplejson.dumps(r), mimetype="application/json")
|
||||
|
||||
@login_required
|
||||
def add_srt(request):
|
||||
file_id = request.POST['id']
|
||||
mime = request.POST['mime']
|
||||
|
@ -95,7 +99,7 @@ def edit_article(request, id):
|
|||
}
|
||||
return render_to_response("editor.html", rDict)
|
||||
|
||||
|
||||
@login_required
|
||||
def image_rotate(request, id):
|
||||
image_id = int(id)
|
||||
if request.GET.has_key('degree'):
|
||||
|
@ -121,6 +125,7 @@ def testCrop(request):
|
|||
}
|
||||
return render_to_response("testCrop.html", d)
|
||||
|
||||
@login_required
|
||||
def imagebox_crop(request):
|
||||
o = request.GET
|
||||
# project_path = "/home/sanj/soc/edgware-py/"
|
||||
|
@ -150,6 +155,7 @@ def test_thumb(request):
|
|||
r = {'path': 'media/images/original/facade.jpg'}
|
||||
return render_to_response("thumbnailTmp.txt", r)
|
||||
|
||||
@login_required
|
||||
def textbox_new(request):
|
||||
if request.GET['json']:
|
||||
box = TextBox()
|
||||
|
@ -182,6 +188,7 @@ def textbox_new(request):
|
|||
else:
|
||||
return False
|
||||
|
||||
@login_required
|
||||
def textbox_update_css(request):
|
||||
box_id = request.GET['id']
|
||||
try:
|
||||
|
@ -215,6 +222,7 @@ def textbox_update_css(request):
|
|||
j = json.dumps(r)
|
||||
return HttpResponse(j, mimetype="application/json")
|
||||
|
||||
@login_required
|
||||
def textbox_set_html(request):
|
||||
id = request.GET['id']
|
||||
html = request.GET['html']
|
||||
|
@ -238,6 +246,7 @@ def textbox_set_html(request):
|
|||
}
|
||||
return HttpResponse(json.dumps(r), mimetype="application/json")
|
||||
|
||||
@login_required
|
||||
def textbox_delete(request):
|
||||
id = request.GET['id']
|
||||
box = TextBox.objects.get(pk=id)
|
||||
|
@ -256,6 +265,7 @@ def textbox_delete(request):
|
|||
})
|
||||
return HttpResponse(str(rev_id))
|
||||
|
||||
@login_required
|
||||
def imagebox_new(request):
|
||||
jsonString = request.GET['json']
|
||||
d = json.loads(jsonString)
|
||||
|
@ -287,6 +297,7 @@ def imagebox_new(request):
|
|||
j = json.dumps(r)
|
||||
return HttpResponse(j, mimetype="application/json")
|
||||
|
||||
@login_required
|
||||
def imagebox_update_css(request):
|
||||
box_id = request.GET['id']
|
||||
box = ImageBox.objects.get(pk = box_id)
|
||||
|
@ -315,6 +326,7 @@ def imagebox_update_css(request):
|
|||
j = json.dumps(r)
|
||||
return HttpResponse(j, mimetype="application/json")
|
||||
|
||||
@login_required
|
||||
def imagebox_resize(request):
|
||||
box_id = request.GET['id']
|
||||
width = request.GET['width']
|
||||
|
@ -352,6 +364,7 @@ def imagebox_resize(request):
|
|||
j = json.dumps(r)
|
||||
return HttpResponse(j, mimetype="application/json")
|
||||
|
||||
@login_required
|
||||
def imagebox_delete(request):
|
||||
id = request.GET['id']
|
||||
box = ImageBox.objects.get(pk=id)
|
||||
|
|
|
@ -272,30 +272,11 @@ Canvas.prototype.init = function() {
|
|||
new_index = parseInt(highest_index) + 1;
|
||||
// console.log('index: ' + new_index);
|
||||
i = new ImageBox(c, r, {css: {'z-index': "" + new_index, 'top':toPx((ev.pageY - top) - height), 'left': toPx((ev.pageX - left) - width)}});
|
||||
} else if (r.mime == 'audio' || r.mime == 'video') {
|
||||
that.addMedia(r);
|
||||
}
|
||||
else if (r.mime == 'audio') {
|
||||
media_box = $(this).children('.audio_video');
|
||||
$.getJSON('/edit/add_media/', {
|
||||
resource_id: r.id,
|
||||
page_id: c.id
|
||||
}, function(data) {
|
||||
media_box.append("<img class='media_icon' src='/static/images/icons/Speaker.png'>");
|
||||
});
|
||||
|
||||
}
|
||||
else if (r.mime == 'video') {
|
||||
|
||||
media_box = $(this).children('.audio_video');
|
||||
$.getJSON('/edit/add_media/', {
|
||||
resource_id: r.id,
|
||||
page_id: c.id
|
||||
}, function(data) {
|
||||
media_box.append("<img class='media_icon' src='/static/images/icons/video.png'>");
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var elem = $(ui.draggable);
|
||||
top = $(this).position().top;
|
||||
left = $(this).position().left;
|
||||
|
@ -315,13 +296,32 @@ Canvas.prototype.init = function() {
|
|||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Canvas.prototype.addMedia = function(resource) {
|
||||
var that = this;
|
||||
$.getJSON("/edit/add_media/", {
|
||||
resource_id: resource.id,
|
||||
page_id: that.id
|
||||
}, function(response) {
|
||||
that.addMediaIcon(resource);
|
||||
});
|
||||
}
|
||||
|
||||
Canvas.prototype.addMediaIcon = function(resource) {
|
||||
var typ = resource.mime;
|
||||
var media_box = this.jq.find('.audio_video');
|
||||
$('<img />').addClass('media_icon').addClass(typ + '_icon').attr("src", "/static/images/icons/" + typ + ".png").attr("title", resource.title).data("resource", resource).appendTo(media_box);
|
||||
}
|
||||
|
||||
Canvas.prototype.loadFromJSON = function(json) {
|
||||
// alert(JSON.stringify(json));
|
||||
// GLOBALFOO = json;
|
||||
var imageBoxes = json.imageBoxes;
|
||||
var textBoxes = json.textBoxes;
|
||||
var videos = json.videos;
|
||||
var audios = json.audios;
|
||||
// alert(audios.length);
|
||||
var that = this;
|
||||
for (var i=0; i < imageBoxes.length; i++) {
|
||||
var resource = imageBoxes[i].resource;
|
||||
|
@ -332,7 +332,15 @@ Canvas.prototype.loadFromJSON = function(json) {
|
|||
var b = new TextBox(that, textBoxes[t]);
|
||||
// that.textBoxes.append(b);
|
||||
}
|
||||
for (var v=0; v < videos.length; v++) {
|
||||
var video = videos[v];
|
||||
that.addMediaIcon(video);
|
||||
}
|
||||
for (var a=0; a < audios.length; a++) {
|
||||
var audio = audios[a];
|
||||
that.addMediaIcon(audio);
|
||||
}
|
||||
}
|
||||
|
||||
Canvas.prototype.toObj = function() {
|
||||
var that = this;
|
||||
|
|
Loading…
Reference in New Issue
Block a user