Changeset 391
- Timestamp:
- 08/02/05 14:59:51 (3 years ago)
- Files:
-
- django/trunk/django/conf/admin_media/css/global.css (modified) (1 diff)
- django/trunk/django/conf/admin_templates/doc/index.html (modified) (1 diff)
- django/trunk/django/conf/admin_templates/doc/view_index.html (modified) (2 diffs)
- django/trunk/django/core/defaulttags.py (modified) (3 diffs)
- django/trunk/django/parts/admin/doc.py (modified) (4 diffs)
- django/trunk/django/templatetags/log.py (modified) (1 diff)
- django/trunk/django/views/admin/doc.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/conf/admin_media/css/global.css
r387 r391 68 68 code strong { color:#930; } 69 69 hr { clear:both; color:#eee; background-color:#eee; height:1px; border:none; margin:0; padding:0; font-size:1px; line-height:1px; } 70 div.system-message { background: #ffc; margin: 10px; padding: 6px 8px; font-size: .8em; } 71 div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; color:red;background:#ffc url(../img/admin/icon_error.gif) 5px .3em no-repeat; } 70 72 71 73 /* PAGE STRUCTURE */ django/trunk/django/conf/admin_templates/doc/index.html
r337 r391 22 22 <p>Each page on the public site is generated by a view. The view defines which template is used to generate the page and which objects are available to that template.</p> 23 23 24 <h3><a href="views/">Views</a></h3>25 <p>Each page on the public site is generated by a view. The view defines which template is used to generate the page and which objects are available to that template.</p>26 27 24 <h3><a href="bookmarklets/">Bookmarklets</a></h3> 28 25 <p>Tools for your browser to quickly access admin functionality.</p> django/trunk/django/conf/admin_templates/doc/view_index.html
r337 r391 11 11 <h1>View documentation</h1> 12 12 13 <div id="content-main"> 13 {% regroup views|dictsort:"site_id" by site as views_by_site %} 14 14 15 {% regroup views|dictsort:"site_id" by site as views_by_site %}16 {% for site_views in views_by_site %}17 <div class="module">18 <h2 id="site{{ site_views.grouper.id }}">Views by URL on {{ site_views.grouper.name }}</h2>19 20 {% for view in site_views.list|dictsort:"url" %}21 <h3><a href="{{ view.module }}.{{ view.name }}/"/>{{ view.url|escape }}</a></h3>22 <p class="small quiet">({{ view.module }}.{{ view.name }})</p>23 <p>{{ view.title }}</p>24 <hr>25 {% endfor %}26 27 </div>28 {% endfor %}29 30 </div>31 32 {% endblock %}33 34 {% block sidebar %}35 15 <div id="content-related" class="sidebar"> 36 16 <div class="module"> 37 17 <h2>Jump to site</h2> 38 18 <ul> 39 {% regroup views|dictsort:"site_id" by site as views_by_site %}40 19 {% for site_views in views_by_site %} 41 20 <li><a href="#site{{ site_views.grouper.id }}">{{ site_views.grouper.name }}</a></li> … … 44 23 </div> 45 24 </div> 25 26 <div id="content-main"> 27 28 {% for site_views in views_by_site %} 29 <div class="module"> 30 <h2 id="site{{ site_views.grouper.id }}">Views by URL on {{ site_views.grouper.name }}</h2> 31 32 {% for view in site_views.list|dictsort:"url" %} 33 {% ifchanged %} 34 <h3><a href="{{ view.module }}.{{ view.name }}/"/>{{ view.url|escape }}</a></h3> 35 <p class="small quiet">View function: {{ view.module }}.{{ view.name }}</p> 36 <p>{{ view.title }}</p> 37 <hr> 38 {% endifchanged %} 39 {% endfor %} 40 </div> 41 {% endfor %} 42 </div> 46 43 {% endblock %} 44 django/trunk/django/core/defaulttags.py
r390 r391 471 471 The ``{% if %}`` tag evaluates a variable, and if that variable is "true" 472 472 (i.e. exists, is not empty, and is not a false boolean value) the contents 473 of the block are output:: 473 of the block are output: 474 475 :: 474 476 475 477 {% if althlete_list %} … … 482 484 be displayed by the ``{{ athlete_list|count }}`` variable. 483 485 484 As you can see, the ``if`` tag can take an option ``{% else %} clause that486 As you can see, the ``if`` tag can take an option ``{% else %}`` clause that 485 487 will be displayed if the test fails. 486 488 … … 502 504 {% endif %} 503 505 504 For simplicity, ``if`` tags do not allow ``and`` clauses; use nested ``if`` s505 instead::506 For simplicity, ``if`` tags do not allow ``and`` clauses; use nested ``if`` 507 tags instead:: 506 508 507 509 {% if athlete_list %} django/trunk/django/parts/admin/doc.py
r3 r391 9 9 import docutils.nodes 10 10 import docutils.parsers.rst.roles 11 12 # 13 # reST roles 14 # 15 ROLES = { 16 # role name, base role url (in the admin) 17 'model' : '/doc/models/%s/', 18 'view' : '/doc/views/%s/', 19 'template' : '/doc/templates/%s/', 20 'filter' : '/doc/filters/#%s', 21 'tag' : '/doc/tags/#%s', 22 } 11 from urlparse import urljoin 23 12 24 13 def trim_docstring(docstring): … … 61 50 return title, body, metadata 62 51 63 def parse_rst(text, default_reference_context, thing_being_parsed=None ):52 def parse_rst(text, default_reference_context, thing_being_parsed=None, link_base='../..'): 64 53 """ 65 54 Convert the string from reST to an XHTML fragment. 66 55 """ 67 56 overrides = { 68 'input_encoding' : 'unicode',69 57 'doctitle_xform' : True, 70 58 'inital_header_level' : 3, 59 "default_reference_context" : default_reference_context, 60 "link_base" : link_base, 71 61 } 72 62 if thing_being_parsed: … … 74 64 parts = docutils.core.publish_parts(text, source_path=thing_being_parsed, 75 65 destination_path=None, writer_name='html', 76 settings_overrides= {'default_reference_context' : default_reference_context})66 settings_overrides=overrides) 77 67 return parts['fragment'] 68 69 # 70 # reST roles 71 # 72 ROLES = { 73 'model' : '%s/models/%s/', 74 'view' : '%s/views/%s/', 75 'template' : '%s/templates/%s/', 76 'filter' : '%s/filters/#%s', 77 'tag' : '%s/tags/#%s', 78 } 78 79 79 80 def create_reference_role(rolename, urlbase): 80 81 def _role(name, rawtext, text, lineno, inliner, options={}, content=[]): 81 node = docutils.nodes.reference(rawtext, text, refuri=(urlbase % text), **options)82 node = docutils.nodes.reference(rawtext, text, refuri=(urlbase % (inliner.document.settings.link_base, text)), **options) 82 83 return [node], [] 83 84 docutils.parsers.rst.roles.register_canonical_role(rolename, _role) … … 85 86 def default_reference_role(name, rawtext, text, lineno, inliner, options={}, content=[]): 86 87 context = inliner.document.settings.default_reference_context 87 node = docutils.nodes.reference(rawtext, text, refuri=(ROLES[context] % text), **options)88 node = docutils.nodes.reference(rawtext, text, refuri=(ROLES[context] % (inliner.document.settings.link_base, text)), **options) 88 89 return [node], [] 89 90 docutils.parsers.rst.roles.register_canonical_role('cmsreference', default_reference_role) django/trunk/django/templatetags/log.py
r3 r391 18 18 """ 19 19 Populates a template variable with the admin log for the given criteria. 20 Usage: 20 21 Usage:: 22 21 23 {% get_admin_log [limit] as [varname] for_user [context_var_containing_user_obj] %} 22 Examples: 24 25 Examples:: 26 23 27 {% get_admin_log 10 as admin_log for_user 23 %} 24 28 {% get_admin_log 10 as admin_log for_user user %} 25 29 {% get_admin_log 10 as admin_log %} 26 Note that [context_var_containing_user_obj] can be a hard-coded integer (user ID) or the 27 name of a template context variable containing the user object whose ID you want. 30 31 Note that ``context_var_containing_user_obj`` can be a hard-coded integer 32 (user ID) or the name of a template context variable containing the user 33 object whose ID you want. 28 34 """ 29 35 def __init__(self, tag_name): django/trunk/django/views/admin/doc.py
r316 r391 3 3 from django.conf import settings 4 4 from django.models.core import sites 5 from django.views.decorators.cache import cache_page6 5 from django.core.extensions import DjangoContext as Context 7 6 from django.core.exceptions import Http404, ViewDoesNotExist … … 33 32 34 33 def template_tag_index(request): 34 import sys 35 35 36 if not doc: 36 37 return missing_docutils_page(request) … … 70 71 }) 71 72 return HttpResponse(t.render(c)) 72 template_tag_index = cache_page(template_tag_index, 15*60)73 73 74 74 def template_filter_index(request): … … 107 107 }) 108 108 return HttpResponse(t.render(c)) 109 template_filter_index = cache_page(template_filter_index, 15*60)110 109 111 110 def view_index(request): … … 119 118 view_functions = extract_views_from_urlpatterns(urlconf.urlpatterns) 120 119 for (func, regex) in view_functions: 121 title, body, metadata = doc.parse_docstring(func.__doc__)122 if title:123 title = doc.parse_rst(title, 'view', 'view:' + func.__name__)124 120 views.append({ 125 121 'name' : func.__name__, 126 122 'module' : func.__module__, 127 'title' : title,128 123 'site_id': settings_mod.SITE_ID, 129 124 'site' : sites.get_object(pk=settings_mod.SITE_ID), … … 135 130 }) 136 131 return HttpResponse(t.render(c)) 137 view_index = cache_page(view_index, 15*60)138 132 139 133 def view_detail(request, view): … … 152 146 body = doc.parse_rst(body, 'view', 'view:' + view) 153 147 for key in metadata: 154 metadata[key] = doc.parse_rst(metadata[key], ' view', 'view:' + view)148 metadata[key] = doc.parse_rst(metadata[key], 'model', 'view:' + view) 155 149 t = template_loader.get_template('doc/view_detail') 156 150 c = Context(request, {
