Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- some progress

  • Loading branch information...
commit d818edeaf8a620e9cbdad6f59fc434f7e47ed0d4 1 parent a503857
@SamuraiJack SamuraiJack authored
View
97 bin/joose.js
@@ -0,0 +1,97 @@
+var argv = require('optimist')
+ .usage('Usage: $0 {OPTIONS}')
+ .wrap(80)
+ .option('port', {
+ alias : 'p',
+ desc : 'The port to listen for connections'
+ })
+ .option('webroot', {
+ alias : 'r',
+ desc : 'A path directory which will act as a web root. Default is current working directory'
+ })
+// .option('entry', {
+// alias : 'e',
+// desc : 'An entry point of your app'
+// })
+// .option('alias', {
+// alias : 'a',
+// desc : 'Register an alias with a colon separator: "to:from"\n'
+// + "Example: --alias 'jquery:jquery-browserify'"
+// })
+// .option('plugin', {
+// alias : 'p',
+// desc : 'Use a plugin. Use a colon separator to specify additional '
+// + 'plugin arguments as a JSON string.\n'
+// + 'Example: --plugin \'fileify:["files","."]\''
+// })
+ .option('help', {
+ alias : 'h',
+ desc : 'Show this message'
+ })
+ .check(function (argv) {
+ if (argv.help) throw ''
+ })
+ .argv
+
+
+var url = require('url')
+var path = require('path')
+var http = require('http')
+var paperboy = require('paperboy')
+
+var port = argv.port || 5000
+var webRoot = path.resolve(argv.webroot || './')
+
+var librarian = new require('librarian')({
+
+ webRoot : webRoot
+})
+
+
+http.createServer(function(req, res) {
+
+ var pathName = path.normalize(url.parse(req.url).pathname)
+
+ if (/\.\.\//.test(pathName)) throw new Error("Can't serve the files above the webRoot directory")
+
+
+ librarian.find(pathName, function () {
+
+ var ip = req.connection.remoteAddress;
+
+ paperboy
+ .deliver(webRoot, req, res)
+ .addHeader('Expires', 300)
+ .addHeader('X-PaperRoute', 'Node')
+ .addHeader('Content-Type', 'text/plain')
+ .before(function() {
+ console.log('Received Request');
+ })
+ .after(function(statCode) {
+ log(statCode, req.url, ip);
+ })
+ .error(function(statCode, msg) {
+ res.writeHead(statCode, {'Content-Type': 'text/plain'});
+ res.end("Error " + statCode);
+ log(statCode, req.url, ip, msg);
+ })
+ .otherwise(function(err) {
+ res.writeHead(404, {'Content-Type': 'text/plain'});
+ res.end("Error 404: File not found");
+ log(404, req.url, ip, err);
+ })
+
+ }, function () {
+ throw new Error("Can't find file: [" + pathName + "] in the webRoot: [" + webRoot + "]")
+ })
+
+}).listen(port)
+
+
+var log = function (statCode, url, ip, err) {
+ var logStr = statCode + ' - ' + url + ' - ' + ip;
+
+ if (err) logStr += ' - ' + err;
+
+ console.log(logStr);
+}
View
1  components.json
@@ -79,3 +79,4 @@
}
}
+
View
11 dist.ini
@@ -18,6 +18,7 @@ copyright_holder = Nickolay Platonov <nplatonov@cpan.org>
[GatherDir]
follow_symlinks = 1
+follow_skip = 2
[PruneCruft]
[PruneFiles]
match = ^misc/.*
@@ -33,11 +34,15 @@ docs_markup = mmd ; default
[JSAN::ReadmeFromMD] ; should be after docs generation
update_sources = 0
-[NPM::Bundle] ; after docs generation to avoid docs for bundles
+[Web::Bundle] ; after docs generation to avoid docs for bundles
-[NPM::Package]
+[Web::NPM::Package]
main = joose-all.js
+dependency = optimist
+dependency = temp
+
+devDependency = test-run
; before release
@@ -73,4 +78,4 @@ tweet = Released {{$DIST}}-{{$VERSION}} {{$URL}}
hash_tags = #npm #node.js
[InstallRelease]
-install_command = sudo npm install . -g
+install_command = sudo npm install . -g
View
1  node_modules/librarian/index.js
@@ -0,0 +1 @@
+module.exports = require('./lib/Librarian.js')
View
29 node_modules/librarian/lib/File.js
@@ -0,0 +1,29 @@
+// File
+
+var path = require('path')
+var fs = require('fs')
+var detective = require('detective')
+
+var Joose = require('../../../joose-all')
+
+module.exports = Joose.Class({
+
+ has : {
+ name : null,
+
+ rawDependencies : {
+ lazy : 'this._buildRawDependencies'
+ },
+
+ inDepthDependencies : Joose.I.Object
+ },
+
+
+ methods : {
+
+ _buildRawDependencies : function () {
+ return detective(fs.readFileSync(this.name))
+ }
+ }
+
+})
View
25 node_modules/librarian/lib/Librarian.js
@@ -0,0 +1,25 @@
+// Librarian
+
+var temp = require('temp')
+
+module.exports = require('../../../joose-all').Class({
+
+ has : {
+ webRoot : null,
+
+ tempRoot : {
+
+ lazy : function () {
+
+ }
+ }
+ },
+
+
+ methods : {
+
+ initialize : function () {
+
+ }
+ }
+})
View
58 misc/require.js → node_modules/librarian/util/require.js
@@ -1,15 +1,15 @@
require = (function () {
- var require = function (fileName, cwd) {
- if (!file) throw new Error("Invalid argument to require")
+ var rootRequire = function (fileName, cwd) {
+ if (!file) throw new Error("Invalid argument to rootRequire")
- var resolved = resolve(fileName, cwd)
+ var resolved = rootResolve(fileName, cwd)
var module = modules[ resolved ]
- if (!module) throw new Error('Failed to resolve module: ' + fileName + ', tried: ' + resolved)
+ if (!module) throw new Error('Failed to rootResolve module: ' + fileName + ', tried: ' + resolved)
- return cache[ resolved ] || (cache[ resolved ] = module(require))
+ return cache[ resolved ] || (cache[ resolved ] = module(rootRequire))
}
var coreModules = {
@@ -20,8 +20,8 @@ require = (function () {
'vm' : true
}
- var modules = require.modules = {}
- var cache = require.cache = {}
+ var modules = rootRequire.modules = {}
+ var cache = rootRequire.cache = {}
var resolveInFileSystem = function (fileName, isFileNotDirectory) {
@@ -35,12 +35,12 @@ require = (function () {
// if it can be a directory (default) - then check for the package.json
if (!isFileNotDirectory) {
if (modules[ fileName + '/package.json']) {
- var packageJSON = require(fileName + '/package.json')
+ var packageJSON = rootRequire(fileName + '/package.json')
var main = packageJSON.main
- // if `main` key presents - resolve it as file
- if (main) return resolve(main, fileName, true)
+ // if `main` key presents - rootResolve it as file
+ if (main) return rootResolve(main, fileName, true)
}
// and finally try to load "index"
@@ -63,12 +63,12 @@ require = (function () {
return path
}
- var resolve = function (fileName, cwd, isFileNotDirectory) {
+ var rootResolve = function (fileName, cwd, isFileNotDirectory) {
if (coreModules[ fileName ]) throw new Error("Core modules are not supported yet")
cwd = cwd || '.'
- // no need to resolve absolute links
+ // no need to rootResolve absolute links
if (/^\//.test(fileName)) return resolveInFileSystem(fileName, isFileNotDirectory)
if (/^(\.\/|\.\.\/)/.test(fileName)) return resolveInFileSystem(cleanupPath(cwd + '/' + fileName))
@@ -97,11 +97,11 @@ require = (function () {
}
- var child = require.child = function (dirName) {
+ var child = rootRequire.child = function (dirName) {
- var childRequire = function (fileName) { return require(fileName, dirName) }
+ var childRequire = function (fileName) { return rootRequire(fileName, dirName) }
- childRequire.resolve = function (fileName) { return resolve(fileName, dirName) }
+ childRequire.resolve = function (fileName) { return rootResolve(fileName, dirName) }
childRequire.modules = modules
childRequire.cache = cache
childRequire.child = child
@@ -109,30 +109,6 @@ require = (function () {
return childRequire
}
-})()
-
-
-
-
-
-
-require.modules["/node_modules/kiokujs/lib/KiokuJS/Backend.js"] = function (rootRequire) {
-
- var __dirname = "/node_modules/kiokujs/lib/KiokuJS"
- var __filename = "/node_modules/kiokujs/lib/KiokuJS/Backend.js"
-
- var exports = {}
- var module = { exports : exports }
-
- var require = rootRequire.child(__dirname)
+ return rootRequire
- require.cache[ __filename ] = exports;
-
- // this wrapping is generally not required (only protects from "return" in original content)
- ;(function () {
- //ORIGINAL_CONTENT
- })()
-
- return module.exports
-}
-
+})()
View
19 node_modules/librarian/util/wrapper.js
@@ -0,0 +1,19 @@
+require.modules["/node_modules/kiokujs/lib/KiokuJS/Backend.js"] = function (rootRequire) {
+
+ var __dirname = "/node_modules/kiokujs/lib/KiokuJS"
+ var __filename = "/node_modules/kiokujs/lib/KiokuJS/Backend.js"
+
+ var exports = {}
+ var module = { exports : exports }
+
+ var require = rootRequire.child(__dirname)
+
+ require.cache[ __filename ] = exports;
+
+ ;(function () {
+ //ORIGINAL_CONTENT
+ })()
+
+ return module.exports
+}
+
View
1  node_modules/paperboy
View
1  node_modules/test-run
Please sign in to comment.
Something went wrong with that request. Please try again.