Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/shanemhansen/vogue into s…

…hanemhansen-master
  • Loading branch information...
commit b769cafe9284718fbd63ca0d96be68c2c05358ec 2 parents c7a1416 + 6a67389
@andrewdavey authored
Showing with 16 additions and 4 deletions.
  1. +1 −1  readme.md
  2. +8 −2 src/Watcher.js
  3. +7 −1 src/vogue.js
View
2  readme.md
@@ -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.
View
10 src/Watcher.js
@@ -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 = [];
@@ -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];
View
8 src/vogue.js
@@ -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) {
@@ -80,6 +80,12 @@ function getOptions() {
'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',
help: 'Show this help message',
Please sign in to comment.
Something went wrong with that request. Please try again.