summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Zapke-Grùˆndemann <info@keimlink.de>2011-12-30 04:00:30 +0100
committerMarkus Zapke-Grùˆndemann <info@keimlink.de>2011-12-30 04:00:30 +0100
commit4fbeb44718ca0f378baeae6fdda29388ff70b29d (patch)
tree0b9008f684664753e7e7667b811e2246ff3e7312
parent1347410c5125775f8b84bff0d12086158c39bea0 (diff)
parent4d8b78ba8747804d0e090eae0674b22ba8f53198 (diff)
Merge branch 'master' of sublab.org:subweb
Conflicts: sublab_project/news/templates/news/news_list.html
-rw-r--r--sublab_project/news/feeds.py32
-rw-r--r--sublab_project/news/templates/news/news_detail.html6
-rw-r--r--sublab_project/news/templates/news/news_list.html6
-rw-r--r--sublab_project/news/urls.py3
-rw-r--r--sublab_project/templates/base.html5
5 files changed, 44 insertions, 8 deletions
diff --git a/sublab_project/news/feeds.py b/sublab_project/news/feeds.py
new file mode 100644
index 0000000..011cee5
--- /dev/null
+++ b/sublab_project/news/feeds.py
@@ -0,0 +1,32 @@
+from django.contrib.syndication.views import Feed
+from django.utils.feedgenerator import Atom1Feed
+from django.core.urlresolvers import reverse
+from django.utils.html import strip_tags
+
+from news.models import News
+
+class NewsFeed(Feed):
+ title = "sublab.org news"
+ description = "the latest news from your sublab"
+
+ def link(self):
+ return reverse(self)
+
+ def items(self):
+ return News.objects.order_by('-date_updated')[:10]
+
+ def item_author_name(self, item):
+ return item.author
+
+ def item_description(self, item):
+ return strip_tags(item.content_html)
+
+ def item_title(self, item):
+ return item.title
+
+ def item_pubdate(self, item):
+ return item.date_created
+
+class NewsFeedAtom(NewsFeed):
+ feed_type = Atom1Feed
+ subtitle = NewsFeed.description
diff --git a/sublab_project/news/templates/news/news_detail.html b/sublab_project/news/templates/news/news_detail.html
index 49d2b7a..27c7449 100644
--- a/sublab_project/news/templates/news/news_detail.html
+++ b/sublab_project/news/templates/news/news_detail.html
@@ -5,9 +5,7 @@
{% block content %}
<p class="news_date">{{ object.date_updated|date:"DATETIME_FORMAT" }}</p>
<h2 id="{{ object.slug }}">{{ object.title }}</h3>
- <p>
- {% if object.image %}<img src="{{ MEDIA_URL }}{{ object.image }}" width="{{ object.image_width }}" height="{{ object.image_height }}" align="right" />{% endif %}
- {{ object.content_html|safe }}
- </p>
+ {% if object.image %}<img src="{{ MEDIA_URL }}{{ object.image }}" width="{{ object.image_width }}" height="{{ object.image_height }}" align="right" />{% endif %}
+ {{ object.content_html|safe }}
<p class="header">{{ object.author }}</p>
{% endblock content %}
diff --git a/sublab_project/news/templates/news/news_list.html b/sublab_project/news/templates/news/news_list.html
index 52ded72..080feaf 100644
--- a/sublab_project/news/templates/news/news_list.html
+++ b/sublab_project/news/templates/news/news_list.html
@@ -6,10 +6,8 @@
<h3 id="{{ post.slug }}">
<a href="{{ post.get_absolute_url }}">{{ post.date_updated|date }} - {{ post.title }}</a>
</h3>
- <p>
- {% if post.image %}<img src="{{ MEDIA_URL }}{{ post.image }}" width="{{ post.image_width }}" height="{{ post.image_height }}" align="right" />{% endif %}
- {{ post.content_html|safe }}
- </p>
+ {% if post.image %}<img src="{{ MEDIA_URL }}{{ post.image }}" width="{{ post.image_width }}" height="{{ post.image_height }}" align="right" />{% endif %}
+ {{ post.content_html|safe }}
{% endfor %}
{% if is_paginated %}
<p>
diff --git a/sublab_project/news/urls.py b/sublab_project/news/urls.py
index fe682ad..7f2029c 100644
--- a/sublab_project/news/urls.py
+++ b/sublab_project/news/urls.py
@@ -2,9 +2,12 @@ from django.conf.urls.defaults import patterns, include, url
from django.views.generic import DetailView
from news.models import News
+from news.feeds import NewsFeed, NewsFeedAtom
from news.views import NewsListView
urlpatterns = patterns('',
url(r'^$', NewsListView.as_view(), name='news_list'),
url(r'^news/(?P<slug>[-\w]+)/$', DetailView.as_view(model=News), name='news_detail'),
+ url(r'^newsfeed/rss/$', NewsFeed(), name='news_feed'),
+ url(r'^newsfeed/atom/$', NewsFeedAtom(), name='news_feed_atom'),
)
diff --git a/sublab_project/templates/base.html b/sublab_project/templates/base.html
index 7499645..074dec9 100644
--- a/sublab_project/templates/base.html
+++ b/sublab_project/templates/base.html
@@ -17,6 +17,11 @@
<link rel="stylesheet" href="{{ STATIC_URL }}autogen/trieste.status.css" type="text/css">
<link rel="stylesheet" href="{{ STATIC_URL }}autogen/nautilus.status.css" type="text/css">
<link rel="shortcut icon" href="{{ STATIC_URL }}img/favicon.png">
+
+ {% block feeds %}
+ <link rel="alternate" type="application/atom+xml" title="sublab.org News (atom)" href="{% url news_feed_atom %}">
+ <link rel="alternate" type="application/rss+xml" title="sublab.org News (rss)" href="{% url news_feed %}">
+ {% endblock feeds %}
</head>
<body>