Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

basic functionality, release tag 0.0.1

  • Loading branch information...
commit 4a9fdb9fa78fcf76d2031583ea5b349582c010cb 0 parents
@stefanfoulis stefanfoulis authored
3  MANIFEST.in
@@ -0,0 +1,3 @@
+include metadata.py
+include README.rst
+recursive-include cmsplugin_banner/templates *
14 README.rst
@@ -0,0 +1,14 @@
+cmsplugin-banner
+===
+
+the default settings are:
+
+the (css) class choices
+CMSPLUGIN_BANNER_STYLE_CHOICES = ( ('default','default'), )
+
+add `"cmsplugin_banner.context_processors.plugin_ad_slots"` to `TEMPLATE_CONTEXT_PROCESSORS`
+
+Setup for Google Ads:
+* load googles javascript somewhere: `<script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js"></script>`
+* initialize the slots somewhere in `<head>` by including `cmsplugin_banner/header_include.html`. This assumes you also add
+`<script type="text/javascript">GA_googleFetchAds();</script>` to head and have a context variable called `AD_ACCOUNT_IDENTIFIER` with the google ad account id.
17 cmsplugin_banner.egg-info/PKG-INFO
@@ -0,0 +1,17 @@
+Metadata-Version: 1.0
+Name: cmsplugin-banner
+Version: 0.0.1
+Summary: A simple django-cms plugin that provides a banner.
+Home-page: http://github.com/divio/cmsplugin-banner
+Author: Divio GmbH
+Author-email: developers@divio.ch
+License: BSD
+Description: UNKNOWN
+Platform: OS Independent
+Classifier: Development Status :: 4 - Beta
+Classifier: Framework :: Django
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Topic :: Internet :: WWW/HTTP
25 cmsplugin_banner.egg-info/SOURCES.txt
@@ -0,0 +1,25 @@
+MANIFEST.in
+README.rst
+metadata.py
+setup.py
+cmsplugin_banner/__init__.py
+cmsplugin_banner/cms_plugins.py
+cmsplugin_banner/conf.py
+cmsplugin_banner/models.py
+cmsplugin_banner.egg-info/PKG-INFO
+cmsplugin_banner.egg-info/SOURCES.txt
+cmsplugin_banner.egg-info/dependency_links.txt
+cmsplugin_banner.egg-info/not-zip-safe
+cmsplugin_banner.egg-info/requires.txt
+cmsplugin_banner.egg-info/top_level.txt
+cmsplugin_banner/migrations/0001_initial.py
+cmsplugin_banner/migrations/0002_auto__chg_field_iframe_title.py
+cmsplugin_banner/migrations/__init__.py
+cmsplugin_banner/templates/.DS_Store
+cmsplugin_banner/templates/cmsplugin_banner/.tmp_banner.html.19470~
+cmsplugin_banner/templates/cmsplugin_banner/.tmp_header_include.html.53653~
+cmsplugin_banner/templates/cmsplugin_banner/.tmp_iframe.html.47034~
+cmsplugin_banner/templates/cmsplugin_banner/.tmp_iframe.html.61451~
+cmsplugin_banner/templates/cmsplugin_banner/.tmp_iframe.html.77505~
+cmsplugin_banner/templates/cmsplugin_banner/banner.html
+cmsplugin_banner/templates/cmsplugin_banner/header_include.html
1  cmsplugin_banner.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
1  cmsplugin_banner.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
1  cmsplugin_banner.egg-info/requires.txt
@@ -0,0 +1 @@
+setuptools
1  cmsplugin_banner.egg-info/top_level.txt
@@ -0,0 +1 @@
+cmsplugin_banner
1  cmsplugin_banner/__init__.py
@@ -0,0 +1 @@
+__version__ = '0.0.1'
13 cmsplugin_banner/admin.py
@@ -0,0 +1,13 @@
+from django.contrib import admin
+from cmsplugin_banner.models import Slot
+
+class SlotAdmin(admin.ModelAdmin):
+ search_fields = ('name', )
+ list_display = ('id', 'name','banners_count')
+ list_editable = ('name',)
+
+ def banners_count(self, obj):
+ return len( obj.banners.all() )
+
+
+admin.site.register(Slot, SlotAdmin)
17 cmsplugin_banner/cms_plugins.py
@@ -0,0 +1,17 @@
+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+from models import Banner
+from django.utils.translation import ugettext as _
+
+class BannerPlugin(CMSPluginBase):
+ model = Banner
+ name = _("banner")
+ render_template = "cmsplugin_banner/banner.html"
+
+ def render(self, context, instance, placeholder):
+ context.update({'instance':instance,
+ 'banner':instance,
+ 'placeholder':placeholder})
+ return context
+
+plugin_pool.register_plugin(BannerPlugin)
3  cmsplugin_banner/conf.py
@@ -0,0 +1,3 @@
+from django.conf import settings
+SLOT_CHOICES = getattr(settings, 'CMSPLUGIN_BANNER_SLOT_CHOICES', ( ('Content-Default','Content-Default'), ))
+STYLE_CHOICES = getattr(settings, 'CMSPLUGIN_BANNER_STYLE_CHOICES', ( ('default','default'), ))
6 cmsplugin_banner/context_processors.py
@@ -0,0 +1,6 @@
+from cmsplugin_banner import conf
+from cmsplugin_banner import models
+def plugin_ad_slots(request):
+ slots = list(models.Slot.objects.filter(banners__gt=0))
+ print slots
+ return {'CMSPLUGIN_BANNER_SLOTS': slots,}
75 cmsplugin_banner/migrations/0001_initial.py
@@ -0,0 +1,75 @@
+# encoding: 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 'Slot'
+ db.create_table('cmsplugin_banner_slot', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('name', self.gf('django.db.models.fields.CharField')(max_length=255)),
+ ))
+ db.send_create_signal('cmsplugin_banner', ['Slot'])
+
+ # Adding model 'Banner'
+ db.create_table('cmsplugin_banner', (
+ ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
+ ('slot', self.gf('django.db.models.fields.related.ForeignKey')(related_name='banners', to=orm['cmsplugin_banner.Slot'])),
+ ('style', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
+ ))
+ db.send_create_signal('cmsplugin_banner', ['Banner'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'Slot'
+ db.delete_table('cmsplugin_banner_slot')
+
+ # Deleting model 'Banner'
+ db.delete_table('cmsplugin_banner')
+
+
+ models = {
+ 'cms.cmsplugin': {
+ 'Meta': {'object_name': 'CMSPlugin'},
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'max_length': '5', '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'}),
+ 'publisher_is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True', 'blank': 'True'}),
+ 'publisher_public': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'publisher_draft'", 'unique': 'True', 'null': 'True', 'to': "orm['cms.CMSPlugin']"}),
+ 'publisher_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '0', 'db_index': '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'})
+ },
+ 'cmsplugin_banner.banner': {
+ 'Meta': {'object_name': 'Banner', 'db_table': "'cmsplugin_banner'", '_ormbases': ['cms.CMSPlugin']},
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'banners'", 'to': "orm['cmsplugin_banner.Slot']"}),
+ 'style': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'})
+ },
+ 'cmsplugin_banner.slot': {
+ 'Meta': {'object_name': 'Slot'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'})
+ }
+ }
+
+ complete_apps = ['cmsplugin_banner']
0  cmsplugin_banner/migrations/__init__.py
No changes.
19 cmsplugin_banner/models.py
@@ -0,0 +1,19 @@
+from django.db import models
+from cms.models import CMSPlugin
+from django.utils.translation import ugettext_lazy as _
+
+from cmsplugin_banner import conf
+
+class Slot(models.Model):
+ name = models.CharField(_("name"), max_length=255)
+
+ def __unicode__(self):
+ return u"%s" % self.name
+
+class Banner(CMSPlugin):
+ title = models.CharField(max_length=255, null=True, blank=True)
+ slot = models.ForeignKey(Slot, related_name="banners")
+ style = models.CharField(_("banner style"), max_length=255, null=True, blank=True, choices=conf.STYLE_CHOICES)
+
+ def __unicode__(self):
+ return u"%s" % (self.title or self.id, )
4 cmsplugin_banner/templates/cmsplugin_banner/banner.html
@@ -0,0 +1,4 @@
+{% if banner.title %}<h3>{{ banner.title }}</h3>{% endif %}
+<div class="banner{% if banner.style %} {{ banner.style }}{% endif %}">
+<script type="text/javascript">GA_googleFillSlot("{{ banner.slot.name }}");</script>
+</div>
3  cmsplugin_banner/templates/cmsplugin_banner/header_include.html
@@ -0,0 +1,3 @@
+<script type="text/javascript">{% for slot in CMSPLUGIN_BANNER_SLOTS %}
+ GA_googleAddSlot("{{ AD_ACCOUNT_IDENTIFIER }}", "{{ slot }}");{% endfor %}
+</script>
8 metadata.py
@@ -0,0 +1,8 @@
+package_name = 'cmsplugin_banner'
+name = 'cmsplugin-banner'
+author = 'Divio GmbH'
+author_email = 'developers@divio.ch'
+description = "A simple django-cms plugin that provides a banner."
+version = __import__(package_name).__version__
+project_url = 'http://github.com/divio/%s' % name
+license = 'BSD'
59 setup.py
@@ -0,0 +1,59 @@
+'''
+setup.py version 0.0.1
+current version: https://gist.github.com/8668de36c00ca78df172
+This is a standard re-usable setup.py file for django apps.
+This file should stay untouched. Instead create a file called metadata.py.
+
+metadata.py example:
+
+package_name = 'gsa'
+name = 'django-gsa'
+author = 'Divio GmbH'
+author_email = 'developers@divio.ch'
+description = "A thin wrapper for using a Google Search Appliance (GSA) for searches in django.s."
+version = '0.1.0'
+project_url = 'http://github.com/divio/%s' % name
+license = 'BSD'
+
+If you have data files you want to include, please create a MANIFEST.in file.
+setup.py is called with include_package_data=True, so packade data will be
+automatically read and included based on MANIFEST.in (or from svn if you
+happen to use it)
+'''
+
+# do not change anything in here
+# edit metadata.py and MANIFEST.in instead
+import metadata as m
+
+from setuptools import setup, find_packages
+
+install_requires = [
+ 'setuptools',
+]
+
+setup(
+ name = m.name,
+ version = m.version,
+ url = m.project_url,
+ license = m.license,
+ platforms=['OS Independent'],
+ description = m.description,
+ author = m.author,
+ author_email = m.author_email,
+ packages=find_packages(),
+ install_requires = install_requires,
+ include_package_data = True, #Accept all data files and directories matched by MANIFEST.in or found in source control.
+ package_dir = {
+ m.package_name:m.package_name,
+ },
+ zip_safe=False,
+ classifiers = [
+ 'Development Status :: 4 - Beta',
+ 'Framework :: Django',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: BSD License',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Topic :: Internet :: WWW/HTTP',
+ ]
+)
Please sign in to comment.
Something went wrong with that request. Please try again.