Comparing version 0.4.7 to 0.4.8
@@ -9,3 +9,2 @@ var path = require("path"); | ||
//setup the module | ||
setup: function(config){ | ||
@@ -58,2 +57,3 @@ var self = this; | ||
var header = (rendered_obj.options && rendered_obj.options.header) || {}; | ||
var encoding = (file_extension === ".html") ? "utf8" : "binary"; | ||
@@ -64,4 +64,4 @@ var file_path = path.join(self.outputDir, (request_basename + file_extension)); | ||
var writeToCache = function() { | ||
fs.writeFile(file_path, body, "binary", function(err){ | ||
var write_to_cache = function() { | ||
fs.writeFile(file_path, body, encoding, function(err){ | ||
if (err) { | ||
@@ -86,10 +86,10 @@ return callback(err); | ||
var checkAndCreateDir = function(dirpath){ | ||
var check_and_create_dir = function(dirpath){ | ||
fs.stat(dirpath, function(err, stat){ | ||
if(err || !stat.isDirectory()){ | ||
fs.mkdir(dirpath, function(){ | ||
return checkAndCreateDirCallback(dirpath); | ||
return check_and_create_dir_callback(dirpath); | ||
}); | ||
} else { | ||
return checkAndCreateDirCallback(dirpath); | ||
return check_and_create_dir_callback(dirpath); | ||
} | ||
@@ -99,11 +99,11 @@ }); | ||
var checkAndCreateDirCallback = function(current_path){ | ||
var check_and_create_dir_callback = function(current_path){ | ||
if(dir_path_portions.length){ | ||
var next_dirpath = path.join(current_path, dir_path_portions.shift()); | ||
return checkAndCreateDir(next_dirpath); | ||
return check_and_create_dir(next_dirpath); | ||
} else { | ||
return writeToCache(); | ||
return write_to_cache(); | ||
} | ||
}; | ||
checkAndCreateDirCallback(""); | ||
check_and_create_dir_callback(""); | ||
}, | ||
@@ -110,0 +110,0 @@ |
var path = require("path"); | ||
var _ = require("underscore"); | ||
var setup = require(path.join(__dirname, "../lib/setup.js")); | ||
var project_creator = require(path.join(__dirname, "../lib/project_creator.js")); | ||
var generator = require(path.join(__dirname, "../lib/site_generator.js")); | ||
@@ -28,5 +28,5 @@ var server = require(path.join(__dirname, "../lib/server.js")); | ||
if (template_path) { | ||
return setup.createStructure(args.pop(), template_path); | ||
return project_creator.createStructure(args.pop(), template_path); | ||
} else { | ||
return setup.createStructure(args.pop()); | ||
return project_creator.createStructure(args.pop()); | ||
} | ||
@@ -33,0 +33,0 @@ }, |
@@ -6,3 +6,3 @@ var _ = require("underscore"); | ||
var default_config = require("./default_config.js"); | ||
var deepExtend = require("./utils/deep_extend.js"); | ||
var deep_extend = require("./utils/deep_extend.js"); | ||
@@ -113,4 +113,4 @@ module.exports = { | ||
} else { | ||
var default_config_clone = deepExtend({}, default_config); | ||
return callback(deepExtend(default_config_clone, user_defined_config)); | ||
var default_config_clone = deep_extend({}, default_config); | ||
return callback(deep_extend(default_config_clone, user_defined_config)); | ||
} | ||
@@ -117,0 +117,0 @@ }); |
@@ -44,3 +44,2 @@ var _ = require("underscore"); | ||
var refresh_all_bundle_fingerprints = function(callback) { | ||
@@ -81,3 +80,3 @@ var bundle_names = _.keys(bundles); | ||
stylesheet_bundle: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
var stylesheet_tag = "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"%s\">"; | ||
@@ -100,3 +99,3 @@ if (!bundling_disabled) { | ||
javascript_bundle: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
var javascript_tag = "<script src=\"%s\"></script>"; | ||
@@ -121,2 +120,10 @@ if (!bundling_disabled) { | ||
setup: function(config) { | ||
bundles = config.bundles; | ||
skip_hosts = config.asset_bundling.skip_hosts; | ||
fingerprint = config.asset_bundling.fingerprint; | ||
asset_bundler.setup(config); | ||
}, | ||
directAccess: function(){ | ||
@@ -142,10 +149,2 @@ return { "tag_helpers": tag_helpers, "block_helpers": block_helpers, "options": {} }; | ||
setup: function(config) { | ||
bundles = config.bundles; | ||
skip_hosts = config.asset_bundling.skip_hosts; | ||
fingerprint = config.asset_bundling.fingerprint; | ||
asset_bundler.setup(config); | ||
} | ||
}; |
@@ -16,3 +16,3 @@ var helper_utils = require("../utils/helper_utils.js"); | ||
datetime: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -27,3 +27,3 @@ return ""; | ||
date: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -38,3 +38,3 @@ return ""; | ||
time: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -49,3 +49,3 @@ return ""; | ||
iso_date: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -52,0 +52,0 @@ return ""; |
@@ -5,3 +5,4 @@ var fs = require("fs"); | ||
var tag_helpers = { | ||
"first-run": function() { | ||
first_run: function() { | ||
var first_run_js = fs.readFileSync(path.join(__dirname, "first_run/first_run.js")); | ||
@@ -14,2 +15,3 @@ var first_run_css = fs.readFileSync(path.join(__dirname, "first_run/first_run.css")); | ||
} | ||
}; | ||
@@ -16,0 +18,0 @@ |
@@ -36,5 +36,5 @@ /*jshint regexp: false */ | ||
"step8": "Woah! Look you just created a nice little site with Punch :)\bTo learn further on the concepts we touched upon and discover other great features in Punch, you can peruse [Punch Guide](https://github.com/laktek/punch/wiki).\bTo remove this block, go to `templates/_footer.mustache` and remove the tag `{{{first-run}}}`.\bHappy Hacking!", | ||
"step8": "Woah! Look you just created a nice little site with Punch :)\bTo learn further on the concepts we touched upon and discover other great features in Punch, you can peruse [Punch Guide](https://github.com/laktek/punch/wiki).\bTo remove this block, go to `templates/_footer.mustache` and remove the tag `{{{first_run}}}`.\bHappy Hacking!", | ||
"skip": "To remove this block, go to `templates/_footer.mustache` and remove the tag `{{{first-run}}}`.\bBTW, [Punch Guide](https://github.com/laktek/punch/wiki) might come in handy, when you want to refer how to get certain things done.\bHappy Hacking!" | ||
"skip": "To remove this block, go to `templates/_footer.mustache` and remove the tag `{{{first_run}}}`.\bBTW, [Punch Guide](https://github.com/laktek/punch/wiki) might come in handy, when you want to refer how to get certain things done.\bHappy Hacking!" | ||
}; | ||
@@ -41,0 +41,0 @@ |
@@ -10,3 +10,3 @@ var helper_utils = require("../utils/helper_utils.js"); | ||
format_list: function() { | ||
return helper_utils.check_args(arguments, arg_condition, function(text) { | ||
return helper_utils.checkArgs(arguments, arg_condition, function(text) { | ||
var arr = []; | ||
@@ -32,3 +32,3 @@ | ||
first: function() { | ||
return helper_utils.check_args(arguments, arg_condition, function(text) { | ||
return helper_utils.checkArgs(arguments, arg_condition, function(text) { | ||
var arr = []; | ||
@@ -49,3 +49,3 @@ | ||
last: function() { | ||
return helper_utils.check_args(arguments, arg_condition, function(text) { | ||
return helper_utils.checkArgs(arguments, arg_condition, function(text) { | ||
var arr = []; | ||
@@ -52,0 +52,0 @@ |
@@ -8,3 +8,3 @@ var helper_utils = require("../utils/helper_utils.js"); | ||
upcase: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -19,3 +19,3 @@ return ""; | ||
downcase: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -30,3 +30,3 @@ return ""; | ||
capitalize: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -41,3 +41,3 @@ return ""; | ||
titleize: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -52,3 +52,3 @@ return ""; | ||
trim: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -63,3 +63,3 @@ return ""; | ||
humanize: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -74,3 +74,3 @@ return ""; | ||
dasherize: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -85,3 +85,3 @@ return ""; | ||
underscored: function() { | ||
return helper_utils.check_args(arguments, function(text) { | ||
return helper_utils.checkArgs(arguments, function(text) { | ||
if(!text) { | ||
@@ -88,0 +88,0 @@ return ""; |
@@ -8,4 +8,4 @@ exports.AssetBundler = require("./asset_bundler.js"); | ||
exports.Publisher = require("./publisher.js"); | ||
exports.ProjectCreator = require("./project_creator.js"); | ||
exports.Server = require("./server.js"); | ||
exports.Setup = require("./setup.js"); | ||
exports.SiteGenerator = require("./site_generator.js"); | ||
@@ -12,0 +12,0 @@ exports.TemplateHandler = require("./template_handler.js"); |
@@ -6,3 +6,3 @@ var cssminPkg = require("cssmin"); | ||
minify: function(input, callback){ | ||
minify: function(input, callback) { | ||
var self = this; | ||
@@ -12,3 +12,3 @@ var output, err; | ||
try { | ||
output = cssminPkg.cssmin(input); // compressed code here | ||
output = cssminPkg.cssmin(input); | ||
} catch(error) { | ||
@@ -15,0 +15,0 @@ err = error; |
@@ -9,3 +9,3 @@ var jsp = require("uglify-js").parser; | ||
minify: function(input, callback){ | ||
minify: function(input, callback) { | ||
var self = this; | ||
@@ -12,0 +12,0 @@ var output, err; |
@@ -48,3 +48,3 @@ var _ = require("underscore"); | ||
var get_helper_content = function(helper, helper_callback){ | ||
var get_helper_content = function(helper, helper_callback) { | ||
helper.get(basepath, output_extension, options, function(err, helper_tags, helper_options, last_modified){ | ||
@@ -65,3 +65,3 @@ if (!err) { | ||
var get_helper_callback = function(){ | ||
var get_helper_callback = function() { | ||
if (cloned_helpers.length) { | ||
@@ -73,2 +73,3 @@ return get_helper_content(cloned_helpers.shift(), get_helper_callback); | ||
}; | ||
return get_helper_callback(); | ||
@@ -223,8 +224,6 @@ }, | ||
} | ||
} else if(!err.ignore){ | ||
} else if (!err.ignore) { | ||
return callback({ "body": null, "modified": true, "options": { "status": 500, "log": { "message": "[Error] " + err.message } } }); | ||
} else { | ||
if (rendering_steps.length) { | ||
} else if (rendering_steps.length) { | ||
return rendering_steps.shift().call(); | ||
} | ||
} | ||
@@ -231,0 +230,0 @@ }; |
@@ -19,2 +19,18 @@ var url = require("url"); | ||
setup: function(config){ | ||
var self = this; | ||
self.cacheSettings = (config.server && config.server.cache) || {}; | ||
renderer.setup(config); | ||
asset_bundler.setup(config); | ||
self.cacheStore = module_utils.requireAndSetup(config.plugins.cache_store, config); | ||
return function(req, res, next){ | ||
return self.handle(req, res, next); | ||
}; | ||
}, | ||
setCacheExpiryHeaders: function(header, cache_settings) { | ||
@@ -42,3 +58,3 @@ var cache_control = ( cache_settings.directives && cache_settings.directives.slice(0) ) || []; | ||
sendResponse: function(response, status_code, headers, body){ | ||
sendResponse: function(response, status_code, headers, body) { | ||
var encoding = (headers["Content-Type"].split(";")[0] === "text/html") ? "utf8" : "binary"; | ||
@@ -244,18 +260,2 @@ | ||
setup: function(config){ | ||
var self = this; | ||
self.cacheSettings = (config.server && config.server.cache) || {}; | ||
renderer.setup(config); | ||
asset_bundler.setup(config); | ||
self.cacheStore = module_utils.requireAndSetup(config.plugins.cache_store, config); | ||
return function(req, res, next){ | ||
return self.handle(req, res, next); | ||
}; | ||
} | ||
}; |
@@ -18,3 +18,2 @@ /* | ||
//set default options | ||
marked.setOptions(self.markedOptions); | ||
@@ -21,0 +20,0 @@ |
@@ -63,3 +63,3 @@ var _ = require("underscore"); | ||
collectSections: function(callback){ | ||
collectSections: function(callback) { | ||
var self = this; | ||
@@ -76,3 +76,3 @@ var collected_sections = []; | ||
getStaticAndCompilableTemplates: function(section, callback){ | ||
getStaticAndCompilableTemplates: function(section, callback) { | ||
var self = this; | ||
@@ -79,0 +79,0 @@ var collected_paths = []; |
@@ -9,4 +9,3 @@ var _ = require("underscore"); | ||
//setup the module | ||
setup: function(config){ | ||
setup: function(config) { | ||
var self = this; | ||
@@ -16,4 +15,4 @@ self.templateDir = config.template_dir; | ||
// check whether the given path is a top level path | ||
isSection: function(template_path){ | ||
// check whether the given path is a top level path | ||
isSection: function(template_path) { | ||
var self = this; | ||
@@ -38,3 +37,3 @@ | ||
// get the template matching the exact path | ||
getTemplate: function(template_path, callback){ | ||
getTemplate: function(template_path, callback) { | ||
var self = this; | ||
@@ -56,3 +55,3 @@ | ||
// get all templates fuzzly matches the path | ||
getTemplates: function(basepath, callback){ | ||
getTemplates: function(basepath, callback) { | ||
var self = this; | ||
@@ -100,3 +99,3 @@ | ||
// reads and outputs the template matching the exact path | ||
readTemplate: function(template_path, callback){ | ||
readTemplate: function(template_path, callback) { | ||
var self = this; | ||
@@ -113,3 +112,3 @@ | ||
// read the best template fuzzly matches the path | ||
// read the best template fuzzly matches the path | ||
negotiateTemplate: function(basepath, output_extension, template_extension, options, callback) { | ||
@@ -164,3 +163,3 @@ var self = this; | ||
// get all partials matching the given path | ||
getPartials: function(basepath, extension, options, callback){ | ||
getPartials: function(basepath, extension, options, callback) { | ||
var self = this; | ||
@@ -236,3 +235,3 @@ | ||
// returns all available template sections | ||
getSections: function(callback){ | ||
getSections: function(callback) { | ||
var self = this; | ||
@@ -239,0 +238,0 @@ var sections = ["/"]; |
module.exports = { | ||
check_args: function() { | ||
checkArgs: function() { | ||
var args, condition, callback; | ||
@@ -5,0 +5,0 @@ |
@@ -5,3 +5,3 @@ { | ||
, "keywords": ["static site", "framework", "web publishing", "generator", "minfier", "server", "mustache", "json", "markdown"] | ||
, "version": "0.4.7" | ||
, "version": "0.4.8" | ||
, "homepage": "https://github.com/laktek/punch" | ||
@@ -8,0 +8,0 @@ , "author": "Lakshan Perera <lakshan@web2media.net> (http://laktek.com)" |
@@ -122,4 +122,16 @@ var fs = require("fs"); | ||
expect(fs.writeFile.mostRecentCall.args.splice(0, 2)).toEqual(["output_dir/path/subdir/test.html", "test"]); | ||
expect(fs.writeFile).toHaveBeenCalledWith("output_dir/path/subdir/test.html", "test", "utf8", jasmine.any(Function)); | ||
}); | ||
it("set the correct encoding", function(){ | ||
spyOn(fs, "stat").andCallFake(function(dirpath, callback){ | ||
return callback(null, {"isDirectory": function(){ return true }}); | ||
}); | ||
spyOn(fs, "writeFile"); | ||
var spyCallback = jasmine.createSpy(); | ||
cache_store.update("path/subdir/test", ".jpg", { "body": "test", "options": { "header": {} } }, {}, spyCallback); | ||
expect(fs.writeFile).toHaveBeenCalledWith("output_dir/path/subdir/test.jpg", "test", "binary", jasmine.any(Function)); | ||
}); | ||
@@ -126,0 +138,0 @@ |
var cli = require("../lib/cli.js"); | ||
var setup = require("../lib/setup.js"); | ||
var project_creator = require("../lib/project_creator.js"); | ||
var server = require("../lib/server.js"); | ||
@@ -40,31 +40,31 @@ var generator = require("../lib/site_generator.js"); | ||
it("create a site in target path with default template", function() { | ||
spyOn(setup, "createStructure"); | ||
spyOn(project_creator, "createStructure"); | ||
cli.setup(["path/target"]); | ||
expect(setup.createStructure).toHaveBeenCalledWith("path/target"); | ||
expect(project_creator.createStructure).toHaveBeenCalledWith("path/target"); | ||
}); | ||
it("create a site in target path with given template", function() { | ||
spyOn(setup, "createStructure"); | ||
spyOn(project_creator, "createStructure"); | ||
cli.setup(["--template", "path/to/template", "path/target"]); | ||
expect(setup.createStructure).toHaveBeenCalledWith("path/target", "path/to/template"); | ||
expect(project_creator.createStructure).toHaveBeenCalledWith("path/target", "path/to/template"); | ||
}); | ||
it("create a site in current path with given template", function() { | ||
spyOn(setup, "createStructure"); | ||
spyOn(project_creator, "createStructure"); | ||
cli.setup(["-t", "path/to/template"]); | ||
expect(setup.createStructure).toHaveBeenCalledWith(undefined, "path/to/template"); | ||
expect(project_creator.createStructure).toHaveBeenCalledWith(undefined, "path/to/template"); | ||
}); | ||
it("create a site in current path with default template", function() { | ||
spyOn(setup, "createStructure"); | ||
spyOn(project_creator, "createStructure"); | ||
cli.setup([]); | ||
expect(setup.createStructure).toHaveBeenCalledWith(undefined); | ||
expect(project_creator.createStructure).toHaveBeenCalledWith(undefined); | ||
}); | ||
@@ -71,0 +71,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
177
10416
1747364