Commits

tehfink committed 465492e Merge

merged fajran's rss code

  • Participants
  • Parent commits 2914ca5, e1ef6b6
  • Branches cms-2.0.2

Comments (0)

Files changed (6)

 syntax: glob
 *.pyc
 cmsplugin_news.egg-info
-dist
+dist
+build
+2914ca57ad45954c4145bcaa8423d7309532f1bf cms-2.0.2
 - Add the cmsplugin_news.navigation.get_nodes to the CMS_NAVIGATION_EXTENDERS setting
 - Create a page in cms and in the 'advanced settings' section of the admin for that page, for 'Navigation extenders' select 'news navigation' and for 'application' select 'news' (Restart of the server required due to caching!)
 - Create the propper templates for your site, the ones included with the app are VERY basic
+- set CMSPLUGIN_NEWS_RSS_TITLE and CMSPLUGIN_NEWS_RSS_DESCRIPTION values to settings.py
 
 Todo and Tomaybes:
 - Add more tests
 CMS_NAVIGATION_EXTENDERS = (
     ('cmsplugin_news.navigation.get_nodes','News navigation'),
 )
+CMSPLUGIN_NEWS_RSS_TITLE = "Latest News"
+CMSPLUGIN_NEWS_RSS_DESCRIPTION = "Latest news entries"
 
 
 Suggestion:

File cmsplugin_news/feeds.py

+from django.contrib.syndication.feeds import Feed
+from django.core.urlresolvers import reverse
+from django.conf import settings
+
+from cmsplugin_news.models import News
+
+class NewsEntryFeed(Feed):
+    title = settings.CMSPLUGIN_NEWS_RSS_TITLE
+    description = settings.CMSPLUGIN_NEWS_RSS_DESCRIPTION
+
+    def items(self):
+        return News.published.all()[:10]
+    
+    def item_pubdate(self, item):
+        return item.pub_date
+
+    def __getattr__(self, name):
+        # The reverse() call should be made after all URLs
+        # are mapped. So we cannot use it when declaring the
+        # 'link' property.
+
+        if name == 'link':
+            return reverse('news_archive_index')
+
+        return Feed.__getattr__(self, name)
+

File cmsplugin_news/urls.py

 from django.conf.urls.defaults import *
 
 from cmsplugin_news.models import News
+from cmsplugin_news.feeds import NewsEntryFeed
 
 news_info_dict = {
     'queryset': News.published.all(),
     'month_format': '%m',
 }
 
+feeds = {
+    'news': NewsEntryFeed,
+}
+
+rss_dict = {
+    'feed_dict': feeds,
+    'url': 'news',
+}
+
 urlpatterns = patterns('django.views.generic.date_based',
     (r'^$', 
         'archive_index', news_info_dict, 'news_archive_index'),
-    
+
     (r'^(?P<year>\d{4})/$', 
         'archive_year', news_info_dict, 'news_archive_year'),
     
         'object_detail', news_info_month_dict, 'news_detail'),
 )
 
+urlpatterns += patterns('',
+    (r'^rss/$',
+        'django.contrib.syndication.views.feed', rss_dict, 'news_rss'),
+)
+
 
 setup(
     name='cmsplugin-news',
-    version='0.3b',
+    version='0.3c-fajran-1',
     description='This is a news app/plugin for the django-cms 2',
     author='Harro van der Klauw',
     author_email='hvdklauw@gmail.com',
     ],
     include_package_data=True,
     zip_safe=False,
-    install_requires=['setuptools', 'setuptools_bzr'],
+    install_requires=['setuptools'],
 )