Commits

Scott Nixon committed 8570bd2

added wymeditor to flatpages by adding the config to article app

  • Participants
  • Parent commits 1a7a151

Comments (0)

Files changed (2)

     (r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': 'http://img1.happyherbivore.com/favicon.ico'}),
     (r'^media/(?P<path>.*)$', 'django.views.static.serve',
 			{'document_root': '/Users/scott/projects/happy/media'}),
+    (r'^tinymce/', include('tinymce.urls')),
     (r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
     url(r'^feed/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}, name='feeds_view'),
     (r'^admin/', include(admin.site.urls)),

File run/widgets.py

 
     def value_from_datadict(self, data, files, name):
         return [data.get(self.recaptcha_challenge_name, None), 
-            data.get(self.recaptcha_response_name, None)]
+            data.get(self.recaptcha_response_name, None)]
+        
+class WYMEditor(forms.Textarea):
+    class Media:
+        js = (
+            'js/jquery.js',
+            'js/wymeditor/jquery.wymeditor.pack.js',
+        )
+
+    def __init__(self, language=None, attrs=None):
+        self.language = language or settings.LANGUAGE_CODE[:2]
+        self.attrs = {'class': 'wymeditor'}
+        if attrs:
+            self.attrs.update(attrs)
+        super(WYMEditor, self).__init__(attrs)
+
+    def render(self, name, value, attrs=None):
+        rendered = super(WYMEditor, self).render(name, value, attrs)
+        return rendered + mark_safe(u'''<script type="text/javascript">
+            jQuery('#id_%s').wymeditor({
+                updateSelector: '.submit-row input[type=submit]',
+                updateEvent: 'click',
+                lang: '%s',
+            });
+            </script>''' % (name, self.language))