highlight matches in clips

This commit is contained in:
rolux 2012-02-01 12:01:39 +00:00
parent 03124c5116
commit daaabba071
12 changed files with 59 additions and 39 deletions

View file

@ -642,7 +642,7 @@
"icons": "posters", "icons": "posters",
"infoIconSize": 256, "infoIconSize": 256,
"item": "", "item": "",
"itemFind": {"conditions": [], "operator": "&"}, "itemFind": "",
"itemSort": [{"key": "position", "operator": "+"}], "itemSort": [{"key": "position", "operator": "+"}],
"itemView": "info", "itemView": "info",
"listColumns": ["title", "director", "country", "year", "language", "runtime", "genre"], "listColumns": ["title", "director", "country", "year", "language", "runtime", "genre"],

View file

@ -124,7 +124,7 @@ class Annotation(models.Model):
layer = self.get_layer() layer = self.get_layer()
if self.value: if self.value:
self.value = utils.cleanup_value(self.value, layer['type']) 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) sortvalue = sort_string(self.findvalue)
if sortvalue: if sortvalue:
self.sortvalue = sortvalue[:1000] self.sortvalue = sortvalue[:1000]

View file

@ -552,7 +552,7 @@ class Item(models.Model):
if isinstance(value, bool): if isinstance(value, bool):
value = value and 'true' or 'false' value = value and 'true' or 'false'
if isinstance(value, basestring): if isinstance(value, basestring):
value = value.strip() value = ox.decodeHtml(ox.stripTags(value.strip()))
f.value = value f.value = value
f.save() f.save()
else: else:

View file

