Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

created django cms rss plugin

  • Loading branch information...
commit 2c544ce6b453870b258305715451884eb9636cbc 0 parents
@zgwmike authored
22 .gitattributes
@@ -0,0 +1,22 @@
+# Auto detect text files and perform LF normalization
+* text=auto
+
+# Custom for Visual Studio
+*.cs diff=csharp
+*.sln merge=union
+*.csproj merge=union
+*.vbproj merge=union
+*.fsproj merge=union
+*.dbproj merge=union
+
+# Standard to msysgit
+*.doc diff=astextplain
+*.DOC diff=astextplain
+*.docx diff=astextplain
+*.DOCX diff=astextplain
+*.dot diff=astextplain
+*.DOT diff=astextplain
+*.pdf diff=astextplain
+*.PDF diff=astextplain
+*.rtf diff=astextplain
+*.RTF diff=astextplain
163 .gitignore
@@ -0,0 +1,163 @@
+#################
+## Eclipse
+#################
+
+*.pydevproject
+.project
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.classpath
+.settings/
+.loadpath
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+
+#################
+## Visual Studio
+#################
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Rr]elease/
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.vspscc
+.builds
+*.dotCover
+
+## TODO: If you have NuGet Package Restore enabled, uncomment this
+#packages/
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+
+# Visual Studio profiler
+*.psess
+*.vsp
+
+# ReSharper is a .NET coding add-in
+_ReSharper*
+
+# Installshield output folder
+[Ee]xpress
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish
+
+# Others
+[Bb]in
+[Oo]bj
+sql
+TestResults
+*.Cache
+ClientBin
+stylecop.*
+~$*
+*.dbmdl
+Generated_Code #added for RIA/Silverlight projects
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+
+
+
+############
+## Windows
+############
+
+# Windows image file caches
+Thumbs.db
+
+# Folder config file
+Desktop.ini
+
+
+#############
+## Python
+#############
+
+*.py[co]
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+eggs
+parts
+bin
+var
+sdist
+develop-eggs
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+
+#Translations
+*.mo
+
+#Mr Developer
+.mr.developer.cfg
+
+# Mac crap
+.DS_Store
29 README.rst
@@ -0,0 +1,29 @@
+=====================
+Django CMS RSS Plugin
+=====================
+
+Simple plugin to show a a rss feed in your django cms site.
+
+Features
+========
+* Show specified number of feeds in the page.
+* You can choose to open the feed in current window or new window.
+* Show any rss feed you specified.
+* The feed list would be cached for specified time long.
+
+Usage
+=====
+
+Add rssplugin to your INSTALLED_APPS in Django settings.py file.
+like following:
+INSTALLED_APPS = (
+ ...
+ 'rssplugin',
+ ...
+ )
+Then you are good to go!
+
+Online Resources
+* Code repository _.
+
+.. _ Code repository : https://github.com/zgwmike/django-rss-plugin
0  rssplugin/__init__.py
No changes.
25 rssplugin/cms_plugins.py
@@ -0,0 +1,25 @@
+__author__ = 'Zhou Guangwen'
+
+from rssplugin.models import RSSPlugin
+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+from django.core.cache import cache
+from django.utils.translation import ugettext as _
+import feedparser
+
+class PlanetPlugin(CMSPluginBase):
+ model = RSSPlugin
+ name = _("RSS Plugin")
+ render_template = "rss/rss.html"
+ admin_preview = False
+
+ def render(self, context, instance, placeholder):
+ feed = cache.get(instance.rss_url)
+ if not feed:
+ feed = feedparser.parse(instance.rss_url)
+ cache.set(instance.rss_url,feed,instance.cache_time)
+ context.update({"instance": instance,
+ "feed": feed})
+ return context
+
+plugin_pool.register_plugin(PlanetPlugin)
61 rssplugin/migrations/0001_initial.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding model 'RSSPlugin'
+ db.create_table('cmsplugin_rssplugin', (
+ ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
+ ('count', self.gf('django.db.models.fields.IntegerField')(default=6)),
+ ('title', self.gf('django.db.models.fields.CharField')(default='Community News', max_length=200, null=True)),
+ ('rss_url', self.gf('django.db.models.fields.URLField')(max_length=200)),
+ ('open_in_new_window', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('cache_time', self.gf('django.db.models.fields.IntegerField')()),
+ ))
+ db.send_create_signal('rssplugin', ['RSSPlugin'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'RSSPlugin'
+ db.delete_table('cmsplugin_rssplugin')
+
+
+ models = {
+ 'cms.cmsplugin': {
+ 'Meta': {'object_name': 'CMSPlugin'},
+ 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 2, 8, 0, 0)'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
+ 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
+ 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
+ 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+ 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+ },
+ 'cms.placeholder': {
+ 'Meta': {'object_name': 'Placeholder'},
+ 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ },
+ 'rssplugin.rssplugin': {
+ 'Meta': {'object_name': 'RSSPlugin', 'db_table': "'cmsplugin_rssplugin'", '_ormbases': ['cms.CMSPlugin']},
+ 'cache_time': ('django.db.models.fields.IntegerField', [], {}),
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'count': ('django.db.models.fields.IntegerField', [], {'default': '6'}),
+ 'open_in_new_window': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'rss_url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
+ 'title': ('django.db.models.fields.CharField', [], {'default': "'Community News'", 'max_length': '200', 'null': 'True'})
+ }
+ }
+
+ complete_apps = ['rssplugin']
0  rssplugin/migrations/__init__.py
No changes.
12 rssplugin/models.py
@@ -0,0 +1,12 @@
+from django.db import models
+from cms.models import CMSPlugin
+from django.utils.translation import ugettext_lazy as _
+# Create your models here.
+class RSSPlugin(CMSPlugin):
+ count = models.IntegerField(default=6)
+ title = models.CharField(max_length=200,default="Community News",null=True,help_text=_("If you specified this value, it will replace feed's title"))
+ rss_url = models.URLField()
+ open_in_new_window = models.BooleanField()
+ cache_time = models.IntegerField(verbose_name=_("Cache time in seconds"))
+ def __unicode__(self):
+ return self.title
21 rssplugin/templates/rss/rss.html
@@ -0,0 +1,21 @@
+{% load cms_tags i18n %}
+<h3>
+ {% if instance.title %}
+ {{ instance.title }}
+ {% else %}
+ {{ feed.feed.title }}
+ {% endif %}
+</h3>
+<ul>
+ {% for e in feed.entries %}
+ {% if forloop.counter <= instance.count %}
+ <li>
+ <a {% if instance.open_in_new_window %} target="_blank" {% endif %} href="{{ e.link }}">{{ e.title }}</a>
+ {% trans %}by{% endtrans %}
+ <a href="{{ e.author_detail.link }}">{{ e.author }}</a>
+ at
+ {{ e.published_parsed|date }}
+ </li>
+ {% endif %}
+ {% endfor %}
+</ul>
16 rssplugin/tests.py
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.assertEqual(1 + 1, 2)
1  rssplugin/views.py
@@ -0,0 +1 @@
+# Create your views here.
0  setup.cfg
No changes.
25 setup.py
@@ -0,0 +1,25 @@
+__author__ = 'Zhou Guangwen'
+import os
+from setuptools import setup
+
+def read(fname):
+ return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+setup(
+ name="django-rss-plugin",
+ version="0.0.1",
+ author="Guangwen Zhou",
+ author_email="zgwmike@hotmail.com",
+ description=("A Django CMS plugin to show django-rss-plugin."),
+ license="BSD",
+ keywords="django cms plugin django-rss-plugin",
+ url="http://github.com/zgwmike/django-rss-plugin",
+ packages=["rssplugin"],
+ classifiers=[
+ 'Development Status :: 3 - Alpha',
+ "Framework :: Django",
+ "Environment :: Web Environment",
+ "License :: OSI Approved :: BSD License"
+ ],
+ long_description=read("README.rst")
+)
Please sign in to comment.
Something went wrong with that request. Please try again.