indiancinema: update config and info view

This commit is contained in:
rolux 2013-02-26 15:55:19 +00:00
parent d8b247d864
commit 20c5186640
2 changed files with 235 additions and 130 deletions

View file

@ -77,13 +77,19 @@
{"id": "director", "title": "Director", "type": "string"}, {"id": "director", "title": "Director", "type": "string"},
{"id": "year", "title": "Year", "type": "integer"}, {"id": "year", "title": "Year", "type": "integer"},
{"id": "language", "title": "Language", "type": "string"}, {"id": "language", "title": "Language", "type": "string"},
{"id": "genre", "title": "Genre", "type": "string"}, {"id": "color", "title": "Color", "type": "string"},
{"id": "sound", "title": "Sound", "type": "string"},
{"id": "productioncompany", "title": "Studio", "type": "string"}, {"id": "productioncompany", "title": "Studio", "type": "string"},
{"id": "writer", "title": "Writer", "type": "string"},
{"id": "producer", "title": "Producer", "type": "string"}, {"id": "producer", "title": "Producer", "type": "string"},
{"id": "codirector", "title": "Co-Director", "type": "string"},
{"id": "writer", "title": "Writer", "type": "string"},
{"id": "cinematographer", "title": "Cinematographer", "type": "string"}, {"id": "cinematographer", "title": "Cinematographer", "type": "string"},
{"id": "editor", "title": "Editor", "type": "string"}, {"id": "editor", "title": "Editor", "type": "string"},
{"id": "actor", "title": "Actor", "type": "string"} {"id": "composer", "title": "Composer", "type": "string"},
{"id": "lyricist", "title": "Lyricist", "type": "string"},
{"id": "actor", "title": "Actor", "type": "string"},
{"id": "genre", "title": "Genre", "type": "string"},
{"id": "keyword", "title": "Keyword", "type": "string"}
], ],
"flags": false, "flags": false,
/* /*
@ -204,8 +210,8 @@
"title": "Studio", "title": "Studio",
"type": ["string"], "type": ["string"],
"autocomplete": true, "autocomplete": true,
"description": true,
"columnWidth": 180, "columnWidth": 180,
"description": true,
"filter": true, "filter": true,
"find": true, "find": true,
"sort": true "sort": true
@ -221,6 +227,17 @@
"sort": true, "sort": true,
"sortType": "person" "sortType": "person"
}, },
{
"id": "codirector",
"title": "Co-Director",
"type": ["string"],
"autocomplete": true,
"columnWidth": 180,
"filter": true,
"find": true,
"sort": true,
"sortType": "person"
},
{ {
"id": "writer", "id": "writer",
"title": "Writer", "title": "Writer",
@ -265,9 +282,20 @@
"sort": true, "sort": true,
"sortType": "person" "sortType": "person"
}, },
{
"id": "lyricist",
"title": "Lyricist",
"type": ["string"],
"autocomplete": true,
"columnWidth": 180,
"filter": true,
"find": true,
"sort": true,
"sortType": "person"
},
{ {
"id": "actor", "id": "actor",
"title": "Actor", "title": "Cast",
"type": ["string"], "type": ["string"],
"autocomplete": true, "autocomplete": true,
"filter": true, "filter": true,
@ -323,7 +351,7 @@
}, },
{ {
"id": "imdbId", "id": "imdbId",
"title": "IMDb", "title": "IMDb ID",
"type": "string", "type": "string",
"columnWidth": 90, "columnWidth": 90,
"sort": true "sort": true
@ -756,7 +784,7 @@
"videoScale": "fit", "videoScale": "fit",
"videoSize": "small", "videoSize": "small",
"videoSubtitles": true, "videoSubtitles": true,
"videoTimeline": "antialias", "videoTimeline": "keyframes",
"videoView": "player", "videoView": "player",
"videoVolume": 1 "videoVolume": 1
}, },

View file

@ -17,9 +17,17 @@ pandora.ui.infoView = function(data) {
iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio),
iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0,
borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8, borderRadius = ui.icons == 'posters' ? 0 : iconSize / 8,
isCopyrighted = !data.year || data.year + 60 >= new Date().getFullYear(), isCopyrighted = !data.year || parseInt(data.year) + 60 >= new Date().getFullYear(),
listWidth = 144 + Ox.UI.SCROLLBAR_SIZE, listWidth = 144 + Ox.UI.SCROLLBAR_SIZE,
margin = 16, margin = 16,
nameKeys = [
'director', 'codirector', 'producer', 'writer', 'cinematographer',
'editor', 'composer', 'lyricist', 'actor'
],
listKeys = nameKeys.concat([
'country', 'language', 'productionCompany', 'genre', 'keyword'
]),
names = getNames(),
statisticsWidth = 128, statisticsWidth = 128,
uid = Ox.uid(), uid = Ox.uid(),
@ -46,8 +54,6 @@ pandora.ui.infoView = function(data) {
}) })
.appendTo($info), .appendTo($info),
$div,
$icon = Ox.Element({ $icon = Ox.Element({
element: '<img>', element: '<img>',
tooltip: canEdit ? ( tooltip: canEdit ? (
@ -121,6 +127,8 @@ pandora.ui.infoView = function(data) {
}) })
.appendTo($data.$element), .appendTo($data.$element),
$descriptions,
$statistics = $('<div>') $statistics = $('<div>')
.css({ .css({
position: 'absolute', position: 'absolute',
@ -136,10 +144,7 @@ pandora.ui.infoView = function(data) {
$deleteButton, $deleteButton,
$browserImages = [], $browserImages = [];
nameKeys = ['actor', 'director', 'writer', 'producer', 'cinematographer', 'editor'],
listKeys = ['country', 'language', 'genre', 'keyword', 'productionCompany'] + nameKeys;
//pandora.createLinks($text); // FIXME: this is wrong for editables that already have clickLink //pandora.createLinks($text); // FIXME: this is wrong for editables that already have clickLink
@ -156,7 +161,7 @@ pandora.ui.infoView = function(data) {
format: function(value) { format: function(value) {
return formatTitle(value); return formatTitle(value);
}, },
tooltip: canEdit ? 'Doubleclick to edit' : '', tooltip: canEdit ? getTooltip : '',
value: data.title value: data.title
}) })
.css({ .css({
@ -187,10 +192,10 @@ pandora.ui.infoView = function(data) {
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
editable: canEdit, editable: canEdit,
format: function(value) { format: function(value) {
return formatValue(value.split(', '), 'name'); return formatLink(value.split(', '), 'name');
}, },
placeholder: formatLight('Unknown Director'), placeholder: formatLight('Unknown Director'),
tooltip: canEdit ? 'Doubleclick to edit' : '', tooltip: canEdit ? getTooltip : '',
value: data.director ? data.director.join(', ') : '' value: data.director ? data.director.join(', ') : ''
}) })
.css({ .css({
@ -209,26 +214,22 @@ pandora.ui.infoView = function(data) {
.appendTo($text); .appendTo($text);
} }
// Country, Year, Language, Runtime ---------------------------------------- renderGroup(['alternativeTitles']);
$div = getBlock(['country', 'year', 'language', 'runtime'])
$div && $div
.css({marginTop: '16px'})
.appendTo($text);
renderGroup(['country', 'year', 'language', 'runtime', 'color', 'sound']);
// Alternative Titles ------------------------------------------------------ renderGroup(['productionCompany']);
$div = getBlock(['alternativeTitles'])
$div && $div
.appendTo($text);
$div = getBlock(['writer', 'producer', 'cinematographer', 'editor', 'productionCompany']) renderGroup([
$div && $div.appendTo($text); 'producer', 'codirector', 'writer', 'cinematographer', 'editor',
'composer', 'lyricist'
]);
$div = getBlock(['actor']) renderGroup(['actor']);
$div && $div.appendTo($text);
$div = getBlock(['genre', 'keyword']) renderGroup(['genre', 'keyword']);
$div && $div.appendTo($text);
renderGroup(['imdbId']);
if (data.summary || canEdit) { if (data.summary || canEdit) {
Ox.Editable({ Ox.Editable({
@ -236,22 +237,23 @@ pandora.ui.infoView = function(data) {
editable: canEdit, editable: canEdit,
maxHeight: Infinity, maxHeight: Infinity,
placeholder: formatLight('No Summary'), placeholder: formatLight('No Summary'),
tooltip: canEdit ? 'Doubleclick to edit' : '', tooltip: canEdit ? getTooltip : '',
type: 'textarea', type: 'textarea',
value: data.summary || '' value: data.summary || ''
}) })
.css(css) .css(css)
.css({marginTop: '8px'}) .css({marginTop: '8px'})
.bindEvent({ .bindEvent({
submit: function(event) { submit: function(data) {
editMetadata('summary', event.value); editMetadata('summary', data.value);
} }
}) })
.appendTo($text); .appendTo($text);
} }
$div = getBlock(['imdbId']) $descriptions = $('<div>').attr({id: 'descriptions'}).appendTo($text);
$div && $div.appendTo($text);
renderDescriptions();
$('<div>').css({height: '16px'}).appendTo($text); $('<div>').css({height: '16px'}).appendTo($text);
@ -276,7 +278,7 @@ pandora.ui.infoView = function(data) {
value = data[key] || 0; value = data[key] || 0;
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
.append(formatKey(itemKey.title, true)) .append(formatKey(itemKey.title, 'statistics'))
.append( .append(
Ox.Theme.formatColor(null, 'gradient') Ox.Theme.formatColor(null, 'gradient')
.css({textAlign: 'right'}) .css({textAlign: 'right'})
@ -294,7 +296,7 @@ pandora.ui.infoView = function(data) {
var value = data[key] || 0; var value = data[key] || 0;
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
.append(formatKey(key, true)) .append(formatKey(key, 'statistics'))
.append( .append(
Ox.Theme.formatColor(value, key == 'volume' ? 'lightness' : key) Ox.Theme.formatColor(value, key == 'volume' ? 'lightness' : key)
.css({textAlign: 'right'}) .css({textAlign: 'right'})
@ -309,7 +311,7 @@ pandora.ui.infoView = function(data) {
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
.append( .append(
formatKey(key.slice(0, -9) + ' per minute', true) formatKey(key.slice(0, -9) + ' per minute', 'statistics')
) )
.append( .append(
Ox.Theme.formatColor(null, 'gradient') Ox.Theme.formatColor(null, 'gradient')
@ -324,7 +326,7 @@ pandora.ui.infoView = function(data) {
var $rightsLevel = $('<div>'); var $rightsLevel = $('<div>');
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
.append(formatKey('Rights Level', true)) .append(formatKey('Rights Level', 'statistics'))
.append($rightsLevel) .append($rightsLevel)
.appendTo($statistics); .appendTo($statistics);
renderRightsLevel(); renderRightsLevel();
@ -335,12 +337,12 @@ pandora.ui.infoView = function(data) {
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
.append(formatKey('Notes', true)) .append(formatKey('Notes', 'statistics'))
.append( .append(
Ox.Editable({ Ox.Editable({
height: 128, height: 128,
placeholder: formatLight('No notes'), placeholder: formatLight('No notes'),
tooltip: 'Doubleclick to edit', tooltip: getTooltip,
type: 'textarea', type: 'textarea',
value: data.notes, value: data.notes,
width: 128 width: 128
@ -391,73 +393,6 @@ pandora.ui.infoView = function(data) {
renderList(); renderList();
} }
function formatEditableValue(value, key) {
var ret;
if (key == 'runtime') {
ret = Math.round(data[key] / 60) + ' min';
} else if(key == 'alternativeTitles') {
ret = value.map(function(value) {
return value[0] + (Ox.isArray(value[1]) ? ' '
+ formatLight('(' + value[1].join(', ') + ')') : '');
}).join(', ');
} else if (key == 'imdbId') {
ret = '<a href="http://www.imdb.com/title/tt'
+ value + '">' + value + '</a>';
} else if (nameKeys.indexOf(key) > -1) {
ret = formatValue(value.split(', '), 'name');
} else if (listKeys.indexOf(key) > -1) {
ret = formatValue(value.split(', '), key);
} else {
ret = value;
}
return ret;
}
function prepareValue(value, key) {
var ret;
if(key == 'alternativeTitles') {
ret = value || '';
} else if (listKeys.indexOf(key) > -1) {
ret = value ? value.join(', ') : [''];
} else {
ret = value || '';
}
return ret;
}
function getBlock(keys) {
var $div;
if (canEdit || keys.filter(function(key) { return data[key]; })) {
$div = $('<div>').css(css);
keys.forEach(function(key, i) {
if (canEdit || data[key]) {
$div.children().length && $('<span>').html(';&nbsp;').appendTo($div);
$('<span>')
.html(formatKey(key))
.appendTo($div);
Ox.EditableContent({
clickLink: pandora.clickLink,
format: function(value) {
return formatEditableValue(value, key);
},
placeholder: formatLight('unknown'),
tooltip: canEdit ? 'Doubleclick to edit' : '',
value: prepareValue(data[key], key)
})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
}
})
.appendTo($div);
}
});
}
return $div;
}
function deleteItem() { function deleteItem() {
pandora.ui.deleteItemDialog(data).open(); pandora.ui.deleteItemDialog(data).open();
} }
@ -467,6 +402,10 @@ pandora.ui.infoView = function(data) {
var edit = {id: data.id}; var edit = {id: data.id};
if (key == 'title') { if (key == 'title') {
Ox.extend(edit, parseTitle(value)); Ox.extend(edit, parseTitle(value));
} else if (key == 'alternativeTitles') {
edit[key] = value ? value.split(', ').map(function(value) {
return [value, []];
}) : [];
} else if (listKeys.indexOf(key) > -1) { } else if (listKeys.indexOf(key) > -1) {
edit[key] = value ? value.split(', ') : []; edit[key] = value ? value.split(', ') : [];
} else { } else {
@ -503,32 +442,51 @@ pandora.ui.infoView = function(data) {
$reflectionIcon.attr({src: src}); $reflectionIcon.attr({src: src});
} }
} }
if (Ox.contains(nameKeys, key)) {
names = getNames();
renderDescriptions();
} else if (key == 'namedescription') {
// ...
}
}); });
} }
} }
function formatKey(key, isStatistics) { function formatKey(key, mode) {
var item = Ox.getObjectById(pandora.site.itemKeys, key); var item = Ox.getObjectById(pandora.site.itemKeys, key);
key = item ? item.title : key; key = item ? item.title : key;
mode = mode || 'text'
if (key == 'alternativeTitles') { if (key == 'alternativeTitles') {
key = 'Alternative Title' + (data.alternativeTitles && data.alternativeTitles.length == 1 ? '' : 's'); key = 'Alternative Title' + (
} else if (key == 'IMDb') { data.alternativeTitles && data.alternativeTitles.length == 1 ? '' : 's'
key = 'IMDb ID'; );
} }
return isStatistics return mode == 'text'
? $('<div>').css({marginBottom: '4px', fontWeight: 'bold'}) ? '<span style="font-weight: bold">' + Ox.toTitleCase(key) + ':</span> '
.html(Ox.toTitleCase(key).replace(' Per ', ' per ')) : mode == 'description'
: '<span style="font-weight: bold">' + Ox.toTitleCase(key) + ':</span> '; ? Ox.toTitleCase(key)
: $('<div>')
.css({marginBottom: '4px', fontWeight: 'bold'})
.html(Ox.toTitleCase(key)
.replace(' Per ', ' per '));
} }
function formatLight(str) { function formatLight(str) {
return '<span class="OxLight">' + str + '</span>'; return '<span class="OxLight">' + str + '</span>';
} }
function formatLink(value, key) {
return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key
? '<a href="/' + key + '=' + value + '">' + value + '</a>'
: value;
}).join(', ');
}
function formatTitle(title) { function formatTitle(title) {
var match = /(.+) (\(S\d{2}E\d{2}\))/.exec(title); var match = /(.+) (\(S\d{2}E\d{2}\))/.exec(title);
if (match) { if (match) {
title = formatValue(match[1], 'title') + ' ' title = formatLink(match[1], 'title') + ' '
+ formatLight(match[2]) + formatLight(match[2])
+ title.substr(match[0].length); + title.substr(match[0].length);
} }
@ -538,12 +496,44 @@ pandora.ui.infoView = function(data) {
); );
} }
function formatValue(value, key) { function formatValue(key, value) {
return (Ox.isArray(value) ? value : [value]).map(function(value) { var ret;
return key ? if (key == 'runtime') {
'<a href="/' + key + '=' + value + '">' + value + '</a>' ret = Math.round(data[key] / 60) + ' min';
: value; } else if (key == 'imdbId') {
}).join(', '); ret = '<a href="http://www.imdb.com/title/tt'
+ value + '">' + value + '</a>';
} else if (nameKeys.indexOf(key) > -1) {
ret = formatLink(value.split(', '), 'name');
} else if (listKeys.indexOf(key) > -1 || key == 'year') {
ret = formatLink(value.split(', '), key);
} else {
ret = value;
}
return ret;
}
function getNames() {
var names = [];
nameKeys.forEach(function(key) {
data[key] && data[key].forEach(function(name) {
var index = Ox.indexOf(names, function(value) {
return value.name == name;
});
if (index == -1) {
names.push({
name: name,
keys: [key],
description: data.namedescription
? data.namedescription[name]
: void 0
});
} else {
names[index].keys.push(key);
}
});
});
return names;
} }
function getRightsLevelElement(rightsLevel) { function getRightsLevelElement(rightsLevel) {
@ -555,6 +545,21 @@ pandora.ui.infoView = function(data) {
); );
} }
function getTooltip(e) {
var $target = $(e.target);
return $target.is('a') || $target.parents('a').length
? 'Shift+doubleclick to edit' : 'Doubleclick to edit';
}
function getValue(key, value) {
return !value ? ''
: key == 'alternativeTitles' ? value.map(function(value) {
return value[0];
}).join(', ')
: Ox.contains(listKeys, key) ? value.join(', ')
: value;
}
function parseTitle(title) { function parseTitle(title) {
var data = {title: title}, var data = {title: title},
match = /(\(S(\d{2})E(\d{2})\))/.exec(title), match = /(\(S(\d{2})E(\d{2})\))/.exec(title),
@ -647,6 +652,76 @@ pandora.ui.infoView = function(data) {
}); });
} }
function renderDescriptions() {
$descriptions.empty();
names.forEach(function(value) {
if (canEdit || value.description) {
$('<div>')
.css(css)
.css({marginTop: '8px', fontWeight: 'bold'})
.html(
formatLink(value.name, 'name')
+ ' (' + value.keys.map(function(key) {
return formatKey(key, 'description');
}).join(', ') + ')'
)
.appendTo($descriptions);
Ox.Editable({
clickLink: pandora.clickLink,
editable: canEdit,
maxHeight: Infinity,
placeholder: 'No description',
tooltip: canEdit ? getTooltip : '',
type: 'textarea',
value: value.description || ''
})
.css(css)
.bindEvent({
submit: function(data) {
editMetadata(
'namedescription',
Ox.extend({}, value.name, data.value)
);
}
})
.appendTo($descriptions);
}
});
}
function renderGroup(keys) {
var $element;
if (canEdit || keys.filter(function(key) {
return data[key];
}).length) {
$element = $('<div>').css(css);
keys.forEach(function(key, i) {
if (canEdit || data[key]) {
if ($element.children().length) {
$('<span>').html('; ').appendTo($element);
}
$('<span>').html(formatKey(key)).appendTo($element);
Ox.EditableContent({
clickLink: pandora.clickLink,
format: function(value) {
return formatValue(key, value);
},
placeholder: formatLight('unknown'),
tooltip: canEdit ? getTooltip : '',
value: getValue(key, data[key])
})
.bindEvent({
submit: function(data) {
editMetadata(key, data.value);
}
})
.appendTo($element);
}
});
$element.appendTo($text);
}
}
function renderList() { function renderList() {
pandora.api.get({ pandora.api.get({
id: data.id, id: data.id,
@ -762,10 +837,12 @@ pandora.ui.infoView = function(data) {
if (canEdit) { if (canEdit) {
$rightsLevelSelect = Ox.Select({ $rightsLevelSelect = Ox.Select({
items: pandora.site.rightsLevels.map(function(rightsLevel, i) { items: pandora.site.rightsLevels.map(function(rightsLevel, i) {
return {id: i, title: rightsLevel.name}; return {
}).filter(function(rightsLevel) { id: i,
return (!isCopyrighted && rightsLevel.title != 'Under Copyright') title: rightsLevel.name,
|| (isCopyrighted && rightsLevel.title != 'Out of Copyright'); disabled: !isCopyrighted && rightsLevel.name == 'Under Copyright'
|| isCopyrighted && rightsLevel.name == 'Out of Copyright'
};
}), }),
width: 128, width: 128,
value: data.rightslevel value: data.rightslevel