@ -53,7 +53,7 @@
/* /*
clipLayers is the ordered list of public layers that will appear as the 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 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"], "clipLayers": ["transcripts", "keywords", "places", "events", "descriptions"],
// fixme: either this, or filter: true in itemKeys, but not both // fixme: either this, or filter: true in itemKeys, but not both
@ -221,7 +221,7 @@
}, },
{ {
"id": "annotations", "id": "annotations",
"title": "Annotation", "title": "Annotations",
"type": "string", "type": "string",
"find": true "find": true
}, },

View file

@ -64,7 +64,6 @@ pandora.UI = (function() {
// switch from item view to list view // switch from item view to list view
args['item'] = ''; args['item'] = '';
} }
add.itemFind = pandora.site.user.ui.itemFind;
if (list != self.previousUI._list) { if (list != self.previousUI._list) {
Ox.Log('UI', 'FIND HAS CHANGED LIST') Ox.Log('UI', 'FIND HAS CHANGED LIST')
// if find has changed list // if find has changed list
@ -79,8 +78,7 @@ pandora.UI = (function() {
} }
}); });
} }
add.itemFind = pandora.isItemFind(args.find) add.itemFind = pandora.getItemFind(args.find);
? args.find : pandora.site.user.ui.itemFind;
} else { } else {
list = self.previousUI._list; list = self.previousUI._list;
} }

View file

@ -4,10 +4,13 @@
pandora.ui.clipList = function(videoRatio) { 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, 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',
that = Ox.IconList({ that = Ox.IconList({
find: !ui.item ? pandora.getItemFind(ui.find) : ui.itemFind,
fixedRatio: fixedRatio, fixedRatio: fixedRatio,
item: function(data, sort, size) { item: function(data, sort, size) {
size = size || 128; // fixme: is this needed? size = size || 128; // fixme: is this needed?
@ -21,9 +24,17 @@ 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.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); return Ox.stripTags(annotation.value);
}).join('; ') : '', }).join('; ') : '';
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) {
@ -73,7 +84,14 @@ pandora.ui.clipList = function(videoRatio) {
conditions:[{key: 'id', value: ui.item, operator: '=='}], conditions:[{key: 'id', value: ui.item, operator: '=='}],
operator: '&' operator: '&'
}; };
query = pandora.user.ui.itemFind; query = {
conditions: ui.itemFind === '' ? [] : [{
key: 'annotations',
value: ui.itemFind,
operator: '='
}],
operator: '&'
};
} }
pandora.api.findClips(Ox.extend({ pandora.api.findClips(Ox.extend({
itemsQuery: itemsQuery, itemsQuery: itemsQuery,

View file

@ -18,17 +18,13 @@ pandora.ui.clipsView = function(videoRatio) {
Ox.Input({ Ox.Input({
clear: true, clear: true,
placeholder: 'Find Clips', placeholder: 'Find Clips',
value: pandora.user.ui.itemFind.conditions[0] value: pandora.user.ui.itemFind,
? pandora.user.ui.itemFind.conditions[0].value : '',
width: 192 width: 192
}) })
.css({float: 'right', margin: '4px'}) .css({float: 'right', margin: '4px'})
.bindEvent({ .bindEvent({
submit: function(data) { submit: function(data) {
pandora.UI.set('itemFind', data.value ? { pandora.UI.set('itemFind', data.value);
conditions: [{key: 'annotations', value: data.value, operator: '='}],
operator: '&'
} : pandora.site.user.ui.itemFind);
// since this is the only way itemFind can change, // since this is the only way itemFind can change,
// there's no need for an event handler // there's no need for an event handler
that.replaceElement(1, that.replaceElement(1,

View file

@ -34,9 +34,6 @@ pandora.ui.contentPanel = function() {
orientation: 'vertical' orientation: 'vertical'
}) })
.bindEvent({ .bindEvent({
pandora_listview: function() {
that.replaceElement(1, pandora.$ui.list = pandora.ui.list());
},
pandora_item: function(data) { pandora_item: function(data) {
if (data.value && data.previousValue) { if (data.value && data.previousValue) {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item()); that.replaceElement(1, pandora.$ui.item = pandora.ui.item());
@ -45,6 +42,9 @@ pandora.ui.contentPanel = function() {
pandora_itemview: function() { pandora_itemview: function() {
that.replaceElement(1, pandora.$ui.item = pandora.ui.item()); 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) { pandora_showbrowser: function(data) {
data.value == that.options('elements')[0].collapsed && that.toggle(0); data.value == that.options('elements')[0].collapsed && that.toggle(0);
}, },

View file

@ -132,8 +132,7 @@ pandora.ui.item = function() {
cuts: result.data.cuts || [], cuts: result.data.cuts || [],
duration: result.data.duration, duration: result.data.duration,
enableSubtitles: pandora.user.ui.videoSubtitles, enableSubtitles: pandora.user.ui.videoSubtitles,
find: pandora.user.ui.itemFind.conditions[0] find: pandora.user.ui.itemFind,
? pandora.user.ui.itemFind.conditions[0].value : '',
getTimelineImageURL: function(i) { getTimelineImageURL: function(i) {
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png'; return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
}, },
@ -172,10 +171,7 @@ pandora.ui.item = function() {
pandora.UI.set({annotationsSort: data.sort}); pandora.UI.set({annotationsSort: data.sort});
}, },
find: function(data) { find: function(data) {
pandora.UI.set('itemFind', data.find ? { pandora.UI.set('itemFind', data.find);
conditions: [{key: 'annotations', value: data.find, operator: '='}],
operator: '&'
} : pandora.site.user.ui.itemFind);
}, },
muted: function(data) { muted: function(data) {
pandora.UI.set('videoMuted', data.muted); pandora.UI.set('videoMuted', data.muted);
@ -245,8 +241,7 @@ pandora.ui.item = function() {
duration: result.data.duration, duration: result.data.duration,
enableDownload: pandora.site.capabilities.canDownloadVideo[pandora.user.level] >= result.data.rightslevel, enableDownload: pandora.site.capabilities.canDownloadVideo[pandora.user.level] >= result.data.rightslevel,
enableSubtitles: pandora.user.ui.videoSubtitles, enableSubtitles: pandora.user.ui.videoSubtitles,
find: pandora.user.ui.itemFind.conditions[0] find: pandora.user.ui.itemFind,
? pandora.user.ui.itemFind.conditions[0].value : '',
getFrameURL: function(position) { getFrameURL: function(position) {
return '/' + pandora.user.ui.item + '/' + pandora.user.ui.videoResolution + 'p' + position + '.jpg'; 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(); pandora.$ui.embedDialog = pandora.ui.embedDialog(data).open();
}, },
find: function(data) { find: function(data) {
pandora.UI.set('itemFind', data.find ? { pandora.UI.set('itemFind', data.find);
conditions: [{key: 'annotations', value: data.find, operator: '='}],
operator: '&'
} : pandora.site.user.ui.itemFind);
}, },
info: function(data) { info: function(data) {
pandora.ui.annotationDialog(data.layer).open(); pandora.ui.annotationDialog(data.layer).open();

View file

@ -37,6 +37,7 @@ pandora.ui.itemClips = function(options) {
}), }),
url = '/' + self.options.id + '/' + self.height + 'p' + clip['in'] + '.jpg', url = '/' + self.options.id + '/' + self.height + 'p' + clip['in'] + '.jpg',
$item = Ox.IconItem({ $item = Ox.IconItem({
find: pandora.user.ui.itemFind,
imageHeight: self.height, imageHeight: self.height,
imageWidth: self.width, imageWidth: self.width,
id: clip.id, id: clip.id,

View file

@ -28,6 +28,10 @@ pandora.ui.mainPanel = function() {
pandora.ui.navigationView(pandora.user.ui.listView) pandora.ui.navigationView(pandora.user.ui.listView)
); );
} else { } 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(); pandora.$ui.list.reloadList();
} }
// FIXME: why is this being handled _here_? // FIXME: why is this being handled _here_?

View file

@ -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) { pandora.getListData = function(list) {
var data = {}, folder; var data = {}, folder;
list = Ox.isUndefined(list) ? pandora.user.ui._list : list; list = Ox.isUndefined(list) ? pandora.user.ui._list : list;
@ -854,13 +872,6 @@ pandora.isClipView = function(view, item) {
).indexOf(view) > -1; ).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.signin = function(data) {
pandora.user = data.user; pandora.user = data.user;
pandora.user.ui._list = pandora.getListState(pandora.user.ui.find); pandora.user.ui._list = pandora.getListState(pandora.user.ui.find);