Permalink
Browse files

added the option to publish without generating

  • Loading branch information...
1 parent 8fdb098 commit 03742c345087b1642304f6332bfaac43c5517dbe @laktek committed Aug 26, 2012
View
@@ -38,7 +38,7 @@ module.exports = {
self.bundles = _.extend(self.bundles, config.bundles);
- self.bundleOptions = _.extend(self.bundleOptions, config.bundle_options);
+ self.bundleOptions = _.extend(self.bundleOptions, config.asset_bundling);
},
compileAndMinify: function(template_path, compiler, minifier, callback) {
View
@@ -42,10 +42,6 @@ module.exports = {
config.generator.blank = config.generator.blank || blank;
- config.plugins.generator_hooks = _.extend({
- "console_output": path.join(__dirname, "generator_hooks/console_output")
- }, config.plugins.generator_hooks);
-
generator.setup(config);
console.log("Generating site...");
View
@@ -7,61 +7,66 @@ module.exports = {
output_extension: "html",
shared_content: "shared",
- skip_asset_bundling: ["localhost", "127.0.0.1", ".local"],
+ asset_bundling: {
+ skip_hosts: ["localhost", "127.0.0.1", ".local"],
+ fingerprint: false
+ },
- server: {
- port: 9009,
- cache: {
- "max_age": 0,
- "public": true
- }
- },
+ bundles: {
+ },
generator: {
blank: false,
skip_paths: []
},
- bundles: {
- },
-
publish: {
+ generate: true
},
plugins: {
- cache_store: path.join(__dirname, "cache_store"),
- template_handler: path.join(__dirname, "template_handler"),
- content_handler: path.join(__dirname, "content_handler"),
- template_engine: path.join(__dirname, "template_engines/mustache_engine"),
+ cache_store: path.join(__dirname, "cache_store.js"),
+ template_handler: path.join(__dirname, "template_handler.js"),
+ content_handler: path.join(__dirname, "content_handler.js"),
+ template_engine: path.join(__dirname, "template_engines/mustache_engine.js"),
parsers: {
- ".markdown": path.join(__dirname, "parsers/markdown")
+ ".markdown": path.join(__dirname, "parsers/markdown.js")
},
publishers: {
- "s3": path.join(__dirname, "publishers/s3"),
- "sftp": path.join(__dirname, "publishers/sftp")
+ "s3": path.join(__dirname, "publishers/s3.js"),
+ "sftp": path.join(__dirname, "publishers/sftp.js")
},
compilers: {
- ".js": path.join(__dirname, "compilers/coffee_script"),
- ".css": path.join(__dirname, "compilers/less")
+ ".js": path.join(__dirname, "compilers/coffee_script.js"),
+ ".css": path.join(__dirname, "compilers/less.js")
},
minifiers: {
- ".js": path.join(__dirname, "minifiers/uglify"),
- ".css": path.join(__dirname, "minifiers/cssmin")
+ ".js": path.join(__dirname, "minifiers/uglify.js"),
+ ".css": path.join(__dirname, "minifiers/cssmin.js")
},
helpers: {
- "text_helper": path.join(__dirname, "helpers/text_helper"),
- "list_helper": path.join(__dirname, "helpers/list_helper"),
- "datetime_helper": path.join(__dirname, "helpers/datetime_helper"),
- "asset_bundle_helper": path.join(__dirname, "helpers/asset_bundle_helper")
+ "text_helper": path.join(__dirname, "helpers/text_helper.js"),
+ "list_helper": path.join(__dirname, "helpers/list_helper.js"),
+ "datetime_helper": path.join(__dirname, "helpers/datetime_helper.js"),
+ "asset_bundle_helper": path.join(__dirname, "helpers/asset_bundle_helper.js")
},
generator_hooks: {
+ "console_hook": path.join(__dirname, "generator_hooks/console_output.js"),
+ }
+ },
+
+ server: {
+ port: 9009,
+ cache: {
+ "max_age": 0,
+ "public": true
}
- }
+ }
};
@@ -15,12 +15,21 @@ var bundling_disabled = false;
var skip_hosts = [];
+var fingerprint = false;
+
var build_bundle_tag = function(template_tag, bundle) {
var file_extension = path_utils.getExtension(bundle, null);
var request_basename = path_utils.getBasename(bundle, file_extension);
- var fingerprinted_path = (request_basename + "-" + bundle_fingerprints[bundle].getTime() + file_extension);
- return util.format(template_tag, fingerprinted_path);
+ var output_path;
+
+ if (fingerprint) {
+ output_path = (request_basename + "-" + bundle_fingerprints[bundle].getTime() + file_extension);
+ } else {
+ output_path = (request_basename + file_extension);
+ }
+
+ return util.format(template_tag, output_path);
};
var build_output_file_tag = function(template_tag, bundle_file, source_file) {
@@ -52,11 +61,15 @@ var refresh_all_bundle_fingerprints = function(callback) {
return refresh_bundle_fingerprint();
});
} else {
- callback();
+ return callback();
}
};
- return refresh_bundle_fingerprint();
+ if (fingerprint) {
+ return refresh_bundle_fingerprint();
+ } else {
+ return callback();
+ }
};
var tag_helpers = {};
@@ -124,7 +137,8 @@ module.exports = {
setup: function(config) {
bundles = config.bundles;
- skip_hosts = config.skip_asset_bundling;
+ skip_hosts = config.asset_bundling.skip_hosts;
+ fingerprint = config.asset_bundling.fingerprint;
asset_bundler.setup(config);
}
View
@@ -47,4 +47,5 @@ exports.Utils.DeepExtend = require("./utils/deep_extend.js");
exports.Utils.DeepFstream = require("./utils/deep_fstream.js");
exports.Utils.Helper = require("./utils/helper_utils.js");
exports.Utils.Module = require("./utils/module_utils.js");
+exports.Utils.Object = require("./utils/object_utils.js");
exports.Utils.Path = require("./utils/path_utils.js");
View
@@ -64,34 +64,38 @@ module.exports = {
}
},
- publish: function(supplied_config, selected_strategy) {
+ publish: function(config) {
var self = this;
var strategy_obj = null;
- self.config = _.extend(_.clone(default_config), supplied_config);
+ self.config = config;
- if (selected_strategy) {
- strategy_obj = self.requireStrategy(selected_strategy);
+ if (!config.publish || _.isEmpty(config.publish)) {
+ var error = "No publishing settings found. Specify the publish settings in the config file.";
+ throw(error);
} else {
- if (!supplied_config.publish || _.isEmpty(supplied_config.publish)) {
- var error = "No publishing settings found. Specify the publish settings in the config file.";
- throw(error);
- } else {
- var specified_strategy = self.config.publish.strategy;
- strategy_obj = self.requireStrategy(specified_strategy);
- }
+ var specified_strategy = config.publish.strategy;
+ strategy_obj = self.requireStrategy(specified_strategy);
}
self.getLastPublishedDate();
- site_generator.setup(self.config);
-
- console.log("Generating the site before publishing...");
-
- site_generator.generate(function() {
+ var publish_site = function() {
console.log("Publishing the site...");
self.delegatedPublish(strategy_obj);
- });
+ }
+
+ if(config.publish.generate) {
+ site_generator.setup(config);
+
+ console.log("Generating the site before publishing...");
+
+ site_generator.generate(function() {
+ return publish_site();
+ });
+ } else {
+ return publish_site();
+ }
}
};
View
@@ -42,7 +42,7 @@ module.exports = {
self.client.stat(remote_dir_path, function(err, stats){
if(err || !stats.isDirectory()){
// create directory
- self.client.mkdir(remote_dir_path, 755, function(err){
+ self.client.mkdir(remote_dir_path, 0755, function(err){
if (err) {
throw err;
}
@@ -23,7 +23,7 @@ describe("setup", function(){
"assets/css/global.css": [ "assets/css/initial.js", "assets/css/form.css"],
"assets/css/layouts.css": [ "assets/css/header.css", "assets/css/body.css"]
},
- bundle_options: {
+ asset_bundling: {
"header": {},
"cache": {}
}
@@ -85,7 +85,7 @@ describe("setup", function(){
asset_bundler.setup(sample_config);
- expect(asset_bundler.bundleOptions).toEqual(sample_config.bundle_options);
+ expect(asset_bundler.bundleOptions).toEqual(sample_config.asset_bundling);
});
});
View
@@ -89,20 +89,7 @@ describe("generate a site", function() {
cli.generate(["--blank"]);
- expect(generator.setup).toHaveBeenCalledWith({ "generator": { "blank": true }, "plugins": { "generator_hooks": { "console_output": jasmine.any(String) } } });
- });
-
- it("extend generator hooks with console output hook", function() {
- spyOn(config_handler, "getConfig").andCallFake(function(path, callback) {
- callback({ "generator": { "blank": false }, "plugins": { "generator_hooks": { "sample_hook": {} } } });
- });
- spyOn(generator, "setup");
- spyOn(generator, "generate");
-
- cli.generate([]);
-
- expect(generator.setup).toHaveBeenCalledWith({ "generator": { "blank": false }, "plugins": { "generator_hooks": { "console_output": jasmine.any(String), "sample_hook": {} } } });
-
+ expect(generator.setup).toHaveBeenCalledWith({ "generator": { "blank": true }, "plugins": { "generator_hooks": {} } });
});
it("setup the generator with the supplied config", function() {
@@ -5,14 +5,28 @@ var asset_bundler = require("../../lib/asset_bundler.js");
describe("stylesheet bundle tag", function(){
- it("output the bundled tag when bundling no host is provided", function(){
+ it("output the bundled tag when bundling no host is provided and fingerprint is disabled", function(){
spyOn(asset_bundler, "setup");
spyOn(asset_bundler, "statBundle").andCallFake(function(basename, extension, callback) {
return callback(null, { "mtime": new Date(2012, 7, 25) });
});
- asset_bundle_helper_obj.setup( { "skip_asset_bundling": ["localhost", "127.0.0.1", ".local"], "bundles": { "/assets/all.css": [ "/assets/initial.css", "/assets/site.css" ]} });
+ asset_bundle_helper_obj.setup( { "asset_bundling": { "skip_hosts": ["localhost", "127.0.0.1", ".local"], "fingerprint": false }, "bundles": { "/assets/all.css": [ "/assets/initial.css", "/assets/site.css" ]} });
+ var spyCallback = jasmine.createSpy();
+ asset_bundle_helper_obj.get( "/path/test", ".html", { "host": "" }, spyCallback);
+
+ expect(asset_bundle_helper.stylesheet_bundle("/assets/all.css")).toEqual("<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"/assets/all.css\">");
+ });
+
+ it("output the bundled tag when bundling no host is provided and fingerprint is enabled", function(){
+ spyOn(asset_bundler, "setup");
+
+ spyOn(asset_bundler, "statBundle").andCallFake(function(basename, extension, callback) {
+ return callback(null, { "mtime": new Date(2012, 7, 25) });
+ });
+
+ asset_bundle_helper_obj.setup( { "asset_bundling": { "skip_hosts": ["localhost", "127.0.0.1", ".local"], "fingerprint": true }, "bundles": { "/assets/all.css": [ "/assets/initial.css", "/assets/site.css" ]} });
var spyCallback = jasmine.createSpy();
asset_bundle_helper_obj.get( "/path/test", ".html", { "host": "" }, spyCallback);
@@ -26,7 +40,7 @@ describe("stylesheet bundle tag", function(){
return callback(null, { "mtime": new Date(2012, 7, 25) });
});
- asset_bundle_helper_obj.setup( { "skip_asset_bundling": ["localhost", "127.0.0.1", ".local"], "bundles": { "/assets/all.css": [ "/assets/initial.css", "/assets/site.less" ]} });
+ asset_bundle_helper_obj.setup( { "asset_bundling": { "skip_hosts": ["localhost", "127.0.0.1", ".local"] }, "bundles": { "/assets/all.css": [ "/assets/initial.css", "/assets/site.less" ]} });
var spyCallback = jasmine.createSpy();
asset_bundle_helper_obj.get( "/path/test", ".html", { "host": "localhost:9009" }, spyCallback);
@@ -37,14 +51,28 @@ describe("stylesheet bundle tag", function(){
describe("javascript bundle tag", function(){
- it("output the bundled tag when host is undefined", function(){
+ it("output the bundled tag when host is undefined and fingerprint is disabled", function(){
+ spyOn(asset_bundler, "setup");
+
+ spyOn(asset_bundler, "statBundle").andCallFake(function(basename, extension, callback) {
+ return callback(null, { "mtime": new Date(2012, 7, 25) });
+ });
+
+ asset_bundle_helper_obj.setup( { "asset_bundling": { "skip_hosts": ["localhost", "127.0.0.1", ".local"], "fingerprint": false }, "bundles": { "/assets/all.js": [ "/assets/jquery.js", "/assets/site.js" ]} });
+ var spyCallback = jasmine.createSpy();
+ asset_bundle_helper_obj.get( "/path/test", ".html", { "host": undefined }, spyCallback);
+
+ expect(asset_bundle_helper.javascript_bundle("/assets/all.js")).toEqual("<script src=\"/assets/all.js\"></script>");
+ });
+
+ it("output the bundled tag when host is undefined and fingerprint is enabled", function(){
spyOn(asset_bundler, "setup");
spyOn(asset_bundler, "statBundle").andCallFake(function(basename, extension, callback) {
return callback(null, { "mtime": new Date(2012, 7, 25) });
});
- asset_bundle_helper_obj.setup( { "skip_asset_bundling": ["localhost", "127.0.0.1", ".local"], "bundles": { "/assets/all.js": [ "/assets/jquery.js", "/assets/site.js" ]} });
+ asset_bundle_helper_obj.setup( { "asset_bundling": { "skip_hosts": ["localhost", "127.0.0.1", ".local"], "fingerprint": true }, "bundles": { "/assets/all.js": [ "/assets/jquery.js", "/assets/site.js" ]} });
var spyCallback = jasmine.createSpy();
asset_bundle_helper_obj.get( "/path/test", ".html", { "host": undefined }, spyCallback);
@@ -58,7 +86,7 @@ describe("javascript bundle tag", function(){
return callback(null, { "mtime": new Date(2012, 7, 25) });
});
- asset_bundle_helper_obj.setup( { "skip_asset_bundling": ["localhost", "127.0.0.1", ".local"], "bundles": { "/assets/all.js": [ "/assets/jquery.js", "/assets/site.coffee" ]} });
+ asset_bundle_helper_obj.setup( { "asset_bundling": { "skip_hosts": ["localhost", "127.0.0.1", ".local"] }, "bundles": { "/assets/all.js": [ "/assets/jquery.js", "/assets/site.coffee" ]} });
var spyCallback = jasmine.createSpy();
asset_bundle_helper_obj.get( "/path/test", ".html", { "host": "localhost:9009" }, spyCallback);
Oops, something went wrong.

0 comments on commit 03742c3

Please sign in to comment.