Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

Commit

Permalink
Initial import of project into git.corp
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoc committed Mar 6, 2013
1 parent 2f92c68 commit 7d09b34
Show file tree
Hide file tree
Showing 14 changed files with 606 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artifacts/*
build/*
coverage/*
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artifacts/*
build/*
coverage/*
14 changes: 14 additions & 0 deletions CONTRIBUTE.md
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
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0.0.1 / 2013-03-04
==================

* Initial release
67 changes: 66 additions & 1 deletion README.md
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.

35 changes: 35 additions & 0 deletions examples/standalone/app.js
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");
});
9 changes: 9 additions & 0 deletions examples/standalone/path/app-modules-meta.js
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: []});
20 changes: 20 additions & 0 deletions examples/standalone/views/page.handlebars
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>
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/static');
Loading

0 comments on commit 7d09b34

Please sign in to comment.