Mercurial > piecrust2
comparison piecrust/processing/requirejs.py @ 852:4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
* Everything is a `ContentSource`, including assets directories.
* Most content sources are subclasses of the base file-system source.
* A source is processed by a "pipeline", and there are 2 built-in pipelines,
one for assets and one for pages. The asset pipeline is vaguely functional,
but the page pipeline is completely broken right now.
* Rewrite the baking process as just running appropriate pipelines on each
content item. This should allow for better parallelization.
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Wed, 17 May 2017 00:11:48 -0700 |
| parents | e5f048799d61 |
| children |
comparison
equal
deleted
inserted
replaced
| 851:2c7e57d80bba | 852:4850f8c21b6e |
|---|---|
| 1 import os | 1 import os |
| 2 import os.path | 2 import os.path |
| 3 import json | |
| 4 import hashlib | |
| 5 import logging | 3 import logging |
| 6 import platform | 4 import platform |
| 7 import subprocess | 5 import subprocess |
| 8 from piecrust.processing.base import Processor, PRIORITY_FIRST | 6 from piecrust.processing.base import Processor, PRIORITY_FIRST, FORCE_BUILD |
| 9 from piecrust.processing.tree import FORCE_BUILD | |
| 10 | 7 |
| 11 | 8 |
| 12 logger = logging.getLogger(__name__) | 9 logger = logging.getLogger(__name__) |
| 13 | 10 |
| 14 | 11 |
| 31 raise Exception("You need to specify `requirejs/build_path` " | 28 raise Exception("You need to specify `requirejs/build_path` " |
| 32 "for RequireJS.") | 29 "for RequireJS.") |
| 33 self._conf.setdefault('bin', 'r.js') | 30 self._conf.setdefault('bin', 'r.js') |
| 34 self._conf.setdefault('out_path', self._conf['build_path']) | 31 self._conf.setdefault('out_path', self._conf['build_path']) |
| 35 | 32 |
| 36 def onPipelineStart(self, pipeline): | 33 def onPipelineStart(self, ctx): |
| 37 super(RequireJSProcessor, self).onPipelineStart(pipeline) | 34 super(RequireJSProcessor, self).onPipelineStart(ctx) |
| 38 | 35 |
| 39 if self._conf is None: | 36 if self._conf is None: |
| 40 return | 37 return |
| 41 | 38 |
| 42 logger.debug("Adding Javascript suppressor to build pipeline.") | 39 logger.debug("Adding Javascript suppressor to build pipeline.") |
| 43 skip = _JavascriptSkipProcessor(self._conf['build_path']) | 40 skip = _JavascriptSkipProcessor(self._conf['build_path']) |
| 44 pipeline.processors.append(skip) | 41 ctx.extra_processors.append(skip) |
| 45 | 42 |
| 46 def matches(self, path): | 43 def matches(self, path): |
| 47 if self._conf is None: | 44 if self._conf is None: |
| 48 return False | 45 return False |
| 49 return path == self._conf['build_path'] | 46 return path == self._conf['build_path'] |
