Permalink
Browse files

feature: Works with Dart 2.0

  • Loading branch information...
MikeMitterer committed Jan 10, 2019
1 parent 9b1b423 commit 59b65c26d90d1f4891f8861642db81bc2dba1b66
@@ -6,7 +6,15 @@ Before you read on - check out this [video](https://www.youtube.com/watch?v=smf1

[![ScreenShot](https://github.com/MikeMitterer/dart-sitegen/blob/master/assets/screenshot.jpg?raw=true)](https://www.youtube.com/watch?v=smf1uvy0yNQ)

### New
## Example

- Install SiteGen `pub global activate sitegen`
- Clone the example from `https://github.com/MikeMitterer/dart-sitegen/tree/master/samples/simple`
- run `sitegen -w`
- open another console window and run `pub run build_runner serve --delete-conflicting-outputs --live-reload`

Play with the sample files...

#### Support for https-connection!
This is absolutely mandatory if your REST-Server
uses [HTTP Strict Transport Security (HSTS)](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security)
@@ -385,7 +393,7 @@ package that I used as basis for **SiteGen**.
### License
Copyright 2015 Michael Mitterer (office@mikemitterer.at),
Copyright 2019 Michael Mitterer (office@mikemitterer.at),
IT-Consulting and Development Limited, Austrian Branch
Licensed under the Apache License, Version 2.0 (the "License");
@@ -7,11 +7,10 @@ import 'dart:math';

import 'package:intl/intl.dart';
import 'package:args/args.dart';
import 'package:command_wrapper/command_wrapper.dart';
import 'package:which/which.dart';
import 'package:where/where.dart';

import 'package:logging/logging.dart';
import 'package:logging_handlers/logging_handlers_shared.dart';
import 'package:console_log_handler/print_log_handler.dart';

import 'package:validate/validate.dart';

@@ -34,7 +33,7 @@ part "src/Generator.dart";

bool _runsOnOSX() => (SysInfo.operatingSystemName == "Mac OS X");

final _commands = new List<CommandWrapper>();
// final _commands = new List<CommandWrapper>();

Future main(List<String> arguments) async {
final Application application = new Application();
@@ -92,7 +92,7 @@ class Application {
new Generator().generate(config);
}
watchScss(config.outputfolder, config);
watchToRefresh(config.outputfolder, config);
// watchToRefresh(config.outputfolder, config);

watchAdditionalFolderScss(config.watchfolder1,config.outputfolder, config);
watchAdditionalFolderScss(config.watchfolder2,config.outputfolder, config);
@@ -294,6 +294,7 @@ class Application {
}
}

/*
void watchToRefresh(final String folder, final Config config) {
Validate.notBlank(folder);
Validate.notNull(config);
@@ -315,6 +316,7 @@ class Application {
_schedulePageRefresh();
});
}
*/

// -- private -------------------------------------------------------------

@@ -359,6 +361,9 @@ class Application {
_autoPrefixer(cssFile,config);
}

/*
REMINDER!
/**
* Weitere Infos:
* https://github.com/guard/guard-livereload
@@ -421,6 +426,7 @@ class Application {

_logger.info("$executable ${script.path} successful!");
}
*/

bool _isFolderAvailable(final String folder) {
Validate.notBlank(folder);
@@ -486,7 +492,9 @@ class Application {
Validate.notNull(dir);
return dir.listSync(recursive: true).where((final file) {
return file is File && file.path.endsWith(".scss") && !file.path.contains("packages");
}).toList();
})
.map((final FileSystemEntity entity) => entity as File)
.toList();
}

void _vickiSay(final String sentence,final Config config) {
@@ -497,7 +505,7 @@ class Application {
return;
}

final ProcessResult result = Process.runSync("say", [ '-v', "Vicki", '-r', '200', sentence.replaceFirst("wsk_", "") ]);
final ProcessResult result = Process.runSync("say", [ '-r', '200', sentence.replaceFirst("wsk_", "") ]);
if (result.exitCode != 0) {
_logger.severe("run faild with: ${(result.stderr as String).trim()}!");
}
@@ -524,6 +532,6 @@ class Application {
Logger.root.level = Level.INFO;
}

Logger.root.onRecord.listen(new LogPrintHandler(messageFormat: "%m"));
Logger.root.onRecord.listen(new LogPrintHandler(transformer: transformerMessageOnly));
}
}
@@ -3,9 +3,9 @@ part of sitegen;
class CommandManager {
static String SASS = "sass";
static String SASSC = "sassc";
static String OSASCRIPT = "osascript";
static String AUTOPREFIXER = "autoprefixer-cli";
static String SAY = "say";
// static String OSASCRIPT = "osascript";

static CommandManager _commandmanager;

@@ -31,9 +31,9 @@ class CommandManager {
class Command {
final String name;
final String exe;
final CommandWrapper wrapper;
//final CommandWrapper wrapper;

Command(this.name, this.exe, this.wrapper);
Command(this.name, this.exe);

}

@@ -45,15 +45,15 @@ Future<Map<String,Command>> _getAvailableCommands() async {

CommandManager.SASS,
CommandManager.SASSC,
CommandManager.OSASCRIPT,
CommandManager.AUTOPREFIXER,
CommandManager.SAY
CommandManager.SAY,
//CommandManager.OSASCRIPT,
];

await Future.forEach(names, (final String binName) async {
try {
final String exe = await which(binName);
commands[binName] = new Command(binName,exe,new CommandWrapper(binName));
final String exe = await where(binName);
commands[binName] = new Command(binName,exe);
} catch(_) { }

});
@@ -73,7 +73,7 @@ class Config {

_settings[Options._ARG_DOCROOT] = _settings[Config._CONF_OUTPUT_DIR]; // web

_settings[Config._CONF_USE_SASS] = true;
_settings[Config._CONF_USE_SASS] = false;
_settings[Config._CONF_USE_AUTOPREFIXER] = true;

_settings[Config._CONF_USE_SECURE_CONNECTION] = false;
@@ -124,7 +124,7 @@ class Config {

String get sasspath => _sasspath;

Map<String,String> get siteoptions => _settings[Config._CONF_SITE_OPTIONS] as Map<String,String>;
Map<String,String> get siteoptions => _toMap(_settings[Config._CONF_SITE_OPTIONS]);

String get ip => _settings[Options._ARG_IP];

@@ -350,4 +350,19 @@ class Config {

return sasspath.join(_SEARCH_PATH_SEPARATOR);
}

Map<String,String> _toMap(final configOption) {
if(configOption is Map<String,String>) {
return configOption;
}

if(configOption is yaml.YamlMap) {
return configOption
.map((key,value) => MapEntry<String,String>(key.toString(),value.toString()));

} else {
return configOption;
}

}
}
@@ -63,7 +63,12 @@ class Generator {
if (hasYamlBlock) {
List<String> yamlBlock = _extractYamlBlockFrom(config.yamldelimeter,lines,extension);
if(yamlBlock.length > 0) {
pageOptions.addAll(yaml.loadYaml(yamlBlock.join('\n')) as Map<String,String>);
final String block = yamlBlock.join('\n');
final yaml.YamlMap ym = yaml.loadYaml(block);

pageOptions.addAll(ym.map((key,value)
=> MapEntry<String,String>(key.toString(),value.toString())));

_resolvePartialsInYamlBlock(partialsDir,pageOptions,config.usemarkdown);

// +1 for the YAML-Block-Delimiter ("~~~") line
@@ -212,19 +217,20 @@ class Generator {
}

return contentDir.listSync(recursive: true)
.where((file) => file is File && (

file.path.endsWith('.md') ||
file.path.endsWith(".markdown") ||
file.path.endsWith(".dart") ||
file.path.endsWith(".js") ||
file.path.endsWith(".json") ||
file.path.endsWith(".html") ||
file.path.endsWith(".scss") ||
file.path.endsWith(".css") ||
file.path.endsWith(".svg")

) && !file.path.contains("packages") ).toList();
.where((final FileSystemEntity entity) => entity is File && (

entity.path.endsWith('.md') ||
entity.path.endsWith(".markdown") ||
entity.path.endsWith(".dart") ||
entity.path.endsWith(".js") ||
entity.path.endsWith(".json") ||
entity.path.endsWith(".html") ||
entity.path.endsWith(".scss") ||
entity.path.endsWith(".css") ||
entity.path.endsWith(".svg"))
&& !entity.path.contains("packages") )
.map((final FileSystemEntity entity) => entity as File)
.toList();
}

List<File> _listImagesFilesIn(final Directory contentDir) {
@@ -235,7 +241,9 @@ class Generator {
file.path.endsWith(".jpg") ||
file.path.endsWith(".gif")

) && !file.path.contains("packages") ).toList();
) && !file.path.contains("packages") )
.map((final FileSystemEntity entity) => entity as File)
.toList();
}

List<File> _listAssetsFilesIn(final Directory contentDir) {
@@ -252,12 +260,16 @@ class Generator {
file.path.endsWith(".css") ||
file.path.endsWith(".svg")

) && !file.path.contains("packages") ).toList();
) && !file.path.contains("packages") )
.map((final FileSystemEntity entity) => entity as File)
.toList();
}


