From 7a01749b66ec8f5d71b6298887985aa29b66e015 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 7 Sep 2010 15:08:23 +0200 Subject: [PATCH] make pandora.json dynamic --- README | 6 ++++++ pandora/app/views.py | 8 ++++++++ pandora/settings.py | 1 + pandora/static/js/pandora.js | 10 +++++----- pandora/{static/json => templates}/pandora.json | 0 pandora/templates/site.js | 1 + pandora/urls.py | 1 + 7 files changed, 22 insertions(+), 5 deletions(-) rename pandora/{static/json => templates}/pandora.json (100%) diff --git a/README b/README index 8191801a6..6869f2652 100644 --- a/README +++ b/README @@ -33,3 +33,9 @@ Development: Apache setup: sudo apt-get install libapache2-mod-wsgi libapache2-mod-xsendfile + +add pandora repository: + sudo apt-get install python-software-properties + sudo add-apt-repository ppa:j/pandora + sudo apt-get update + sudo apt-get install oxtools mkvtoolnix diff --git a/pandora/app/views.py b/pandora/app/views.py index 5fd48b2f7..17b84887e 100644 --- a/pandora/app/views.py +++ b/pandora/app/views.py @@ -32,3 +32,11 @@ def site_js(request): siteSettings[s.key] = s.value context = RequestContext(request, {'settings':settings, 'pages': pages, 'siteSettings': siteSettings}) return render_to_response('site.js', context, mimetype="application/javascript") + +def pandora_json(request): + siteSettings = {} + for s in models.SiteSettings.objects.all(): + siteSettings[s.key] = s.value + context = RequestContext(request, {'settings':settings, 'siteSettings': siteSettings}) + return render_to_response('pandora.json', context, mimetype="application/javascript") + diff --git a/pandora/settings.py b/pandora/settings.py index abaa3a206..47ddc2fdc 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -5,6 +5,7 @@ import os from os.path import join SITENAME = 'Pandora' +SITEID = 'pandora' URL = 'pan.do/ra' PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)) diff --git a/pandora/static/js/pandora.js b/pandora/static/js/pandora.js index 6158afc69..11398f198 100755 --- a/pandora/static/js/pandora.js +++ b/pandora/static/js/pandora.js @@ -3,10 +3,10 @@ ***/ var app = new Ox.App({ - config: '/static/json/pandora.json', + config: '/pandora.json', init: 'hello', - id: 'oxdb', - name: 'OxDB', + id: site.id, + name: site.name, requestURL: '/api/' }).launch(function(data) { Ox.print('data', data) @@ -521,7 +521,7 @@ app.constructList = function(view) { id: data['id'], info: data[info], title: data.title + (data.director ? ' (' + data.director + ')' : ''), - url: 'http://0xdb.org/' + data.id + '/poster.' + size + '.' + 'jpg', + url: 'http://0xdb.org/' + data.id + '/poster.' + size + '.' + 'jpg', //url: data.poster.url.replace(/.jpg/, size + '.jpg'), width: data.poster.width || 80 // fixme: remove later }; }, @@ -1941,4 +1941,4 @@ app.getGroupWidth = function(pos, panelWidth) { }); -*/ \ No newline at end of file +*/ diff --git a/pandora/static/json/pandora.json b/pandora/templates/pandora.json similarity index 100% rename from pandora/static/json/pandora.json rename to pandora/templates/pandora.json diff --git a/pandora/templates/site.js b/pandora/templates/site.js index 03e14a632..37575bcaf 100644 --- a/pandora/templates/site.js +++ b/pandora/templates/site.js @@ -1,6 +1,7 @@ var site = {}; site.url = "{{settings.URL}}"; site.name = "{{settings.SITENAME}}"; +site.id = "{{settings.SITEID}}"; site.pages = {}; {% for page in pages %} diff --git a/pandora/urls.py b/pandora/urls.py index 3c219a7c5..898e94fb3 100644 --- a/pandora/urls.py +++ b/pandora/urls.py @@ -13,6 +13,7 @@ urlpatterns = patterns('', (r'^api/', include('backend.urls')), (r'^api/upload/$', 'archive.views.firefogg_upload'), (r'^site.js$', 'app.views.site_js'), + (r'^pandora.json$', 'app.views.pandora_json'), (r'^$', 'app.views.intro'), (r'^ra$', 'app.views.index'), (r'^r/(?P.*)$', 'oxuser.views.recover'),