Donald Stufft avatar Donald Stufft committed 0f9d84c

initial checkin

Comments (0)

Files changed (8)

+Copyright (c) 2009, Xenofox, LLC
+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 the Xenofox, LLC 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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
+include LICENSE
+include README
+include MANIFEST.in
+recursive-include cmsplugin_plaintext *
+ALPHA
+
+Name: cmsplugin-plaintext
+Description: Adds a plaintext plugin for django-cms.
+Download: http://bitbucket.org/xenofox/cmsplugin-plaintext/
+
+Requirements:
+- django-cms-2.0.0 final
+- django: 1.1.1
++ requirements for django-cms-2.0
+
+Last tested with:
+- django-cms-2.0.0 final
+- django: 1.1.1
+
+Setup
+- make sure requirements are installed and properly working
+- add cmsplugin_plaintext to python path
+- add 'cmsplugin_plaintext' to INSTALLED_APPS
+- run 'python manage.py syncdb'
+
+TODO:
+- Add tests
+- Add translations

cmsplugin_plaintext/__init__.py

+VERSION = (0, 1, 0, 'alpha')
+__version__ = '.'.join(map(str, VERSION))

cmsplugin_plaintext/cms_plugins.py

+from django.utils.translation import ugettext as _
+
+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+
+from cmsplugin_plaintext.models import CMSCharFieldPlugin, CMSTextFieldPlugin
+
+class CharFieldPlugin(CMSPluginBase):
+    model = CMSCharFieldPlugin
+    name = _('plaintext')
+    render_template = 'cmsplugin_plaintext/text.html'
+
+    def render(self, context, instance, placeholder):
+        context.update({
+            'body': instance.body,
+            'object': instance,
+            'placeholder': placeholder
+        })
+        return context
+
+class TextFieldPlugin(CMSPluginBase):
+    model = CMSTextFieldPlugin
+    name = _('plaintext text area')
+    render_template = 'plaintext/text.html'
+
+    def render(self, context, instance, placeholder):
+        context.update({
+            'body': instance.body,
+            'object': instance,
+            'placeholder': placeholder
+        })
+        return context
+
+plugin_pool.register_plugin(CharFieldPlugin)
+plugin_pool.register_plugin(TextFieldPlugin)

cmsplugin_plaintext/models.py

+from django.utils.translation import ugettext as _
+from django.db import models
+
+from cms.models import CMSPlugin
+
+class CMSCharFieldPlugin(CMSPlugin):
+    body = models.CharField(_('body'), max_length=500)
+
+    def __unicode__(self):
+        return u'%s' % (self.body,)
+
+class CMSTextFieldPlugin(CMSPlugin):
+    body = models.TextField(_('body'))
+
+    def __unicode__(self):
+        return u'%s' % (self.body,)

cmsplugin_plaintext/templates/cmsplugin_plaintext/text.html

+{{ body }}
+#!/usr/bin/env python
+
+from distutils.core import setup
+
+setup(
+        name='cmsplugin-plaintext',
+        version='0.1.0',
+        description='Adds a plaintext plugin for django-cms.',
+        author='Xenofox, LLC', 
+        author_email='info@xenofox.com',
+        url='http://bitbucket.org/xenofox/cmsplugin-plaintext/',
+        packages=['cmsplugin_plaintext'],
+        classifiers=[
+            'Development Status :: 3 - Alpha',
+            'Environment :: Web Environment',
+            'Framework :: Django',
+            'Intended Audience :: Developers',
+            'Natural Language :: English',
+            'Operating System :: OS Independent',
+            'Programming Language :: Python :: 2',
+            'Topic :: Software Development :: Libraries :: Python Modules',
+            'Topic :: Utilities',
+            'License :: OSI Approved :: BSD License',
+            ]
+        )
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.