Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/shanemhansen/vogue into s…
Browse files Browse the repository at this point in the history
…hanemhansen-master
  • Loading branch information
andrewdavey committed Apr 1, 2011
2 parents c7a1416 + 6a67389 commit b769caf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -23,7 +23,7 @@ Run the Vogue server.
vogue --port 8001 /path/to/website

--port : The port used for Vogue's HTTP server. Optional, defaults to 8001.

--rewrite : A rule in the form of token:replace-ment-token to help rewrite urls to filesystem paths
Open http://localhost:8001/ to see instructions for loading the Vogue client into your
web pages.

Expand Down
10 changes: 8 additions & 2 deletions src/Watcher.js
Expand Up @@ -3,9 +3,9 @@ var fs = require('fs')

exports.Watcher = Watcher;

function Watcher(webDirectory) {
function Watcher(webDirectory,rewrite) {
this.webDirectory = webDirectory;

this.rewrite = rewrite;
// array of VogueClient objects
this.clients = [];

Expand All @@ -22,6 +22,12 @@ Watcher.prototype.removeClient = function(client) {
};

Watcher.prototype.getFilenameForHref = function(href) {
if(this.rewrite && typeof rewrite =="string") {
var parts = this.rewrite.split(':');
if(parts.length == 2) {
href = href.replace(parts[0],parts[1]);
}
}
// Remove any querystring junk.
// e.g. "foo/bar.css?abc=123" --> "foo/bar.css"
href = href.split('?')[0];
Expand Down
8 changes: 7 additions & 1 deletion src/vogue.js
Expand Up @@ -22,7 +22,7 @@ var VogueClient = require('./VogueClient').VogueClient
var options = getOptions()
, server = http.createServer(handleHttpRequest)
, socket = io.listen(server)
, watcher = new Watcher(options.webDirectory);
, watcher = new Watcher(options.webDirectory,options.rewrite);

server.listen(options.port);
socket.on('connection', function(clientSocket) {
Expand Down Expand Up @@ -79,6 +79,12 @@ function getOptions() {
help: 'Port to run Vogue server on',
'default': 8001
},
{
name: ['--rewrite', '-r'],
type: 'string',
help: 'foo:bar replaces foo in url with bar when looking for the file',
'default': null
},
{
name: ['--help','-h','-?'],
type: 'flag',
Expand Down

0 comments on commit b769caf

Please sign in to comment.