# HG changeset patch # User Ludovic Chabant # Date 1424071791 28800 # Node ID c1d4e86a39184388d70d638a074ea9037d58e1d0 # Parent f43f199756711a45cf477ebf2a5175c84c12eb79 less: Generate a proper, available URL for the LESS CSS map file. * The `less` processor now generates a usable URL for map files. * The server can serve files from inside the `_cache` directory. diff -r f43f19975671 -r c1d4e86a3918 piecrust/processing/less.py --- a/piecrust/processing/less.py Sun Feb 15 22:48:42 2015 -0800 +++ b/piecrust/processing/less.py Sun Feb 15 23:29:51 2015 -0800 @@ -56,8 +56,10 @@ self._ensureInitialized() map_path = self._getMapPath(in_path) - map_path = os.path.relpath(map_path) - args = [self._conf['bin'], '--source-map=%s' % map_path] + map_url = '/' + os.path.relpath(map_path, self.app.root_dir) + args = [self._conf['bin'], + '--source-map=%s' % map_path, + '--source-map-url=%s' % map_url] args += self._conf['options'] args.append(in_path) args.append(out_path) diff -r f43f19975671 -r c1d4e86a3918 piecrust/serving.py --- a/piecrust/serving.py Sun Feb 15 22:48:42 2015 -0800 +++ b/piecrust/serving.py Sun Feb 15 23:29:51 2015 -0800 @@ -194,7 +194,13 @@ def _try_serve_asset(self, environ, request): rel_req_path = request.path.lstrip('/').replace('/', os.sep) - full_path = os.path.join(self._out_dir, rel_req_path) + if request.path.startswith('/_cache/'): + # Some stuff needs to be served directly from the cache directory, + # like LESS CSS map files. + full_path = os.path.join(self.root_dir, rel_req_path) + else: + full_path = os.path.join(self._out_dir, rel_req_path) + try: response = self._make_wrapped_file_response( environ, full_path)