add itemTitleKeys to config and move getItemTitle to its own file, use everywhere title strings are used

This commit is contained in:
j 2014-11-21 14:26:50 +00:00
parent a9091db9ef
commit fb5a5c5cf7
16 changed files with 41 additions and 49 deletions

View file

@ -79,7 +79,7 @@ def load_config():
#add missing defaults
for section in (
'capabilities', 'cantPlay', 'itemName', 'media', 'posters',
'capabilities', 'cantPlay', 'itemName', 'itemTitleKeys', 'media', 'posters',
'site', 'tv', 'user.ui', 'user.ui.part', 'user.ui.showFolder',
'menuExtras', 'languages'
):

View file

@ -620,6 +620,7 @@
"plural": "Movies"
},
"itemRequiresVideo": true,
"itemTitleKeys": ["title", "director", "year"],
"itemViews": [
{"id": "info", "title": "Info"},
{"id": "player", "title": "Player"},

View file

@ -636,6 +636,7 @@
"plural": "Movies"
},
"itemRequiresVideo": false,
"itemTitleKeys": ["title", "director", "year"],
"itemViews": [
{"id": "info", "title": "Info"},
{"id": "documents", "title": "Documents"},

View file

@ -515,6 +515,7 @@
"plural": "Videos"
},
"itemRequiresVideo": true,
"itemTitleKeys": ["title", "director", "year"],
"itemViews": [
{"id": "info", "title": "Info"},
{"id": "player", "title": "Player"},

View file

@ -435,6 +435,7 @@
"plural": "Videos"
},
"itemRequiresVideo": true,
"itemTitleKeys": ["title", "director", "year"],
"itemViews": [
{"id": "info", "title": "Info"},
{"id": "player", "title": "Player"},

View file

@ -105,7 +105,7 @@ pandora.ui.browser = function() {
height: ratio <= 1 ? size : size / ratio,
id: data.id,
info: info,
title: data.title + (data.director && data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
title: pandora.getItemTitle(data),
url: url,
width: ratio >= 1 ? size : size * ratio
};
@ -115,7 +115,7 @@ pandora.ui.browser = function() {
query: pandora.user.ui.find
}), callback);
},
keys: ['director', 'id', 'modified', 'posterRatio', 'title', 'year'],
keys: ['id', 'modified', 'posterRatio'].concat(pandora.site.itemTitleKeys),
max: 1,
min: 1,
orientation: 'horizontal',

View file

@ -94,7 +94,7 @@ pandora.ui.editPanel = function(isEmbed) {
editable: edit.type == 'static' && edit.editable,
enableSubtitles: ui.videoSubtitles,
formatTitle: function() {
return pandora.getItemTitle(Ox.last(arguments));
return pandora.getItemTitle(Ox.last(arguments), true);
},
fullscreen: false,
getClipImageURL: function(id, width, height) {

View file

@ -40,7 +40,7 @@ pandora.ui.embedGrid = function() {
height: Math.round(ratio <= 1 ? size : size / ratio),
id: data.id,
info: info,
title: data.title + (data.director && data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
title: pandora.getItemTitle(data),
url: url,
width: Math.round(ratio >= 1 ? size : size * ratio)
};
@ -51,7 +51,7 @@ pandora.ui.embedGrid = function() {
}), callback);
return Ox.clone(data, true);
},
keys: ['director', 'id', 'modified', 'posterRatio', 'title', 'year'],
keys: ['id', 'modified', 'posterRatio'].concat(pandora.site.itemTitleKeys),
max: 1,
selected: ui.listSelection,
size: 128,
@ -125,4 +125,4 @@ pandora.ui.embedGrid = function() {
return that;
};
};

13
static/js/getItemTitle.js Normal file
View file

@ -0,0 +1,13 @@
'use strict';
pandora.getItemTitle = function(itemData, includeYear) {
return (itemData.title || Ox._('Untitled')) + (
Ox.len(itemData.director) || (includeYear && itemData.year)
? ' (' + (
Ox.len(itemData.director)
? itemData.director
: [Ox._('Unknown Director')]
).join(', ') + ')'
: ''
) + (includeYear && itemData.year ? ' ' + itemData.year : '')
};

View file

