mirror of
https://github.com/bspeice/M28_App
synced 2025-07-02 14:35:55 -04:00
Initial upload for the M28 Charlotte App
Contains initial PhoneGap code, and Django template system Template system is set up to render the templates out so PhoneGap can use them, rather than having to re-code everything by hand.
This commit is contained in:
0
M28_django/M28/__init__.py
Normal file
0
M28_django/M28/__init__.py
Normal file
BIN
M28_django/M28/__init__.pyc
Normal file
BIN
M28_django/M28/__init__.pyc
Normal file
Binary file not shown.
18
M28_django/M28/dist/testing.html
vendored
Normal file
18
M28_django/M28/dist/testing.html
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Testing...</title>
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<h1>This is some new content!</h1>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
||||
|
0
M28_django/M28/management/__init__.py
Normal file
0
M28_django/M28/management/__init__.py
Normal file
BIN
M28_django/M28/management/__init__.pyc
Normal file
BIN
M28_django/M28/management/__init__.pyc
Normal file
Binary file not shown.
0
M28_django/M28/management/commands/__init__.py
Normal file
0
M28_django/M28/management/commands/__init__.py
Normal file
BIN
M28_django/M28/management/commands/__init__.pyc
Normal file
BIN
M28_django/M28/management/commands/__init__.pyc
Normal file
Binary file not shown.
48
M28_django/M28/management/commands/render_pages.py
Normal file
48
M28_django/M28/management/commands/render_pages.py
Normal file
@ -0,0 +1,48 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.template.loader import render_to_string
|
||||
import os
|
||||
import codecs
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
args = '<full_path_to_render>'
|
||||
help = 'Renders the templates found in <APP_DIR>/pages to either the supplied path or <APP_DIR>/dist'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
import M28 #Application
|
||||
APP_DIR = M28.__path__[0]
|
||||
|
||||
# Allow this to be an option later maybe?
|
||||
IN_DIR = os.path.join(APP_DIR, 'pages')
|
||||
|
||||
if len(args) > 0:
|
||||
OUT_DIR = args[0]
|
||||
else:
|
||||
OUT_DIR = os.path.join(APP_DIR, 'dist')
|
||||
|
||||
# Verify the IN_DIR is sane
|
||||
if os.path.exists(IN_DIR):
|
||||
if not os.path.isdir(IN_DIR):
|
||||
raise CommandError("Could not open the 'pages' directory for rendering the templates!\n")
|
||||
else:
|
||||
os.mkdir(IN_DIR)
|
||||
raise CommandError("The pages directory didn't exist! I've created one for you. Put your pages there.")
|
||||
|
||||
# Verify the OUT_DIR is sane
|
||||
if os.path.exists(OUT_DIR):
|
||||
if not os.path.isdir(OUT_DIR):
|
||||
raise CommandError("Could not open the 'dist' directory for rendering the templates!\n")
|
||||
else:
|
||||
os.mkdir(OUT_DIR)
|
||||
self.stderr.write("The 'dist' directory didn't exist! I've created it for you and I'm about to fill it up.")
|
||||
|
||||
# Now we're ready to start going!
|
||||
for (root, directories, files) in os.walk(IN_DIR):
|
||||
for file in files:
|
||||
full_path = os.path.join(root, file)
|
||||
self.stdout.write("Rendering file %s..." % file)
|
||||
|
||||
utf8_template_string = render_to_string(file)
|
||||
|
||||
out_path = os.path.join(OUT_DIR, file)
|
||||
codecs.open(out_path, 'w', 'utf8').write(utf8_template_string)
|
BIN
M28_django/M28/management/commands/render_pages.pyc
Normal file
BIN
M28_django/M28/management/commands/render_pages.pyc
Normal file
Binary file not shown.
3
M28_django/M28/models.py
Normal file
3
M28_django/M28/models.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
BIN
M28_django/M28/models.pyc
Normal file
BIN
M28_django/M28/models.pyc
Normal file
Binary file not shown.
5
M28_django/M28/pages/testing.html
Normal file
5
M28_django/M28/pages/testing.html
Normal file
@ -0,0 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block body_content %}
|
||||
<h1>This is some new content!</h1>
|
||||
{% endblock %}
|
17
M28_django/M28/templates/base.html
Normal file
17
M28_django/M28/templates/base.html
Normal file
@ -0,0 +1,17 @@
|
||||
{% block html %}
|
||||
<html>
|
||||
{% block head %}
|
||||
<head>
|
||||
<title>Testing...</title>
|
||||
</head>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<body>
|
||||
{% block body_content %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
{% endblock %}
|
||||
|
||||
</html>
|
||||
{% endblock %}
|
16
M28_django/M28/tests.py
Normal file
16
M28_django/M28/tests.py
Normal file
@ -0,0 +1,16 @@
|
||||
"""
|
||||
This file demonstrates writing tests using the unittest module. These will pass
|
||||
when you run "manage.py test".
|
||||
|
||||
Replace this with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.assertEqual(1 + 1, 2)
|
1
M28_django/M28/views.py
Normal file
1
M28_django/M28/views.py
Normal file
@ -0,0 +1 @@
|
||||
# Create your views here.
|
Reference in New Issue
Block a user