Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

working on package.json layouts for npm install

  • Loading branch information...
commit 9217796c2c5d49debc661d14bbc660e4fb878153 1 parent 01571c5
@aconbere authored
View
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010 Anders Conbere
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
13 bin/boxer.js
@@ -0,0 +1,13 @@
+#!/usr/bin/env node
+
+var sys = require('sys');
+
+var options = require('./options').options;
+var inputHandlers = require("./input_handlers");
+var outputHandlers = require("./output_handlers");
+
+var Collector = require('../lib/collector').Collector;
+
+var collector = new Collector(options.input, options.output,
+ inputHandlers, outputHandlers);
+collector.run();
View
35 bin/input_handlers.js
@@ -0,0 +1,35 @@
+var path = require('path');
+var sys = require('sys');
+var mustache = require("mustache");
+
+exports.templates = function (template) {
+ template.outputPath = false;
+ template.render = function (context) {
+ return mustache.to_html(this.body, context);
+ };
+ return template;
+}
+
+exports.posts = function (post) {
+ var published;
+
+ if (post.headers.published) {
+ var args = post.headers.published.split(/[-: ]/);
+ if (args.length >= 3) {
+ published = new Date(args[0], args[1], args[2]);
+ } else if (args.length >= 6) {
+ published = new Date(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
+ }
+ } else {
+ published = new Date();
+ }
+
+ post.ext = path.extname(post.filePath);
+ post.basename= path.basename(post.filePath, post.ext);
+ post.outputPath = "posts/" + published.getFullYear() + "/"
+ + published.getMonth() + "/"
+ + published.getDate() + "/"
+ + post.basename + "/"
+ + "index.html";
+ return post;
+};
View
50 bin/options.js
@@ -0,0 +1,50 @@
+var sys = require('sys');
+var path = require('path');
+var optparse = require('optparse');
+var file = require('file/main');
+
+var options = { "input": null
+ , "output": null
+ , "verbose": false
+ };
+
+var switches = [ ['-h', '--help', 'Shows help sections']
+ , ['-v', '--verbose', 'Verbose Output']
+ ];
+
+var parser = new optparse.OptionParser(switches);
+var banner = 'boxer input output [-vh]';
+
+parser.on('help', function() {
+ sys.p(banner);
+ process.exit();
+});
+
+parser.on(2, function(val) {
+ val = file.path.join(process.cwd(), val);
+ path.exists(val, function(exists) {
+ if(!exists) {
+ sys.puts("Input path " + val + " does not exist");
+ parser.halt();
+ }
+ });
+ options.input = val;
+});
+
+parser.on(3, function(val) {
+ options.output = file.path.join(process.cwd(), val);
+});
+
+parser.on('verbose', function() {
+ options.verbose = true;
+});
+
+parser.parse(process.argv);
+
+if (!options.input || !options.output) {
+ sys.puts("both input and output must be given\n" + banner);
+ process.exit();
+}
+
+exports.options = options;
+exports.parser = parser;
View
30 bin/output_handlers.js
@@ -0,0 +1,30 @@
+var sys = require('sys');
+var markdown = require("markdown");
+
+var markup = {};
+
+markup[".mkd"] = function (body) {
+ return markdown.parse(body);
+};
+
+
+exports.posts = function (post, collector) {
+ if (markup[post.ext]) {
+ post.body = markup[post.ext](post.body);
+ }
+
+ collector.context.post = post.context();
+ return post;
+};
+
+exports.postProcessing = function (item, collector) {
+ if (item.headers.template) {
+ var templates = collector.findByRelPath("_templates/" + item.headers.template);
+ var template = templates[0];
+
+ if (template) {
+ item.body = template.render(collector.context);
+ }
+ }
+ return item;
+};
View
12 lib/boxer.js
@@ -1,10 +1,2 @@
-var sys = require('sys');
-
-var options = require('./options').options;
-var Collector = require('./collector').Collector;
-var inputHandlers = require("./input_handlers");
-var outputHandlers = require("./output_handlers");
-
-var collector = new Collector(options.input, options.output,
- inputHandlers, outputHandlers);
-collector.run();
+exports.Collector = require("./collector").Collector;
+exports.Item = require("./collector").Item;
View
2  lib/collector.js
@@ -60,8 +60,6 @@ Collector.prototype.process = function () {
that.outputHandlers.preProcessing(item, that);
}
- sys.puts("this wasn't being called");
- sys.p(item);
// calls label specific output handlers
if (item.label && that.outputHandlers[item.label]) {
that.outputHandlers[item.label](item, that);
View
4 lib/item.js
@@ -1,10 +1,8 @@
var fs = require("fs");
var sys = require("sys");
var path = require("path");
-var kiwi = require("kiwi");
-
var dir = require("./dir");
-var yaml = kiwi.require("yaml");
+var yaml = require("yaml");
var Item = function (origin, filePath, label) {
this.origin = origin;
View
20 package.json
@@ -0,0 +1,20 @@
+{ "name" : "boxer"
+, "description" : "A Static Website Publishing Tool"
+, "version" : "0.0.1"
+, "author" : "Anders Conbere <aconberei@conbere.org>"
+, "repository" :
+ { "type" : "git"
+ , "url" : "http://github.com/aconbere/boxer.git"
+ }
+, "bugs" :
+ { "mail" : "npm-@googlegroups.com"
+ , "web" : "http://github.com/aconbere/boxer/issues"
+ }
+, "os" : [ "linux", "darwin", "freebsd" ]
+, "directories" : { "lib" : "./lib/" }
+, "main" : "./lib/boxer"
+, "bin" : { "boxer" : "./bin/boxer.js" }
+, "engines" : { "node" : ">=0.1.93" }
+, "licenses" :
+ [ { "type" : "MIT" } ]
+}
Please sign in to comment.
Something went wrong with that request. Please try again.