├── comps ├── models.py ├── management │ ├── __init__.py │ └── commands │ │ ├── __init__.py │ │ └── export_comps.py ├── templates │ ├── comps_test │ │ ├── bar.html │ │ ├── foo.html │ │ └── subdirectory │ │ │ └── foo.html │ └── comps │ │ └── comp_listing.html ├── tests │ ├── __init__.py │ ├── urls.py │ └── test_views.py ├── __init__.py ├── urls.py └── views.py ├── example ├── __init__.py ├── urls.py ├── local_settings.py ├── templates │ ├── comps │ │ └── index.html │ └── base.html ├── wsgi.py └── settings.py ├── MANIFEST.in ├── .gitignore ├── AUTHORS.txt ├── manage.py ├── docs ├── index.rst ├── releases.rst ├── quick-start.rst ├── make.bat ├── Makefile └── conf.py ├── tox.ini ├── README.md ├── setup.py ├── LICENSE.txt └── runtests.py /comps/models.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /comps/management/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /comps/management/commands/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /comps/templates/comps_test/bar.html: -------------------------------------------------------------------------------- 1 |

This is a test

2 | -------------------------------------------------------------------------------- /comps/templates/comps_test/foo.html: -------------------------------------------------------------------------------- 1 |

This is a test

2 | -------------------------------------------------------------------------------- /comps/tests/__init__.py: -------------------------------------------------------------------------------- 1 | from .test_views import CompsViewsTestCase 2 | -------------------------------------------------------------------------------- /comps/templates/comps_test/subdirectory/foo.html: -------------------------------------------------------------------------------- 1 |

This is a test

