comparison piecrust/data/assetor.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 43091c9837bf
children 0445a2232de7
comparison
equal deleted inserted replaced
32:43091c9837bf 33:62c7a97c8340
1 import re
2 import os 1 import os
3 import os.path 2 import os.path
4 import logging 3 import logging
5 from piecrust.uriutil import multi_replace 4 from piecrust.uriutil import multi_replace
6 5
14 13
15 def build_base_url(app, uri, rel_assets_path): 14 def build_base_url(app, uri, rel_assets_path):
16 base_url_format = app.env.base_asset_url_format 15 base_url_format = app.env.base_asset_url_format
17 rel_assets_path = rel_assets_path.replace('\\', '/') 16 rel_assets_path = rel_assets_path.replace('\\', '/')
18 17
19 # Remove any extension or pagination suffix from the URL, since 18 # Remove any extension since we'll be copying assets into the 1st
20 # we'll be copying assets into the 1st sub-page's folder. 19 # sub-page's folder.
21 pretty = app.config.get('site/pretty_urls') 20 pretty = app.config.get('site/pretty_urls')
22 if not pretty: 21 if not pretty:
23 uri, _ = os.path.splitext(uri) 22 uri, _ = os.path.splitext(uri)
24 pgn_suffix_re = app.config.get('__cache/pagination_suffix_re')
25 m = re.search(pgn_suffix_re, uri)
26 if m:
27 uri = uri[:m.start():]
28 23
29 base_url = multi_replace( 24 base_url = multi_replace(
30 base_url_format, 25 base_url_format,
31 { 26 {
32 '%path%': rel_assets_path, 27 '%path%': rel_assets_path,