diff options
author | Tom Willemsen | 2012-03-12 01:45:07 +0100 |
---|---|---|
committer | Tom Willemsen | 2012-03-12 01:45:07 +0100 |
commit | 2dab9254e1da14db38c0862c44bace2ad4993bda (patch) | |
tree | 4060d2945c838718a3279278bd0c58d48ee8a295 | |
parent | 68d0a20fffa78b813a64c4d7c2faf60f46646e03 (diff) | |
download | ryuslash.org-2dab9254e1da14db38c0862c44bace2ad4993bda.tar.gz ryuslash.org-2dab9254e1da14db38c0862c44bace2ad4993bda.zip |
Add seperate page per post
-rw-r--r-- | static/main.css | 29 | ||||
-rw-r--r-- | templates/aggregator/base.html | 24 | ||||
-rw-r--r-- | templates/aggregator/post_content.html | 28 | ||||
-rw-r--r-- | templates/aggregator/post_detail.html | 24 | ||||
-rw-r--r-- | templates/aggregator/posts.html | 105 | ||||
-rw-r--r-- | urls.py | 6 |
6 files changed, 140 insertions, 76 deletions
diff --git a/static/main.css b/static/main.css index c040cbf..8a7f2b5 100644 --- a/static/main.css +++ b/static/main.css @@ -18,6 +18,10 @@ body { font-family: "DejaVu Sans", sans-serif; } +.clear { + clear: both; +} + .post { background-color: #808080; padding: 5px; @@ -27,7 +31,18 @@ body { } .post h3 { - margin-bottom: 10px; + float: left; +} + +.post .postsubtitle { + margin-left: 50px; + text-align: right; + font-size: 75%; +} + +.post .postcontent { + margin-top: 17px; + clear: left; } #logo { @@ -70,7 +85,7 @@ body { } #content h2 { - margin-bottom: 3px; + margin-bottom: 5px; } #feeds { @@ -97,15 +112,13 @@ body { position: relative; } -#pager #previous { - position: absolute; - left: 5px; +#pager .nav-prev { + float: left; } -#pager #next { +#pager .nav-next { float: right; - position: absolute; - right: 5px; + text-align: right; } #pager #current { diff --git a/templates/aggregator/base.html b/templates/aggregator/base.html new file mode 100644 index 0000000..1f3ec37 --- /dev/null +++ b/templates/aggregator/base.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> + +<html> + <head> + <title>ryuslash</title> + <link href="/static/main.css" type="text/css" rel="stylesheet" /> + <link rel="shortcut icon" href="/static/favicon.png" /> + </head> + <body> + + <a href="/"><img src="/static/logo.png" id="logo"></a> + + <h1 id="sitetitle"> + <span id="blue">ryu</span><span id="orange">slash</span> + </h1> + <div id="sitesubtitle">Will this ever really be my website?</div> + + {% block menu %}{% endblock %} + + <div id="content"> + {% block content %}{% endblock %} + </div> + </body> +</html> diff --git a/templates/aggregator/post_content.html b/templates/aggregator/post_content.html new file mode 100644 index 0000000..36b419d --- /dev/null +++ b/templates/aggregator/post_content.html @@ -0,0 +1,28 @@ +<div class="post {{ post.feed.name|slugify }}"> + <h3> + <a href="/post/{{ post.pk }}/"><img src="{{ post.feed.get_favicon_url }}" /></a> + <a href="/post/{{ post.pk }}/"> + {% if post.feed.uses_title %} + {{ post.title }} + {% else %} + {{ post.updated }} + {% endif %} + </a> + </h3> + <div class="postsubtitle"> + Via + <a href="{{ post.feed.base_url }}">{{ post.feed.name }}</a> + (<a href="{{ post.feed.get_profile_url }}">profile</a>, + <a href="{{ post.remote_url }}">origin</a>) + </div> + + <div class="postcontent"> + {% autoescape off %} + {% if post.feed.br2nl %} + {{ post.body|linebreaks }} + {% else %} + {{ post.body }} + {% endif %} + {% endautoescape %} + </div> +</div> diff --git a/templates/aggregator/post_detail.html b/templates/aggregator/post_detail.html new file mode 100644 index 0000000..eb39f95 --- /dev/null +++ b/templates/aggregator/post_detail.html @@ -0,0 +1,24 @@ +{% extends "aggregator/base.html" %} + +{% block content %} +{% include "aggregator/post_content.html" with post=object %} + +<div id="pager"> + {% with next=object.get_next_by_updated previous=object.get_previous_by_updated %} + {% if previous %} + <div class="nav-prev"> + <a href="/post/{{ previous.pk }}/" id="previous"> + {{ previous.title }}</a> + </div> + {% endif %} + + {% if next %} + <div class="nav-next"> + <a href="/post/{{ next.pk }}/" id="next">{{ next.title }}</a> + </div> + {% endif %} + {% endwith %} + <div class="clear"></div> + +</div> +{% endblock %} diff --git a/templates/aggregator/posts.html b/templates/aggregator/posts.html index 5b8bc1c..2a5b8a1 100644 --- a/templates/aggregator/posts.html +++ b/templates/aggregator/posts.html @@ -1,70 +1,41 @@ -<!DOCTYPE html> - -<html> - <head> - <title>ryuslash</title> - <link href="/static/main.css" type="text/css" rel="stylesheet" /> - <link rel="shortcut icon" href="/static/favicon.png" /> - </head> - <body> - - <img src="/static/logo.png" id="logo"> - - <h1 id="sitetitle"><span id="blue">ryu</span><span id="orange">slash</span></h1> - <div id="sitesubtitle">Will this ever really be my website?</div> - - <div id="feeds"> - {% for feed in feeds %} - <a href="{{ feed.get_profile_url }}"> - <img src="{{ feed.get_favicon_url }}"> - {{ feed.name }} - </a> - {% endfor %} +{% extends "aggregator/base.html" %} + +{% block menu %} +<div id="feeds"> + {% for feed in feeds %} + <a href="{{ feed.get_profile_url }}"> + <img src="{{ feed.get_favicon_url }}"> + {{ feed.name }} + </a> + {% endfor %} +</div> +{% endblock %} + +{% block content %} +{% regroup list.object_list by updated.date as grouped_list %} +{% for group in grouped_list %} + <h2>{{ group.grouper }}</h2> + + {% for post in group.list %} + {% include "aggregator/post_content.html" %} + {% endfor %} +{% endfor %} + +<div id="pager"> + {% if list.has_previous %} + <div class="nav-prev"> + <a href="/{{ list.previous_page_number }}/" id="previous">previous</a> </div> + {% endif %} - <div id="content"> - {% regroup list.object_list by updated.date as grouped_list %} - {% for group in grouped_list %} - <h2>{{ group.grouper }}</h2> - - {% for post in group.list %} - <div class="post {{ post.feed.name|slugify }}"> - <h3> - <a href="{{ post.feed.get_profile_url }}"><img src="{{ post.feed.get_favicon_url }}" /></a> - <a href="{{ post.remote_url }}"> - {% if post.feed.uses_title %} - {{ post.title }} - {% else %} - {{ post.updated }} - {% endif %} - </a> - </h3> - - {% autoescape off %} - {% if post.feed.br2nl %} - {{ post.body|linebreaks }} - {% else %} - {{ post.body }} - {% endif %} - {% endautoescape %} - </div> - {% endfor %} - {% endfor %} - - <div id="pager"> - {% if list.has_previous %} - <a href="/{{ list.previous_page_number }}/" id="previous">previous</a> - {% endif %} - - {% if list.has_next %} - <a href="/{{ list.next_page_number }}/" id="next">next</a> - {% endif %} - - <div id="current"> - {{ list.number }} / {{ list.paginator.num_pages }} - </div> - - </div> + {% if list.has_next %} + <div class="nav-next"> + <a href="/{{ list.next_page_number }}/" id="next">next</a> </div> - </body> -</html> + {% endif %} + + <div id="current"> + {{ list.number }} / {{ list.paginator.num_pages }} + </div> +</div> +{% endblock %} @@ -1,11 +1,15 @@ from django.conf.urls.defaults import patterns, include, url from django.contrib.staticfiles.urls import staticfiles_urlpatterns - +from django.views.generic import DetailView from django.contrib import admin + +from aggregator.models import Post + admin.autodiscover() urlpatterns = patterns('', url(r'^((?P<page>\d+)/)?$', 'aggregator.views.posts'), + url(r'^post/((?P<pk>\d+)/)?$', DetailView.as_view(model=Post)), url(r'^admin/', include(admin.site.urls))) urlpatterns += staticfiles_urlpatterns() |