Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

loading local settings if passed in the argument.

  • Loading branch information...
commit 25eb6b52467115563e9fb6e1afedbeb93d0cdd75 1 parent 0188c60
@saml saml authored
Showing with 16 additions and 18 deletions.
  1. +1 −0  .gitignore
  2. +6 −6 README.markdown
  3. +9 −12 src/main.js
View
1  .gitignore
@@ -1,2 +1,3 @@
tmp/
img
+*.local.js
View
12 README.markdown
@@ -8,11 +8,11 @@ For example,
will execute
- convert srcDir/some/image.jpg -resize 10x20 destDir/some/image.c.10x20.jpg
+ convert srcDir/some/image.jpg -resize 10x20 destDir/tempFile.jpg
and serves
- destDir/some/image.c.10x20.jpg
+ destDir/tempFile.jpg
convert command, srcDir, and destDir are configurable.
@@ -28,11 +28,11 @@ Download and install [Node.js](http://nodejs.org/):
Run
- node src/main.js localhost:8888
+ node src/main.js
Configure
- vim src/settings.js
-
-
+ cp src/settings.js settings.local.js
+ vim settings.local.js
+ node src/main.js /absolute/path/to/settings.local.js
View
21 src/main.js
@@ -9,11 +9,11 @@ var util = require('./util');
var tempfile = require('./tempfile');
var settings = require('./settings');
-//GET /path/to/image.c.120x64.jpg
+//GET /path/to/image.jpg/120x64.jpg
//will execute
//convert scrDir/path/to/image.jpg \
-// -size 120x64 destDir/image.c.120x64.jpg
-//and serve destDir/path/to/image.c.120x64.jpg
+// -size 120x64 destDir/tempFile.jpg
+//and serve destDir/tempFile.jpg
var Server = function(convert, srcDir, destDir) {
var me = {};
@@ -237,7 +237,11 @@ var main = function() {
// console.log("Usage: %s %s config.json".f(argv[0], argv[1]));
// process.exit(1);
//}
- //
+
+ if (argv.length >= 2) {
+ console.log("Loading settings from " + argv[2]);
+ settings = require(argv[2]);//override settings module with what's supplied by commandline.
+ }
var port = settings.port || 8080;
var host = settings.host || '127.0.0.1';
@@ -253,14 +257,7 @@ var main = function() {
destDir = path.join(baseDir, destDir);
}
- if (argv.length > 2) {
- var hostPort = argv[2];
- var m = /([^:]+):(\d+)/.exec(hostPort);
- if (m) {
- host = m[1];
- port = m[2] * 1.0;
- }
- }
+
console.log('Using\n'
+ '\thost\t%s\n'.f(host)
Please sign in to comment.
Something went wrong with that request. Please try again.