forked from 0x2620/pandora
new clip sort key scheme; fix for info line(s) in icon lists
This commit is contained in:
parent
bb728c9369
commit
7fd64740aa
8 changed files with 64 additions and 46 deletions
|
@ -10,13 +10,13 @@
|
|||
"canSeeExtraItemViews": {"friend": true, "staff": true, "admin": true}
|
||||
},
|
||||
"clipKeys": [
|
||||
{"id": "clip:text", "title": "Text", "type": "string"},
|
||||
{"id": "clip:position", "title": "Position", "type": "float"},
|
||||
{"id": "clip:duration", "title": "Duration", "type": "float"},
|
||||
{"id": "clip:hue", "title": "Hue", "type": "hue"},
|
||||
{"id": "clip:saturation", "title": "Saturation", "type": "float"},
|
||||
{"id": "clip:lightness", "title": "Lightness", "type": "float"},
|
||||
{"id": "clip:volume", "title": "Volume", "type": "float"}
|
||||
{"id": "text", "title": "Text", "type": "string"},
|
||||
{"id": "position", "title": "Position", "type": "float", "sortOperator": "-"},
|
||||
{"id": "duration", "title": "Duration", "type": "float"},
|
||||
{"id": "hue", "title": "Hue", "type": "float", "sortOperator": "-"},
|
||||
{"id": "saturation", "title": "Saturation", "type": "float"},
|
||||
{"id": "lightness", "title": "Lightness", "type": "float"},
|
||||
{"id": "volume", "title": "Volume", "type": "float"}
|
||||
],
|
||||
"groups": [
|
||||
{"id": "director", "title": "Director", "type": "string"},
|
||||
|
@ -298,9 +298,10 @@
|
|||
{
|
||||
"id": "hue",
|
||||
"title": "Hue",
|
||||
"type": "hue",
|
||||
"type": "float",
|
||||
"columnWidth": 90,
|
||||
"format": {"type": "color", "args": ["hue"]}
|
||||
"format": {"type": "color", "args": ["hue"]},
|
||||
"sortOperator": "-"
|
||||
},
|
||||
{
|
||||
"id": "saturation",
|
||||
|
|
|
@ -31,9 +31,10 @@ def order_query(qs, sort):
|
|||
operator = e['operator']
|
||||
if operator != '-':
|
||||
operator = ''
|
||||
clip_keys = ('start', 'end', 'hue', 'saturation', 'lightness', 'volume'
|
||||
clip_keys = ('public_id', 'start', 'end', 'hue', 'saturation', 'lightness', 'volume'
|
||||
'annotations__value')
|
||||
key = {
|
||||
'id': 'public_id',
|
||||
'in': 'start',
|
||||
'out': 'end',
|
||||
'position': 'start',
|
||||
|
|
|
@ -73,7 +73,7 @@ Ox.load({
|
|||
Ox.extend(pandora.site, {
|
||||
clipKeys: Ox.map(data.site.clipKeys, function(key) {
|
||||
return Ox.extend(key, {
|
||||
operator: pandora._getSortOperator(key.type)
|
||||
operator: pandora.getSortOperator(key.id)
|
||||
});
|
||||
}),
|
||||
findKeys: Ox.map(data.site.itemKeys, function(key) {
|
||||
|
@ -100,7 +100,7 @@ Ox.load({
|
|||
},
|
||||
sortKeys: Ox.map(pandora.site.itemKeys, function(key) {
|
||||
return key.columnWidth ? Ox.extend(key, {
|
||||
operator: pandora._getSortOperator(key.type)
|
||||
operator: pandora.getSortOperator(key.id)
|
||||
}) : null;
|
||||
})
|
||||
});
|
||||
|
|
|
@ -414,7 +414,7 @@ pandora.URL = (function() {
|
|||
} else {
|
||||
action = 'push';
|
||||
}
|
||||
self.URL[action](getState(), pandora.getPageTitle(), getState(keys));
|
||||
self.URL[action](getState(), pandora.getPageTitle(), getState(/*keys*/));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ pandora.ui.clipList = function(videoRatio) {
|
|||
fixedRatio: fixedRatio,
|
||||
item: function(data, sort, size) {
|
||||
size = size || 128; // fixme: is this needed?
|
||||
var ratio, width, height, url, sortKey, info;
|
||||
var ratio, width, height,
|
||||
format, info, sortKey, url;
|
||||
if (!ui.item) {
|
||||
ratio = data.videoRatio;
|
||||
width = ratio > fixedRatio ? size : Math.round(size * ratio / fixedRatio);
|
||||
|
@ -19,13 +20,19 @@ pandora.ui.clipList = function(videoRatio) {
|
|||
width = fixedRatio > 1 ? size : Math.round(size * fixedRatio);
|
||||
height = fixedRatio > 1 ? Math.round(size / fixedRatio) : size;
|
||||
}
|
||||
url = '/' + data.id.split('/')[0] + '/' + height + 'p' + data['in'] + '.jpg';
|
||||
sortKey = sort[0].key.split(':').pop();
|
||||
info = ['hue', 'saturation', 'lightness'].indexOf(sortKey) > -1
|
||||
? Ox.formatColor(data[sortKey], sortKey)
|
||||
: Ox.formatDuration(data['in'], 'short') + ' - '
|
||||
+ Ox.formatDuration(data['out'], 'short'),
|
||||
title = data.subtitles[0]; //fixme: could be other layer
|
||||
url = '/' + data.id.split('/')[0] + '/' + height + 'p' + data['in'] + '.jpg';
|
||||
sortKey = sort[0].key;
|
||||
if (['text', 'position', 'duration'].indexOf(sortKey) > -1) {
|
||||
info = Ox.formatDuration(data['in'], 'short') + ' - '
|
||||
+ Ox.formatDuration(data.out, 'short');
|
||||
} else {
|
||||
format = pandora.getSortKeyData(sortKey).format;
|
||||
info = format
|
||||
? Ox['format' + Ox.toTitleCase(format.type)]
|
||||
.apply(this, Ox.merge([data[sortKey]], format.args || []))
|
||||
: data[sortKey];
|
||||
}
|
||||
return {
|
||||
height: height,
|
||||
id: data.id,
|
||||
|
|
|
@ -145,19 +145,28 @@ pandora.ui.list = function() {
|
|||
var ui = pandora.user.ui,
|
||||
ratio = ui.icons == 'posters'
|
||||
? (ui.showSitePoster ? 5/8 : data.posterRatio) : 1,
|
||||
info = ['hue', 'saturation', 'lightness'].indexOf(sort[0].key) > -1
|
||||
? Ox.formatColor(data[sort[0].key], sort[0].key)
|
||||
: data[['title', 'director'].indexOf(sort[0].key) > -1 ? 'year' : sort[0].key];
|
||||
url = '/' + data.id + '/' + (
|
||||
ui.icons == 'posters'
|
||||
? (ui.showSitePoster ? 'siteposter' : 'poster') : 'icon'
|
||||
) + size + '.jpg',
|
||||
format, info, sortKey;
|
||||
if (['title', 'director'].indexOf(sort[0].key) > -1) {
|
||||
info = data['year']
|
||||
} else {
|
||||
sortKey = sort[0].key,
|
||||
format = pandora.getSortKeyData(sortKey).format,
|
||||
info = format
|
||||
? Ox['format' + Ox.toTitleCase(format.type)]
|
||||
.apply(this, Ox.merge([data[sortKey]], format.args || []))
|
||||
: data[sortKey];
|
||||
}
|
||||
size = size || 128;
|
||||
return {
|
||||
height: Math.round(ratio <= 1 ? size : size / ratio),
|
||||
id: data.id,
|
||||
info: info,
|
||||
title: data.title + (data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
|
||||
url: '/' + data.id + '/' + (
|
||||
ui.icons == 'posters'
|
||||
? (ui.showSitePoster ? 'siteposter' : 'poster') : 'icon'
|
||||
) + size + '.jpg',
|
||||
url: url,
|
||||
width: Math.round(ratio >= 1 ? size : size * ratio)
|
||||
};
|
||||
},
|
||||
|
|
|
@ -1,23 +1,27 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
pandora.ui.sortSelect = function() {
|
||||
var items = [],
|
||||
var isClipView = pandora.isClipView(),
|
||||
items = [],
|
||||
sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
|
||||
that;
|
||||
if (pandora.isClipView()) {
|
||||
if (isClipView) {
|
||||
items = pandora.site.clipKeys.map(function(key) {
|
||||
return Ox.extend(Ox.clone(key), {
|
||||
checked: key.id == pandora.user.ui[sortKey][0].key,
|
||||
title: 'Sort by ' + (!pandora.user.ui.item ? 'Clip ' : '') + key.title
|
||||
});
|
||||
});
|
||||
//!pandora.user.ui.item && items.push({});
|
||||
// fixme: a separator would be good
|
||||
// !pandora.user.ui.item && items.push({});
|
||||
}
|
||||
if (!pandora.user.ui.item) {
|
||||
items = Ox.merge(items, pandora.site.sortKeys.map(function(key) {
|
||||
return Ox.extend(Ox.clone(key), {
|
||||
items = Ox.merge(items, Ox.map(pandora.site.sortKeys, function(key) {
|
||||
return Ox.getPositionById(items, key.id) == -1
|
||||
? Ox.extend(Ox.clone(key), {
|
||||
checked: key.id == pandora.user.ui[sortKey][0].key,
|
||||
title: 'Sort by ' + key.title
|
||||
});
|
||||
})
|
||||
: null;
|
||||
}));
|
||||
}
|
||||
that = Ox.Select({
|
||||
|
|
|
@ -592,19 +592,15 @@ pandora.getMetadataByIdOrName = function(item, view, str, callback) {
|
|||
};
|
||||
}());
|
||||
|
||||
pandora._getSortOperator = function(type) {
|
||||
return ['hue', 'string', 'text'].indexOf(
|
||||
Ox.isArray(type) ? type[0] : type
|
||||
) > -1 ? '+' : '-';
|
||||
pandora.getSortKeyData = function(key) {
|
||||
return Ox.getObjectById(pandora.site.itemKeys, key)
|
||||
|| Ox.getObjectById(pandora.site.clipKeys, key);
|
||||
}
|
||||
|
||||
pandora.getSortOperator = function(key) { // fixme: remove?
|
||||
var type = Ox.getObjectById(
|
||||
/^clip:/.test(key) ? pandora.site.clipKeys : pandora.site.itemKeys,
|
||||
key
|
||||
).type;
|
||||
return ['hue', 'string', 'text'].indexOf(
|
||||
Ox.isArray(type) ? type[0] : type
|
||||
pandora.getSortOperator = function(key) {
|
||||
var data = pandora.getSortKeyData(key);
|
||||
return data.sortOperator || ['string', 'text'].indexOf(
|
||||
Ox.isArray(data.type) ? data.type[0] : data.type
|
||||
) > -1 ? '+' : '-';
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue