This repository has been archived by the owner on Feb 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Krzysiek Szularz
committed
May 15, 2013
1 parent
0d65fad
commit 0b813d9
Showing
11 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
__version__ = '0.0.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{% load cms_tags %} | ||
<div class="{{ instance.class_name }}"> | ||
{% for plugin in instance.child_plugin_instances %} | ||
{% render_plugin plugin %} | ||
{% endfor %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Style | ||
package-name: aldryn-style | ||
url: https://github.com/aldryn/aldryn-style | ||
author: | ||
name: Divio AG | ||
url: https://www.divio.ch | ||
installed-apps: | ||
- aldryn_style | ||
version: 0.0.1 | ||
description: Wraps inner plugin with a classy div. | ||
license: | ||
name: BSD | ||
text: !literal-include LICENSE.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
from cmscloud_client import forms | ||
|
||
import re | ||
|
||
|
||
class ClassNamesField(forms.CharField): | ||
|
||
CLASS_NAME_RE = re.compile(r'^\w[\w-_]*$') | ||
|
||
def clean(self, value): | ||
value = super(ClassNamesField, self).clean(value) | ||
value = filter(bool, map(lambda x: x.strip(), value.split(','))) | ||
for class_name in value: | ||
if not self.CLASS_NAME_RE.match(class_name): | ||
raise forms.ValidationError(u'%s is not a proper class name.' % (class_name, )) | ||
return value | ||
|
||
|
||
class Form(forms.BaseForm): | ||
|
||
class_names = ClassNamesField('Class names') | ||
|
||
def to_settings(self, data, settings): | ||
settings['STYLE_CLASS_NAMES'] = data['class_names'] | ||
return settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from setuptools import setup | ||
from aldryn_style import __version__ | ||
|
||
|
||
CLASSIFIERS = [ | ||
'Development Status :: 2 - Pre-Alpha', | ||
'Environment :: Web Environment', | ||
'Framework :: Django', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: BSD License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Topic :: Communications', | ||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content', | ||
'Programming Language :: Python :: 2.6', | ||
'Programming Language :: Python :: 2.7', | ||
] | ||
|
||
setup( | ||
name='aldryn-style', | ||
version=__version__, | ||
description='Wraps inner plugin with a classy div', | ||
author='Divio AG', | ||
author_email='[email protected]', | ||
url='https://github.com/aldryn/aldryn-style', | ||
packages=['aldryn_style'], | ||
license='LICENSE.txt', | ||
platforms=['OS Independent'], | ||
classifiers=CLASSIFIERS, | ||
include_package_data=True, | ||
zip_safe=False | ||
) |