Luke Plant  committed f644c24

Updates for new plugin system in django-cms2, and README update.

  • Participants
  • Parent commits 43c9fb7
  • Branches default

Comments (0)

Files changed (7)

 is derived from the skins/templates found in django-cms2, with the following
  - name of the skin changed from 'django' to 'semanticeditor'.  This is
    necessary if we are to allow two different versions of WYMeditor on the
    same page, one using the normal WYMeditor + CMS controls, another with
    the full 'semantic editor' controls, for longer pieces of content.
- - The skin.js file removes the 'classes' panel, since it is replaced by
-   dynamic elements.
+ - updateSelector option changed to 'input[value=Save]', since we now
+   have other submit buttons that we don't want to bind to.
+ - The skin.js file removes the 'classes' panel, since this is not needed
+   and is replaced by dynamic elements.
  - skins.css - added styling for additional presentation controls
     - the WYMeditor plugin javascript file can be added to Media
     - our editorwdiget.html template can be used.
+Column layouts
+Since you often need to know the number of columns, the system produces HTML
+like the following, for 2 columns in a row:
+ div class=row2col
+   div class=col
+ or more sections
+   div class=col
+ or more sections
+For 3 columns in a row
+ div class=row3col
+    ...etc
+Columns can be applied to sections at any heading level, but you can't nest
+columns within columns, and you can't "mix" the heading level the columns
+apply to *within* a row.  So you *can* have layouts at least as complex as
+ H1 
+  H2 - new row (2 column row)     - NB col structure at H2 level
+  H2 (same col as above)
+  H2 - new col
+  H2 - new row (3 column row)
+  H2 - new col
+  H2 - new col
+ H1 - new row (2 column row)      - NB col structure as H1 level
+ H1 - new col
+But you can't have:
+ H1 - new row
+  ... content ...
+  H2 - new col                   - this would be within the row started 
+                                   at the H1 level.
+The reason for this explained in the source code.  Users get helpful error
+messages if they try to ask for something impossible.

File semanticeditor/

+from cms.plugin_pool import plugin_pool
+from cms.plugin_base import CMSPluginBase
+from django.utils.translation import ugettext_lazy as _
+from cms.plugins.text.models import Text
+from semanticeditor.forms import SemanticTextForm
+class SemanticTextPlugin(CMSPluginBase):
+    model = Text
+    name = _("Text with presentation")
+    form = SemanticTextForm
+    def render(self, request, instance):
+        return instance.body

File semanticeditor/

+from django.forms.models import ModelForm
+from cms.plugins.text.models import Text
+from django import forms
+from semanticeditor.widgets import SemanticEditor
+class SemanticTextForm(ModelForm):
+    body = forms.CharField(widget=SemanticEditor())
+    class Meta:
+        model = Text
+        exclude = ('page', 'position', 'placeholder', 'language', 'plugin_type')

File semanticeditor/media/semanticeditor/javascript/wymeditor/plugins/semantic/wymeditor.semantic.js

 	    $(this).attr('id', 'id_optsbox_label_' + i);
 		orbitalPosition: 270,
-		spacing:         15,
+		spacing:         5,
 		tooltipClass: 	 'orbitaltooltip-simplebox',
 		html:            help

File semanticeditor/media/semanticeditor/javascript/wymeditor/skins/semanticeditor/skin.css

 	.orbitaltooltip-simplebox {
 	    background: #ddd;
-	    width: 400px;
+	    width: 300px;
 	    height: auto;
 	    min-height: 100px;
-	    max-height: 400px;
+	    max-height: 260px;
 	    overflow-y: scroll;
 	    overflow-x: hidden;
 	    border: 2px solid #607e98;

File semanticeditor/templates/semanticeditor/editorwidget.html

-{% load mptt_tags %}
+{% load mptt_tags i18n %}
 {% full_tree_for_model cms.Page as pages %}
 <script type="text/javascript">
     jQuery('#id_{{ name }}').wymeditor({
         lang: '{{ language }}',
         skin: 'semanticeditor',
         skinPath: "{{ SE_MEDIA_URL }}javascript/wymeditor/skins/semanticeditor/",
-        updateSelector: '.submit-row input[type=submit],',
+        updateSelector: 'input[value=Save],',
         updateEvent: 'click',
         postInit: function(wym) {
             wym.resizable({handles: "s", maxHeight: 600});

File semanticeditor/

-# Override for widgets in django-cms
-# Include all the normal ones
-from cms.admin.widgets import *
+from cms.plugins.text.widgets import WYMEditor
 from django import forms
 from django.conf import settings
+from django.utils.safestring import mark_safe
+from django.utils.translation.trans_real import get_language
+from django.template.loader import render_to_string
 import os
 join = os.path.join
-    def render_extra(self, name, value, attrs=None):
+    def render_additions(self, name, value, attrs=None):
+        language = get_language()
         context = {
             'name': name,
-            'language': self.language,
+            'language': language,
             'SE_MEDIA_URL': settings.SE_MEDIA_URL,
         return mark_safe(render_to_string(
             'semanticeditor/editorwidget.html', context))