2 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md 2 | include LICENSE.txt 3 | include AUTHORS.txt 4 | recursive-include comps/templates * 5 | -------------------------------------------------------------------------------- /example/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import patterns, include, url 2 | 3 | urlpatterns = patterns('', 4 | url(r'^', include('comps.urls')) 5 | ) 6 | -------------------------------------------------------------------------------- /comps/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | A simple application that provides an entry point for integrating 3 | front end designers into a django project 4 | """ 5 | 6 | __version__ = '1.0.0' 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[co] 2 | .project 3 | .pydevproject 4 | *~ 5 | *.db 6 | *.orig 7 | *.DS_Store 8 | *.swp 9 | .coverage 10 | .tox 11 | *.egg-info/* 12 | docs/_build/* 13 | dist/* 14 | -------------------------------------------------------------------------------- /example/local_settings.py: -------------------------------------------------------------------------------- 1 | from example.settings import * 2 | 3 | # Designate the folder for initial comp/design work 4 | COMPS_DIR = os.path.join(PROJECT_PATH, 'example/templates/comps') 5 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | Primary Author: 2 | 3 | David Ray (daaray) 4 | 5 | Contributing Authors: 6 | 7 | Mark Lavin (mlavin) 8 | Rebecca Lovewell (rebecca-caktus) 9 | Caleb Smith (calebsmith) 10 | -------------------------------------------------------------------------------- /example/templates/comps/index.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block title %}Test Index Page{% endblock %} 4 | {% block content %} 5 | 6 |

This is a sample page

7 | {% endblock %} 8 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.local_settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /comps/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | from comps import views 3 | 4 | urlpatterns = [ 5 | url(r'^comps(?:/(?P[\w\-]+))?/$', 6 | views.comp_listing, 7 | name='comp-listing'), 8 | url(r'^comps(?:/(?P[\w\-]+))?/(?P[\w.\-]+)$', 9 | views.comp, 10 | name='comp'), 11 | url(r'^export-comps/$', 12 | views.export_comps, 13 | name='export-comps'), 14 | ] 15 | -------------------------------------------------------------------------------- /comps/tests/urls.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.http import HttpResponseNotFound, HttpResponseServerError 4 | from django.conf.urls import include, url 5 | 6 | 7 | handler404 = 'comps.tests.urls.test_404' 8 | handler500 = 'comps.tests.urls.test_500' 9 | 10 | 11 | def test_404(request): 12 | return HttpResponseNotFound() 13 | 14 | 15 | def test_500(request): 16 | return HttpResponseServerError() 17 | 18 | 19 | urlpatterns = [ 20 | url(r'^comps/', include('comps.urls')), 21 | ] 22 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. django-scribbler documentation master file, created by 2 | sphinx-quickstart on Wed Jul 25 21:12:10 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | .. include:: ../README.rst 7 | 8 | Contents 9 | ------------------------------------ 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | quick-start 15 | releases 16 | 17 | 18 | Indices and tables 19 | ================== 20 | 21 | * :ref:`genindex` 22 | * :ref:`modindex` 23 | * :ref:`search` 24 | 25 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | downloadcache = {toxworkdir}/_download/ 3 | envlist = {py27,py34,py35}-{dj1.8,dj1.9,dj1.10},py33-dj1.8,docs 4 | 5 | [testenv] 6 | basepython = 7 | py27: python2.7 8 | py33: python3.3 9 | py34: python3.4 10 | py35: python3.5 11 | deps = 12 | dj1.8: Django>=1.8,<1.9 13 | dj1.9: Django>=1.9,<1.10 14 | dj1.10: Django>=1.10,<1.11 15 | commands = {envpython} runtests.py 16 | 17 | [testenv:docs] 18 | basepython = python2.7 19 | deps = Sphinx==1.1.3 20 | commands = 21 | {envbindir}/sphinx-build -a -n -b html -d docs/_build/doctrees docs docs/_build/html 22 | -------------------------------------------------------------------------------- /example/templates/base.html: -------------------------------------------------------------------------------- 1 | {% load url from future %} 2 | 3 | 4 | 5 | {% block title %}{% endblock %} 6 | 7 | 8 | 9 | {% block extra-meta %}{% endblock %} 10 | {% block extra-css %}{% endblock %} 11 | 12 | 13 |
14 | {% block content %}{% endblock %} 15 |
16 | {% block extra-js %}{% endblock %} 17 | 18 | 19 | -------------------------------------------------------------------------------- /docs/releases.rst: -------------------------------------------------------------------------------- 1 | Release History 2 | ==================================== 3 | 4 | Release and change history for django-comps 5 | 6 | v1.0.0 (Released 2017-01-24) 7 | ------------------------------------ 8 | 9 | - Python 3.5 support, Django 1.7 - 1.10 support 10 | - Drop Python 2.6, Django 1.4-1.6 11 | 12 | 13 | v0.3.0 (Released 2014-02-04) 14 | ------------------------------------ 15 | 16 | - Python 3 support, Django 1.4 - 1.6 support 17 | - Better exception handling for missing templates 18 | 19 | 20 | v0.2.0 (Released 2012-10-20) 21 | ------------------------------------ 22 | 23 | - Add management command to ouput rendered HTML and resources 24 | - Add front end UX to output zipfile of rendered HTML and resources 25 | - Add tox support 26 | 27 | 28 | v0.1.0 (Released 2012-07-25) 29 | ------------------------------------ 30 | 31 | - Initial public release. 32 | -------------------------------------------------------------------------------- /example/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for example project. 3 | 4 | This module contains the WSGI application used by Django's development server 5 | and any production WSGI deployments. It should expose a module-level variable 6 | named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover 7 | this application via the ``WSGI_APPLICATION`` setting. 8 | 9 | Usually you will have the standard Django WSGI application here, but it also 10 | might make sense to replace the whole Django WSGI application with a custom one 11 | that later delegates to the Django one. For example, you could introduce WSGI 12 | middleware here, or combine a Django application with an application of another 13 | framework. 14 | 15 | """ 16 | import os 17 | 18 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings") 19 | 20 | # This application object is used by any WSGI server configured to use this 21 | # file. This includes Django's development server, if the WSGI_APPLICATION 22 | # setting points here. 23 | from django.core.wsgi import get_wsgi_application 24 | application = get_wsgi_application() 25 | 26 | # Apply WSGI middleware here. 27 | # from helloworld.wsgi import HelloWorldApplication 28 | # application = HelloWorldApplication(application) 29 | 30 | -------------------------------------------------------------------------------- /comps/templates/comps/comp_listing.html: -------------------------------------------------------------------------------- 1 | {% if templates %} 2 |

HTML Templates

3 |
    4 | {% for template in templates %} 5 | {% if subdirectory %} 6 |
  • {{ template }}
  • 7 | {% else %} 8 |
  • {{ template }}
  • 9 | {% endif %} 10 | {% endfor %} 11 |
12 | {% endif %} 13 | {% if directories %} 14 |

Subdirectories

15 |
    16 | {% for directory in directories %} 17 | {% if subdirectory %} 18 |
  • {{ directory }}
  • 19 | {% else %} 20 |
  • {{ directory }}
  • 21 | {% endif %} 22 | {% endfor %} 23 |
