forked from 0x2620/pandora
highlight matches in clips
This commit is contained in:
parent
03124c5116
commit
daaabba071
12 changed files with 59 additions and 39 deletions
|
@ -642,7 +642,7 @@
|
|||
"icons": "posters",
|
||||
"infoIconSize": 256,
|
||||
"item": "",
|
||||
"itemFind": {"conditions": [], "operator": "&"},
|
||||
"itemFind": "",
|
||||
"itemSort": [{"key": "position", "operator": "+"}],
|
||||
"itemView": "info",
|
||||
"listColumns": ["title", "director", "country", "year", "language", "runtime", "genre"],
|
||||
|
|
|
@ -124,7 +124,7 @@ class Annotation(models.Model):
|
|||
layer = self.get_layer()
|
||||
if self.value:
|
||||
self.value = utils.cleanup_value(self.value, layer['type'])
|
||||
self.findvalue = ox.stripTags(self.value).strip()
|
||||
self.findvalue = ox.decodeHtml(ox.stripTags(self.value).strip())
|
||||
sortvalue = sort_string(self.findvalue)
|
||||
if sortvalue:
|
||||
self.sortvalue = sortvalue[:1000]
|
||||
|
|
|
@ -552,7 +552,7 @@ class Item(models.Model):
|
|||
if isinstance(value, bool):
|
||||
value = value and 'true' or 'false'
|
||||
if isinstance(value, basestring):
|
||||
value = value.strip()
|
||||
value = ox.decodeHtml(ox.stripTags(value.strip()))
|
||||
f.value = value
|
||||
f.save()
|
||||
else:
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
/*
|
||||
clipLayers is the ordered list of public layers that will appear as the
|
||||
text of clips. Excluding a layer from this list means it will not be
|
||||
included in find annotations.
|
||||
included in find annotations. // FIXME: the last bit is not implemented.
|
||||
*/
|
||||
"clipLayers": ["transcripts", "keywords", "places", "events", "descriptions"],
|
||||
// fixme: either this, or filter: true in itemKeys, but not both
|
||||
|
@ -221,7 +221,7 @@
|
|||
},
|
||||
{
|
||||
"id": "annotations",
|
||||
"title": "Annotation",
|
||||
"title": "Annotations",
|
||||
"type": "string",
|
||||
"find": true
|
||||
},
|
||||
|
|
|
@ -64,7 +64,6 @@ pandora.UI = (function() {
|
|||
// switch from item view to list view
|
||||
args['item'] = '';
|
||||
}
|
||||
add.itemFind = pandora.site.user.ui.itemFind;
|
||||
if (list != self.previousUI._list) {
|
||||
Ox.Log('UI', 'FIND HAS CHANGED LIST')
|
||||
// if find has changed list
|
||||
|
@ -79,8 +78,7 @@ pandora.UI = (function() {
|
|||
}
|
||||
});
|
||||
}
|
||||
add.itemFind = pandora.isItemFind(args.find)
|
||||
? args.find : pandora.site.user.ui.itemFind;
|
||||
add.itemFind = pandora.getItemFind(args.find);
|
||||
} else {
|
||||
list = self.previousUI._list;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
|
||||
pandora.ui.clipList = function(videoRatio) {
|
||||
|
||||
Ox.print('CLIP LIST FIND', !pandora.user.ui.item ? pandora.getItemFind(pandora.user.ui.find) : pandora.user.ui.itemFind);
|
||||
|
||||
var ui = pandora.user.ui,
|
||||
fixedRatio = !ui.item ? 16/9 : videoRatio,
|
||||
isClipView = !ui.item ? ui.listView == 'clip' : ui.itemView == 'clips',
|
||||
that = Ox.IconList({
|
||||
find: !ui.item ? pandora.getItemFind(ui.find) : ui.itemFind,
|
||||
fixedRatio: fixedRatio,
|
||||
item: function(data, sort, size) {
|
||||
size = size || 128; // fixme: is this needed?
|
||||
|
@ -21,9 +24,17 @@ pandora.ui.clipList = function(videoRatio) {
|
|||
width = fixedRatio > 1 ? size : Math.round(size * fixedRatio);
|
||||
height = fixedRatio > 1 ? Math.round(size / fixedRatio) : size;
|
||||
}
|
||||
title = data.annotations ? data.annotations.map(function(annotation) {
|
||||
title = data.annotations ? data.annotations.sort(function(a, b) {
|
||||
var layerA = pandora.site.clipLayers.indexOf(a.layer),
|
||||
layerB = pandora.site.clipLayers.indexOf(b.layer);
|
||||
return layerA < layerB ? -1
|
||||
: layerA > layerB ? 1
|
||||
: a.value < b.value ? -1
|
||||
: a.value > b.value ? 1
|
||||
: 0;
|
||||
}).map(function(annotation) {
|
||||
return Ox.stripTags(annotation.value);
|
||||
}).join('; ') : '',
|
||||
}).join('; ') : '';
|
||||
url = '/' + data.id.split('/')[0] + '/' + height + 'p' + data['in'] + '.jpg';
|
||||
sortKey = sort[0].key;
|
||||
if (['text', 'position', 'duration'].indexOf(sortKey) > -1) {
|
||||
|
@ -73,7 +84,14 @@ pandora.ui.clipList = function(videoRatio) {
|
|||
conditions:[{key: 'id', value: ui.item, operator: '=='}],
|
||||
operator: '&'
|
||||
};
|
||||
query = pandora.user.ui.itemFind;
|
||||
query = {
|
||||
conditions: ui.itemFind === '' ? [] : [{
|
||||
key: 'annotations',
|
||||
value: ui.itemFind,
|
||||
operator: '='
|
||||
}],
|
||||
operator: '&'
|
||||
};
|
||||
}
|
||||
pandora.api.findClips(Ox.extend({
|
||||
itemsQuery: itemsQuery,
|
||||
|
|
|
@ -18,17 +18,13 @@ pandora.ui.clipsView = function(videoRatio) {
|
|||
Ox.Input({
|
||||
clear: true,
|
||||
placeholder: 'Find Clips',
|
||||
value: pandora.user.ui.itemFind.conditions[0]
|
||||
? pandora.user.ui.itemFind.conditions[0].value : '',
|
||||
value: pandora.user.ui.itemFind,
|
||||
width: 192
|
||||
})
|
||||
.css({float: 'right', margin: '4px'})
|
||||
.bindEvent({
|
||||
submit: function(data) {
|
||||
pandora.UI.set('itemFind', data.value ? {
|
||||
conditions: [{key: 'annotations', value: data.value, operator: '='}],
|
||||
operator: '&'
|
||||
} : pandora.site.user.ui.itemFind);
|
||||
pandora.UI.set('itemFind', data.value);
|
||||
// since this is the only way itemFind can change,
|
||||
// there's no need for an event handler
|
||||
that.replaceElement(1,
|
||||
|
|
|
@ -34,9 +34,6 @@ pandora.ui.contentPanel = function() {
|
|||
orientation: 'vertical'
|
||||
})
|
||||
.bindEvent({
|
||||
pandora_listview: function() {
|
||||
that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
|
||||
},
|
||||
pandora_item: function(data) {
|
||||
if (data.value && data.previousValue) {
|
||||
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
|
||||
|
@ -45,6 +42,9 @@ pandora.ui.contentPanel = function() {
|
|||
pandora_itemview: function() {
|
||||
that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
|
||||
},
|
||||
pandora_listview: function() {
|
||||
that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
|
||||
},
|
||||
pandora_showbrowser: function(data) {
|
||||
data.value == that.options('elements')[0].collapsed && that.toggle(0);
|
||||
},
|
||||
|
|
|
@ -132,8 +132,7 @@ pandora.ui.item = function() {
|
|||
cuts: result.data.cuts || [],
|
||||
duration: result.data.duration,
|
||||
enableSubtitles: pandora.user.ui.videoSubtitles,
|
||||
find: pandora.user.ui.itemFind.conditions[0]
|
||||
? pandora.user.ui.itemFind.conditions[0].value : '',
|
||||
find: pandora.user.ui.itemFind,
|
||||
getTimelineImageURL: function(i) {
|
||||
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
|
||||
},
|
||||
|
@ -172,10 +171,7 @@ pandora.ui.item = function() {
|
|||
pandora.UI.set({annotationsSort: data.sort});
|
||||
},
|
||||
find: function(data) {
|
||||
pandora.UI.set('itemFind', data.find ? {
|
||||
conditions: [{key: 'annotations', value: data.find, operator: '='}],
|
||||
operator: '&'
|
||||
} : pandora.site.user.ui.itemFind);
|
||||
pandora.UI.set('itemFind', data.find);
|
||||
},
|
||||
muted: function(data) {
|
||||
pandora.UI.set('videoMuted', data.muted);
|
||||
|
@ -245,8 +241,7 @@ pandora.ui.item = function() {
|
|||
duration: result.data.duration,
|
||||
enableDownload: pandora.site.capabilities.canDownloadVideo[pandora.user.level] >= result.data.rightslevel,
|
||||
enableSubtitles: pandora.user.ui.videoSubtitles,
|
||||
find: pandora.user.ui.itemFind.conditions[0]
|
||||
? pandora.user.ui.itemFind.conditions[0].value : '',
|
||||
find: pandora.user.ui.itemFind,
|
||||
getFrameURL: function(position) {
|
||||
return '/' + pandora.user.ui.item + '/' + pandora.user.ui.videoResolution + 'p' + position + '.jpg';
|
||||
},
|
||||
|
@ -359,10 +354,7 @@ pandora.ui.item = function() {
|
|||
pandora.$ui.embedDialog = pandora.ui.embedDialog(data).open();
|
||||
},
|
||||
find: function(data) {
|
||||
pandora.UI.set('itemFind', data.find ? {
|
||||
conditions: [{key: 'annotations', value: data.find, operator: '='}],
|
||||
operator: '&'
|
||||
} : pandora.site.user.ui.itemFind);
|
||||
pandora.UI.set('itemFind', data.find);
|
||||
},
|
||||
info: function(data) {
|
||||
pandora.ui.annotationDialog(data.layer).open();
|
||||
|
|
|
@ -37,6 +37,7 @@ pandora.ui.itemClips = function(options) {
|
|||
}),
|
||||
url = '/' + self.options.id + '/' + self.height + 'p' + clip['in'] + '.jpg',
|
||||
$item = Ox.IconItem({
|
||||
find: pandora.user.ui.itemFind,
|
||||
imageHeight: self.height,
|
||||
imageWidth: self.width,
|
||||
id: clip.id,
|
||||
|
|
|
@ -28,6 +28,10 @@ pandora.ui.mainPanel = function() {
|
|||
pandora.ui.navigationView(pandora.user.ui.listView)
|
||||
);
|
||||
} else {
|
||||
if (['clips', 'clip'].indexOf(pandora.user.ui.listView) > -1) {
|
||||
Ox.print('HELLO????', pandora.user.ui.itemFind)
|
||||
pandora.$ui.list.options({find: pandora.user.ui.itemFind});
|
||||
}
|
||||
pandora.$ui.list.reloadList();
|
||||
}
|
||||
// FIXME: why is this being handled _here_?
|
||||
|
|
|
@ -602,6 +602,24 @@ pandora.getItemByIdOrTitle = function(str, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
pandora.getItemFind = function(find) {
|
||||
var itemFind = '';
|
||||
Ox.forEach(find.conditions, function(condition) {
|
||||
if (
|
||||
(
|
||||
condition.key == '*' || condition.key == 'annotations'
|
||||
|| Ox.getIndexById(pandora.site.layers, condition.key) > -1
|
||||
)
|
||||
&& condition.value.length
|
||||
&& ['=', '=='].indexOf(condition.operator) > -1
|
||||
) {
|
||||
itemFind = condition.value;
|
||||
return false;
|
||||
}
|
||||
})
|
||||
return itemFind;
|
||||
};
|
||||
|
||||
pandora.getListData = function(list) {
|
||||
var data = {}, folder;
|
||||
list = Ox.isUndefined(list) ? pandora.user.ui._list : list;
|
||||
|
@ -854,13 +872,6 @@ pandora.isClipView = function(view, item) {
|
|||
).indexOf(view) > -1;
|
||||
};
|
||||
|
||||
pandora.isItemFind = function(find) {
|
||||
return find.conditions.length == 1
|
||||
&& (find.conditions[0].key == 'annotations'
|
||||
||Ox.getIndexById(pandora.site.layers, find.conditions[0].key) > -1)
|
||||
&& find.conditions[0].operator == '=';
|
||||
};
|
||||
|
||||
pandora.signin = function(data) {
|
||||
pandora.user = data.user;
|
||||
pandora.user.ui._list = pandora.getListState(pandora.user.ui.find);
|
||||
|
|
Loading…
Reference in a new issue