diff --git a/pandora/api/views.py b/pandora/api/views.py index e66e641..cb0a9e5 100644 --- a/pandora/api/views.py +++ b/pandora/api/views.py @@ -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) diff --git a/static/js/pandora.api.js b/static/js/pandora.api.js index 9cb3429..ca95bff 100755 --- a/static/js/pandora.api.js +++ b/static/js/pandora.api.js @@ -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 = '

Overview

use this api in the browser with Ox.app or use pandora_client to use it in python
'; + app.site.default_info = '

Overview

use this api in the browser with Ox.app or use pandora_client to use it in python
'; 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); diff --git a/static/js/pandora.js b/static/js/pandora.js index 4fe25dd..05773d0 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -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) { diff --git a/static/js/pandora/Query.js b/static/js/pandora/Query.js index 8265ad3..0f620f7 100644 --- a/static/js/pandora/Query.js +++ b/static/js/pandora/Query.js @@ -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}); diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 5d015d8..5d01ca9 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -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; diff --git a/static/js/pandora/pandora.js b/static/js/pandora/pandora.js index 29052b5..b140ae8 100644 --- a/static/js/pandora/pandora.js +++ b/static/js/pandora/pandora.js @@ -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(); } diff --git a/static/js/pandora/ui/account.js b/static/js/pandora/ui/account.js index 0c79bd0..aae61b2 100644 --- a/static/js/pandora/ui/account.js +++ b/static/js/pandora/ui/account.js @@ -348,7 +348,7 @@ pandora.ui.accountWelcomeDialog = function() { content: new Ox.Element().html('Welcome, ' + app.user.username + '!

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; diff --git a/static/js/pandora/ui/backButton.js b/static/js/pandora/ui/backButton.js index 6376953..b0535a9 100644 --- a/static/js/pandora/ui/backButton.js +++ b/static/js/pandora/ui/backButton.js @@ -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', diff --git a/static/js/pandora/ui/editor.js b/static/js/pandora/ui/editor.js index 4644be2..f82d47a 100644 --- a/static/js/pandora/ui/editor.js +++ b/static/js/pandora/ui/editor.js @@ -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, diff --git a/static/js/pandora/ui/filter.js b/static/js/pandora/ui/filter.js index e936916..3c14178 100644 --- a/static/js/pandora/ui/filter.js +++ b/static/js/pandora/ui/filter.js @@ -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; }; diff --git a/static/js/pandora/ui/findElement.js b/static/js/pandora/ui/findElement.js index 02da85b..20e25d2 100644 --- a/static/js/pandora/ui/findElement.js +++ b/static/js/pandora/ui/findElement.js @@ -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', diff --git a/static/js/pandora/ui/folderBrowserList.js b/static/js/pandora/ui/folderBrowserList.js index a432bad..cb94518 100644 --- a/static/js/pandora/ui/folderBrowserList.js +++ b/static/js/pandora/ui/folderBrowserList.js @@ -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({ diff --git a/static/js/pandora/ui/folders.js b/static/js/pandora/ui/folders.js index a09e00e..e569d64 100644 --- a/static/js/pandora/ui/folders.js +++ b/static/js/pandora/ui/folders.js @@ -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({ diff --git a/static/js/pandora/ui/group.js b/static/js/pandora/ui/group.js index cb8d628..385abaf 100644 --- a/static/js/pandora/ui/group.js +++ b/static/js/pandora/ui/group.js @@ -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, diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index 8756751..a27898b 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -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({ diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 0c1aa76..0c5271a 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -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)); diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js index 6a3e71f..90484f8 100644 --- a/static/js/pandora/ui/menu.js +++ b/static/js/pandora/ui/menu.js @@ -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') { diff --git a/static/js/pandora/ui/sectionButtons.js b/static/js/pandora/ui/sectionButtons.js index 336b170..edc3eb6 100644 --- a/static/js/pandora/ui/sectionButtons.js +++ b/static/js/pandora/ui/sectionButtons.js @@ -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'); } } }); diff --git a/static/js/pandora/ui/sectionSelect.js b/static/js/pandora/ui/sectionSelect.js index fda1814..e220cef 100644 --- a/static/js/pandora/ui/sectionSelect.js +++ b/static/js/pandora/ui/sectionSelect.js @@ -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'} ] diff --git a/static/js/pandora/ui/viewSelect.js b/static/js/pandora/ui/viewSelect.js index fa9148b..6b7b13a 100644 --- a/static/js/pandora/ui/viewSelect.js +++ b/static/js/pandora/ui/viewSelect.js @@ -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