24 | {% endif %} 25 | {% if subdirectory %} 26 | 27 | {% endif %} 28 | {% if not subdirectory %} 29 | 30 | Download a zipfile of all rendered templates for distribution 31 | {% endif %} 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | django-comps 2 | ========================== 3 | 4 | An app that facilitates rapid prototyping. 5 | 6 | Provides an entry point for deeper integration of front end designers with 7 | little to no experienceinto a project. 8 | 9 | Features 10 | ------- 11 | Protypes can be built in the ``COMPS_DIR`` and render within he context of 12 | a Django project, without the need for defined views. 13 | 14 | * Take advantage of the templating engine 15 | * No need to pre-configure urls and views during prototyping 16 | * Onboard new designers to the wonders of Django 17 | 18 | Installation 19 | ------------ 20 | 21 | django-comps requires Django >= 1.4 and Python >= 2.6. 22 | 23 | ``pip install django-comps`` 24 | 25 | 26 | Documentation 27 | ------------- 28 | 29 | Documentation on using django-comps is available on 30 | [Read The Docs](http://readthedocs.org/docs/django-comps/). 31 | 32 | 33 | License 34 | -------------------------------------- 35 | 36 | django-comps is released under the BSD License. See the 37 | [LICENSE](https://github.com/daaray/django-comps/blob/master/LICENSE) file for more details. 38 | 39 | 40 | Contributing 41 | -------------------------------------- 42 | 43 | If you think you've found a bug or are interested in contributing to this project 44 | check out [django-comps on Github](https://github.com/daaray/django-comps>). 45 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | from setuptools import setup, find_packages 3 | 4 | 5 | def read_file(filename): 6 | """Read a file into a string""" 7 | path = os.path.abspath(os.path.dirname(__file__)) 8 | filepath = os.path.join(path, filename) 9 | try: 10 | return open(filepath).read() 11 | except IOError: 12 | return '' 13 | 14 | 15 | setup( 16 | name='django-comps', 17 | version=__import__('comps').__version__, 18 | author='Caktus Consulting Group', 19 | author_email='solutions@caktusgroup.com', 20 | packages=find_packages(), 21 | include_package_data=True, 22 | url='https://github.com/caktus/django-comps', 23 | license='BSD', 24 | description=u' '.join(__import__('comps').__doc__.splitlines()).strip(), 25 | classifiers=[ 26 | 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 27 | 'Intended Audience :: Developers', 28 | 'License :: OSI Approved :: BSD License', 29 | 'Programming Language :: Python', 30 | 'Programming Language :: Python :: 2.6', 31 | 'Programming Language :: Python :: 2.7', 32 | 'Programming Language :: Python :: 3.3', 33 | 'Framework :: Django', 34 | 'Topic :: Software Development :: Libraries :: Python Modules', 35 | 'Development Status :: 4 - Beta', 36 | 'Operating System :: OS Independent', 37 | 'Environment :: Web Environment' 38 | ], 39 | long_description=read_file('README.md'), 40 | test_suite="runtests.runtests", 41 | ) 42 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, David Ray 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the Caktus Consulting Group, LLC nor the names of its 15 | contributors may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /comps/management/commands/export_comps.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from django.conf import settings 4 | from django.core.management import call_command 5 | from django.core.management.base import NoArgsCommand, CommandError 6 | from django.template import RequestContext 7 | from django.template.loader import render_to_string 8 | from django.test.client import RequestFactory 9 | 10 | 11 | class Command(NoArgsCommand): 12 | help = 'Exports current comps directory as static HTML pages.' 13 | 14 | def handle_noargs(self, **options): 15 | comps = getattr(settings, 'COMPS_DIR', None) 16 | if comps is None: 17 | raise CommandError('Missing COMPS_DIR setting') 18 | output = os.path.join(comps, os.pardir, 'output') 19 | if not os.path.exists(output): 20 | os.mkdir(output) 21 | request = RequestFactory().get('/') 22 | context = RequestContext(request, {}) 23 | context['STATIC_URL'] = './static/' 24 | context['debug'] = False 25 | settings.STATIC_ROOT = os.path.join(output, 'static') 26 | for dirname, dirs, filenames in os.walk(comps): 27 | for filename in filenames: 28 | full_path = os.path.join(dirname, filename) 29 | rel_path = os.path.relpath(full_path, comps) 30 | template_path = os.path.join('comps', rel_path) 31 | rendered = render_to_string(template_path, context) 32 | result = os.path.join(output, rel_path) 33 | with open(result, 'w') as f: 34 | f.write(rendered) 35 | call_command('collectstatic', interactive=False) 36 | -------------------------------------------------------------------------------- /runtests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | 4 | from django.conf import settings 5 | from django import setup 6 | 7 | 8 | if not settings.configured: 9 | settings.configure( 10 | DATABASES={ 11 | 'default': { 12 | 'ENGINE': 'django.db.backends.sqlite3', 13 | 'NAME': ':memory:', 14 | } 15 | }, 16 | INSTALLED_APPS=( 17 | 'django.contrib.auth', 18 | 'django.contrib.contenttypes', 19 | 'django.contrib.sessions', 20 | 'comps', 21 | ), 22 | SITE_ID=1, 23 | SECRET_KEY='super-secret', 24 | TEMPLATES=[ 25 | { 26 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 27 | 'APP_DIRS': True, 28 | 'OPTIONS': { 29 | 'context_processors': ( 30 | 'django.contrib.auth.context_processors.auth', 31 | 'django.template.context_processors.request', 32 | ), 33 | } 34 | }, 35 | ], 36 | ROOT_URLCONF='comps.tests.urls', 37 | PASSWORD_HASHERS=( 38 | 'django.contrib.auth.hashers.MD5PasswordHasher', 39 | ), 40 | ) 41 | 42 | 43 | from django.test.utils import get_runner 44 | 45 | 46 | def runtests(): 47 | setup() 48 | TestRunner = get_runner(settings) 49 | test_runner = TestRunner(verbosity=1, interactive=True, failfast=False) 50 | failures = test_runner.run_tests(['comps', ]) 51 | sys.exit(failures) 52 | 53 | 54 | if __name__ == '__main__': 55 | runtests() 56 | -------------------------------------------------------------------------------- /docs/quick-start.rst: -------------------------------------------------------------------------------- 1 | Getting Started 2 | ==================================== 3 | 4 | Below are the basic steps need to get django-comps integrated into your 5 | Django project. 6 | 7 | 8 | Configure Settings 9 | ------------------------------------ 10 | 11 | You need to include ``comps`` to your installed apps. 12 | 13 | .. code-block:: python 14 | 15 | INSTALLED_APPS = ( 16 | # Other installed apps would go here 17 | 'comps', 18 | ) 19 | 20 | 21 | django-comps inspects the contents of a template directory. Configure the path 22 | for the directory you will be storing your design/prototyping work: 23 | 24 | .. code-block:: python 25 | 26 | COMPS_DIR = '/path/to/project/templates/comps' 27 | 28 | 29 | Configure Urls 30 | ------------------------------------ 31 | 32 | You should include the comps urls in your root url patterns. 33 | 34 | .. code-block:: python 35 | 36 | if 'comps' in settings.INSTALLED_APPS: 37 | urlpatterns += [ 38 | url(r'^', include('comps.urls')) 39 | ] 40 | 41 | That should be enough to get you up and running with django-comps. 42 | 43 | Usage 44 | ------------------------------------ 45 | 46 | Protypes can be built in the ``COMPS_DIR`` and render within he context of a Django project, without the need for defined views. 47 | 48 | * Take advantage of the templating engine 49 | * No need to pre-configure urls and views during prototyping 50 | * Onboard new designers to the wonders of Django 51 | 52 | Plumbing 53 | ------------------------------------ 54 | 55 | * **/comps** renders a list of files with **.html** extensions and **directories** located within the COMPS_DIR 56 | * **/comp/*.html** renders the template 57 | -------------------------------------------------------------------------------- /comps/tests/test_views.py: -------------------------------------------------------------------------------- 1 | from io import BytesIO 2 | import os 3 | import zipfile 4 | 5 | from django.conf import settings 6 | from django.core.urlresolvers import reverse 7 | from django.test.client import Client 8 | from django.test import TestCase 9 | 10 | 11 | class CompsViewsTestCase(TestCase): 12 | 13 | def setUp(self): 14 | self.client = Client() 15 | #setup testing template path 16 | cwd = os.path.dirname(__file__) 17 | path_parts = cwd.split(os.sep)[:-1] 18 | base_path = os.path.join(*path_parts) 19 | settings.COMPS_DIR = os.path.join(os.sep, base_path, 20 | 'templates', 'comps_test') 21 | 22 | def test_comp_listing(self): 23 | """ 24 | render the listing template 25 | """ 26 | response = self.client.get(reverse('comp-listing')) 27 | templates = response.context['templates'] 28 | self.assertEqual(response.status_code, 200) 29 | self.assertEqual(len(templates), 2) 30 | self.assertEqual(len(response.context['directories']), 1) 31 | 32 | def test_comp_subdirectory_listing(self): 33 | """ 34 | render the listing template for a subdirectory 35 | """ 36 | response = self.client.get(reverse('comp-listing', 37 | args=['subdirectory']) 38 | ) 39 | self.assertEqual(response.status_code, 200) 40 | self.assertEqual(len(response.context['templates']), 1) 41 | self.assertEqual(response.context['directories'], []) 42 | 43 | def test_comp_html_template(self): 44 | """ 45 | Render the template 46 | """ 47 | response = self.client.get(reverse('comp', args=['foo.html']), follow=True) 48 | self.assertEqual(response.status_code, 200) 49 | 50 | def test_comp_no_template(self): 51 | """ 52 | Redirect to comp_listing if the template does not exist 53 | """ 54 | response = self.client.get(reverse('comp', args=['nothing'])) 55 | self.assertEqual(response.status_code, 302) 56 | 57 | def test_zip_export(self): 58 | """ 59 | Ensure all of the templates were exported 60 | """ 61 | files = ['foo.html', 'bar.html', 'subdirectory/foo.html'] 62 | response = self.client.get(reverse('export-comps')) 63 | self.assertEqual(response.status_code, 200) 64 | zf = zipfile.ZipFile(BytesIO(response.content)) 65 | zf_filenames = [x.filename for x in zf.filelist] 66 | self.assertEqual(len(zf_filenames), len(files)) 67 | matches = set(zf_filenames) & set(files) 68 | self.assertEqual(len(matches), 3) 69 | -------------------------------------------------------------------------------- /comps/views.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | from io import BytesIO 5 | 6 | from zipfile import ZipFile 7 | 8 | from django.conf import settings 9 | from django.http import HttpResponse 10 | from django.shortcuts import redirect, render 11 | from django.template import RequestContext, TemplateDoesNotExist 12 | from django.template.loader import get_template, render_to_string 13 | 14 | PY2 = sys.version_info[0] == 2 15 | 16 | 17 | def comp_listing(request, directory_slug=None): 18 | """ 19 | Output the list of HTML templates and subdirectories in the COMPS_DIR 20 | """ 21 | context = {} 22 | working_dir = settings.COMPS_DIR 23 | if directory_slug: 24 | working_dir = os.path.join(working_dir, directory_slug) 25 | dirnames = [] 26 | templates = [] 27 | items = os.listdir(working_dir) 28 | templates = [x for x in items if os.path.splitext(x)[1] == '.html'] 29 | dirnames = [x for x in items if \ 30 | not os.path.isfile(os.path.join(working_dir, x))] 31 | templates.sort() 32 | dirnames.sort() 33 | context['directories'] = dirnames 34 | context['templates'] = templates 35 | context['subdirectory'] = directory_slug 36 | return render(request, "comps/comp_listing.html", context) 37 | 38 | 39 | def comp(request, slug, directory_slug=None): 40 | """ 41 | View the requested comp 42 | """ 43 | context = {} 44 | path = settings.COMPS_DIR 45 | comp_dir = os.path.split(path)[1] 46 | template = "{0}/{1}".format(comp_dir, slug) 47 | if directory_slug: 48 | template = "{0}/{1}/{2}".format(comp_dir, directory_slug, slug) 49 | working_dir = os.path.join(path, slug) 50 | if os.path.isdir(working_dir): 51 | return redirect('comp-listing', directory_slug=slug) 52 | 53 | try: 54 | t = get_template(template) 55 | except TemplateDoesNotExist: 56 | return redirect('comp-listing') 57 | 58 | c = RequestContext(request, context) 59 | return HttpResponse(t.render(c)) 60 | 61 | 62 | def export_comps(request): 63 | """ 64 | Returns a zipfile of the rendered HTML templates in the COMPS_DIR 65 | """ 66 | in_memory = BytesIO() 67 | zip = ZipFile(in_memory, "a") 68 | 69 | comps = settings.COMPS_DIR 70 | static = settings.STATIC_ROOT or "" 71 | context = RequestContext(request, {}) 72 | context['debug'] = False 73 | 74 | # dump static resources 75 | # TODO: inspect each template and only pull in resources that are used 76 | for dirname, dirs, filenames in os.walk(static): 77 | for filename in filenames: 78 | full_path = os.path.join(dirname, filename) 79 | rel_path = os.path.relpath(full_path, static) 80 | content = open(full_path, 'rb').read() 81 | try: 82 | ext = os.path.splitext(filename)[1] 83 | except IndexError: 84 | pass 85 | if ext == '.css': 86 | # convert static refs to relative links 87 | dotted_rel = os.path.relpath(static, full_path) 88 | new_rel_path = '{0}{1}'.format(dotted_rel, '/static') 89 | content = content.replace(b'/static', bytes(new_rel_path, 'utf8')) 90 | path = os.path.join('static', rel_path) 91 | zip.writestr(path, content) 92 | 93 | for dirname, dirs, filenames in os.walk(comps): 94 | for filename in filenames: 95 | full_path = os.path.join(dirname, filename) 96 | rel_path = os.path.relpath(full_path, comps) 97 | template_path = os.path.join(comps.split('/')[-1], rel_path) 98 | html = render_to_string(template_path, context) 99 | # convert static refs to relative links 100 | depth = len(rel_path.split(os.sep)) - 1 101 | if depth == 0: 102 | dotted_rel = '.' 103 | else: 104 | dotted_rel = '' 105 | i = 0 106 | while i < depth: 107 | dotted_rel += '../' 108 | i += 1 109 | new_rel_path = '{0}{1}'.format(dotted_rel, '/static') 110 | html = html.replace('/static', new_rel_path) 111 | if PY2: 112 | html = unicode(html) 113 | zip.writestr(rel_path, html.encode('utf8')) 114 | 115 | for item in zip.filelist: 116 | item.create_system = 0 117 | zip.close() 118 | 119 | response = HttpResponse(content_type="application/zip") 120 | response["Content-Disposition"] = "attachment; filename=comps.zip" 121 | in_memory.seek(0) 122 | response.write(in_memory.read()) 123 | 124 | return response 125 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. linkcheck to check all external links for integrity 37 | echo. doctest to run all doctests embedded in the documentation if enabled 38 | goto end 39 | ) 40 | 41 | if "%1" == "clean" ( 42 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 43 | del /q /s %BUILDDIR%\* 44 | goto end 45 | ) 46 | 47 | if "%1" == "html" ( 48 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 49 | if errorlevel 1 exit /b 1 50 | echo. 51 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 52 | goto end 53 | ) 54 | 55 | if "%1" == "dirhtml" ( 56 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 57 | if errorlevel 1 exit /b 1 58 | echo. 59 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 60 | goto end 61 | ) 62 | 63 | if "%1" == "singlehtml" ( 64 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 68 | goto end 69 | ) 70 | 71 | if "%1" == "pickle" ( 72 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished; now you can process the pickle files. 76 | goto end 77 | ) 78 | 79 | if "%1" == "json" ( 80 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished; now you can process the JSON files. 84 | goto end 85 | ) 86 | 87 | if "%1" == "htmlhelp" ( 88 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can run HTML Help Workshop with the ^ 92 | .hhp project file in %BUILDDIR%/htmlhelp. 93 | goto end 94 | ) 95 | 96 | if "%1" == "qthelp" ( 97 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 98 | if errorlevel 1 exit /b 1 99 | echo. 100 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 101 | .qhcp project file in %BUILDDIR%/qthelp, like this: 102 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\django-comps.qhcp 103 | echo.To view the help file: 104 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\django-comps.ghc 105 | goto end 106 | ) 107 | 108 | if "%1" == "devhelp" ( 109 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished. 113 | goto end 114 | ) 115 | 116 | if "%1" == "epub" ( 117 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 121 | goto end 122 | ) 123 | 124 | if "%1" == "latex" ( 125 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 129 | goto end 130 | ) 131 | 132 | if "%1" == "text" ( 133 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The text files are in %BUILDDIR%/text. 137 | goto end 138 | ) 139 | 140 | if "%1" == "man" ( 141 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 145 | goto end 146 | ) 147 | 148 | if "%1" == "texinfo" ( 149 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 150 | if errorlevel 1 exit /b 1 151 | echo. 152 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 153 | goto end 154 | ) 155 | 156 | if "%1" == "gettext" ( 157 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 158 | if errorlevel 1 exit /b 1 159 | echo. 160 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 161 | goto end 162 | ) 163 | 164 | if "%1" == "changes" ( 165 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 166 | if errorlevel 1 exit /b 1 167 | echo. 168 | echo.The overview file is in %BUILDDIR%/changes. 169 | goto end 170 | ) 171 | 172 | if "%1" == "linkcheck" ( 173 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 174 | if errorlevel 1 exit /b 1 175 | echo. 176 | echo.Link check complete; look for any errors in the above output ^ 177 | or in %BUILDDIR%/linkcheck/output.txt. 178 | goto end 179 | ) 180 | 181 | if "%1" == "doctest" ( 182 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Testing of doctests in the sources finished, look at the ^ 186 | results in %BUILDDIR%/doctest/output.txt. 187 | goto end 188 | ) 189 | 190 | :end 191 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-comps.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-comps.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/django-comps" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/django-comps" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /example/settings.py: -------------------------------------------------------------------------------- 1 | # Django settings for example project. 2 | import os 3 | 4 | PROJECT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) 5 | 6 | DEBUG = True 7 | TEMPLATE_DEBUG = DEBUG 8 | 9 | ADMINS = ( 10 | # ('Your Name', 'your_email@example.com'), 11 | ) 12 | 13 | MANAGERS = ADMINS 14 | 15 | DATABASES = { 16 | 'default': { 17 | 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 18 | 'NAME': os.path.join(PROJECT_PATH, 'blip.db'), # Or path to database file if using sqlite3. 19 | 'USER': '', # Not used with sqlite3. 20 | 'PASSWORD': '', # Not used with sqlite3. 21 | 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 22 | 'PORT': '', # Set to empty string for default. Not used with sqlite3. 23 | } 24 | } 25 | 26 | # Local time zone for this installation. Choices can be found here: 27 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 28 | # although not all choices may be available on all operating systems. 29 | # On Unix systems, a value of None will cause Django to use the same 30 | # timezone as the operating system. 31 | # If running in a Windows environment this must be set to the same as your 32 | # system time zone. 33 | TIME_ZONE = 'America/Chicago' 34 | 35 | # Language code for this installation. All choices can be found here: 36 | # http://www.i18nguy.com/unicode/language-identifiers.html 37 | LANGUAGE_CODE = 'en-us' 38 | 39 | SITE_ID = 1 40 | 41 | # If you set this to False, Django will make some optimizations so as not 42 | # to load the internationalization machinery. 43 | USE_I18N = True 44 | 45 | # If you set this to False, Django will not format dates, numbers and 46 | # calendars according to the current locale. 47 | USE_L10N = True 48 | 49 | # If you set this to False, Django will not use timezone-aware datetimes. 50 | USE_TZ = True 51 | 52 | # Absolute filesystem path to the directory that will hold user-uploaded files. 53 | # Example: "/home/media/media.lawrence.com/media/" 54 | MEDIA_ROOT = '' 55 | 56 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a 57 | # trailing slash. 58 | # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" 59 | MEDIA_URL = '' 60 | 61 | # Absolute path to the directory static files should be collected to. 62 | # Don't put anything in this directory yourself; store your static files 63 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. 64 | # Example: "/home/media/media.lawrence.com/static/" 65 | STATIC_ROOT = '' 66 | 67 | # URL prefix for static files. 68 | # Example: "http://media.lawrence.com/static/" 69 | STATIC_URL = '/static/' 70 | 71 | # Additional locations of static files 72 | STATICFILES_DIRS = ( 73 | # Put strings here, like "/home/html/static" or "C:/www/django/static". 74 | # Always use forward slashes, even on Windows. 75 | # Don't forget to use absolute paths, not relative paths. 76 | os.path.join(PROJECT_PATH, 'static'), 77 | ) 78 | 79 | # List of finder classes that know how to find static files in 80 | # various locations. 81 | STATICFILES_FINDERS = ( 82 | 'django.contrib.staticfiles.finders.FileSystemFinder', 83 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 84 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder', 85 | ) 86 | 87 | # Make this unique, and don't share it with anybody. 88 | SECRET_KEY = 'zl8n#*c2)rso==w@9ygsnpy&0xpy5mkv15rxb5r+&!e&k&-@fg' 89 | 90 | # List of callables that know how to import templates from various sources. 91 | TEMPLATE_LOADERS = ( 92 | 'django.template.loaders.filesystem.Loader', 93 | 'django.template.loaders.app_directories.Loader', 94 | # 'django.template.loaders.eggs.Loader', 95 | ) 96 | 97 | TEMPLATE_CONTEXT_PROCESSORS = ( 98 | 'django.contrib.auth.context_processors.auth', 99 | 'django.contrib.messages.context_processors.messages', 100 | 'django.core.context_processors.debug', 101 | 'django.core.context_processors.media', 102 | 'django.core.context_processors.i18n', 103 | 'django.core.context_processors.static', 104 | 'django.core.context_processors.request', 105 | ) 106 | 107 | MIDDLEWARE_CLASSES = ( 108 | 'django.middleware.common.CommonMiddleware', 109 | 'django.contrib.sessions.middleware.SessionMiddleware', 110 | 'django.middleware.csrf.CsrfViewMiddleware', 111 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 112 | 'django.contrib.messages.middleware.MessageMiddleware', 113 | # Uncomment the next line for simple clickjacking protection: 114 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 115 | ) 116 | 117 | ROOT_URLCONF = 'example.urls' 118 | 119 | # Python dotted path to the WSGI application used by Django's runserver. 120 | WSGI_APPLICATION = 'example.wsgi.application' 121 | 122 | TEMPLATE_DIRS = ( 123 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". 124 | # Always use forward slashes, even on Windows. 125 | # Don't forget to use absolute paths, not relative paths. 126 | os.path.join(PROJECT_PATH, 'templates'), 127 | ) 128 | 129 | INSTALLED_APPS = ( 130 | 'django.contrib.auth', 131 | 'django.contrib.contenttypes', 132 | 'django.contrib.sessions', 133 | 'django.contrib.sites', 134 | 'django.contrib.messages', 135 | 'django.contrib.staticfiles', 136 | # Uncomment the next line to enable the admin: 137 | 'django.contrib.admin', 138 | # Uncomment the next line to enable admin documentation: 139 | # 'django.contrib.admindocs', 140 | 'comps', 141 | 'example', 142 | ) 143 | 144 | # A sample logging configuration. The only tangible logging 145 | # performed by this configuration is to send an email to 146 | # the site admins on every HTTP 500 error when DEBUG=False. 147 | # See http://docs.djangoproject.com/en/dev/topics/logging for 148 | # more details on how to customize your logging configuration. 149 | LOGGING = { 150 | 'version': 1, 151 | 'disable_existing_loggers': False, 152 | 'filters': { 153 | 'require_debug_false': { 154 | '()': 'django.utils.log.RequireDebugFalse' 155 | } 156 | }, 157 | 'handlers': { 158 | 'mail_admins': { 159 | 'level': 'ERROR', 160 | 'filters': ['require_debug_false'], 161 | 'class': 'django.utils.log.AdminEmailHandler' 162 | } 163 | }, 164 | 'loggers': { 165 | 'django.request': { 166 | 'handlers': ['mail_admins'], 167 | 'level': 'ERROR', 168 | 'propagate': True, 169 | }, 170 | } 171 | } 172 | 173 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # django-comps documentation build configuration file, created by 4 | # sphinx-quickstart on Wed Jul 25 21:12:10 2012. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = [] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.rst' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'django-comps' 44 | copyright = u'2012, David Ray' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = '1.0' 52 | # The full version, including alpha/beta/rc tags. 53 | release = '1.0.0' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | #today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | #today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = ['_build'] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_module_names = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | #html_theme_path = [] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | #html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | #html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | #html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | #html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | #html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | #html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | #html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | #html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | #html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | #html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | #html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | #html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | #html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | #html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | #html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | #html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = 'django-compsdoc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | latex_elements = { 173 | # The paper size ('letterpaper' or 'a4paper'). 174 | #'papersize': 'letterpaper', 175 | 176 | # The font size ('10pt', '11pt' or '12pt'). 177 | #'pointsize': '10pt', 178 | 179 | # Additional stuff for the LaTeX preamble. 180 | #'preamble': '', 181 | } 182 | 183 | # Grouping the document tree into LaTeX files. List of tuples 184 | # (source start file, target name, title, author, documentclass [howto/manual]). 185 | latex_documents = [ 186 | ('index', 'django-comps.tex', u'django-comps Documentation', 187 | u'David Ray', 'manual'), 188 | ] 189 | 190 | # The name of an image file (relative to this directory) to place at the top of 191 | # the title page. 192 | #latex_logo = None 193 | 194 | # For "manual" documents, if this is true, then toplevel headings are parts, 195 | # not chapters. 196 | #latex_use_parts = False 197 | 198 | # If true, show page references after internal links. 199 | #latex_show_pagerefs = False 200 | 201 | # If true, show URL addresses after external links. 202 | #latex_show_urls = False 203 | 204 | # Documents to append as an appendix to all manuals. 205 | #latex_appendices = [] 206 | 207 | # If false, no module index is generated. 208 | #latex_domain_indices = True 209 | 210 | 211 | # -- Options for manual page output -------------------------------------------- 212 | 213 | # One entry per manual page. List of tuples 214 | # (source start file, name, description, authors, manual section). 215 | man_pages = [ 216 | ('index', 'django-comps', u'django-comps Documentation', 217 | [u'David Ray'], 1) 218 | ] 219 | 220 | # If true, show URL addresses after external links. 221 | #man_show_urls = False 222 | 223 | 224 | # -- Options for Texinfo output ------------------------------------------------ 225 | 226 | # Grouping the document tree into Texinfo files. List of tuples 227 | # (source start file, target name, title, author, 228 | # dir menu entry, description, category) 229 | texinfo_documents = [ 230 | ('index', 'django-comps', u'django-comps Documentation', 231 | u'David Ray', 'django-comps', 'A rapid prototyping facilitator.', 232 | 'Miscellaneous'), 233 | ] 234 | 235 | # Documents to append as an appendix to all manuals. 236 | #texinfo_appendices = [] 237 | 238 | # If false, no module index is generated. 239 | #texinfo_domain_indices = True 240 | 241 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 242 | #texinfo_show_urls = 'footnote' 243 | --------------------------------------------------------------------------------