Django

Code

Changeset 4789

Show
Ignore:
Timestamp:
03/23/07 14:31:37 (2 years ago)
Author:
jacob
Message:

Vastly improved the djangoproject.com doc system; it now draws from SVN directly (i.e. no more need for a hourly cron builder).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • djangoproject.com/django_website/apps/docs/models.py

    r3008 r4789  
    11from django.db import models 
    22 
    3 class Document(models.Model): 
    4     title = models.CharField(maxlength=200) 
    5     slug = models.CharField(maxlength=50, unique=True, prepopulate_from=('title',)) 
    6     doc_path = models.CharField(maxlength=200, 
    7         help_text="Relative to the docs directory in django SVN. Leave off the file extension.") 
    8     last_updated = models.DateTimeField(auto_now=True) 
    9  
     3class DocumentRelease(models.Model): 
     4    version = models.CharField(maxlength=20, unique=True) 
     5    repository_path = models.CharField(maxlength=50, help_text="(i.e. 'tags/releases/0.95' or 'branches/0.95-bugfixes')") 
     6    release_date = models.DateField() 
     7     
    108    class Meta: 
    11         db_table = 'docs_documents' 
    12         ordering = ('title',) 
    13  
     9        ordering = ('-release_date',) 
     10         
    1411    class Admin: 
    15         fields = ( 
    16             (None, {'fields': ('title', 'slug', 'doc_path')}), 
    17         ) 
    18         list_display = ('title', 'doc_path') 
    19  
     12        list_display = ("version", "repository_path", "release_date") 
     13         
    2014    def __str__(self): 
    21         return self.title 
    22  
     15        return self.version 
     16     
    2317    def get_absolute_url(self): 
    24         return "/documentation/%s/" % self.slug 
    25  
    26     def get_content(self): 
    27         try: 
    28             return self._doc_content 
    29         except AttributeError: 
    30             import os 
    31             from django.conf import settings 
    32             doc_path = os.path.join(settings.DJANGO_DOCUMENT_ROOT_PATH, "%s.html" % self.doc_path) 
    33             if os.path.exists(doc_path): 
    34                 self._doc_content = open(doc_path).read() 
    35             else: 
    36                 self._doc_content = '' 
    37             return self._doc_content 
    38  
    39     def get_toc(self): 
    40         try: 
    41             return self._toc_content 
    42         except AttributeError: 
    43             import os 
    44             from django.conf import settings 
    45             toc_path = os.path.join(settings.DJANGO_DOCUMENT_ROOT_PATH, "%s_toc.html" % self.doc_path) 
    46             if os.path.exists(toc_path): 
    47                 self._toc_content = open(toc_path).read() 
    48             else: 
    49                 self._toc_content = '' 
    50             return self._toc_content 
     18        return "/documentation/%s/" % (self.version) 
     19     
  • djangoproject.com/django_website/apps/docs/urls.py

    r3008 r4789  
    11from django.conf.urls.defaults import * 
    2 from models import Document # relative import 
    32 
    4 info_dict = { 
    5     'queryset': Document.objects.all(), 
    6     'slug_field': 'slug', 
    7 
    8  
    9 urlpatterns = patterns('django.views.generic.list_detail', 
    10     (r'^(?P<slug>[\w\/]+)/$', 'object_detail', info_dict), 
     3urlpatterns = patterns('django_website.apps.docs.views', 
     4    (r'^$',                                             'doc_index'), 
     5    (r'^(?P<version>[\d.]+)/$',                         'doc_index'), 
     6    (r'^models/$',                                      'model_index'), 
     7    (r'^models/(?P<slug>\w+)/$',                        'model_detail'), 
     8    (r'^(?P<version>[\d.]+)/models/$',                  'model_index'), 
     9    (r'^(?P<version>[\d.]+)/models/(?P<slug>\w+)/$',    'model_detail'), 
     10    (r'^(?P<slug>[\w-]+)/$',                            'doc_detail'), 
     11    (r'^(?P<version>[\d.]+)/(?P<slug>[\w-]+)/$',        'doc_detail'), 
    1112) 
  • djangoproject.com/django_website/settings.py

    r3703 r4789  
    1 # from worldonline.settings.default import * 
     1import os, platform 
     2 
     3# Far too clever trick to know if we're running on the deployment server. 
     4DEVELOPMENT_MODE = ("servers.ljworld.com" not in platform.node()) 
    25 
    36ADMINS = (('Adrian Holovaty','holovaty@gmail.com'), ('Jacob Kaplan-Moss', 'jacob@lawrence.com')) 
     
    710MANAGERS = (('Wilson Miner','wminer@ljworld.com'),) 
    811 
    9 DEBUG = False 
    10 PREPEND_WWW = True 
    11  
    12 DATABASE_ENGINE = 'postgresql' 
    13 DATABASE_NAME = 'djangoproject' 
    14 DATABASE_USER = 'apache' 
    15 DATABASE_PASSWORD = '' 
    16 DATABASE_HOST = '10.0.0.80' # set to empty string for localhost 
     12if DEVELOPMENT_MODE: 
     13    DEBUG = True 
     14    PREPEND_WWW = False 
     15    DATABASE_ENGINE = "sqlite3" 
     16    DATABASE_NAME = "/tmp/djangoproject.db" 
     17    CACHE_BACKEND = "file:///tmp/djangoprojectcache/" 
     18    TEMPLATE_DIRS = [os.path.join(os.path.dirname(__file__), "templates")] 
     19    DJANGO_SVN_ROOT = "http://code.djangoproject.com/svn/django/" 
     20else: 
     21    DEBUG = False 
     22    PREPEND_WWW = True 
     23    DATABASE_ENGINE = 'postgresql' 
     24    DATABASE_NAME = 'djangoproject' 
     25    DATABASE_USER = 'apache' 
     26    DATABASE_PASSWORD = '' 
     27    DATABASE_HOST = '10.0.0.80' # set to empty string for localhost 
     28    CACHE_BACKEND = 'memcached://127.0.0.1:11211/' 
     29    TEMPLATE_DIRS = ['/home/html/templates/djangoproject.com/'] 
     30    DJANGO_SVN_ROOT = "file:///home/svn/django/django/" 
    1731 
    1832SITE_ID = 1 
    19 TEMPLATE_DIRS = ( 
    20     '/home/html/templates/djangoproject.com/', 
    21 ) 
    2233ROOT_URLCONF = 'django_website.urls' 
    2334INSTALLED_APPS = ( 
     
    4354DJANGO_TESTS_PATH = "/home/html/djangoproject.com/tests/" 
    4455 
    45 CACHE_BACKEND = 'memcached://127.0.0.1:11211/' 
    46  
    4756CACHE_MIDDLEWARE_SECONDS = 60 * 60 * 1 # 1 hour 
    4857CACHE_MIDDLEWARE_KEY_PREFIX = 'djangoproject' 
  • djangoproject.com/django_website/sitemaps.py

    r3704 r4789  
    11from django.contrib.sitemaps import Sitemap 
    22from django_website.apps.blog.models import Entry 
    3 from django_website.apps.docs.models import Document 
    43from django.contrib.flatpages.models import FlatPage 
    54import datetime 
     
    3938    # We'd rather not look up the date of the latest comment -- not worth the overhead. 
    4039 
    41 class DocumentationSitemap(Sitemap): 
    42     changefreq = 'weekly' 
    43     priority = 0.8 
    44  
    45     def items(self): 
    46         return Document.objects.all() 
    47  
    48     # lastmod is not implemented, because documentation contains comments. 
    49     # We'd rather not look up the date of the latest comment -- not worth the overhead. 
  • djangoproject.com/django_website/templates/docs/detail.html

    r4783 r4789  
    11{% extends "base_docs.html" %} 
    22 
    3 {% block title %}Documentation | {{ object.title }}{% endblock %} 
     3{% block title %}{{ doc.title }} | Django Documentation{% endblock %} 
    44 
    55{% block content %} 
    6 {{ object.get_content }} 
     6<h1>{{ doc.title }}</h1> 
    77 
    8 {% load comments %} 
    9 {% get_free_comment_list for docs.document object.id as comment_list %} 
     8<h2 class="deck"> 
     9{% ifequal version "trunk" %} 
     10  This document is for Django's SVN release, which can be 
     11  significantly different than previous releases. Get old docs here:  
     12  {% for r in all_versions %} 
     13    <a href="../{{ r.version }}/{{ slug }}/">{{ r.version }}</a>{% if forloop.last %}.{% else %},{% endif %} 
     14  {% endfor %} 
     15{% else %} 
     16  This document describes Django version {{ version }}. For current documentation,  
     17  <a href="/documentation/{{ slug }}/">go here</a>. 
     18{% endifequal %} 
     19</h2> 
     20 
     21{{ doc.body }} 
    1022 
    1123<div id="content-secondary"> 
    12 <h2 id="comments">Comments</h2> 
    13  
    14 {% for comment in comment_list %} 
    15 <div class="comment" id="c{{ comment.id }}"> 
    16         <h3>{{ comment.person_name|escape }} <span class="small quiet">{{ comment.submit_date|date:"F j, Y" }} at {{ comment.submit_date|date:"P" }}</span></h3> 
    17     {{ comment.comment|escape|urlizetrunc:"40"|linebreaks }} 
    18 </div> 
    19 {% endfor %} 
    20  
    21 <h2>Post a comment</h2> 
    22  
    23 <p class="small quiet"><strong>Note:</strong> Please only use the comments for 
    24 questions/criticisms/suggestions on the docs. This is <strong>not</strong> the place 
    25 to ask technical support questions. For tech support, ask in the IRC 
    26 channel or post to the <a href="http://groups-beta.google.com/group/django-users"> 
    27 django-users list</a>. Comments will be periodically reviewed, integrated into 
    28 the documentation proper and removed.</p> 
    29  
    30 {% free_comment_form for docs.document object.id %} 
     24  <h2 id="comments">Questions/Feedback</h2> 
     25  <p> 
     26    If you notice errors with this documentmentation, please <a 
     27    href="http://code.djangoproject.com/simpleticket?component=Documentation"> 
     28    open a ticket</a> and let us know! 
     29  </p> 
     30  <p> 
     31    Please only use the ticket tracker for criticisms and improvements on the 
     32    docs. For tech support, ask in the IRC channel or post to the <a 
     33    href="http://groups-beta.google.com/group/django-users"> django-users 
     34    list</a>. 
     35  </p> 
    3136</div> 
    3237{% endblock %} 
    3338 
    34 {% block content-related %}<h2>Contents</h2>{{ object.get_toc }}{% endblock %} 
     39{% block content-related %} 
     40  <h2>Contents</h2> 
     41  {{ doc.toc }} 
     42{% endblock %} 
  • djangoproject.com/django_website/templates/flatfiles/docs.html

    r4401 r4789  
    33{% block content %} 
    44<h1>{{ flatpage.title }}</h1> 
     5 
     6{% ifequal version "trunk" %} 
     7   
     8{% endifequal %} 
    59 
    610{{ flatpage.content }} 
  • djangoproject.com/django_website/urls.py

    r3705 r4789  
    66from django_website.apps.aggregator.models import FeedItem 
    77from django_website.apps.blog.feeds import WeblogEntryFeed 
    8 from django_website.sitemaps import FlatPageSitemap, WeblogSitemap, DocumentationSitemap 
     8from django_website.sitemaps import FlatPageSitemap, WeblogSitemap 
    99from django.views.decorators.cache import cache_page 
    1010 
     
    2727sitemaps = { 
    2828    'weblog': WeblogSitemap, 
    29     'docs': DocumentationSitemap, 
    3029    'flatpages': FlatPageSitemap, 
    3130}