Changeset 72

Show
Ignore:
Timestamp:
04/06/08 16:30:54 (5 months ago)
Author:
simon
Message:

Implemented paging of entries.
Increased the amount of white space and the maximum page width.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bitstructures/trunk/css/bitstructures.css

    r44 r72  
    99#nameplate-container { 
    1010        margin: 0; 
    11         padding: 24px 0 16px 24px; 
     11        padding: 24px 0 16px 32px; 
    1212        background-color: #ffde00; 
    1313} 
     
    2626 
    2727#container { 
    28         max-width: 64em; 
     28        max-width: 67em; 
    2929} 
    3030 
     
    3535 
    3636#content { 
    37         padding: 0 24px 48px 24px; 
     37        padding: 0 32px 48px 32px; 
    3838} 
    3939 
     
    4343 
    4444#info-block { 
    45         padding: 0 24px 0 0; 
     45        padding: 0 32px 0 0; 
    4646} 
    4747 
    48 .info-entry { 
    49         padding: 24px 0 0 0; 
    50 
    51  
    52 .entry { 
     48.entry, .info-entry, .page-nav { 
    5349        padding: 24px 0 0 0; 
    5450} 
     
    6258} 
    6359 
    64 h2 a { 
     60.entry h2 a { 
    6561        text-decoration: none; 
    6662        font-weight: bold; 
     
    6864} 
    6965 
    70 h2 a:hover { 
     66.entry h2 a:hover { 
    7167        text-decoration: none; 
    7268        background-color: #82993d; 
    7369        color: white; 
     70} 
     71 
     72.page-nav { 
     73        font-size: 1.2em; 
     74        font-weight: bold; 
     75        margin: 0; 
     76        color: #777; 
    7477} 
    7578 
  • bitstructures/trunk/substructure/urls.py

    r25 r72  
    88    (r'^drafts/(?P<slug>[a-z0-9-]+)$', 'draft_page'), 
    99    (r'^drafts/(?P<slug>[a-z0-9-]+)/(?P<num>\d+)/(?P<filename>[a-zA-Z0-9-_\.]+)$', 'draft_codeblock'), 
    10     (r'^fb-atom.xml$', 'atom_feed') 
     10    (r'^fb-atom.xml$', 'atom_feed'), 
     11    (r'^all$', 'all') 
    1112) 
    1213 
  • bitstructures/trunk/substructure/views.py

    r42 r72  
    77from bitstructures.substructure.codeblocks import MarkdownCodeblocksParser 
    88 
     9DEFAULT_SUBSTRUCTURE_NUM_ENTRIES_PER_PAGE = 5 
     10 
    911def blog(request): 
     12    page = 1 
     13    if ('page' in request.GET) and (int(request.GET['page']) > 0): 
     14        page = int(request.GET['page']) 
     15    if settings.SUBSTRUCTURE_NUM_ENTRIES_PER_PAGE: 
     16        num_entries_per_page = settings.SUBSTRUCTURE_NUM_ENTRIES_PER_PAGE 
     17    else: 
     18        num_entries_per_page = DEFAULT_SUBSTRUCTURE_NUM_ENTRIES_PER_PAGE 
     19    skip = (page - 1) * num_entries_per_page 
     20    skip_to = skip + num_entries_per_page 
    1021    data = get_context_data(request) 
    11     data['entry_list'] = Entry.objects.filter(date_published__isnull=False).order_by('-date_published') 
     22    data['entry_list'] = get_published_entries().order_by('-date_published')[skip:skip_to] 
     23    data['next_page'] = skip_to < data['num_published_entries'] 
     24    data['next_page_num'] = page + 1 
     25    data['previous_page'] = page > 1 
     26    data['previous_page_first_page'] = page == 2 
     27    data['previous_page_num'] = page - 1 
    1228    return render_to_response('substructure/blog.html', data) 
    1329 
     
    7288    return HttpResponse(t.render(c), mimetype='application/atom+xml') 
    7389 
     90def all(request): 
     91    data = get_context_data(request) 
     92    data['entry_list'] = get_published_entries().order_by('-date_published') 
     93    return render_to_response('substructure/all.html', data) 
     94 
     95def get_published_entries(): 
     96    return Entry.objects.filter(date_published__isnull=False) 
     97 
    7498def redirect_to_feedburner(request): 
    7599    return HttpResponseRedirect(settings.SUBSTRUCTURE_FEEDBURNER_REDIRECT_URL) 
     
    77101def get_context_data(request): 
    78102    data = { 'MEDIA_URL': settings.MEDIA_URL } 
     103    data['num_published_entries'] = get_published_entries().count() 
    79104    if user_can_change_entry(request): 
    80105        data['user_can_change_entry'] = True 
  • bitstructures/trunk/templates/substructure/base.html

    r41 r72  
    3838 
    3939<div class="info-entry"> 
     40<h2>Starting points</h2> 
     41<ul> 
     42<li><a href="/all">All entries</a> ({{ num_published_entries }})</li> 
     43</ul> 
     44</div> 
     45 
     46<div class="info-entry"> 
    4047<h2>Colophon</h2> 
    4148<p>This site is running a 
  • bitstructures/trunk/templates/substructure/blog.html

    r2 r72  
    77{% endfor %} 
    88 
     9<div class="page-nav">{% if previous_page %}<a href="/{% if not previous_page_first_page %}?page={{ previous_page_num }}{% endif %}">&laquo; newer</a>{% else %}&laquo; newer{% endif %} 
     10| {% if next_page %}<a href="/?page={{ next_page_num }}">older &raquo;</a>{% else %}older &raquo;{% endif %}</div> 
     11 
    912{% endblock %}