List<File> _listTemplatesIn(final Directory templateDir) {
return templateDir.listSync().where((file) => file is File && !file.path.contains("packages")).toList();
return templateDir.listSync().where((file) => file is File && !file.path.contains("packages"))
.map((final FileSystemEntity entity) => entity as File)
.toList();
}

List<File> _listDataFilesIn(final Directory contentDir) {
@@ -267,7 +279,9 @@ class Generator {
file.path.endsWith('.yaml') ||
file.path.endsWith(".json")

) && !file.path.contains("packages")).toList();
) && !file.path.contains("packages"))
.map((final FileSystemEntity entity) => entity as File)
.toList();
}

bool _isMarkdownSupported(final bool markdownForSite, final Map page_options) {
@@ -355,7 +369,7 @@ class Generator {

} else {

data = JSON.decode(file.readAsStringSync());
data = json.decode(file.readAsStringSync());
}

final String filename = path.basenameWithoutExtension(file.path).toLowerCase();
@@ -6,7 +6,7 @@ homepage: https://github.com/MikeMitterer/dart-sitegen
version: 1.7.0

environment:
sdk: ">=1.8.0 <2.0.0"
sdk: ">=2.0.0 <3.0.0"

# Add the bin/sitegen.dart script to the scripts pub installs.
# Activate local repo:
@@ -16,29 +16,29 @@ executables:
sitegen:

dependencies:
browser: ^0.10.0

logging: ^0.11.0
logging_handlers: ^0.8.0
console_log_handler: ^0.1.0
logging: '>=0.11.3 <1.0.0'
console_log_handler: ^1.0.0
# path: /Volumes/Daten/DevLocal/DevDart/ConsoleLogHandler

validate: ^1.0.0

args: ^0.13.0
path: ^1.3.0
args: ^1.4.0
yaml: ^2.1.0
markdown: ^0.9.0
mustache: ^0.2.0
intl: ^0.12.0
path: ^1.0.0
markdown: ^2.0.0
mustache: ^1.0.0
intl: ^0.15.0
http_server: ^0.9.0

system_info: 0.0.16

packages: ^0.1.0
system_info: ^0.1.0
where: ^6.0.0

packages: ^0.4.0
#path: /Volumes/Daten/DevLocal/DevDart/Packages

command_wrapper: "^0.2.0"

dev_dependencies:
test: any
grinder: any
grinder: any

build_runner: any
build_test: any
@@ -1,5 +1,5 @@
// ----------------------------------------------------------------------------
// Copyright (c) 2015, Michael Mitterer (office@mikemitterer.at),
// Copyright (c) 2019, Michael Mitterer (office@mikemitterer.at),
// IT-Consulting and Development Limited.
//
// All Rights Reserved.
@@ -17,12 +17,19 @@
// limitations under the License.
//

@import "package:m4d_components/assets/styles/material-design-lite";
@import "package:m4d_components/assets/styles/splashscreen/dots";

html, body {
font-family : 'Roboto', 'Helvetica', sans-serif;
margin : 0;
padding : 0;
}

//.mdl-layout {
// background-color: green !important;
//}

// ----------------------------------------------------------------------------
// ---- Application specific part
// -
@@ -1,7 +1,7 @@
title: Welcome
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<div class="mdl-panel mdl-shadow--2dp">
Hi, I am content
Hi, I am content!
</div>
<div class="mdl-panel mdl-shadow--2dp">
<a href="special/xtreme.html">XTREME</a> is for testing minimal content!<br>
Oops, something went wrong.

0 comments on commit 59b65c2

Please sign in to comment.