From 16f1c42ff81716b4d994eae45deae037eda88b5e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 23 Jan 2011 00:59:56 +0530 Subject: [PATCH] use init request instead of config --- pandora/api/views.py | 13 +++++++++++-- static/js/pandora.api.js | 3 +-- static/js/pandora.js | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pandora/api/views.py b/pandora/api/views.py index 4f0c6c766..8782b7c22 100644 --- a/pandora/api/views.py +++ b/pandora/api/views.py @@ -2,11 +2,14 @@ # vi:si:et:sw=4:sts=4:ts=4 from __future__ import division +import os + from django.shortcuts import render_to_response from django.template import RequestContext from django.conf import settings from ox.django.shortcuts import render_to_json_response, json_response +from ox.utils import json from pandora.user.models import get_user_json @@ -42,7 +45,7 @@ def api(request): return response -def hello(request): +def init(request): ''' return {'status': {'code': int, 'text': string}, 'data': {user: object}} @@ -55,8 +58,14 @@ def hello(request): response['data']['user'] = {'name': 'Guest', 'group': 'guest', 'preferences': {}} + with open(os.path.join(settings.PROJECT_ROOT, 'templates', 'site.json')) as f: + response['data']['config'] = json.load(f) + response['data']['config']['site']['id'] = settings.SITEID + response['data']['config']['site']['name'] = settings.SITENAME + response['data']['config']['site']['sectionName'] = settings.SITENAME + response['data']['config']['site']['url'] = settings.URL return render_to_json_response(response) -actions.register(hello) +actions.register(init) def error(request): diff --git a/static/js/pandora.api.js b/static/js/pandora.api.js index 8eddbd3d5..4e3c43c60 100755 --- a/static/js/pandora.api.js +++ b/static/js/pandora.api.js @@ -4,8 +4,7 @@ var app = new Ox.App({ apiURL: '/api/', - config: '/site.json', - init: 'hello', + init: 'init', }).launch(function(data) { Ox.print('data', data) app.config = data.config; diff --git a/static/js/pandora.js b/static/js/pandora.js index 105cddef4..acb5bd13b 100755 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -5,7 +5,7 @@ var pandora = new Ox.App({ apiURL: '/api/', config: '/site.json', - init: 'hello', + init: 'init', }).launch(function(data) { //Ox.print('data', data);