config/site

This commit is contained in:
j 2011-05-28 13:18:28 +02:00
parent f113a170f3
commit 1e57ecc423
20 changed files with 62 additions and 59 deletions

View file

@ -73,11 +73,11 @@ def init(request):
value = ItemSort.objects.aggregate(Max(name))['%s__max'%name]
key['format']['args'][0] = value
response['data']['config'] = config
response['data']['site'] = config
if request.user.is_authenticated():
response['data']['user'] = get_user_json(request.user)
else:
response['data']['user'] = response['data']['config']['user']
response['data']['user'] = response['data']['site']['user']
return render_to_json_response(response)
actions.register(init)

View file

@ -11,9 +11,9 @@ var app = new Ox.App({
apiURL: '/api/',
init: 'init',
}).bindEvent('load', function(event, data) {
app.config = data.config;
app.site.= data.config;
app.user = data.user;
app.config.default_info = '<div class="OxSelectable"><h2>Overview</h2>use this api in the browser with Ox.app or use <a href="http://code.0x2620.org/pandora_client">pandora_client</a> to use it in python</div>';
app.site.default_info = '<div class="OxSelectable"><h2>Overview</h2>use this api in the browser with Ox.app or use <a href="http://code.0x2620.org/pandora_client">pandora_client</a> to use it in python</div>';
app.$body = $('body');
app.$document = $(document);
app.$window = $(window);
@ -22,7 +22,7 @@ var app = new Ox.App({
app.$ui = {};
app.$ui.actionList = constructList();
app.$ui.actionInfo = Ox.Container().css({padding: '16px'}).html(app.config.default_info);
app.$ui.actionInfo = Ox.Container().css({padding: '16px'}).html(app.site.default_info);
app.api.api({docs: true, code: true}, function(results) {
app.actions = results.data.actions;
@ -36,7 +36,7 @@ var app = new Ox.App({
elements: [
{
element: new Ox.Element().append(new Ox.Element()
.html(app.config.site.name + ' API').css({
.html(app.site.site.name + ' API').css({
'padding': '4px',
})).css({
'background-color': '#ddd',
@ -146,7 +146,7 @@ function constructList() {
hash += k + ','
});
else
info.html(app.config.default_info);
info.html(app.site.default_info);
document.location.hash = hash.substring(0, hash.length-1);
app.$ui.actionInfo.html(info);

View file

@ -7,7 +7,6 @@
// fixme: sort=-director doesn't work
// fixme: don't reload full right panel on sortSelect
// fixme: clear items cache after login/logout
// fixme: rename config to site (site/user is better than config/user)
// fixme: replace global app object with pandora.app or move to pandora itself
Ox.load('UI', {
debug: true,
@ -36,9 +35,9 @@ Ox.load('Geo', function() {
.resize(resizeWindow)
.unload(unloadWindow)
},
config: data.config,
site: data.site,
ui: {
findKeys: $.map(data.config.itemKeys, function(key, i) {
findKeys: $.map(data.site.itemKeys, function(key, i) {
return key.find ? key : null;
}),
infoRatio: 16 / 9,
@ -47,7 +46,7 @@ Ox.load('Geo', function() {
site: $.merge([
{id: 'site', title: 'Site', items: $.merge([
{id: 'home', title: 'Home'}
], $.merge(data.config.sitePages, [
], $.merge(data.site.sitePages, [
{id: 'software', title: 'Software'},
{id: 'help', title: 'Help'}
]))},
@ -65,14 +64,14 @@ Ox.load('Geo', function() {
{id: 'personal', title: 'Personal Lists'},
{id: 'favorite', title: 'Favorite Lists', showBrowser: false},
{id: 'featured', title: 'Featured Lists', showBrowser: false}
],
]
},
selectedMovies: [],
sortKeys: $.map(data.config.itemKeys, function(key, i) {
sortKeys: $.map(data.site.itemKeys, function(key, i) {
return key.columnWidth ? key : null;
})
},
user: data.user.level == 'guest' ? $.extend({}, data.config.user) : data.user
user: data.user.level == 'guest' ? $.extend({}, data.site.user) : data.user
});
if (data.user.level == 'guest' && $.browser.mozilla) {

View file

@ -98,7 +98,7 @@ pandora.Query = (function() {
if (app.user.ui.listQuery.conditions.length) {
list = app.user.ui.listQuery.conditions[0].value;
!app.user.ui.lists[list] && pandora.UI.set(
['lists', list].join('|'), app.config.user.ui.lists['']
['lists', list].join('|'), app.site.user.ui.lists['']
);
}
pandora.UI.set({list: list});

View file

@ -29,7 +29,7 @@ pandora.URL = (function() {
pandora.UI.set({
section: 'site',
sitePage: url
})
});
},
'^(find)$': function() {
pandora.Query.fromString('?find='); // fixme: silly hack
@ -50,7 +50,7 @@ pandora.URL = (function() {
item = split[0],
view = new RegExp(
'^(' + $.map(app.config.itemViews, function(v) {
return v.id
return v.id;
}).join('|') + ')$'
).exec(split[1]);
view = view ? view[0] : app.user.ui.itemView;

View file

@ -60,7 +60,7 @@ pandora.getGroupWidth = function(pos, panelWidth) { // fixme: don't pass panelWi
}
pandora.getSortOperator = function(key) { // fixme: make static
var type = Ox.getObjectById(app.config.itemKeys, key).type;
var type = Ox.getObjectById(app.site.itemKeys, key).type;
return ['hue', 'string', 'text'].indexOf(
Ox.isArray(type) ? type[0] : type
) > -1 ? '+' : '-';
@ -74,7 +74,7 @@ pandora.login = function(data) {
pandora.logout = function(data) {
app.user = data.user;
Ox.Theme(app.config.user.ui.theme);
Ox.Theme(app.site.user.ui.theme);
app.$ui.appPanel.reload();
}

View file

@ -348,7 +348,7 @@ pandora.ui.accountWelcomeDialog = function() {
content: new Ox.Element().html('Welcome, ' + app.user.username + '!<br/><br/>Your account has been created.'),
height: 160,
keys: {enter: 'close', escape: 'close'},
title: 'Welcome to ' + app.config.site.name,
title: 'Welcome to ' + app.site.site.name,
width: 300
});
return that;

View file

@ -1,7 +1,7 @@
// vim: et:ts=4:sw=4:sts=4:ft=js
pandora.ui.backButton = function() {
var that = Ox.Button({
title: 'Back to ' + app.config.itemName.plural,
title: 'Back to ' + app.site.itemName.plural,
width: 96
}).css({
float: 'left',

View file

@ -15,7 +15,7 @@ pandora.ui.annotations = function() {
}
}),
$bins = [];
$.each(app.config.layers, function(i, layer) {
$.each(app.site.layers, function(i, layer) {
var $bin = new Ox.CollapsePanel({
id: layer.id,
size: 16,

View file

@ -1,7 +1,7 @@
// vim: et:ts=4:sw=4:sts=4:ft=js
pandora.ui.filter = function() {
var that = new Ox.Filter({
findKeys: $.map(app.config.itemKeys, function(key) {
findKeys: $.map(app.site.itemKeys, function(key) {
return {
autocomplete: key.autocomplete,
autocompleteSortKey: key.autocompleteSortKey,
@ -9,12 +9,12 @@ pandora.ui.filter = function() {
id: key.id,
title: key.title,
type: key.type == 'layer' ? Ox.getObjectById(
app.config.layers, key.id
app.site.layers, key.id
).type : key.type
};
}),
sortKeys: app.ui.sortKeys,
viewKeys: app.config.listViews
viewKeys: app.site.listViews
});
return that;
};

View file

@ -10,7 +10,7 @@ pandora.ui.findElement = function() {
elements: $.merge(app.user.ui.list ? [
app.$ui.findListSelect = new Ox.Select({
items: [
{id: 'all', title: 'Find: All ' + app.config.itemName.plural},
{id: 'all', title: 'Find: All ' + app.site.itemName.plural},
{id: 'list', title: 'Find: This List'}
],
overlap: 'right',

View file

@ -534,7 +534,7 @@ pandora.ui.folders = function() {
type: data.id == 'new' ? 'static' : 'smart'
}, function(result) {
id = result.data.id;
pandora.UI.set(['lists', id].join('|'), app.config.user.ui.lists['']); // fixme: necessary?
pandora.UI.set(['lists', id].join('|'), app.site.user.ui.lists['']); // fixme: necessary?
pandora.URL.set('?find=list:' + id)
Ox.Request.clearCache(); // fixme: remove
$list.reloadList().bindEventOnce({

View file

@ -70,7 +70,7 @@ pandora.ui.folders = function() {
type: data.id == 'new' ? 'static' : 'smart'
}, function(result) {
id = result.data.id;
pandora.UI.set(['lists', id].join('|'), app.config.user.ui.lists['']); // fixme: necessary?
pandora.UI.set(['lists', id].join('|'), app.site.user.ui.lists['']); // fixme: necessary?
pandora.URL.set('?find=list:' + id)
Ox.Request.clearCache(); // fixme: remove
$list.reloadList().bindEventOnce({

View file

@ -9,7 +9,7 @@ pandora.ui.group = function(id, query) {
//alert(id + ' ' + JSON.stringify(pandora.Query.toObject(id)))
var i = app.user.ui.groups.indexOf(id),
panelWidth = app.$ui.document.width() - (app.user.ui.showSidebar * app.user.ui.sidebarSize) - 1,
title = Ox.getObjectById(app.config.groups, id).title,
title = Ox.getObjectById(app.site.groups, id).title,
width = pandora.getGroupWidth(i, panelWidth),
that = new Ox.TextList({
columns: [
@ -71,7 +71,7 @@ pandora.ui.group = function(id, query) {
}
});
new Ox.Select({
items: $.map(app.config.groups, function(v) {
items: $.map(app.site.groups, function(v) {
return {
checked: v.id == id,
id: v.id,
@ -123,7 +123,7 @@ pandora.ui.group = function(id, query) {
}
function getGroupObject(id) {
var i = app.user.ui.groups.indexOf(id),
title = Ox.getObjectById(app.config.groups, id).title,
title = Ox.getObjectById(app.site.groups, id).title,
width = pandora.getGroupWidth(i, panelWidth);
return {
id: id,

View file

@ -5,7 +5,7 @@ pandora.ui.item = function() {
if (result.status.code != 200) {
app.$ui.contentPanel.replaceElement(1,
Ox.Element().html(
'The '+app.config.itemName.singular+' you are looking for does not exist.'));
'The '+app.site.itemName.singular+' you are looking for does not exist.'));
} else if (app.user.ui.itemView == 'calendar') {
app.$ui.contentPanel.replaceElement(1, Ox.Element().html('Calendar'));
} else if (app.user.ui.itemView == 'clips') {
@ -16,7 +16,7 @@ pandora.ui.item = function() {
var $form,
$edit = new Ox.Element()
.append($form = new Ox.FormElementGroup({
elements: Ox.map(app.config.itemKeys, function(key) {
elements: Ox.map(app.site.itemKeys, function(key) {
return new Ox.Input({
id: key.id,
label: key.title,
@ -37,7 +37,7 @@ pandora.ui.item = function() {
click: function(event, data) {
var values = $form.value();
var changed = {};
Ox.map(app.config.itemKeys, function(key, i) {
Ox.map(app.site.itemKeys, function(key, i) {
if(values[i] && values[i] != ''+result.data[key.id]) {
if(Ox.isArray(key.type) && key.type[0] == 'string') {
changed[key.id] = values[i].split(', ');
@ -117,7 +117,7 @@ pandora.ui.item = function() {
video.profiles.forEach(function(profile) {
streams[profile] = video.baseUrl + '/' + profile + 'p.' + format;
});
$.each(app.config.layers, function(i, layer) {
$.each(app.site.layers, function(i, layer) {
layers[i] = $.extend({}, layer, {items: result.data.layers[layer.id]});
});
app.$ui.contentPanel.replaceElement(1, app.$ui.editor = new Ox.VideoEditor({

View file

@ -6,9 +6,9 @@ pandora.ui.list = function(view) { // fixme: remove view argument
/*
keys = Ox.unique($.merge(
$.map(app.user.ui.lists[app.user.ui.list].columns, function(id) {
return Ox.getObjectById(app.config.sortKeys, id);
return Ox.getObjectById(app.site.sortKeys, id);
}),
app.config.sortKeys
app.site.sortKeys
));
Ox.print('$$$$', keys)
*/
@ -236,7 +236,7 @@ pandora.ui.list = function(view) { // fixme: remove view argument
init: function(event, data) {
app.$ui.total.html(pandora.ui.status('total', data));
data = [];
$.each(app.config.totals, function(i, v) {
$.each(app.site.totals, function(i, v) {
data[v.id] = 0;
});
app.$ui.selected.html(pandora.ui.status('selected', data));

View file

@ -10,11 +10,11 @@ pandora.ui.mainMenu = function() {
],
id: 'mainMenu',
menus: [
{ id: app.config.site.id + 'Menu', title: app.config.site.name, items: [
{ id: app.site.site.id + 'Menu', title: app.site.site.name, items: [
{ id: 'home', title: 'Home' },
{},
{ id: 'about', title: 'About ' + app.config.site.name },
{ id: 'news', title: app.config.site.name + ' News' },
{ id: 'about', title: 'About ' + app.site.site.name },
{ id: 'news', title: app.site.site.name + ' News' },
{ id: 'tour', title: 'Take a Tour' },
{ id: 'faq', title: 'Frequently Asked Questions' },
{ id: 'terms', title: 'Terms of Service' },
@ -25,7 +25,7 @@ pandora.ui.mainMenu = function() {
{ id: 'report', title: 'Report a Bug' }
] },
{},
{ id: 'contact', title: 'Contact ' + app.config.site.name }
{ id: 'contact', title: 'Contact ' + app.site.site.name }
] },
{ id: 'userMenu', title: 'User', items: [
{ id: 'username', title: 'User: ' + (isGuest ? 'not logged in' : app.user.username), disabled: true },
@ -37,7 +37,7 @@ pandora.ui.mainMenu = function() {
] },
{ id: 'listMenu', title: 'List', items: [
{ id: 'history', title: 'History', items: [
{ id: 'allmovies', title: 'All ' + app.config.itemName.plural }
{ id: 'allmovies', title: 'All ' + app.site.itemName.plural }
] },
{ id: 'lists', title: 'View List', items: [
{ id: 'favorites', title: 'Favorites' }
@ -52,7 +52,7 @@ pandora.ui.mainMenu = function() {
{ id: 'newsmartlist', title: 'New Smart List...', keyboard: 'alt control n' },
{ id: 'newsmartlistfromresults', title: 'New Smart List from Results...', keyboard: 'shift alt control n' },
{},
{ id: 'addmovietolist', title: ['Add Selected ' + app.config.itemName.singular + ' to List...', 'Add Selected ' + app.config.itemName.plural + ' to List...'], disabled: true },
{ id: 'addmovietolist', title: ['Add Selected ' + app.site.itemName.singular + ' to List...', 'Add Selected ' + app.site.itemName.plural + ' to List...'], disabled: true },
{},
{ id: 'setposterframe', title: 'Set Poster Frame', disabled: true }
]},
@ -70,8 +70,8 @@ pandora.ui.mainMenu = function() {
{ id: 'invertselection', title: 'Invert Selection', disabled: true, keyboard: 'alt control a' }
] },
{ id: 'viewMenu', title: 'View', items: [
{ id: 'movies', title: 'View ' + app.config.itemName.plural, items: [
{ group: 'viewmovies', min: 0, max: 1, items: $.map(app.config.listViews, function(view, i) {
{ id: 'movies', title: 'View ' + app.site.itemName.plural, items: [
{ group: 'viewmovies', min: 0, max: 1, items: $.map(app.site.listViews, function(view, i) {
return $.extend({
checked: app.user.ui.lists[app.user.ui.list].listView == view.id,
}, view);
@ -87,8 +87,8 @@ pandora.ui.mainMenu = function() {
{ id: 'video', title: 'Video' }
] },
{},
{ id: 'openmovie', title: ['Open ' + app.config.itemName.singular, 'Open ' + app.config.itemName.plural], disabled: true, items: [
{ group: 'movieview', min: 0, max: 1, items: $.map(app.config.itemViews, function(view, i) {
{ id: 'openmovie', title: ['Open ' + app.site.itemName.singular, 'Open ' + app.site.itemName.plural], disabled: true, items: [
{ group: 'movieview', min: 0, max: 1, items: $.map(app.site.itemViews, function(view, i) {
return $.extend({
checked: app.user.ui.itemView == view.id,
}, view);
@ -98,17 +98,17 @@ pandora.ui.mainMenu = function() {
{ id: 'lists', title: 'Hide Lists', keyboard: 'shift l' },
{ id: 'info', title: 'Hide Info', keyboard: 'shift i' },
{ id: 'groups', title: 'Hide Groups', keyboard: 'shift g' },
{ id: 'movies', title: 'Hide ' + app.config.itemName.plural, disabled: true, keyboard: 'shift m' }
{ id: 'movies', title: 'Hide ' + app.site.itemName.plural, disabled: true, keyboard: 'shift m' }
]},
{ id: 'sortMenu', title: 'Sort', items: [
{ id: 'sortmovies', title: 'Sort ' + app.config.itemName.plural + ' by', items: [
{ id: 'sortmovies', title: 'Sort ' + app.site.itemName.plural + ' by', items: [
{ group: 'sortmovies', min: 1, max: 1, items: $.map(app.ui.sortKeys, function(key, i) {
return $.extend({
checked: app.user.ui.lists[app.user.ui.list].sort[0].key == key.id,
}, key);
}) }
] },
{ id: 'ordermovies', title: 'Order ' + app.config.itemName.plural, items: [
{ id: 'ordermovies', title: 'Order ' + app.site.itemName.plural, items: [
{ group: 'ordermovies', min: 1, max: 1, items: [
{ id: 'ascending', title: 'Ascending', checked: app.user.ui.lists[app.user.ui.list].sort[0].operator === '' },
{ id: 'descending', title: 'Descending', checked: app.user.ui.lists[app.user.ui.list].sort[0].operator == '-' }
@ -149,7 +149,7 @@ pandora.ui.mainMenu = function() {
{ id: 'report', title: 'Report a Bug' },
] },
{ id: 'helpMenu', title: 'Help', items: [
{ id: 'help', title: app.config.site.name + ' Help', keyboard: 'shift ?' }
{ id: 'help', title: app.site.site.name + ' Help', keyboard: 'shift ?' }
] },
{ id: 'debugMenu', title: 'Debug', items: [
{ id: 'query', title: 'Show pandora.Query' },
@ -221,7 +221,7 @@ pandora.ui.mainMenu = function() {
height: 498,
id: 'home',
keys: {enter: 'close', escape: 'close'},
title: app.config.site.name,
title: app.site.site.name,
width: 800
}).open();
} else if (data.id == 'register') {

View file

@ -2,8 +2,8 @@
pandora.ui.sectionButtons = function() {
var that = new Ox.ButtonGroup({
buttons: [
{id: 'site', selected: app.user.ui.section == 'site', title: app.config.site.name},
{id: 'items', selected: app.user.ui.section == 'items', title: app.config.itemName.plural},
{id: 'site', selected: app.user.ui.section == 'site', title: app.site.site.name},
{id: 'items', selected: app.user.ui.section == 'items', title: app.site.itemName.plural},
{id: 'texts', selected: app.user.ui.section == 'texts', title: 'Texts'},
{id: 'admin', selected: app.user.ui.section == 'admin', title: 'Admin'}
],
@ -20,6 +20,10 @@ pandora.ui.sectionButtons = function() {
pandora.URL.set(app.user.ui.sitePage);
} else if (section == 'items') {
pandora.URL.set(pandora.Query.toString());
} else if (section == 'texts') {
pandora.URL.set('texts');
} else if (section == 'admin') {
pandora.URL.set('admin');
}
}
});

View file

@ -4,8 +4,8 @@ pandora.ui.sectionSelect = function() {
var that = new Ox.Select({
id: 'sectionSelect',
items: [
{checked: app.user.ui.section == 'site', id: 'site', title: app.config.site.name},
{checked: app.user.ui.section == 'items', id: 'items', title: app.config.itemName.plural},
{checked: app.user.ui.section == 'site', id: 'site', title: app.site.site.name},
{checked: app.user.ui.section == 'items', id: 'items', title: app.site.itemName.plural},
{checked: app.user.ui.section == 'texts', id: 'texts', title: 'Texts'},
{checked: app.user.ui.section == 'admin', id: 'admin', title: 'Admin'}
]

View file

@ -2,12 +2,12 @@
pandora.ui.viewSelect = function() {
var that = new Ox.Select({
id: 'viewSelect',
items: !app.user.ui.item ? $.map(app.config.listViews, function(view) {
items: !app.user.ui.item ? $.map(app.site.listViews, function(view) {
return $.extend($.extend({}, view), {
checked: app.user.ui.lists[app.user.ui.list].listView == view.id,
title: 'View ' + view.title
});
}) : $.map(app.config.itemViews, function(view) {
}) : $.map(app.site.itemViews, function(view) {
return $.extend($.extend({}, view), {
checked: app.user.ui.itemView == view.id,
title: 'View: ' + view.title