use preview cube (if available)
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 05 Oct 2010 18:18:49 +0200
changeset 240 6a74a6011af7
parent 239 607876043cd6
child 241 d785490eafb8
use preview cube (if available)
__pkginfo__.py
debian/control
views/__init__.py
views/secondary.py
--- a/__pkginfo__.py	Tue Oct 05 14:27:16 2010 +0200
+++ b/__pkginfo__.py	Tue Oct 05 18:18:49 2010 +0200
@@ -21,6 +21,7 @@
 
 __depends__ = {'cubicweb': '>= 3.9.0'}
 __recommends__ = {'cubicweb-tag': None,
+                  'cubicweb-preview': None,
                   'cubicweb-comment': '>= 1.6.3',
                   'cubicweb-datafeed': None,
                   'feedparser': None,
--- a/debian/control	Tue Oct 05 14:27:16 2010 +0200
+++ b/debian/control	Tue Oct 05 18:18:49 2010 +0200
@@ -11,6 +11,7 @@
 Architecture: all
 Depends: cubicweb-common (>= 3.9.0)
 Suggests: cubicweb-comment (>= 1.6.3), cubicweb-tag, cubicweb-datafeed, python-feedparser, python-rdflib
+Recommends: cubicweb-preview
 Description: blog component for the CubicWeb framework
  This CubicWeb component provides blogging functionnalities.
  .
--- a/views/__init__.py	Tue Oct 05 14:27:16 2010 +0200
+++ b/views/__init__.py	Tue Oct 05 18:18:49 2010 +0200
@@ -1,6 +1,9 @@
 from cubicweb.selectors import is_instance
 from cubicweb.view import EntityAdapter
 from cubicweb.web.views import ibreadcrumbs
+from cubicweb.web.views.autoform import AutomaticEntityForm
+
+from cubes.preview.views.forms import PreviewFormMixin
 
 class BlogEntryIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter):
     __select__ = is_instance('BlogEntry', 'MicroBlogEntry')
@@ -33,3 +36,15 @@
                                     {'eid': self.entity.eid})
         if rset:
             return rset.get_entity(0,0)
+
+
+class PreviewAutomaticEntityForm(PreviewFormMixin, AutomaticEntityForm):
+    preview_mode = 'inline'
+    __select__ = AutomaticEntityForm.__select__ & is_instance('Blog', 'BlogEntry',
+                                                              'MicroBlog', 'MicroBlogEntry')
+
+def registration_callback(vreg):
+    vreg.register(BlogEntryIBreadCrumbsAdapter)
+    vreg.register(BlogEntryIPrevNextAdapter)
+    if 'preview' in vreg.config.cubes():
+        vreg.register(PreviewAutomaticEntityForm)
--- a/views/secondary.py	Tue Oct 05 14:27:16 2010 +0200
+++ b/views/secondary.py	Tue Oct 05 18:18:49 2010 +0200
@@ -65,13 +65,14 @@
             link = u'<a href="%s" title="">[%s]</a>' % (
                 url, self._cw._('see more archives'))
             items.append( u'<li class="">%s</li>\n' % link )
-        self.w(u'<div class="boxFrame">')
+        w = self.w
+        w(u'<div class="boxFrame">')
         if items:
-            self.w(u'<div class="boxContent">\n')
-            self.w(u'<ul class="boxListing">')
-            self.w(''.join(items))
-            self.w(u'</ul>\n</div>\n')
-        self.w(u'</div>')
+            w(u'<div class="boxContent">\n')
+            w(u'<ul class="boxListing">')
+            w(''.join(items))
+            w(u'</ul>\n</div>\n')
+        w(u'</div>')
 
 
 class BlogEntrySameETypeListView(baseviews.SameETypeListView):