Skip to content
Browse files

Stylus mw now configurable, tweaks to blocks to enable better working…

… in 0.5.9.
  • Loading branch information...
1 parent de7c2c2 commit f6459b2928e5936f03c57581a16f7e5c1ede3ba1 @cliftonc committed Oct 21, 2011
Showing with 27 additions and 20 deletions.
  1. +0 −1 .gitignore
  2. +19 −17 app.js
  3. +7 −2 lib/Blocks.js
  4. +1 −0 lib/conf/default.json
View
1 .gitignore
@@ -13,5 +13,4 @@ conf/*.json
*.swp
*.sock
*.gz
-
*.sass-cache
View
36 app.js
@@ -71,24 +71,26 @@ function bootApplication(next) {
app.mwHelpers = {};
// Stylus
- app.mwHelpers.stylusMiddleware = function (themePath) {
- var mw = stylus.middleware({
- src: themePath + '/stylus',
- dest: themePath + '/public',
- debug: false,
- compile: function (str, path) { // optional, but recommended
- return stylus(str)
- .set('filename', path)
- .set('warn', app.config.get('libraries:stylus:warn'))
- .set('compress', app.config.get('libraries:stylus:compress'));
- }
- });
- mw.tag = 'theme.stylus';
- return mw;
- };
+
// Load placeholder, replaced later
- app.use(app.mwHelpers.stylusMiddleware(''));
-
+ if(app.config.get('libraries:stylus:enabled')) {
+ app.mwHelpers.stylusMiddleware = function (themePath) {
+ var mw = stylus.middleware({
+ src: themePath + '/stylus',
+ dest: themePath + '/public',
+ debug: false,
+ compile: function (str, path) { // optional, but recommended
+ return stylus(str)
+ .set('filename', path)
+ .set('warn', app.config.get('libraries:stylus:warn'))
+ .set('compress', app.config.get('libraries:stylus:compress'));
+ }
+ });
+ mw.tag = 'theme.stylus';
+ return mw;
+ };
+ app.use(app.mwHelpers.stylusMiddleware(''));
+ }
// Static
app.mwHelpers.staticMiddleware = function (themePath) {
var mw = express["static"](themePath + '/public', {maxAge: 86400000});
View
9 lib/Blocks.js
@@ -17,8 +17,13 @@ var rootpath = process.cwd() + '/',
*/
function RenderedBlocks(cache) {
+ // Store the content rendered by modules
this.content = {};
+
+ // Flags to indicate if it should be cached
this.contentCache = {};
+
+ // The cache itself
this.cache = cache;
}
@@ -48,8 +53,8 @@ RenderedBlocks.prototype.set = function (block, content, layout, next) {
*/
RenderedBlocks.prototype.get = function (key, next) {
- // Check to see if the key is a regex
- if (typeof key === 'function') {
+ // Check to see if the key is a regex, for 0.4 and 0.5 nodej
+ if (typeof key === 'object' || typeof key === "function") {
var item, items = [];
for (item in this.content) {
if (this.content.hasOwnProperty(item)) {
View
1 lib/conf/default.json
@@ -62,6 +62,7 @@
},
"libraries":{
"stylus":{
+ "enable":false,
"warn":true,
"compress":false
},

0 comments on commit f6459b2

Please sign in to comment.
Something went wrong with that request. Please try again.