Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit a998074f1c0883370982288575210afd8008ba7b @KristianOellegaard committed Mar 9, 2012
@@ -0,0 +1,15 @@
+Awesome text plugin for django. Features text plugins wrapped in HTML code.
+
+e.g.
+
+
+Example: template.html
+----------------------
+<div class='someclass'>
+ {{ body|safe }} {# Text plugin content goes here #}
+</div?
+
+
+I will add more docs when time allows it, but otherwise have a look at the source, its definitely not rocket science.
+
+Can be distributed under the BSD License
@@ -0,0 +1 @@
+__version__ = '0.1'
@@ -0,0 +1,11 @@
+from cmsplugin_text_ng.models import TextNGTemplate, TextNGTemplateCategory
+from django.contrib import admin
+
+class TextNGTemplateAdmin(admin.ModelAdmin):
+ list_display = ('title', 'category', 'path')
+ list_filter = ('category',)
+ search_fields = ('title', 'category', 'path')
+
+admin.site.register(TextNGTemplate, TextNGTemplateAdmin)
+
+admin.site.register(TextNGTemplateCategory)
@@ -0,0 +1,20 @@
+from cms.plugins.text.cms_plugins import TextPlugin
+from cmsplugin_text_ng.models import TextNG
+from django.utils.translation import ugettext_lazy as _
+from cms.plugin_pool import plugin_pool
+from django import template
+from django.template.context import Context
+from django.utils.safestring import mark_safe
+
+class TextPluginNextGeneration(TextPlugin):
+ model = TextNG
+ name = _("Text NG")
+
+ def render(self, context, instance, placeholder):
+ context = super(TextPluginNextGeneration, self).render(context, instance, placeholder)
+ t = template.loader.get_template(instance.template.path)
+ context.update({'body': mark_safe(t.render(Context(context)))})
+ return context
+
+
+plugin_pool.register_plugin(TextPluginNextGeneration)
@@ -0,0 +1,89 @@
+# 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 'TextNGTemplateCategory'
+ db.create_table('cmsplugin_text_ng_textngtemplatecategory', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=128)),
+ ))
+ db.send_create_signal('cmsplugin_text_ng', ['TextNGTemplateCategory'])
+
+ # Adding model 'TextNGTemplate'
+ db.create_table('cmsplugin_text_ng_textngtemplate', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('category', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cmsplugin_text_ng.TextNGTemplateCategory'], null=True, blank=True)),
+ ('title', self.gf('django.db.models.fields.CharField')(max_length=128)),
+ ('path', self.gf('django.db.models.fields.CharField')(max_length=128)),
+ ))
+ db.send_create_signal('cmsplugin_text_ng', ['TextNGTemplate'])
+
+ # Adding model 'TextNG'
+ db.create_table('cmsplugin_textng', (
+ ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
+ ('body', self.gf('django.db.models.fields.TextField')()),
+ ('template', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cmsplugin_text_ng.TextNGTemplate'])),
+ ))
+ db.send_create_signal('cmsplugin_text_ng', ['TextNG'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'TextNGTemplateCategory'
+ db.delete_table('cmsplugin_text_ng_textngtemplatecategory')
+
+ # Deleting model 'TextNGTemplate'
+ db.delete_table('cmsplugin_text_ng_textngtemplate')
+
+ # Deleting model 'TextNG'
+ db.delete_table('cmsplugin_textng')
+
+
+ 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': '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'})
+ },
+ 'cmsplugin_text_ng.textng': {
+ 'Meta': {'object_name': 'TextNG', 'db_table': "'cmsplugin_textng'"},
+ 'body': ('django.db.models.fields.TextField', [], {}),
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'template': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_text_ng.TextNGTemplate']"})
+ },
+ 'cmsplugin_text_ng.textngtemplate': {
+ 'Meta': {'ordering': "['title']", 'object_name': 'TextNGTemplate'},
+ 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cmsplugin_text_ng.TextNGTemplateCategory']", 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'path': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+ },
+ 'cmsplugin_text_ng.textngtemplatecategory': {
+ 'Meta': {'ordering': "['title']", 'object_name': 'TextNGTemplateCategory'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+ }
+ }
+
+ complete_apps = ['cmsplugin_text_ng']
No changes.
@@ -0,0 +1,36 @@
+from django.db import models
+from cms.plugins.text.models import AbstractText
+from django.utils.translation import ugettext_lazy as _
+
+class TextNGTemplateCategory(models.Model):
+ title = models.CharField(max_length=128)
+
+ def __unicode__(self):
+ return self.title
+
+ class Meta:
+ verbose_name = _('template category')
+ verbose_name_plural = _('template categories')
+ ordering = ['title']
+
+class TextNGTemplate(models.Model):
+ category = models.ForeignKey(TextNGTemplateCategory, blank=True, null=True)
+ title = models.CharField(max_length=128)
+ path = models.CharField(max_length=128)
+
+ def __unicode__(self):
+ if self.category:
+ return u"%s (%s)" % (self.title, self.category)
+ return self.title
+
+ class Meta:
+ verbose_name = _('template')
+ verbose_name_plural = _('templates')
+ ordering = ['title']
+
+class TextNG(AbstractText):
+ template = models.ForeignKey(TextNGTemplate)
+
+ class Meta:
+ verbose_name = _('text')
+ verbose_name_plural = _('texts')
@@ -0,0 +1,34 @@
+# coding: utf-8
+import os
+
+from setuptools import setup, find_packages
+from cmsplugin_text_ng import __version__ as version
+
+def read(fname):
+ return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+setup(
+ name = 'cmsplugin-text-ng',
+ version = version,
+ description = read('README.rst.rst'),
+ author = 'Kristian Øllegaard',
+ author_email = 'kristian@oellegaard.com',
+ url = 'https://github.com/KristianOellegaard/cmsplugin-text-ng',
+ packages = find_packages(),
+ zip_safe=False,
+ include_package_data = True,
+ install_requires=[
+ 'Django>=1.2',
+ 'django-cms>=2.0',
+ ],
+ classifiers = [
+ "Development Status :: 3 - Alpha",
+ "Framework :: Django",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: BSD License",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python :: 2.6",
+ "Programming Language :: Python :: 2.7",
+ "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
+ ]
+)

0 comments on commit a998074

Please sign in to comment.