forked from 0x2620/pandora
text key clip lists
This commit is contained in:
parent
001fbd3ba5
commit
c8b59c34c6
4 changed files with 22 additions and 13 deletions
|
@ -84,7 +84,7 @@ def findClips(request):
|
||||||
qs = qs[query['range'][0]:query['range'][1]]
|
qs = qs[query['range'][0]:query['range'][1]]
|
||||||
|
|
||||||
ids = []
|
ids = []
|
||||||
keys = filter(lambda k: k not in models.Clip.layers, data['keys'])
|
keys = filter(lambda k: k not in models.Clip.layers + ['annotations'], data['keys'])
|
||||||
if filter(lambda k: k not in models.Clip.clip_keys, keys):
|
if filter(lambda k: k not in models.Clip.clip_keys, keys):
|
||||||
qs = qs.select_related('item__sort')
|
qs = qs.select_related('item__sort')
|
||||||
|
|
||||||
|
@ -95,20 +95,27 @@ def findClips(request):
|
||||||
|
|
||||||
keys = data['keys']
|
keys = data['keys']
|
||||||
|
|
||||||
def add_annotations(layer, qs):
|
def add_annotations(key, qs, add_layer=False):
|
||||||
for a in qs.values('public_id', 'value', 'clip__public_id'):
|
values = ['public_id', 'value', 'clip__public_id']
|
||||||
|
if add_layer:
|
||||||
|
values.append('layer')
|
||||||
|
for a in qs.values(*values):
|
||||||
for i in response['data']['items']:
|
for i in response['data']['items']:
|
||||||
if i['id'] == a['clip__public_id']:
|
if i['id'] == a['clip__public_id']:
|
||||||
if not layer in i:
|
if not key in i:
|
||||||
i[layer] = []
|
i[key] = []
|
||||||
i[layer].append({
|
l = {
|
||||||
'id': a['public_id'],
|
'id': a['public_id'],
|
||||||
'value': a['value'],
|
'value': a['value'],
|
||||||
})
|
}
|
||||||
|
if add_layer:
|
||||||
|
l['layer'] = a['layer']
|
||||||
|
i[key].append(l)
|
||||||
if response['data']['items']:
|
if response['data']['items']:
|
||||||
if 'annotations' in keys:
|
if 'annotations' in keys:
|
||||||
add_annotations('annotations',
|
add_annotations('annotations',
|
||||||
Annotation.objects.filter(layer__in=models.Clip.layers, clip__in=ids))
|
Annotation.objects.filter(layer__in=models.Clip.layers, clip__in=ids),
|
||||||
|
True)
|
||||||
for layer in filter(lambda l: l in keys, models.Clip.layers):
|
for layer in filter(lambda l: l in keys, models.Clip.layers):
|
||||||
add_annotations(layer,
|
add_annotations(layer,
|
||||||
Annotation.objects.filter(layer=layer, clip__in=ids))
|
Annotation.objects.filter(layer=layer, clip__in=ids))
|
||||||
|
|
|
@ -7,7 +7,9 @@ pandora.ui.clipList = function(videoRatio) {
|
||||||
var ui = pandora.user.ui,
|
var ui = pandora.user.ui,
|
||||||
fixedRatio = !ui.item ? 16/9 : videoRatio,
|
fixedRatio = !ui.item ? 16/9 : videoRatio,
|
||||||
isClipView = !ui.item ? ui.listView == 'clip' : ui.itemView == 'clips',
|
isClipView = !ui.item ? ui.listView == 'clip' : ui.itemView == 'clips',
|
||||||
|
textKey = Ox.getObjectById(pandora.site.layers, 'subtitles')
|
||||||
|
? 'subtitles'
|
||||||
|
: 'annotations',
|
||||||
that = Ox.IconList({
|
that = Ox.IconList({
|
||||||
fixedRatio: fixedRatio,
|
fixedRatio: fixedRatio,
|
||||||
item: function(data, sort, size) {
|
item: function(data, sort, size) {
|
||||||
|
@ -22,7 +24,7 @@ pandora.ui.clipList = function(videoRatio) {
|
||||||
width = fixedRatio > 1 ? size : Math.round(size * fixedRatio);
|
width = fixedRatio > 1 ? size : Math.round(size * fixedRatio);
|
||||||
height = fixedRatio > 1 ? Math.round(size / fixedRatio) : size;
|
height = fixedRatio > 1 ? Math.round(size / fixedRatio) : size;
|
||||||
}
|
}
|
||||||
title = data.subtitles ? data.subtitles[0].value : ''; //fixme: could be other layer
|
title = data[textKey] ? data[textKey][0].value : '';
|
||||||
url = '/' + data.id.split('/')[0] + '/' + height + 'p' + data['in'] + '.jpg';
|
url = '/' + data.id.split('/')[0] + '/' + height + 'p' + data['in'] + '.jpg';
|
||||||
sortKey = sort[0].key;
|
sortKey = sort[0].key;
|
||||||
if (['text', 'position', 'duration'].indexOf(sortKey) > -1) {
|
if (['text', 'position', 'duration'].indexOf(sortKey) > -1) {
|
||||||
|
@ -79,7 +81,7 @@ pandora.ui.clipList = function(videoRatio) {
|
||||||
}, data), callback);
|
}, data), callback);
|
||||||
},
|
},
|
||||||
keys: Ox.merge(
|
keys: Ox.merge(
|
||||||
['id', 'in', 'out', 'subtitles'], //fixme: could be other layer
|
['id', 'in', 'out', textKey],
|
||||||
!ui.item ? ['videoRatio'] : []
|
!ui.item ? ['videoRatio'] : []
|
||||||
),
|
),
|
||||||
max: 1,
|
max: 1,
|
||||||
|
|
|
@ -308,7 +308,7 @@ pandora.ui.posterInfo = function(data) {
|
||||||
})
|
})
|
||||||
.html(
|
.html(
|
||||||
data.title + (
|
data.title + (
|
||||||
data.director ? ' (' + data.director.join(', ') + ')' : ''
|
Ox.len(data.director) ? ' (' + data.director.join(', ') + ')' : ''
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
that = Ox.SplitPanel({
|
that = Ox.SplitPanel({
|
||||||
|
|
|
@ -32,7 +32,7 @@ pandora.ui.item = function() {
|
||||||
pandora.$ui.itemTitle
|
pandora.$ui.itemTitle
|
||||||
.options({
|
.options({
|
||||||
title: '<b>' + result.data.title
|
title: '<b>' + result.data.title
|
||||||
+ (result.data.director && result.data.director.length
|
+ (Ox.len(result.data.director)
|
||||||
? ' (' + result.data.director.join(', ') + ')'
|
? ' (' + result.data.director.join(', ') + ')'
|
||||||
: '')
|
: '')
|
||||||
+ (result.data.year ? ' ' + result.data.year : '') + '</b>'
|
+ (result.data.year ? ' ' + result.data.year : '') + '</b>'
|
||||||
|
|
Loading…
Reference in a new issue