Changeset 25 for bitstructures
- Timestamp:
- 12/09/07 15:54:23 (13 months ago)
- Location:
- bitstructures/trunk
- Files:
-
- 3 added
- 4 modified
-
README (modified) (1 diff)
-
images/LICENSE (added)
-
substructure/codeblocks.py (added)
-
substructure/tests.py (added)
-
substructure/urls.py (modified) (1 diff)
-
substructure/views.py (modified) (3 diffs)
-
templates/substructure/base.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
bitstructures/trunk/README
r2 r25 1 Bitstructures.com 2 3 This is the code running bitstructures.com. It's not really set up (yet) 4 for easy deployment in other situations but please feel free to reuse 5 parts if useful. 6 7 Unless explicitly stated, the source code is licensed under the MIT license. 8 Please see the LICENSE file. 9 1 10 Dependencies 2 11 -
bitstructures/trunk/substructure/urls.py
r24 r25 5 5 (r'^$', 'blog'), 6 6 (r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[a-z0-9-]+)$', 'entry_page'), 7 (r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[a-z0-9-]+)/(?P<num>\d+)/(?P<filename>[a-zA-Z0-9-_\.]+)$', 'entry_codeblock'), 7 8 (r'^drafts/(?P<slug>[a-z0-9-]+)$', 'draft_page'), 9 (r'^drafts/(?P<slug>[a-z0-9-]+)/(?P<num>\d+)/(?P<filename>[a-zA-Z0-9-_\.]+)$', 'draft_codeblock'), 8 10 (r'^fb-atom.xml$', 'atom_feed') 9 11 ) -
bitstructures/trunk/substructure/views.py
r24 r25 5 5 from django.conf import settings 6 6 from bitstructures.substructure.models import Entry 7 from bitstructures.substructure.codeblocks import MarkdownCodeblocksParser 7 8 8 9 def blog(request): … … 13 14 def entry_page(request, year, month, slug): 14 15 entry = get_object_or_404(Entry, slug=slug) 16 check_view_entry(entry, year, month) 17 data = get_context_data(request) 18 data['entry'] = entry 19 return render_to_response('substructure/entry_page.html', data) 20 21 def entry_codeblock(request, year, month, slug, num, filename): 22 entry = get_object_or_404(Entry, slug=slug) 23 check_view_entry(entry, year, month) 24 return get_codeblock_response(entry, num, filename) 25 26 def check_view_entry(entry, year, month): 15 27 if not entry.is_published(): 16 28 raise Http404 … … 19 31 if int(month) != entry.date_published.month: 20 32 raise Http404 33 34 def draft_page(request, slug): 35 entry = get_object_or_404(Entry, slug=slug) 36 check_view_draft(request, entry) 21 37 data = get_context_data(request) 22 38 data['entry'] = entry 23 39 return render_to_response('substructure/entry_page.html', data) 24 40 25 def draft_page(request, slug): 26 if not user_can_change_entry(request): 27 raise Http404 41 def draft_codeblock(request, slug, num, filename): 28 42 entry = get_object_or_404(Entry, slug=slug) 43 check_view_draft(request, entry) 44 return get_codeblock_response(entry, num, filename) 45 46 def check_view_draft(request, entry): 29 47 if not entry.is_draft(): 30 48 raise Http404 31 data = get_context_data(request) 32 data['entry'] = entry 33 return render_to_response('substructure/entry_page.html', data) 49 50 def get_codeblock_response(entry, num, filename): 51 parser = MarkdownCodeblocksParser() 52 codeblock = parser.get_codeblock(entry.text, int(num)) 53 if codeblock: 54 if filename.lower().endswith('html'): 55 return HttpResponse(codeblock, mimetype='text/html') 56 else: 57 return HttpResponse(codeblock, mimetype='text/plain') 58 else: 59 raise Http404 34 60 35 61 def atom_feed(request): -
bitstructures/trunk/templates/substructure/base.html
r24 r25 35 35 the <a href="http://dojotoolkit.org/">Dojo</a> JavaScript toolkit.</p> 36 36 <p><a href="http://del.icio.us/simonbates">del.icio.us/simonbates</a></p> 37 </div> 38 39 <div class="info-entry"> 40 <h2>Colophon</h2> 41 <p>This site is running a 42 <a href="http://trac.bitstructures.com/browser/bitstructures/trunk">custom 43 Python application</a> (MIT license) built with 44 <a href="http://www.djangoproject.com/">Django</a>.</p> 37 45 <p><a href="/atom.xml"><img src="{{ MEDIA_URL }}images/feed-icon-14x14.png" alt="Site feed"> Site feed</a></p> 38 46 </div>
