This repository has been archived by the owner on Mar 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial import of project into git.corp
- Loading branch information
albertoc
committed
Mar 6, 2013
1 parent
2f92c68
commit 7d09b34
Showing
14 changed files
with
606 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
artifacts/* | ||
build/* | ||
coverage/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
artifacts/* | ||
build/* | ||
coverage/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## How to contribute ? | ||
|
||
- The main source files are located under `lib/`. | ||
- Test are located under `test/*`. | ||
- Examples are located under `examples`. | ||
|
||
To run the unit tests (with coverage by default): | ||
|
||
npm test | ||
|
||
To generate the API docs under `build/apidocs`: | ||
|
||
./scripts/gendocs.sh | ||
open ./build/apidocs/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0.0.1 / 2013-03-04 | ||
================== | ||
|
||
* Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,69 @@ | ||
modown-static | ||
============= | ||
|
||
modown static and combo handler | ||
modown static and combo handler | ||
|
||
# Modown Static Component | ||
|
||
This compontent . | ||
|
||
## Goals | ||
|
||
* register and serve static assets from a specific folder | ||
* register and serve static assets based on an explicit mapping to protect other files that should not be exposed | ||
* serve combo urls based on the static assets that were registered | ||
* support custom filters (regex) to include and/or exclude assets | ||
|
||
## Usage as stand alone middleware for express | ||
|
||
``` | ||
var statichandler = require('modown-static'); | ||
app.use('/public/', statichandler.public('full/path/to/folder/')); | ||
app.use('/protected/', statichandler.map({ | ||
"something/foo.js": "full/path/to/something/foo.js", | ||
"bar.js": "full/path/to/something/bar.js" | ||
})); | ||
app.use(statichandler.combine({ | ||
comboBase: "/combo~", | ||
comboSep: "~" | ||
})); | ||
``` | ||
|
||
The example above will allow you to access any file within the folder | ||
`full/path/to/folder/` by following the route `http://hostname:port/public/whatever/file.js` | ||
without any protection, which means all files could be accessed. Under | ||
the hood this is equivalent to use `express.static` middleware. | ||
|
||
It also expose two files from another folder `full/path/to/root/folder/`, | ||
those files could be accesed thru `http://hostname:port/protected/something/foo.js` | ||
and `http://hostname:port/protected/bar.js`, and it protects any other file within | ||
the root folder. It also provides a nice abstraction where filenames and paths in | ||
the filesystem are not longer relevant when it comes to serve them, and the mapping | ||
has to be explicit. | ||
|
||
And last, but not least, it turns on the combo capabilities for all the previous | ||
registered assets, and doing so by defining the `path` to the combo, and the | ||
separator token. As a result, a urls like these will be valid: | ||
|
||
* http://hostname:port/combo~something/foo.js~bar.js | ||
* http://hostname:port/combo~whatever/file.js~something/foo.js~bar.js | ||
|
||
## Usage as a modown plugin | ||
|
||
``` | ||
modown.plug(require('modown-static')); | ||
app.use('/public/', modown.static.public('full/path/to/folder/')); | ||
app.use('/protected/', modown.static.map({ | ||
"something/foo.js": "full/path/to/something/foo.js", | ||
"bar.js": "full/path/to/something/bar.js" | ||
})); | ||
app.use(modown.static.combine({ | ||
comboBase: "/combo~", | ||
comboSep: "~" | ||
})); | ||
``` | ||
|
||
## How to contribute | ||
|
||
See the CONTRIBUTE.md file for info. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*jslint node:true, nomen: true*/ | ||
|
||
'use strict'; | ||
|
||
var express = require('express'), | ||
exphbs = require('express3-handlebars'), | ||
libstatic = require('../../'), | ||
app = express(); | ||
|
||
|
||
app.configure('development', function () { | ||
|
||
|
||
}); | ||
|
||
app.configure('production', function () { | ||
|
||
|
||
}); | ||
|
||
// template engine | ||
app.engine('handlebars', exphbs()); | ||
app.set('view engine', 'handlebars'); | ||
|
||
// creating a page with YUI embeded | ||
app.get('/', function (req, res, next) { | ||
res.render('page'); | ||
}); | ||
|
||
// listening | ||
app.set('port', process.env.PORT || 8666); | ||
app.listen(app.get('port'), function () { | ||
console.log("Server listening on port " + | ||
app.get('port') + " in " + app.get('env') + " mode"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
YUI.add('app-modules-meta', function (Y, NAME) { | ||
Y.applyConfig({ | ||
groups: { | ||
app: { | ||
modules: {} | ||
} | ||
} | ||
}); | ||
}, '', {requires: []}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
|
||
<title>stand alone usage of `modown-yui`</title> | ||
|
||
</head> | ||
<body> | ||
|
||
<h1>header goes here!</h1> | ||
|
||
<div id="content"> | ||
Page Loaded OK | ||
</div> | ||
|
||
<script> | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./lib/static'); |
Oops, something went wrong.