forked from 0x2620/pandora
add js pages
This commit is contained in:
parent
7faf052587
commit
f606ee998d
4 changed files with 32 additions and 2 deletions
|
@ -1,3 +1,13 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
|
|
||||||
|
class Page(models.Model):
|
||||||
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
modified = models.DateTimeField(auto_now=True)
|
||||||
|
name = models.CharField(max_length=1024, unique=True)
|
||||||
|
body = models.TextField(blank=True)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return self.name
|
||||||
|
|
|
@ -4,11 +4,25 @@ from django.shortcuts import render_to_response, get_object_or_404, get_list_or_
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
from oxdjango.shortcuts import json_response, render_to_json_response, get_object_or_404_json
|
||||||
|
|
||||||
|
import models
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
context = RequestContext(request, {'settings':settings})
|
context = RequestContext(request, {'settings':settings})
|
||||||
return render_to_response('index.html', context)
|
return render_to_response('index.html', context)
|
||||||
|
|
||||||
def site_js(request):
|
def api_getPage(request):
|
||||||
context = RequestContext(request, {'settings':settings})
|
data = json.loads(request.POST['data'])
|
||||||
|
name = data['page']
|
||||||
|
page = get_object_or_404_json(models.Archive, name=name)
|
||||||
|
response = json_response({'name': page.name, 'body': page.body})
|
||||||
|
return render_to_json_response(response)
|
||||||
|
|
||||||
|
return render_to_response('site.js', context, mimetype="application/javascript")
|
||||||
|
|
||||||
|
|
||||||
|
def site_js(request):
|
||||||
|
pages = models.Page.objects.all()
|
||||||
|
context = RequestContext(request, {'settings':settings, 'pages': pages})
|
||||||
return render_to_response('site.js', context, mimetype="application/javascript")
|
return render_to_response('site.js', context, mimetype="application/javascript")
|
||||||
|
|
|
@ -105,6 +105,7 @@ INSTALLED_APPS = (
|
||||||
'devserver',
|
'devserver',
|
||||||
# 'south',
|
# 'south',
|
||||||
|
|
||||||
|
'app',
|
||||||
'backend',
|
'backend',
|
||||||
'oxuser',
|
'oxuser',
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
var site = {};
|
var site = {};
|
||||||
site.url = "{{settings.URL}}";
|
site.url = "{{settings.URL}}";
|
||||||
site.name = "{{settings.SITENAME}}";
|
site.name = "{{settings.SITENAME}}";
|
||||||
|
|
||||||
|
site.pages = {};
|
||||||
|
{% for page in pages %}
|
||||||
|
site.pages['{{page.name}}'] = '{{page.body|escapejs}}';
|
||||||
|
{% endfor %}
|
||||||
|
|
Loading…
Reference in a new issue