Skip to content

Commit

Permalink
feature: Improved speed
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMitterer committed Nov 16, 2015
1 parent 960733a commit f01c10f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 205 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,3 +13,4 @@ packages
*.js.map *.js.map
.pub .pub
refreshChromium-1.0.applescript refreshChromium-1.0.applescript
*.lock
23 changes: 6 additions & 17 deletions lib/src/Generator.dart
Expand Up @@ -56,9 +56,7 @@ class Generator {
final String extension = path.extension(relativeFileName).replaceFirst(".","").toLowerCase(); final String extension = path.extension(relativeFileName).replaceFirst(".","").toLowerCase();


_logger.fine("\nFile: ${relativeFileName}, Path: $relativePath"); _logger.fine("\nFile: ${relativeFileName}, Path: $relativePath");

final List<String> lines = file.readAsLinesSync();
String fileContent = file.readAsStringSync();
final List<String> lines = fileContent.replaceAll("\r","").split(new RegExp("\n",multiLine: true));
Map<String,dynamic> pageOptions = {}; Map<String,dynamic> pageOptions = {};


final bool hasYamlBlock = _hasYamlBlock(config.yamldelimeter,lines,extension); final bool hasYamlBlock = _hasYamlBlock(config.yamldelimeter,lines,extension);
Expand All @@ -74,29 +72,18 @@ class Generator {
lines.removeRange(0,1); lines.removeRange(0,1);
} }
} }
// Now remove the YAML-Block
fileContent = _removeYamlBlock(fileContent,config);


pageOptions = _fillInPageNestingLevel(relativeFileName,pageOptions); pageOptions = _fillInPageNestingLevel(relativeFileName,pageOptions);
pageOptions = _fillInDefaultPageOptions(config.dateformat,file, pageOptions,config.siteoptions); pageOptions = _fillInDefaultPageOptions(config.dateformat,file, pageOptions,config.siteoptions);
pageOptions['_data'] = dataMap; pageOptions['_data'] = dataMap;

pageOptions['_content'] = renderTemplate(lines.join('\n'), pageOptions,
//_logger.info("---- ${relativeFileName}:\n$fileContent");

pageOptions['_content'] = renderTemplate(fileContent, pageOptions,
_partialsResolver(partialsDir,isMarkdownSupported: config.usemarkdown)); _partialsResolver(partialsDir,isMarkdownSupported: config.usemarkdown));
// pageOptions['_content'] = renderTemplate(lines.join('\n'), pageOptions,
// _partialsResolver(partialsDir,isMarkdownSupported: config.usemarkdown));


pageOptions['_template'] = "none"; pageOptions['_template'] = "none";


// Set add the newlines back into _content (_removeYamlBlock replaced them)
pageOptions['_content'] = (pageOptions['_content'] as String).replaceAll(new RegExp(_NEWLINE_PROTECTOR,multiLine: true),"\n");
//_logger.info("**** ${relativeFileName}:\n${pageOptions['_content']}");

String outputExtension = extension; String outputExtension = extension;
if (isMarkdown(file) && _isMarkdownSupported(config.usemarkdown, pageOptions)) { if (isMarkdown(file) && _isMarkdownSupported(config.usemarkdown, pageOptions)) {
pageOptions['_content'] = md.markdownToHtml(pageOptions['_content'],inlineSyntaxes: [ ]); pageOptions['_content'] = md.markdownToHtml(pageOptions['_content']);
outputExtension = "html"; outputExtension = "html";
} }


Expand All @@ -109,7 +96,9 @@ class Generator {
templateContent = template.readAsStringSync(); templateContent = template.readAsStringSync();
} }


_showPageOptions(relativeFileName,relativePath,pageOptions,config); if(config.loglevel == "debug") {
_showPageOptions(relativeFileName,relativePath,pageOptions,config);
}


final String content = _fixPathRefs(renderTemplate(templateContent, pageOptions, final String content = _fixPathRefs(renderTemplate(templateContent, pageOptions,
_partialsResolver(partialsDir,isMarkdownSupported: config.usemarkdown)),config); _partialsResolver(partialsDir,isMarkdownSupported: config.usemarkdown)),config);
Expand Down
187 changes: 0 additions & 187 deletions pubspec.lock

This file was deleted.

2 changes: 1 addition & 1 deletion pubspec.yaml
Expand Up @@ -27,7 +27,7 @@ dependencies:
args: ^0.13.0 args: ^0.13.0
path: ^1.3.0 path: ^1.3.0
yaml: ^2.1.0 yaml: ^2.1.0
markdown: ^0.8.0 markdown: ^0.9.0
mustache: ^0.2.0 mustache: ^0.2.0
intl: ^0.12.0 intl: ^0.12.0
http_server: ^0.9.0 http_server: ^0.9.0
Expand Down

0 comments on commit f01c10f

Please sign in to comment.