[view] add support for sitemap generation (closes #2551626)
authorDavid Douard <david.douard@logilab.fr>
Fri, 02 Aug 2013 16:56:43 +0200
changeset 305 26c0ad70ac58
parent 304 2e5c49312081
child 310 7629dfa69b76
[view] add support for sitemap generation (closes #2551626)
__pkginfo__.py
views/__init__.py
--- a/__pkginfo__.py	Mon Aug 05 11:19:19 2013 +0200
+++ b/__pkginfo__.py	Fri Aug 02 16:56:43 2013 +0200
@@ -13,7 +13,7 @@
 author_email = "contact@logilab.fr"
 web = 'http://www.cubicweb.org/project/%s' % distname
 classifiers = [
-    'Environment :: Web Environment', 
+    'Environment :: Web Environment',
     'Framework :: CubicWeb',
     'Programming Language :: Python',
     'Programming Language :: JavaScript',
@@ -24,6 +24,7 @@
                   'cubicweb-preview': None,
                   'cubicweb-comment': '>= 1.6.3',
                   'cubicweb-datafeed': None,
+                  'cubicweb-seo': None,
                   'feedparser': None,
                   'rdflib': None,
                   }
--- a/views/__init__.py	Mon Aug 05 11:19:19 2013 +0200
+++ b/views/__init__.py	Fri Aug 02 16:56:43 2013 +0200
@@ -36,9 +36,22 @@
             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.preview.views.forms import PreviewFormMixin