Mercurial > piecrust2
comparison piecrust/uriutil.py @ 33:62c7a97c8340
Get the un-paginated URL of a page early and pass that around.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 19 Aug 2014 15:36:28 -0700 |
parents | 30a42341cfa8 |
children | b7ab1b503510 |
comparison
equal
deleted
inserted
replaced
32:43091c9837bf | 33:62c7a97c8340 |
---|---|
1 import re | 1 import re |
2 import os.path | |
2 import string | 3 import string |
3 import logging | 4 import logging |
4 import functools | 5 import functools |
5 | 6 |
6 | 7 |
76 def get_slug(app, uri): | 77 def get_slug(app, uri): |
77 site_root = app.config.get('site/root') | 78 site_root = app.config.get('site/root') |
78 uri = uri[len(site_root):] | 79 uri = uri[len(site_root):] |
79 return uri.lstrip('/') | 80 return uri.lstrip('/') |
80 | 81 |
82 | |
83 def get_first_sub_uri(app, uri): | |
84 pretty_urls = app.config.get('site/pretty_urls') | |
85 if not pretty_urls: | |
86 uri, ext = os.path.splitext(uri) | |
87 | |
88 pgn_suffix_re = app.config.get('__cache/pagination_suffix_re') | |
89 m = re.search(pgn_suffix_re, uri) | |
90 if m: | |
91 uri = uri[:m.start()] | |
92 | |
93 if not pretty_urls: | |
94 uri += ext | |
95 | |
96 return uri | |
97 |