From 7b0ccb713733b97aac3398585a3c6da0adb20f66 Mon Sep 17 00:00:00 2001 From: Ilker Cetinkaya Date: Tue, 12 Feb 2013 22:17:21 +0100 Subject: [PATCH] minor improvements on plugin as well as some short docs. --- hyde/ext/plugins/requirejs.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/hyde/ext/plugins/requirejs.py b/hyde/ext/plugins/requirejs.py index b1a3d5e..399ed67 100644 --- a/hyde/ext/plugins/requirejs.py +++ b/hyde/ext/plugins/requirejs.py @@ -1,6 +1,20 @@ # -*- coding: utf-8 -*- """ requirejs plugin + +Calls r.js optimizer in order to proces javascript files, +bundle them into one single file and compress it. + +The call to r.js is being made with options -o and out. Example: + + r.js -o rjs.conf out=app.js + +whereas rjs.conf is the require.js configuration file pointing +to the main javascript file as well as passing options to r.js. +The bundled and compressed result is written to 'app.js' file +within the deployment structure. + +Please see the homepage of requirejs for usage details. """ from hyde.plugin import CLTransformer @@ -9,7 +23,6 @@ from hyde.fs import File import re import subprocess - class RequireJSPlugin(CLTransformer): def __init__(self, site): @@ -19,23 +32,13 @@ class RequireJSPlugin(CLTransformer): def executable_name(self): return "r.js" - def _should_replace_imports(self, resource): - return getattr(resource, 'meta', {}).get('uses_template', True) - def begin_site(self): - """ - Find the rjs conf file and set their relative deploy path. - """ for resource in self.site.content.walk_resources(): if resource.source_file.name == "rjs.conf": new_name = "app.js" target_folder = File(resource.relative_deploy_path).parent resource.relative_deploy_path = target_folder.child(new_name) - @property - def plugin_name(self): - return "requirejs" - def text_resource_complete(self, resource, text): if not resource.source_file.name == 'rjs.conf': return