Permalink
Browse files

feature: --ip option to set your local IP

  • Loading branch information...
MikeMitterer committed Aug 14, 2015
1 parent 3ff5ccc commit 4d5da109bc33a2718a7ee941a2ddee6f70b12b43
Showing with 36 additions and 13 deletions.
  1. +17 −5 README.md
  2. +8 −8 lib/src/Application.dart
  3. +8 −0 lib/src/Config.dart
  4. +3 −0 lib/src/Options.dart
View
@@ -1,12 +1,13 @@
# SiteGen
Now with Speech output on OSX, disabled for all other OSs.
# SiteGen
Static site generator. Includes a webserver, sass + autoprefix support
### New
`--ip` option - now you can set the IP the server listens to. (Defaults to 127.0.0.1)
Helps to test your site from within a VM for example.
With extra assets-folder and partials-support. A static site generator in [Dart][dart], webserver included.
You can write your pages in HTML or [Markdown][markdown]. For Templates [Mustache][mustache] is supported.
### Breaking change in v1.0.0
html-Folder moved into .sitegen!!!!!
A webserver for a quick review is included. On Mac you also get automatic page refresh. On other
platforms you could try [LivePage][livepage] chrome extension for maximum productivity.
@@ -243,6 +244,7 @@ Usage: sitegen [options]
-s, --settings Prints settings
-h, --help Shows this message
-g, --generate Generate site
-c, --generatecss Generate CSS (compile SCSS2CSS)
-w, --watch Observes SRC-dir
-x, --watchandserve Shortcut to watch and serve
-i, --init Initializes your site
@@ -255,16 +257,26 @@ Usage: sitegen [options]
--[no-]useapfx Enables / disables Autoprefixer
(defaults to on)
--[no-]talktome Enables / disables Speek-Output
(defaults to on)
--ip Sets the IP-Address to listen on
(defaults to "127.0.0.1")
--port Sets the port to listen on
(defaults to "8000")
--docroot Document root
(defaults to "web")
-v, --loglevel Sets the appropriate loglevel
[info, debug, warning]
Sample:
'Generates all basic files and folders: 'sitegen -i'
'Observes the default dirs and serves the web-folder: 'sitegen -w --serve'
'Observes the default dirs and serves the web-folder: 'sitegen -x'
'Generates the static site in your 'web-folder': 'sitegen -g'
```
View
@@ -88,7 +88,7 @@ class Application {
if (argResults.wasParsed(Options._ARG_SERVE) || argResults.wasParsed(Options._ARG_WATCH_AND_SERVE)) {
foundOptionToWorkWith = true;
final String port = argResults[Options._ARG_PORT];
serve(config.docroot, port);
serve(config.docroot, port, config.ip);
}
if (!foundOptionToWorkWith) {
@@ -103,7 +103,7 @@ class Application {
}
}
void serve(final String folder, final String port) {
void serve(final String folder, final String port, final String ip) {
Validate.notBlank(folder);
Validate.notBlank(port);
@@ -124,7 +124,7 @@ class Application {
virtDir.directoryHandler = _directoryHandler;
runZoned(() {
HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, int.parse(port)).then( (final HttpServer server) {
HttpServer.bind(ip, int.parse(port)).then( (final HttpServer server) {
_logger.info('Server running on port: $port, $MY_HTTP_ROOT_PATH');
server.listen( (final HttpRequest request) {
_logger.info("${request.connectionInfo.remoteAddress.address}:${request.connectionInfo.localPort} - ${request.method} ${request.uri}");
@@ -139,7 +139,7 @@ class Application {
Validate.notBlank(folder);
Validate.notNull(config);
_logger.info('Observing $folder...');
_logger.info('Observing (watch) $folder...');
final Directory srcDir = new Directory(folder);
@@ -172,7 +172,7 @@ class Application {
try {
scssFiles.forEach((final File file) {
_logger.info("Observing: ${file.path}");
_logger.info("Observing: (watchScss) ${file.path}");
file.watch(events: FileSystemEvent.MODIFY).listen((final FileSystemEvent event) {
_logger.fine(event.toString());
@@ -218,7 +218,7 @@ class Application {
try {
_logger.info("Observing: ${dirToCheck.path}");
_logger.info("Observing: (watchAdditionalFolderScss) ${dirToCheck.path}");
dirToCheck.watch(events: FileSystemEvent.MODIFY).listen((final FileSystemEvent event) {
_logger.fine(event.toString());
@@ -244,7 +244,7 @@ class Application {
Validate.notBlank(folder);
Validate.notNull(config);
_logger.fine('Observing $folder...');
_logger.fine('Observing: (watchToRefresh) $folder...');
void _schedulePageRefresh() {
if(timerForPageRefresh == null) {
@@ -268,7 +268,7 @@ class Application {
Validate.notBlank(folder);
Validate.notNull(config);
_logger.fine('Observing $folder (SCSS)... ');
_logger.fine('Observing: (_compileSCSSFile) $folder (SCSS)... ');
final Directory dir = new Directory(folder);
final List<File> scssFiles = _listSCSSFilesIn(dir);
View
@@ -55,6 +55,7 @@ class Config {
_settings[Config._CONF_SITE_OPTIONS] = {};
_settings[Options._ARG_IP] = "127.0.0.1";
_settings[Options._ARG_PORT] = "8080";
_settings[Options._ARG_DOCROOT] = _settings[Config._CONF_OUTPUT_DIR]; // web
@@ -105,6 +106,8 @@ class Config {
Map<String,String> get siteoptions => _settings[Config._CONF_SITE_OPTIONS];
String get ip => _settings[Options._ARG_IP];
String get port => _settings[Options._ARG_PORT];
String get docroot => _settings[Options._ARG_DOCROOT];
@@ -152,6 +155,7 @@ class Config {
settings["SASS compiler"] = sasscompiler;
settings["Browser"] = browser;
settings["IP-Address"] = ip;
settings["Port"] = port;
settings["Document root"] = docroot;
@@ -204,6 +208,10 @@ class Config {
_settings[Options._ARG_LOGLEVEL] = _argResults[Options._ARG_LOGLEVEL];
}
if(_argResults.wasParsed(Options._ARG_IP)) {
_settings[Options._ARG_IP] = _argResults[Options._ARG_IP];
}
if(_argResults.wasParsed(Options._ARG_PORT)) {
_settings[Options._ARG_PORT] = _argResults[Options._ARG_PORT];
}
View
@@ -10,6 +10,7 @@ class Options {
static const _ARG_GENERATE = 'generate';
static const _ARG_GENERATE_CSS = 'generatecss';
static const _ARG_SERVE = 'serve';
static const _ARG_IP = 'ip';
static const _ARG_PORT = 'port';
static const _ARG_WATCH = 'watch';
static const _ARG_WATCH_AND_SERVE = 'watchandserve';
@@ -72,6 +73,8 @@ class Options {
..addFlag(_ARG_TALK_TO_ME, negatable: true, help: "Enables / disables Speek-Output", defaultsTo: _runsOnOSX())
..addOption(_ARG_IP, help: "Sets the IP-Address to listen on", defaultsTo: "127.0.0.1")
..addOption(_ARG_PORT, help: "Sets the port to listen on", defaultsTo: "8000")
..addOption(_ARG_DOCROOT, help: "Document root", defaultsTo: "web")

0 comments on commit 4d5da10

Please sign in to comment.