@ -80,7 +80,7 @@ pandora.ui.info = function() {
that.append(pandora.$ui.listInfo = pandora.ui.listInfo());
previousView == 'video' && resizeInfo();
} else if (view == 'poster') {
pandora.api.get({id: id, keys: ['director', 'modified', 'posterRatio', 'title']}, function(result) {
pandora.api.get({id: id, keys: ['modified', 'posterRatio'].concat(pandora.site.itemTitleKeys)}, function(result) {
var ratio = result.data.posterRatio,
height = pandora.getInfoHeight(true);
emptyInfo();
@ -379,11 +379,7 @@ pandora.ui.posterInfo = function(data) {
textOverflow: 'ellipsis',
overflow: 'hidden'
})
.html(
data.title + (
Ox.len(data.director) ? ' (' + data.director.join(', ') + ')' : ''
)
),
.html(pandora.getItemTitle(data)),
that = Ox.SplitPanel({
elements: [
{

View file

@ -14,10 +14,10 @@ pandora.ui.item = function() {
id: pandora.user.ui.item,
keys: isVideoView ? [
'audioTracks',
'cuts', 'director', 'duration', 'durations', 'editable', 'layers',
'cuts', 'duration', 'durations', 'editable', 'layers',
'modified', 'parts', 'posterFrame', 'rendered', 'rightslevel',
'size', 'title', 'videoRatio', 'year'
] : []
'size', 'videoRatio',
].concat(pandora.site.itemTitleKeys) : []
}, pandora.user.ui.itemView == 'info' && pandora.site.capabilities.canEditMetadata[pandora.user.level] ? 0 : -1, function(result) {
if (pandora.user.ui.item != item) {
@ -32,7 +32,7 @@ pandora.ui.item = function() {
}
pandora.$ui.itemTitle
.options({title: '<b>' + pandora.getItemTitle(result.data) + '</b>'})
.options({title: '<b>' + pandora.getItemTitle(result.data, true) + '</b>'})
.show();
// fixme: layers have value, subtitles has text?

View file

@ -152,7 +152,7 @@ pandora.ui.list = function() {
height: Math.round(ratio <= 1 ? size : size / ratio),
id: data.id,
info: info,
title: data.title + (data.director && data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
title: pandora.getItemTitle(data),
url: url,
width: Math.round(ratio >= 1 ? size : size * ratio)
};
@ -163,7 +163,7 @@ pandora.ui.list = function() {
}), callback);
return Ox.clone(data, true);
},
keys: ['director', 'id', 'modified', 'posterRatio', 'title', 'year'],
keys: ['id', 'modified', 'posterRatio'].concat(pandora.site.itemTitleKeys),
selected: ui.listSelection,
size: 128,
sort: ui.listSort,
@ -209,7 +209,7 @@ pandora.ui.list = function() {
height: Math.round(ratio <= 1 ? size : size / ratio),
id: data.id,
info: info,
title: data.title + (data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
title: pandora.getItemTitle(data),
url: url,
width: Math.round(ratio >= 1 ? size : size * ratio)
},
@ -239,7 +239,7 @@ pandora.ui.list = function() {
});
return Ox.clone(data, true);
},
keys: ['clips', 'director', 'duration', 'id', 'modified', 'posterRatio', 'title', 'videoRatio', 'year'],
keys: ['clips', 'duration', 'id', 'modified', 'posterRatio', 'videoRatio'].concat(pandora.site.itemTitleKeys),
selected: ui.listSelection,
size: 192,
sort: ui.listSort,
@ -296,7 +296,7 @@ pandora.ui.list = function() {
height: Math.round(ratio <= 1 ? size : size / ratio),
id: data.id,
info: info,
title: data.title + (data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
title: pandora.getItemTitle(data),
url: url,
width: Math.round(ratio >= 1 ? size : size * ratio)
},
@ -356,7 +356,7 @@ pandora.ui.list = function() {
}} : {})), callback);
return Ox.clone(data, true);
},
keys: ['clips', 'director', 'duration', 'id', 'modified', 'posterRatio', 'rendered', 'title', 'year'],
keys: ['clips', 'duration', 'id', 'modified', 'posterRatio', 'rendered'].concat(pandora.site.itemTitleKeys),
selected: ui.listSelection,
size: 192,
sort: ui.listSort,

View file

@ -437,7 +437,7 @@ pandora.ui.listIconPanel = function(listData) {
height: size,
id: data.id,
info: data[['title', 'director'].indexOf(sort[0].key) > -1 ? 'year' : sort[0].key],
title: data.title + (data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
title: pandora.getItemTitle(data),
url: pandora.getMediaURL('/' + data.id + '/icon' + size + '.jpg?' + data.modified),
width: size
};
@ -453,7 +453,7 @@ pandora.ui.listIconPanel = function(listData) {
}
}), callback);
},
keys: ['director', 'duration', 'id', 'modified', 'posterFrame', 'title', 'videoRatio', 'year'],
keys: ['duration', 'id', 'modified', 'posterFrame', 'videoRatio'].concat(pandora.site.itemTitleKeys),
max: 1,
min: 1,
//orientation: 'vertical',

View file

@ -58,7 +58,7 @@ pandora.ui.previewDialog = function() {
that.update = function() {
pandora.requests.preview && pandora.api.cancel(pandora.requests.preview);
pandora.requests.preview = pandora.api.find({
keys: ['director', 'id', 'modified', 'posterRatio', 'title', 'year'],
keys: ['id', 'modified', 'posterRatio'].concat(pandora.site.itemTitleKeys),
query: {
conditions: [{
key: 'id',
@ -73,11 +73,7 @@ pandora.ui.previewDialog = function() {
? pandora.site.posters.ratio
: item.posterRatio,
size = getSize(posterRatio),
title = item.title + (
item.director.length ? ' (' + item.director.join(', ') + ')' : ''
) + (
item.year ? ' ' + item.year : ''
);
title = pandora.getItemTitle(item, true);
$image = $('<img>')
.attr({src: pandora.getMediaURL('/' + item.id + '/' + (
pandora.user.ui.showSitePosters ? 'siteposter' : 'poster'

View file

@ -98,12 +98,7 @@ pandora.ui.tv = function() {
title: pandora.site.site.name + ' &mdash; ' + (
list || Ox._('All {0}', [Ox._(pandora.site.itemName.plural)])
) + ' &mdash; '
+ result.data.title
+ (
result.data.director
? ' (' + result.data.director.join(', ') + ') '
: ''
) + result.data.year,
+ pandora.getItemTitle(result.data, true),
video: videoOptions.video,
volume: pandora.user.ui.videoVolume
})

View file

@ -1281,18 +1281,6 @@ pandora.getItemIdAndPosition = function() {
return ret;
}
pandora.getItemTitle = function(itemData) {
return (itemData.title || Ox._('Untitled')) + (
Ox.len(itemData.director) || itemData.year
? ' (' + (
Ox.len(itemData.director)
? itemData.director
: [Ox._('Unknown Director')]
).join(', ') + ')'
: ''
) + (itemData.year ? ' ' + itemData.year : '')
};
pandora.getLargeClipTimelineURL = function(item, inPoint, outPoint, type, callback) {
var fps = 25,
width = Math.ceil((outPoint - inPoint) * fps),