[views] refactor a bit the sitemap rules and make seo a recommend (closes #2551626)
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Tue, 06 Aug 2013 10:53:45 +0200
changeset 314 268148de1a95
parent 311 5e77cefb98df
child 315 aa2c081b0de6
[views] refactor a bit the sitemap rules and make seo a recommend (closes #2551626)
__pkginfo__.py
debian/control
views/__init__.py
--- a/__pkginfo__.py	Mon Aug 05 11:00:58 2013 +0200
+++ b/__pkginfo__.py	Tue Aug 06 10:53:45 2013 +0200
@@ -23,6 +23,7 @@
 __recommends__ = {'cubicweb-tag': None,
                   'cubicweb-preview': None,
                   'cubicweb-comment': '>= 1.6.3',
+                  'cubicweb-seo': None,
                   'cubicweb-datafeed': None,
                   'cubicweb-seo': None,
                   'feedparser': None,
--- a/debian/control	Mon Aug 05 11:00:58 2013 +0200
+++ b/debian/control	Tue Aug 06 10:53:45 2013 +0200
@@ -11,7 +11,7 @@
 Architecture: all
 Depends: cubicweb-common (>= 3.17.0)
 Suggests: cubicweb-comment (>= 1.6.3), cubicweb-tag, cubicweb-datafeed, python-feedparser, python-rdflib
-Recommends: cubicweb-preview
+Recommends: cubicweb-preview, cubicweb-seo
 Description: blog component for the CubicWeb framework
  This CubicWeb component provides blogging functionnalities.
  .
--- a/views/__init__.py	Mon Aug 05 11:00:58 2013 +0200
+++ b/views/__init__.py	Tue Aug 06 10:53:45 2013 +0200
@@ -36,24 +36,31 @@
             return rset.get_entity(0,0)
 
 
-try:
-    from cubes.seo.views import SitemapRule
-    class BlogSitemapRule(SitemapRule):
-        __regid__ = 'blog'
-        query = 'Any X WHERE X is ET, ET name in ("Blog", "BlogEntry", "MicroBlog", "MicroBlogEntry")'
-        priority = 1.0
-except ImportError:
-    pass
-
 def registration_callback(vreg):
     vreg.register(BlogEntryIBreadCrumbsAdapter)
     vreg.register(BlogEntryIPrevNextAdapter)
 
     loaded_cubes = vreg.config.cubes()
+
     if 'seo' in loaded_cubes:
-        vreg.register(BlogSitemapRule)
-    if 'preview' in vreg.config.cubes():
+        from cubes.seo.views import SitemapRule
+
+        class BlogEntrySitemapRule(SitemapRule):
+            __regid__ = 'blogentry'
+            query = 'Any X WHERE X is BlogEntry'
+            priority = 1.0
+            chfreq = 'yearly'
 
+        class MicroBlogEntrySitemapRule(SitemapRule):
+            __regid__ = 'microblogentry'
+            query = 'Any X WHERE X is MicroBlogEntry'
+            priority = 1.0
+            chfreq = 'yearly'
+
+        vreg.register(BlogEntrySitemapRule)
+        vreg.register(MicroBlogEntrySitemapRule)
+
+    if 'preview' in loaded_cubes:
         from cubes.preview.views.forms import PreviewFormMixin
         class PreviewAutomaticEntityForm(PreviewFormMixin, AutomaticEntityForm):
             preview_mode = 'inline'