diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d25254b --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,24 @@ +Copyright (c) 2012, Divio AG +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Divio AG nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL DIVIO AG BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..cdc203c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include LICENSE.txt +recursive-include aldryn_style/templates * +recursive-include aldryn_style/locale * +recursive-include aldryn_style/migrations * +recursive-exclude * *.pyc diff --git a/aldryn_style/__init__.py b/aldryn_style/__init__.py new file mode 100644 index 0000000..2bb0f2c --- /dev/null +++ b/aldryn_style/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +__version__ = '0.0.1' diff --git a/aldryn_style/cms_plugins.py b/aldryn_style/cms_plugins.py new file mode 100644 index 0000000..91a05ee --- /dev/null +++ b/aldryn_style/cms_plugins.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from django.utils.translation import ugettext_lazy as _ + +from cms.plugin_base import CMSPluginBase +from cms.plugin_pool import plugin_pool + +from aldryn_style import models + + +class StylePlugin(CMSPluginBase): + + render_template = 'aldryn_style/style.html' + name = _('Style') + model = models.StylePlugin + allow_children = True + + def render(self, context, instance, placeholder): + context['instance'] = instance + return context + +plugin_pool.register_plugin(StylePlugin) diff --git a/aldryn_style/migrations/0001_initial.py b/aldryn_style/migrations/0001_initial.py new file mode 100644 index 0000000..18642bb --- /dev/null +++ b/aldryn_style/migrations/0001_initial.py @@ -0,0 +1,53 @@ +# -*- 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 'StylePlugin' + db.create_table('cmsplugin_styleplugin', ( + ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)), + ('class_name', self.gf('django.db.models.fields.CharField')(max_length=50)), + )) + db.send_create_signal('aldryn_style', ['StylePlugin']) + + + def backwards(self, orm): + # Deleting model 'StylePlugin' + db.delete_table('cmsplugin_styleplugin') + + + models = { + 'aldryn_style.styleplugin': { + 'Meta': {'object_name': 'StylePlugin', 'db_table': "'cmsplugin_styleplugin'", '_ormbases': ['cms.CMSPlugin']}, + 'class_name': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}) + }, + '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.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'}) + } + } + + complete_apps = ['aldryn_style'] \ No newline at end of file diff --git a/aldryn_style/migrations/__init__.py b/aldryn_style/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/aldryn_style/models.py b/aldryn_style/models.py new file mode 100644 index 0000000..aa6f029 --- /dev/null +++ b/aldryn_style/models.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from django.db import models +from django.conf import settings +from django.utils.translation import ugettext_lazy as _ + +from cms.models.pluginmodel import CMSPlugin + + +def get_class_choices(): + return [(x, x) for x in getattr(settings, 'STYLE_CLASS_NAMES', [''])] + + +class StylePlugin(CMSPlugin): + + class_name = models.CharField(_('Class name'), choices=get_class_choices(), max_length=50) + + def __unicode__(self): + return self.class_name diff --git a/aldryn_style/templates/aldryn_style/style.html b/aldryn_style/templates/aldryn_style/style.html new file mode 100644 index 0000000..37cefd2 --- /dev/null +++ b/aldryn_style/templates/aldryn_style/style.html @@ -0,0 +1,6 @@ +{% load cms_tags %} +