Comparing version 0.5.5 to 0.5.7
@@ -5,2 +5,3 @@ var coffee_script = require("coffee-script"); | ||
compiler_options: {}, | ||
force_compile: false, | ||
@@ -7,0 +8,0 @@ input_extensions: [".coffee"], |
@@ -6,2 +6,3 @@ var less = require("less"); | ||
input_extensions: [".less"], | ||
force_compile: true, | ||
@@ -8,0 +9,0 @@ compile: function(input, filename, callback){ |
@@ -265,6 +265,12 @@ var _ = require("underscore"); | ||
if (file.indexOf(".") > 0 || file[0] === "_") { | ||
var basename = file.split(".")[0]; | ||
var basename; | ||
if (basename[0] === "_") { | ||
basename = basename.substr(1); | ||
// given entry is a extended directory | ||
if (file[0] === "_") { | ||
basename = file.substr(1); | ||
} else { | ||
// given entry is a JSON file | ||
var path_portions = file.split("."); | ||
path_portions.pop(); //remove the final extension | ||
basename = path_portions.join("."); | ||
} | ||
@@ -285,3 +291,3 @@ | ||
// provide the best matching content for the given arguments | ||
negotiateContent: function(basepath, content_type, options, callback) { | ||
negotiateContent: function(basepath, output_extension, options, callback) { | ||
var self = this; | ||
@@ -292,2 +298,7 @@ var collected_contents = {}; | ||
// treat files with special output extensions | ||
if (output_extension !== ".html") { | ||
basepath = basepath + output_extension; | ||
} | ||
self.getContent(basepath, function(err, contents, modified_date) { | ||
@@ -294,0 +305,0 @@ if (!err) { |
@@ -10,3 +10,3 @@ module.exports = { | ||
} else if (file_path && !modified) { | ||
process.stdout.write(".") | ||
process.stdout.write("."); | ||
} | ||
@@ -13,0 +13,0 @@ |
@@ -125,3 +125,3 @@ var _ = require("underscore"); | ||
if (_.include(compiler.input_extensions, template_extension)) { | ||
if (template.last_modified > last_modified) { | ||
if (compiler.force_compile || template.last_modified > last_modified) { | ||
@@ -128,0 +128,0 @@ self.templates.readTemplate(template.full_path, function(err, template_output) { |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "0.5.5", | ||
"version": "0.5.7", | ||
"homepage": "https://github.com/laktek/punch", | ||
@@ -18,0 +18,0 @@ "author": "Lakshan Perera <lakshan@web2media.net> (http://laktek.com)", |
@@ -310,2 +310,10 @@ var default_handler = require("../lib/content_handler.js"); | ||
it("get the content for a path with special output format", function(){ | ||
spyOn(default_handler, "getContent"); | ||
var spyCallback = jasmine.createSpy(); | ||
default_handler.negotiateContent("path/test", ".rss", {}, spyCallback); | ||
expect(default_handler.getContent.mostRecentCall.args[0]).toEqual("path/test.rss"); | ||
}); | ||
it("extend it with shared contents", function(){ | ||
@@ -398,2 +406,13 @@ spyOn(default_handler, "getContent").andCallFake(function(path, callback){ | ||
it("collect files with special output extensions", function(){ | ||
spyOn(fs, "readdir").andCallFake(function(path, callback) { | ||
return callback(null, ["index.json", "page1.json", "page1.rss.json", "page2.json", "_shared"]); | ||
}); | ||
var spyCallback = jasmine.createSpy(); | ||
default_handler.getContentPaths("path/test", spyCallback); | ||
expect(spyCallback).toHaveBeenCalledWith(null, ["path/test/index", "path/test/page1", "path/test/page1.rss", "path/test/page2"]); | ||
}); | ||
it("collect the extended directories", function(){ | ||
@@ -400,0 +419,0 @@ spyOn(fs, "readdir").andCallFake(function(path, callback){ |
@@ -347,7 +347,7 @@ var renderer = require("../lib/page_renderer.js"); | ||
it("call the callback without an output if template is not modified", function() { | ||
it("call the callback without an output if force compile option is disabled and template is not modified", function() { | ||
var spyCompile = jasmine.createSpy(); | ||
renderer.compilers = { | ||
".js": { "compile": spyCompile, "input_extensions": [".coffee"] } | ||
".js": { "compile": spyCompile, "input_extensions": [".coffee"], "force_compile": false } | ||
}; | ||
@@ -379,2 +379,33 @@ | ||
it("call compile if force compile option is enabled and template is not modified", function() { | ||
var spyCompile = jasmine.createSpy(); | ||
renderer.compilers = { | ||
".css": { "compile": spyCompile, "input_extensions": [".less"], "force_compile": true } | ||
}; | ||
var spyGetTemplates = jasmine.createSpy(); | ||
spyGetTemplates.andCallFake(function(basepath, callback) { | ||
callback(null, [{ "full_path": "path/test.html", "last_modified": new Date(2012, 6, 13) }, | ||
{ "full_path": "path/test.less", "last_modified": new Date(2012, 6, 13) } | ||
]); | ||
}); | ||
var spyReadTemplate = jasmine.createSpy(); | ||
spyReadTemplate.andCallFake(function(path, callback) { | ||
callback(null, "template output"); | ||
}); | ||
renderer.templates = { | ||
"getTemplates": spyGetTemplates, | ||
"readTemplate": spyReadTemplate, | ||
"templateDir": "templates" | ||
}; | ||
var spyCallback = jasmine.createSpy(); | ||
renderer.compileTo("path/test.css", ".css", new Date(2012, 11, 25), spyCallback); | ||
expect(spyCompile).toHaveBeenCalledWith("template output", "templates/path/test.less", jasmine.any(Function)); | ||
}); | ||
it("call the callback with an error if no compiler found for the given content type", function() { | ||
@@ -381,0 +412,0 @@ var spyCompile = jasmine.createSpy(); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1890355
183
10690