Author: jacob
Date: 2008-08-20 16:52:03 -0500 (Wed, 20 Aug 2008)
New Revision: 8452

Added:
   djangoproject.com/djangodocs/
   djangoproject.com/djangodocs/__init__.py
   djangoproject.com/djangodocs/manage.py
   djangoproject.com/djangodocs/settings.py
   djangoproject.com/djangodocs/templates/
   djangoproject.com/djangodocs/templates/docs/
   djangoproject.com/djangodocs/templates/docs/doc.html
   djangoproject.com/djangodocs/templates/docs/genindex.html
   djangoproject.com/djangodocs/templates/docs/modindex.html
   djangoproject.com/djangodocs/urls.py
   djangoproject.com/djangodocs/views.py
Log:
[djangoproject.com] Added basic app/site for docs.djangoproject.com.

Added: djangoproject.com/djangodocs/__init__.py
===================================================================

Added: djangoproject.com/djangodocs/manage.py
===================================================================
--- djangoproject.com/djangodocs/manage.py                              (rev 0)
+++ djangoproject.com/djangodocs/manage.py      2008-08-20 21:52:03 UTC (rev 
8452)
@@ -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)


Property changes on: djangoproject.com/djangodocs/manage.py
___________________________________________________________________
Name: svn:executable
   + *

Added: djangoproject.com/djangodocs/settings.py
===================================================================
--- djangoproject.com/djangodocs/settings.py                            (rev 0)
+++ djangoproject.com/djangodocs/settings.py    2008-08-20 21:52:03 UTC (rev 
8452)
@@ -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"
\ No newline at end of file

Added: djangoproject.com/djangodocs/templates/docs/doc.html
===================================================================
--- djangoproject.com/djangodocs/templates/docs/doc.html                        
        (rev 0)
+++ djangoproject.com/djangodocs/templates/docs/doc.html        2008-08-20 
21:52:03 UTC (rev 8452)
@@ -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 %}

Added: djangoproject.com/djangodocs/templates/docs/genindex.html
===================================================================
--- djangoproject.com/djangodocs/templates/docs/genindex.html                   
        (rev 0)
+++ djangoproject.com/djangodocs/templates/docs/genindex.html   2008-08-20 
21:52:03 UTC (rev 8452)
@@ -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 %}
\ No newline at end of file

Added: djangoproject.com/djangodocs/templates/docs/modindex.html
===================================================================
--- djangoproject.com/djangodocs/templates/docs/modindex.html                   
        (rev 0)
+++ djangoproject.com/djangodocs/templates/docs/modindex.html   2008-08-20 
21:52:03 UTC (rev 8452)
@@ -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 %}
\ No newline at end of file

Added: djangoproject.com/djangodocs/urls.py
===================================================================
--- djangoproject.com/djangodocs/urls.py                                (rev 0)
+++ djangoproject.com/djangodocs/urls.py        2008-08-20 21:52:03 UTC (rev 
8452)
@@ -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,
+    ),
+)

Added: djangoproject.com/djangodocs/views.py
===================================================================
--- djangoproject.com/djangodocs/views.py                               (rev 0)
+++ djangoproject.com/djangodocs/views.py       2008-08-20 21:52:03 UTC (rev 
8452)
@@ -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,
+    )
\ No newline at end of file


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to