diff piecrust/serving.py @ 240:c1d4e86a3918

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.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 15 Feb 2015 23:29:51 -0800
parents e534d2bc657c
children da5e6e00fb41
line wrap: on
line diff
--- 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)