cleanup / fix input urls
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 12 Oct 2010 18:17:59 +0200
changeset 244 f535efbb2be2
parent 243 42fa2eb965df
child 245 ffcb398f540e
cleanup / fix input urls
views/urlpublishing.py
--- a/views/urlpublishing.py	Tue Oct 12 18:17:53 2010 +0200
+++ b/views/urlpublishing.py	Tue Oct 12 18:17:59 2010 +0200
@@ -5,34 +5,37 @@
 
 class BlogReqRewriter(SimpleReqRewriter):
     rules = [
+        # links generated by archives by date/author boxes
+        (rgx('/(micro)?blog/([0-9]+)/blogentries'),
+         dict(rql='Any B,BD ORDERBY BD DESC WHERE B creation_date BD, B entry_of BL, BL eid %(eid)s' % {'eid': r'\2'},
+              )),
+        (rgx('/(micro)?blog/([0-9]+)/blogentries/([a-z_]+)'),
+         dict(rql='Any B,BD ORDERBY BD DESC WHERE B creation_date BD, B entry_of BL, BL eid %(eid)s, '
+              'X created_by U, U login "%(user)s"' % {'eid': r'\2', 'user': r'\3'},
+              user=r'\2')),
+        (rgx('/(micro)?blog/([0-9]+)/blogentries/([0-9]{4})'),
+         dict(rql='Any B,BD ORDERBY BD DESC WHERE B creation_date BD, B entry_of BL, BL eid %(eid)s'
+              'HAVING YEAR(BD)= %(year)s' % {'eid': r'\2', 'year': r'\3'},
+              )),
+        (rgx('/(micro)?blog/([0-9]+)/blogentries/([0-9]{4})/([0-9]{2})'),
+         dict(rql='Any B,BD ORDERBY BD DESC WHERE B creation_date BD, B entry_of BL, BL eid %(eid)s '
+              'HAVING YEAR(BD)= %(year)s, MONTH(BD)=%(month)s' % {'eid': r'\2', 'year': r'\3', 'month': r'\4'},
+              )),
+
+        # XXX use or kill
         (rgx('/blogentry/([a-z_]+)'),
          dict(rql='Any X ORDERBY CD DESC WHERE X is BlogEntry, X creation_date CD, X created_by U, U login "%(user)s"' % {'user': r'\1'},
               user = r'\1')),
         (rgx('/blogentry/([a-z_]+)\.rss'),
          dict(rql='Any X ORDERBY CD DESC LIMIT 20 WHERE X is BlogEntry, X creation_date CD, X created_by U, U login "%(user)s"' % {'user': r'\1'}, vid='rss')),
+
+
         (rgx('/blogentries/([0-9]{4})'),
-         dict(rql='Any B ORDERBY CD DESC WHERE B is BlogEntry, B creation_date CD, '
-                  'B creation_date >= "%(param)s-01-01", '
-                  'B creation_date <= "%(param)s-12-31"' % {'param': r'\1'},
-              )),
+         dict(rql='Any B,BD ORDERBY BD DESC WHERE B is BlogEntry, B creation_date BD '
+                  'HAVING YEAR(BD) = %(year)s' % {'year': r'\1'})),
         (rgx('/blogentries/([0-9]{4})/([0-9]{2})'),
-         dict(rql='Any B, BD ORDERBY BD DESC '
-                  'WHERE B is BlogEntry, B creation_date BD, '
-                  'B creation_date >=  "%(year)s/%(month)s/01", B creation_date <= "%(year)s/%(month)s/30"' % {'year': r'\1', 'month': r'\2'},
-              )),
-        (rgx('/blog/([0-9]+)/blogentries'),
-         dict(rql='Any B ORDERBY CD DESC WHERE B is BlogEntry, B creation_date CD, '
-                  'B entry_of BL, BL eid %(eid)s' % {'eid': r'\1'},
-              )),
-        (rgx('/blog/([0-9]+)/blogentries/([0-9]{4})'),
-         dict(rql='Any B ORDERBY CD DESC WHERE B is BlogEntry, B creation_date CD, '
-                  'B creation_date >= "%(param)s-01-01", '
-                  'B creation_date <= "%(param)s-12-31", B entry_of BL, BL eid %(eid)s' % {'eid': r'\1', 'param': r'\2'},
-              )),
-        (rgx('/blog/([0-9]+)/blogentries/([0-9]{4})/([0-9]{2})'),
-         dict(rql='Any B, BD ORDERBY BD DESC '
-                  'WHERE B is BlogEntry, B creation_date BD, B entry_of BL, BL eid %(eid)s, '
-                  'B creation_date >=  "%(year)s/%(month)s/01", B creation_date <= "%(year)s/%(month)s/30"' % {'eid': r'\1', 'year': r'\2', 'month': r'\3'},
-              )),
+         dict(rql='Any B,BD ORDERBY BD DESC WHERE B is BlogEntry, B creation_date BD '
+                  'HAVING YEAR(BD) = %(year)s, MONTH(BD) = %(month)s' % {'year': r'\1',
+                                                                         'month': r'\2'})),
 
         ]