Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[djangoproject.com] Added basic app/site for docs.djangoproject.com.

git-svn-id: http://code.djangoproject.com/svn/djangoproject.com@8452 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 43a37d3284efb803033c44152de21c8586279e5f 1 parent 6af870d
jacob authored
View
0  djangodocs/__init__.py
No changes.
View
11 djangodocs/manage.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+from django.core.management import execute_manager
+try:
+ import settings # Assumed to be in the same directory.
+except ImportError:
+ import sys
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+ sys.exit(1)
+
+if __name__ == "__main__":
+ execute_manager(settings)
View
10 djangodocs/settings.py
@@ -0,0 +1,10 @@
+from django_website.settings import *
+
+INSTALLED_APPS = []
+TEMPLATE_DIRS = [os.path.join(os.path.dirname(__file__), "templates")] + TEMPLATE_DIRS
+ROOT_URLCONF = 'djangodocs.urls'
+
+if DEVELOPMENT_MODE:
+ DOCS_PICKLE_ROOT = "/Users/jacob/Projects/Django/upstream/docs/_build/pickle/"
+else:
+ DOCS_PICKLE_ROOT = "/home/jacob/django-docs/docs/_build/pickle"
View
72 djangodocs/templates/docs/doc.html
@@ -0,0 +1,72 @@
+{% extends "base_docs.html" %}
+
+{% block title %}{{ doc.title }} | Django Documentation{% endblock %}
+
+{% block billboard %}<h2><a href="{{ home }}">Django documentation</a></h2>{% endblock %}
+
+{% block content %}
+
+{% block body %}
+ {{ doc.body }}
+{% endblock %}
+
+<div id="content-secondary">
+ <h2 id="comments">Questions/Feedback</h2>
+ <p>
+ If you notice errors with this documentation, please <a
+ href="http://code.djangoproject.com/simpleticket?component=Documentation">
+ open a ticket</a> and let us know!
+ </p>
+ <p>
+ Please only use the ticket tracker for criticisms and improvements on the
+ docs. For tech support, ask in the IRC channel or post to the <a
+ href="http://groups-beta.google.com/group/django-users"> django-users
+ list</a>.
+ </p>
+</div>
+{% endblock %}
+
+{% block content-related %}
+ {% block toc-wrapper %}
+ <h2>Contents</h2>
+ {% block toc %}
+ {{ doc.toc }}
+ {% endblock %}
+ {% endblock %}
+
+ {% block browse-wrapper %}
+ <h2>Browse</h2>
+ <ul>
+ {% block browse %}
+ {% if doc.prev %}
+ <li>Prev: <a href="{{ doc.prev.link }}">{{ doc.prev.title }}</a></li>
+ {% endif %}
+ {% if doc.next %}
+ <li>Next: <a href="{{ doc.next.link }}">{{ doc.next.title }}</a></li>
+ {% endif %}
+ {% for doc, title, accesskey, shorttitle in env.rellinks %}
+ <li><a href="{{ home }}{{ doc }}/">{{ title }}</a></li>
+ {% endfor %}
+ {% endblock %}
+ </ul>
+ {% endblock %}
+
+ {% block breadcrumbs-wrapper %}
+ <h2>You are here:</h2>
+ <ul>
+ {% block breadcrumbs %}
+ <li>
+ <a href="{{ home }}">{{ env.docstitle }}</a>
+ {% for p in doc.parents %}
+ <ul><li><a href="{{ p.link }}">{{ p.title }}</a>
+ {% endfor %}
+ <ul><li>{% block current-page-title %}{{ doc.title }}{% endblock %}</li></ul>
+ {% for p in doc.parents %}</li></ul>{% endfor %}
+ </li>
+ {% endblock %}
+ </ul>
+ {% endblock %}
+
+ <h3>Last update:</h3>
+ <div>{{ update_date|date:"F j, Y, P" }} (<a href="http://www.timeanddate.com/worldclock/city.html?n=64">CDT</a>)</div>
+{% endblock %}
View
45 djangodocs/templates/docs/genindex.html
@@ -0,0 +1,45 @@
+{% extends "docs/doc.html" %}
+
+{% block title %}General Index | Django Documentation{% endblock %}
+{% block toc-wrapper %}{% endblock %}
+{% block current-page-title %}General Index{% endblock %}
+
+{% block body %}
+ <h1>General Index</h1>
+
+ <p class="indexletters">
+ {% for letter, _ in doc.genindexentries %}
+ <a href="#{{ letter }}">{{ letter }}</a> {% if not forloop.last %} |{% endif %}
+ {% endfor %}
+ </p>
+
+
+ {% for letter, entries in doc.genindexentries %}
+ <br/ ><hr />
+
+ <h2 id="{{ letter }}">{{ letter }}</h2>
+
+ <dl class="index">
+ {% for name, contents in entries %}
+ <dt>
+ {# contents.0 is a list of links for the item #}
+ {% if contents.0 %}
+ <a href="{{ contents.0.0 }}">{{ name }}</a>
+ {% else %}
+ {{ name }}
+ {% endif %}
+ </dt>
+
+ {# contents.1 is a list of subitems #}
+ {% if contents.1 %}
+ {% for subname, sublinks in contents.1 %}
+ <dd>
+ <a href="{{ sublinks.0 }}">{{ subname }}</a>
+ {% for link in sublinks|slice:"1:" %}, <a href="{{ link }}">[Link]</a>{% endfor %}
+ </dd>
+ {% endfor %}
+ {% endif %}
+ {% endfor %}
+ </dl>
+ {% endfor %}
+{% endblock %}
View
17 djangodocs/templates/docs/modindex.html
@@ -0,0 +1,17 @@
+{% extends "docs/doc.html" %}
+
+{% block title %}Module Index | Django Documentation{% endblock %}
+{% block toc-wrapper %}{% endblock %}
+{% block current-page-title %}Module Index{% endblock %}
+
+{% block body %}
+ <h1>Module Index</h1>
+
+ <dl>
+ {% for modname, collapse, cgroup, indent, fname, synops, pform, dep in doc.modindexentries %}
+ <dt><a href="{{ fname }}"><tt class="literal xref">{{ modname }}</tt></a></dt>
+ <dd>{{ synops }}</dd>
+ {% endfor %}
+ </dl>
+
+{% endblock %}
View
25 djangodocs/urls.py
@@ -0,0 +1,25 @@
+import djangodocs.views
+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('',
+ url(
+ r'^$',
+ djangodocs.views.index,
+ ),
+ url(
+ r'^(?P<lang>[a-z-]+)/$',
+ djangodocs.views.language,
+ ),
+ url(
+ r'^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/(?P<url>[\w/-]*)$',
+ djangodocs.views.document,
+ ),
+ url(
+ r'^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/_images/(?P<path>.*)$',
+ djangodocs.views.images,
+ ),
+ url(
+ r'^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/_source/(?P<path>.*)$',
+ djangodocs.views.source,
+ ),
+)
View
66 djangodocs/views.py
@@ -0,0 +1,66 @@
+import cPickle as pickle
+import datetime
+import django.views.static
+from django.conf import settings
+from django.core import urlresolvers
+from django.http import HttpResponseRedirect, Http404
+from django.shortcuts import render_to_response
+from unipath import FSPath as Path
+
+def index(request):
+ return HttpResponseRedirect(
+ urlresolvers.reverse(document, kwargs={
+ 'lang': 'en',
+ 'version': 'dev',
+ 'url': '',
+ })
+ )
+
+def language(request, lang):
+ return HttpResponseRedirect(
+ urlresolvers.reverse(document, kwargs={
+ 'lang': lang,
+ 'version': 'dev',
+ 'url': '',
+ })
+ )
+
+def document(request, lang, version, url):
+ if lang != 'en' or version != 'dev' or url == "search/": raise Http404()
+
+ docroot = Path(settings.DOCS_PICKLE_ROOT)
+
+ # First look for <bits>/index.fpickle, then for <bits>.fpickle
+ bits = url.strip('/').split('/')
+ doc = docroot.child(*(bits+['index.fpickle']))
+ if not doc.exists():
+ doc = docroot.child(*bits[:-1] + ["%s.fpickle" % bits[-1]])
+ if not doc.exists():
+ raise Http404("'%s' does not exist" % doc)
+
+ # Build up a list of templates to search for so that if the page is
+ # "ref/models", the list will be ["docs/ref/models.html", "docs/ref.html"]
+ bits[-1] = bits[-1].replace('.fpickle', '')
+ templates = ["docs/%s.html" % "/".join(bits[:-i+1]) for i in range(len(bits))]
+ return render_to_response(templates + ['docs/doc.html'], {
+ 'doc': pickle.load(open(doc)),
+ 'env': pickle.load(open(docroot.child('globalcontext.pickle'))),
+ 'update_date': datetime.datetime.fromtimestamp(docroot.child('last_build').mtime()),
+ 'home': urlresolvers.reverse(document, kwargs={'lang':lang, 'version':version, 'url':''}),
+ })
+
+def images(request, lang, version, path):
+ if lang != 'en' or version != 'dev': raise Http404()
+ return django.views.static.serve(
+ request,
+ document_root = Path(settings.DOCS_PICKLE_ROOT).child('_images'),
+ path = path,
+ )
+
+def source(request, lang, version, path):
+ if lang != 'en' or version != 'dev': raise Http404()
+ return django.views.static.serve(
+ request,
+ document_root = Path(settings.DOCS_PICKLE_ROOT).child('_sources'),
+ path = path,
+ )
Please sign in to comment.
Something went wrong with that request. Please try again.