changeset 1653:57e864bb8852

Add the ability to create new Blog and Blog entry items.
author Pavel Sviderski <pavel@psviderski.name>
date Fri, 10 Aug 2012 14:36:12 +0200
parents 64fe4e3c449b
children d7ba0ca0b4bb
files MoinMoin/items/__init__.py MoinMoin/templates/modify_blog_entry_meta.html MoinMoin/templates/modify_blog_meta.html
diffstat 3 files changed, 64 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Thu Aug 09 22:54:37 2012 +0800
+++ b/MoinMoin/items/__init__.py	Fri Aug 10 14:36:12 2012 +0200
@@ -29,7 +29,7 @@
 
 from whoosh.query import Term, And, Prefix
 
-from MoinMoin.forms import RequiredText, OptionalText, JSON, Tags, Submit
+from MoinMoin.forms import RequiredText, OptionalText, JSON, Tags, DateTime, Submit
 
 from MoinMoin.security.textcha import TextCha, TextChaizedForm
 from MoinMoin.signalling import item_modified
@@ -533,7 +533,7 @@
     """
     @property
     def ModifyForm(self):
-        class C(Item._ModifyForm):
+        class C(self._ModifyForm):
             content_form = self.content.ModifyForm
         C.__name__ = 'ModifyForm'
         return C
@@ -649,9 +649,39 @@
         ITEMTYPES = [
             (u'default', u'Default', 'Wiki item'),
             (u'ticket', u'Ticket', 'Ticket item'),
+            (u'blog', u'Blog', 'Blog item'),
+            (u'blogentry', u'Blog entry', 'Blog entry item'),
         ]
 
         return render_template('modify_select_itemtype.html',
                                item_name=self.name,
                                itemtypes=ITEMTYPES,
                               )
+
+
+# TODO: move into a separate items/blog.py module
+class BlogMetaForm(BaseMetaForm):
+    supertags = (Tags.using(label=L_('Supertags (Categories)'))
+                 .with_properties(placeholder=L_("Ordered comma separated list of tags")))
+
+class BlogEntryMetaForm(BaseMetaForm):
+    summary = (OptionalText.using(label=L_("Title"))
+               .with_properties(placeholder=L_("One-line title of the blog entry")))
+    ptime = DateTime.using(label=L_('Publication time (UTC)'), optional=True)
+
+@register
+class Blog(Default):
+    itemtype = u'blog'
+
+    class _ModifyForm(Default._ModifyForm):
+        meta_form = BlogMetaForm
+        meta_template = 'modify_blog_meta.html'
+
+
+@register
+class BlogEntry(Default):
+    itemtype = u'blogentry'
+
+    class _ModifyForm(Default._ModifyForm):
+        meta_form = BlogEntryMetaForm
+        meta_template = 'modify_blog_entry_meta.html'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/templates/modify_blog_entry_meta.html	Fri Aug 10 14:36:12 2012 +0200
@@ -0,0 +1,16 @@
+{% import "forms.html" as forms %}
+
+{% macro meta_editor(form) %}
+    <h2>Blog entry metadata</h2>
+    <dl>
+        {% for e in [
+            'itemtype',
+            'contenttype',
+            'summary',
+            'tags',
+            'ptime',
+            ] %}
+            {{ forms.render(form[e]) }}
+        {% endfor %}
+    </dl>
+{% endmacro %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/templates/modify_blog_meta.html	Fri Aug 10 14:36:12 2012 +0200
@@ -0,0 +1,16 @@
+{% import "forms.html" as forms %}
+
+{% macro meta_editor(form) %}
+    <h2>Blog metadata</h2>
+    <dl>
+        {% for e in [
+            'itemtype',
+            'contenttype',
+            'summary',
+            'tags',
+            'supertags',
+            ] %}
+            {{ forms.render(form[e]) }}
+        {% endfor %}
+    </dl>
+{% endmacro %}