diff --git a/docs/settings.rst b/docs/settings.rst index 2a1cfe75..a3ac6606 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -82,9 +82,9 @@ Setting name (default value) What does it do? generated HTML, using the `Typogrify `_ library -`LESS_GENERATOR` (``FALSE``) Set to True if you want to enable compiling less - files. Requires installation of `less css`_. -`LESS_COMPILER` (``'/usr/bin/lessc'``) The path to less css compiler (`lessc`) +`LESS_GENERATOR` (``FALSE``) Set to True or complete path to `lessc` (if not + found in system PATH) to enable compiling less + css files. Requires installation of `less css`_. ================================================ ===================================================== .. [#] Default is the system locale. diff --git a/pelican/__init__.py b/pelican/__init__.py index 1161f7e2..6b3d12fb 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -134,7 +134,7 @@ class Pelican(object): generators = [ArticlesGenerator, PagesGenerator, StaticGenerator] if self.settings['PDF_GENERATOR']: generators.append(PdfGenerator) - if self.settings['LESS_GENERATOR']: + if self.settings['LESS_GENERATOR']: # can be True or PATH to lessc generators.append(LessCSSGenerator) return generators diff --git a/pelican/generators.py b/pelican/generators.py index 4eecd9dc..37413ddb 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -418,7 +418,7 @@ class PdfGenerator(Generator): class LessCSSGenerator(Generator): - """Compile less css files. This assumes we have `lessc` in our PATH.""" + """Compile less css files.""" def _compile(self, less_file, source_dir, dest_dir): base = os.path.relpath(less_file, source_dir) @@ -433,13 +433,18 @@ class LessCSSGenerator(Generator): logger.error("Couldn't create the pdf output folder in " + target_dir) - cmd = ' '.join([self.settings['LESS_COMPILER'], less_file, target]) + cmd = ' '.join([self._lessc, less_file, target]) subprocess.call(cmd, shell=True) logger.info(u' [ok] compiled %s' % base) def generate_output(self, writer=None): logger.info(u' Compiling less css') + # store out compiler here, so it won't be evaulted on each run of + # _compile + lg = self.settings['LESS_GENERATOR'] + self._lessc = lg if isinstance(lg, basestring) else 'lessc' + # walk static paths for static_path in self.settings['STATIC_PATHS']: for f in self.get_files( diff --git a/pelican/settings.py b/pelican/settings.py index 8d8a7d75..771c72c6 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -68,7 +68,6 @@ _DEFAULT_CONFIG = {'PATH': '.', 'ARTICLE_PERMALINK_STRUCTURE': '', 'TYPOGRIFY': False, 'LESS_GENERATOR': False, - 'LESS_COMPILER': '/usr/bin/lessc', } diff --git a/tests/test_generators.py b/tests/test_generators.py index ce1b9e7e..ecaacfcd 100644 --- a/tests/test_generators.py +++ b/tests/test_generators.py @@ -68,7 +68,6 @@ class TestLessCSSGenerator(unittest.TestCase): settings = _DEFAULT_CONFIG.copy() settings['STATIC_PATHS'] = ['static'] settings['LESS_GENERATOR'] = True - settings['LESS_COMPILER'] = 'lessc' # we'll nest here for py < 2.7 compat with temporary_folder() as temp_content: