urlpublishing.py 2.38 KB
Newer Older
1
2
from cubicweb.web.views.urlrewrite import SimpleReqRewriter, rgx

Arthur Lutz's avatar
Arthur Lutz committed
3

4
5
class BlogReqRewriter(SimpleReqRewriter):
    rules = [
Sylvain Thénault's avatar
Sylvain Thénault committed
6
7
        # links generated by archives by date/author boxes
        (rgx('/(micro)?blog/([0-9]+)/blogentries'),
Arthur Lutz's avatar
flake8    
Arthur Lutz committed
8
9
         dict(rql='Any B,BD ORDERBY BD DESC WHERE B creation_date BD, '
                  'B entry_of BL, BL eid %(eid)s' % {'eid': r'\2'},
Sylvain Thénault's avatar
Sylvain Thénault committed
10
11
              )),
        (rgx('/(micro)?blog/([0-9]+)/blogentries/([a-z_]+)'),
Arthur Lutz's avatar
flake8    
Arthur Lutz committed
12
13
14
         dict(rql='Any B,BD ORDERBY BD DESC WHERE B creation_date BD, '
                  'B entry_of BL, BL eid %(eid)s, '
                  'B created_by U, U login "%(user)s"' % {'eid': r'\2', 'user': r'\3'},
Sylvain Thénault's avatar
Sylvain Thénault committed
15
16
17
18
19
20
              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})'),
Arthur Lutz's avatar
flake8    
Arthur Lutz committed
21
22
23
24
25
         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'},
Sylvain Thénault's avatar
Sylvain Thénault committed
26
27
28
              )),

        # XXX use or kill
29
        (rgx('/blogentry/([a-z_]+)'),
Arthur Lutz's avatar
flake8    
Arthur Lutz committed
30
31
         dict(rql='Any B,BD ORDERBY BD DESC WHERE B is BlogEntry, '
                  'B creation_date BD, B created_by U, U login "%(user)s"' % {'user': r'\1'},
Arthur Lutz's avatar
Arthur Lutz committed
32
              user=r'\1')),
33
        (rgx('/blogentry/([a-z_]+)\.rss'),
Arthur Lutz's avatar
flake8    
Arthur Lutz committed
34
35
36
         dict(rql='Any B,BD ORDERBY BD DESC LIMIT 20 WHERE B is BlogEntry, '
                  'B creation_date BD, B created_by U, U login "%(user)s"' % {'user': r'\1'},
              vid='rss')),
Sylvain Thénault's avatar
Sylvain Thénault committed
37
38


39
        (rgx('/blogentries/([0-9]{4})'),
Sylvain Thénault's avatar
Sylvain Thénault committed
40
41
         dict(rql='Any B,BD ORDERBY BD DESC WHERE B is BlogEntry, B creation_date BD '
                  'HAVING YEAR(BD) = %(year)s' % {'year': r'\1'})),
42
        (rgx('/blogentries/([0-9]{4})/([0-9]{2})'),
Sylvain Thénault's avatar
Sylvain Thénault committed
43
44
45
         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'})),
46

Arthur Lutz's avatar
Arthur Lutz committed
47
    ]