Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:andreyfedoseev/django-less

Conflicts:
	less/utils.py
  • Loading branch information...
commit 477d2d58aecc9281573c9b2bc155a757e6aae9c0 2 parents 9bb3f81 + b4be184
@andreyfedoseev authored
Showing with 11 additions and 5 deletions.
  1. +3 −0  README.rst
  2. +1 −0  less/settings.py
  3. +7 −5 less/utils.py
View
3  README.rst
@@ -97,6 +97,9 @@ Settings
``LESS_EXECUTABLE``
Path to LESS compiler executable. Default: ``"lessc"``.
+``LESS_OPTIONS``
+ Options sent to ``lessc``. Default: ``[]``.
+
``LESS_ROOT``
Controls the absolute file path that compiled files will be written to. Default: ``STATIC_ROOT``.
View
1  less/settings.py
@@ -7,6 +7,7 @@
LESS_MTIME_DELAY = getattr(settings, "LESS_MTIME_DELAY", 10) # 10 seconds
LESS_ROOT = getattr(settings, "LESS_ROOT", getattr(settings, "STATIC_ROOT", getattr(settings, "MEDIA_ROOT")))
LESS_OUTPUT_DIR = getattr(settings, "LESS_OUTPUT_DIR", "LESS_CACHE")
+LESS_OPTIONS = getattr(settings, "LESS_OPTIONS", [])
LESS_DEVMODE = getattr(settings, "LESS_DEVMODE", False)
LESS_DEVMODE_WATCH_DIRS = getattr(settings, "LESS_DEVMODE_WATCH_DIRS", [settings.STATIC_ROOT])
LESS_DEVMODE_EXCLUDE = getattr(settings, "LESS_DEVMODE_EXCLUDE", ())
View
12 less/utils.py
@@ -1,8 +1,9 @@
from less import LessException
-from less.settings import LESS_EXECUTABLE, LESS_ROOT, LESS_OUTPUT_DIR
+from less.settings import LESS_EXECUTABLE, LESS_ROOT, LESS_OUTPUT_DIR, \
+ LESS_OPTIONS
from django.conf import settings
import logging
-import posixpath
+import urlparse
import re
import os
import subprocess
@@ -21,14 +22,15 @@ class URLConverter(object):
def __init__(self, content, source_path):
self.content = content
self.source_dir = os.path.dirname(source_path)
+ if not self.source_dir.endswith('/'):
+ self.source_dir = self.source_dir + '/'
def convert_url(self, matchobj):
url = matchobj.group(1)
url = url.strip(' \'"')
if url.startswith(('http://', 'https://', '/', 'data:')):
return "url('%s')" % url
- full_url = posixpath.normpath("/".join([self.source_dir, url]))
- return "url('%s')" % full_url
+ return "url('%s')" % urlparse.urljoin(self.source_dir, url)
def convert(self):
return self.URL_PATTERN.sub(self.convert_url, self.content)
@@ -40,7 +42,7 @@ def compile_less(input, output, less_path):
if not os.path.exists(less_root):
os.makedirs(less_root)
- args = [LESS_EXECUTABLE, input]
+ args = [LESS_EXECUTABLE] + LESS_OPTIONS + [input]
popen_kwargs = dict(
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Please sign in to comment.
Something went wrong with that request. Please try again.