hide some metadata from guests

This commit is contained in:
rolux 2013-03-07 10:46:16 +00:00
parent 34be7923a7
commit 62c33ef2a4

View file

@ -7,6 +7,7 @@ pandora.ui.infoView = function(data) {
var ui = pandora.user.ui, var ui = pandora.user.ui,
canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level], canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level],
canSeeAllMetadata = pandora.user.level != 'guest',
css = { css = {
marginTop: '4px', marginTop: '4px',
textAlign: 'justify', textAlign: 'justify',
@ -262,8 +263,11 @@ pandora.ui.infoView = function(data) {
.html( .html(
formatKey('Alternative Title' + (data.alternativeTitles.length == 1 ? '' : 's')) formatKey('Alternative Title' + (data.alternativeTitles.length == 1 ? '' : 's'))
+ data.alternativeTitles.map(function(value) { + data.alternativeTitles.map(function(value) {
return value[0] + (Ox.isArray(value[1]) ? ' ' return value[0] + (
+ formatLight('(' + value[1].join(', ') + ')') : ''); canSeeAllMetadata && Ox.isArray(value[1])
? ' ' + formatLight('(' + value[1].join(', ') + ')')
: ''
);
}).join(', ') }).join(', ')
) )
.appendTo($text); .appendTo($text);
@ -319,19 +323,21 @@ pandora.ui.infoView = function(data) {
// FIXME: 'uncredited' should be removed on the backend // FIXME: 'uncredited' should be removed on the backend
value.character = value.character.replace('(uncredited)', '').trim(); value.character = value.character.replace('(uncredited)', '').trim();
return formatValue(value.actor, 'name') return formatValue(value.actor, 'name')
+ (value.character ? ' ' + (
+ formatLight('(' + formatValue(value.character) + ')') canSeeAllMetadata && value.character
: ''); ? ' ' + formatLight('(' + formatValue(value.character) + ')')
: ''
);
}).join(', ') }).join(', ')
) )
.appendTo($text); .appendTo($text);
if (data.genre || data.keyword) { if (data.genre || (data.keyword && canSeeAllMetadata)) {
$div = $('<div>') $div = $('<div>')
.css(css) .css(css)
.appendTo($text); .appendTo($text);
html = []; html = [];
['genre', 'keyword'].forEach(function(key) { (canSeeAllMetadata ? ['genre', 'keyword'] : ['genre']).forEach(function(key) {
data[key] && html.push( data[key] && html.push(
formatKey(key == 'keyword' ? 'keywords' : key) formatKey(key == 'keyword' ? 'keywords' : key)
+ formatValue(data[key], key) + formatValue(data[key], key)
@ -347,96 +353,100 @@ pandora.ui.infoView = function(data) {
) )
.appendTo($text); .appendTo($text);
data.trivia && data.trivia.forEach(function(value) { if (canSeeAllMetadata) {
$('<div>')
.css({ data.trivia && data.trivia.forEach(function(value) {
display: 'table-row' $('<div>')
}) .css({
.append( display: 'table-row'
$('<div>') })
.css({ .append(
display: 'table-cell', $('<div>')
width: '12px', .css({
paddingTop: '4px' display: 'table-cell',
}) width: '12px',
.html('<span style="font-weight: bold">&bull;</span>') paddingTop: '4px'
) })
.append( .html('<span style="font-weight: bold">&bull;</span>')
$('<div>') )
.css({ .append(
display: 'table-cell', $('<div>')
paddingTop: '4px', .css({
textAlign: 'justify', display: 'table-cell',
MozUserSelect: 'text', paddingTop: '4px',
WebkitUserSelect: 'text' textAlign: 'justify',
}) MozUserSelect: 'text',
.html(value) WebkitUserSelect: 'text'
) })
.append( .html(value)
$('<div>').css({clear: 'both'}) )
) .append(
.appendTo($text); $('<div>').css({clear: 'both'})
}); )
.appendTo($text);
data.filmingLocations && $('<div>')
.css(css)
.html(
formatKey('Filming Locations') + data.filmingLocations.map(function(location) {
return '<a href="/map/@' + location + '">' + location + '</a>'
}).join(', ')
)
.appendTo($text);
data.releasedate && $('<div>')
.css(css)
.html(
formatKey('Release Date') + Ox.formatDate(data.releasedate, '%A, %B %e, %Y')
)
.appendTo($text);
if (data.budget || data.gross || data.profit) {
$div = $('<div>')
.css(css)
.appendTo($text);
html = [];
['budget', 'gross', 'profit'].forEach(function(key) {
data[key] && html.push(
formatKey(key == 'profit' && data[key] < 0 ? 'loss' : key)
+ Ox.formatCurrency(Math.abs(data[key]), '$')
);
}); });
$div.html(html.join('; '));
}
if (data.connections) { data.filmingLocations && $('<div>')
$div = $('<div>')
.css(css) .css(css)
.appendTo($text); .html(
html = []; formatKey('Filming Locations') + data.filmingLocations.map(function(location) {
[ return '<a href="/map/@' + location + '">' + location + '</a>'
'Edited from', 'Edited into',
'Features', 'Featured in',
'Follows', 'Followed by',
'References', 'Referenced in',
'Remake of', 'Remade as',
'Spin off from', 'Spin off',
'Spoofs', 'Spoofed in'
].forEach(function(key) {
data.connections[key] && html.push(
formatKey(key) + data.connections[key].map(function(connection) {
return (
connection.item
? '<a href="/' + connection.item + '">' + connection.title + '</a>'
: connection.title
) + (
connection.description
? ' ' + formatLight('(' + connection.description + ')')
: ''
);
}).join(', ') }).join(', ')
); )
}); .appendTo($text);
$div.html(html.join('; '));
data.releasedate && $('<div>')
.css(css)
.html(
formatKey('Release Date') + Ox.formatDate(data.releasedate, '%A, %B %e, %Y')
)
.appendTo($text);
if (data.budget || data.gross || data.profit) {
$div = $('<div>')
.css(css)
.appendTo($text);
html = [];
['budget', 'gross', 'profit'].forEach(function(key) {
data[key] && html.push(
formatKey(key == 'profit' && data[key] < 0 ? 'loss' : key)
+ Ox.formatCurrency(Math.abs(data[key]), '$')
);
});
$div.html(html.join('; '));
}
if (data.connections) {
$div = $('<div>')
.css(css)
.appendTo($text);
html = [];
[
'Edited from', 'Edited into',
'Features', 'Featured in',
'Follows', 'Followed by',
'References', 'Referenced in',
'Remake of', 'Remade as',
'Spin off from', 'Spin off',
'Spoofs', 'Spoofed in'
].forEach(function(key) {
data.connections[key] && html.push(
formatKey(key) + data.connections[key].map(function(connection) {
return (
connection.item
? '<a href="/' + connection.item + '">' + connection.title + '</a>'
: connection.title
) + (
connection.description
? ' ' + formatLight('(' + connection.description + ')')
: ''
);
}).join(', ')
);
});
$div.html(html.join('; '));
}
} }
['reviews', 'links'].forEach(function(key) { ['reviews', 'links'].forEach(function(key) {