Mercurial > public > sg101
changeset 32:07da6967fc40
Created a current_news template tag for the home page.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 05 May 2009 00:56:18 +0000 |
parents | 5eed5e7c1c98 |
children | c018872385ea |
files | gpp/news/templatetags/__init__.py gpp/news/templatetags/news_tags.py gpp/templates/downloads/latest_tag.html gpp/templates/home.html gpp/templates/news/current_news.html gpp/templates/news/story_summary.html gpp/templates/weblinks/latest_tag.html |
diffstat | 6 files changed, 40 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/news/templatetags/news_tags.py Tue May 05 00:56:18 2009 +0000 @@ -0,0 +1,19 @@ +""" +Template tags for the news application. +""" +from django import template + +from news.models import Story + + +register = template.Library() + + +@register.inclusion_tag('news/current_news.html', takes_context=True) +def current_news(context): + stories = Story.objects.all()[:10] + return { + 'stories': stories, + 'MEDIA_URL': context['MEDIA_URL'], + 'on_home': True, + }
--- a/gpp/templates/downloads/latest_tag.html Sun May 03 20:27:57 2009 +0000 +++ b/gpp/templates/downloads/latest_tag.html Tue May 05 00:56:18 2009 +0000 @@ -1,4 +1,4 @@ -<h3>New Downloads</h3> +<h2>New Downloads</h2> {% if downloads %} <ol> {% for dl in downloads %}
--- a/gpp/templates/home.html Sun May 03 20:27:57 2009 +0000 +++ b/gpp/templates/home.html Tue May 05 00:56:18 2009 +0000 @@ -1,8 +1,12 @@ {% extends 'base.html' %} {% load bulletin_tags %} +{% load news_tags %} {% load weblinks_tags %} {% load downloads_tags %} {% block title %}Home{% endblock %} +{% block custom_css %} +<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/news.css" /> +{% endblock %} {% block content %} <h2>Welcome to SurfGuitar101!</h2> <p>You are looking at a test version of the new SurfGuitar101 website, dubbed <strong>SG101 2.0</strong>. @@ -18,6 +22,7 @@ Also, I hope that the look and feel of this site can be greatly improved to something really cool! I'll need lots of help for this aspect, as I'm more of a coder than a designer.</p> {% current_bulletins %} +{% current_news %} <div class="span-9 append-1"> {% latest_weblinks %} </div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/news/current_news.html Tue May 05 00:56:18 2009 +0000 @@ -0,0 +1,10 @@ +{% load tagging_tags %} +{% if stories %} +<h2>Current News Stories</h2> +{% for story in stories %} + {% tags_for_object story as story_tags %} + {% include 'news/story_summary.html' %} +{% endfor %} +<hr /> +<p>For more news stories, check out our <a href="{% url news-index_page page=1 %}">news archive</a>.</p> +{% endif %}
--- a/gpp/templates/news/story_summary.html Sun May 03 20:27:57 2009 +0000 +++ b/gpp/templates/news/story_summary.html Tue May 05 00:56:18 2009 +0000 @@ -1,7 +1,11 @@ {% load comment_tags %} {% get_comment_count for story as comment_count %} <div class="news-story-container"> +{% if on_home %} +<h3><a href="{{ story.get_absolute_url }}">{{ story.title }}</a></h3> +{% else %} <h4><a href="{{ story.get_absolute_url }}">{{ story.title }}</a></h4> +{% endif %} <div class="news-details"> Submitted by {{ story.submitter.username }} on {{ story.date_published|date:"F d, Y" }}. </div>