Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R370 #340

Merged
merged 9 commits into from Oct 9, 2016
Merged

R370 #340

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 6 additions & 18 deletions electron-md-render-template/Builder.hx
Expand Up @@ -97,12 +97,15 @@ class Builder {

if (timestamp < maxDuration) {
if ([for (k in completedScripts.keys()) k].length == 0) {
for (script in scripts) {
if (scripts.length > 0) for (script in scripts) {
var name = script.withoutExtension();
require( '$__dirname/$script'.normalize() );
completedScripts.set( name, false );
window.document.addEventListener( '$name:complete', handleScriptCompletion );

} else {
timeoutId = cast setTimeout( save, waitFor );

}

} else {
Expand Down Expand Up @@ -157,14 +160,7 @@ class Builder {
if (timeoutId != null) clearTimeout( cast timeoutId );

timestamp = haxe.Timer.stamp() - timestamp;

if (timestamp < maxDuration) {
timeoutId = cast setTimeout( preCheck, waitFor );

} else {
timeoutId = cast setTimeout( preCheck, waitFor );

}
timeoutId = cast setTimeout( preCheck, waitFor );
}

private function mutation(changes:Array<MutationRecord>, observer:MutationObserver):Void {
Expand All @@ -174,18 +170,10 @@ class Builder {
case 'characterData':

case 'childList':
//console.log( 'child list mutation update' );
if (timeoutId != null) clearTimeout( cast timeoutId );

timestamp = haxe.Timer.stamp() - timestamp;

if (timestamp < maxDuration) {
timeoutId = cast setTimeout( preCheck, waitFor );

} else {
timeoutId = cast setTimeout( preCheck, waitFor );

}
timeoutId = cast setTimeout( preCheck, waitFor );

case _:

Expand Down
6 changes: 3 additions & 3 deletions electron-md-render-template/Controller.hx
Expand Up @@ -90,7 +90,7 @@ class Controller {
Extra scripts to be loaded which extend this scripts abilities.
*/
@alias('sc')
public var scripts:Array<String>;
public var scripts:Array<String> = [];

private var completedScripts:Map<String, Bool> = new Map();

Expand Down Expand Up @@ -160,7 +160,7 @@ class Controller {
}

private function init() {
data = { scripts:[], payload:payload, html:'', args:Sys.args(), port:port };
data = { scripts:[], payload:payload, html:'', args:Sys.args().map(function(a) return a.normalize()), port:port };
// Modify the json structure.
for (object in json) {
console.log( json );
Expand Down Expand Up @@ -304,7 +304,7 @@ class Controller {
private function processHtml(html:String):Void {
ipcMain.once('save', save);

trace( 'serving from ' + '$cwd/$root'.normalize() );
console.log( 'serving from ' + '$cwd/$root'.normalize() );
var files = untyped __js__("new {0}", server.Server)('$cwd/$root'.normalize());
var ns = require('http').createServer(function (request, response) {
request.addListener('end', function () {
Expand Down
10 changes: 5 additions & 5 deletions htmlmin.sh
@@ -1,6 +1,6 @@
INPUT="$@"
INPUT_DIR=${INPUT%/*}
#echo $INPUT
echo $INPUT
#echo $INPUT_DIR
if [ "$INPUT_DIR" == "$INPUT" ]; then
#echo "correcting path"
Expand Down Expand Up @@ -62,8 +62,8 @@ cp -u $BIN $MIN
#electron --enable-logging . --input "//$INPUT" --script ./script.js --outputDir "//$BIN_DIR" --show --scripts linkqueue.js font.characters.js sitemap.js checkmissing.js
html-minifier \
--collapse-boolean-attributes --remove-comments --remove-empty-attributes --remove-redundant-attributes \
--collapse-whitespace --preserve-line-breaks --decode-entities --minify-js --remove-style-link-type-attributes \
--remove-script-type-attributes -o "$MIN" "$BIN"
--preserve-line-breaks --decode-entities --minify-js --remove-style-link-type-attributes \
--remove-script-type-attributes --prevent-attributes-escaping -o "$MIN" "$BIN"
cp $MIN $OPT
# saving from $OPT to $DIR/$BASE.opt.html and back to $OPT prevents `invalid filename $OPT` error.
#critical "$MIN" --minify true --base ./min/ --ignore "@font-face" --ignore "fonts.google" --inline > $OPT_CRIT
Expand All @@ -73,6 +73,6 @@ cp $MIN $OPT
#fi
html-minifier \
--collapse-boolean-attributes --remove-comments --remove-empty-attributes --remove-redundant-attributes \
--collapse-whitespace --decode-entities --minify-js --remove-style-link-type-attributes \
--remove-script-type-attributes --minify-css -o "$OPT" "$OPT_CRIT"
--decode-entities --minify-js --remove-style-link-type-attributes \
--remove-script-type-attributes --minify-css --prevent-attributes-escaping -o "$OPT" "$OPT_CRIT"
#zopfli --i1000 $OPT
23 changes: 15 additions & 8 deletions render.sh
@@ -1,5 +1,4 @@
INPUT="$@"
#echo $INPUT
STR="${INPUT:3}"
BIN=./bin$STR
BIN_DIR=${BIN%/*}
Expand All @@ -14,15 +13,23 @@ MIN_BASE="${MIN_BASE/.md/}"
OPT=./opt$STR
OPT_DIR=${OPT%/*}
OPT_BASE="${OPT/$OPT_DIR/}"
OPT_BASE="${OPT_BASE/.html/}"
OPT_BASE="${OPT_BASE/.md/}"
OPT_CRIT=$OPT_DIR$OPT_BASE.crt.html
OPT_TWIN=$OPT_DIR$OPT_BASE.opt.html

mkdir -p $BIN_DIR
mkdir -p $MIN_DIR
mkdir -p $OPT_DIR
mkdir -p $BIN_DIR$BIN_BASE
mkdir -p $MIN_DIR$MIN_BASE
mkdir -p $OPT_DIR$OPT_BASE

electron --enable-logging ./render/index.js \
-md markdown-it-abbr markdown-it-attrs markdown-it-emoji markdown-it-footnote \
markdown-it-headinganchor \
-s ./render/build.js -r src -i $INPUT -o $BIN_DIR$BIN_BASE/index.html -b src
-md markdown-it-abbr markdown-it-attrs markdown-it-emoji \
markdown-it-footnote markdown-it-headinganchor \
-s ./render/build.js -r src -i $INPUT -o $BIN_DIR$BIN_BASE/index.max.html -b src \
-j ./src/data/ld36.json ./src/data/ld36.manual.json \
--scripts ../site/subresourceintegrity.js ../site/font.characters.js ../site/screengrab.js \
-rs opt -w 1920 -h 1080

html-minifier \
--collapse-boolean-attributes --remove-comments --remove-empty-attributes --remove-redundant-attributes \
--collapse-whitespace --decode-entities --remove-style-link-type-attributes \
--remove-script-type-attributes -o $OPT_DIR$OPT_BASE/index.html $BIN_DIR$BIN_BASE/index.max.html