Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
skial committed May 6, 2014
1 parent cd40cca commit b606066
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 79 deletions.
22 changes: 8 additions & 14 deletions src/uhx/sys/Tuli.hx
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,22 @@ class Tuli {
// This is currently not saved, so the data has to be recreated on each call.
// Call via your `hxml` file `--macro uhx.macro.Tuli.onData(pack.age.Class.callback)`
public static function onData(callback:Dynamic->Dynamic, ?when:TuliState):Void {
//initialize();
(when == null || when == Before) ? dataPluginsBefore.push( callback ) : dataPluginsAfter.push( callback );
if (when == null) when = Before;
switch (when) {
case Before: dataPluginsBefore.push( callback );
case After: dataPluginsAfter.push( callback );
}
}

private static var finishCallbacksBefore:Array<Void->Void> = [];
private static var finishCallbacksAfter:Array<Void->Void> = [];

public static function onFinish(callback:Void->Void, ?when:TuliState):Void {
//initialize();
if (when == null) when = After;
switch (when) {
case After: finishCallbacksAfter.push( callback );
case Before: finishCallbacksBefore.push( callback );
}
//(when == null || when == After) ? finishCallbacksAfter.push( callback ) : finishCallbacksBefore.push( callback );
}

private static var classes:Map<String, Class<TuliPlugin>> = new Map();
Expand Down Expand Up @@ -198,9 +199,6 @@ class Tuli {
var item = allItems[index].normalize();
var location = '$path/$item'.normalize();

/*if (!location.isDirectory()) {
files.push( item );
} else {*/
if (location.isDirectory()) {
allItems = allItems.concat( location.readDirectory().map( function(d) return '$item/$d'.normalize() ) );
}
Expand All @@ -219,13 +217,9 @@ class Tuli {

for (file in config.files) {
var stats = '$path/${file.path}'.stat();
//if (asISO8601( stats.mtime ) != file.modified) {
file.size = stats.size;
file.modified = asISO8601(stats.mtime);
file.stats = stats;
/*} else {
}*/
file.size = stats.size;
file.modified = asISO8601(stats.mtime);
file.stats = stats;
}

config.files = config.files.concat( [for (newItem in newItems) if (!'$path/$newItem'.isDirectory()) {
Expand Down
67 changes: 36 additions & 31 deletions src/uhx/tuli/plugins/Atom.hx
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,45 @@ class Atom {

}

domEntry = entry.parse();
var title = dom.find('h1').first().text().trim();

domEntry.find('id').setText( id );
domEntry.find('title').setText( dom.find('h1').first().text() );
domEntry.find('summary').setText( dom.find('p').first().text() );
domEntry.find('content').setAttr('src', id).setAttr('type','text/html');
domEntry.find('published').setText( Tuli.asISO8601( file.stats.ctime ) );

domFeed.find('updated').setText( Tuli.asISO8601( file.stats.mtime ) );
domEntry.find('updated').setText( Tuli.asISO8601( file.stats.mtime ) );

domFeed.find('link').setAttr('href', 'http://haxe.io/$path');
domFeed.first().next().append( null, domEntry );
// The following line causes a memory leak.
//domFeed.find('author').afterThisInsert( domEntry );

xmlCache.set( path, domFeed );

if (!xmlCache.exists( html + 'index.html' )) {
xmlCache.set( html + 'index.html', dom );
}

var result = domFeed.html();

while (result.indexOf('&amp;') > -1) {
result = result.replace('&amp;', '&');
}

for (key in Markdown.characters.keys()) {
result = result.replace(Markdown.characters.get( key ), key );
if (title != '') {
domEntry = entry.parse();

domEntry.find('id').setText( id );
domEntry.find('title').setText( title );
domEntry.find('summary').setText( dom.find('p').first().text() );
domEntry.find('content').setAttr('src', id).setAttr('type','text/html');
domEntry.find('published').setText( Tuli.asISO8601( file.stats.ctime ) );

domFeed.find('updated').setText( Tuli.asISO8601( file.stats.mtime ) );
domEntry.find('updated').setText( Tuli.asISO8601( file.stats.mtime ) );

domFeed.find('link').setAttr('href', 'http://haxe.io/$path');
domFeed.first().next().append( null, domEntry );
// The following line causes a memory leak.
//domFeed.find('author').afterThisInsert( domEntry );

xmlCache.set( path, domFeed );

if (!xmlCache.exists( html + 'index.html' )) {
xmlCache.set( html + 'index.html', dom );
}

var result = domFeed.html();

while (result.indexOf('&amp;') > -1) {
result = result.replace('&amp;', '&');
}

for (key in Markdown.characters.keys()) {
result = result.replace(Markdown.characters.get( key ), key );
}

Tuli.fileCache.set( path, result );

}

Tuli.fileCache.set( path, result );

dom = null;
domFeed = null;
domEntry = null;
Expand Down
74 changes: 40 additions & 34 deletions src/uhx/tuli/plugins/RSS.hx
Original file line number Diff line number Diff line change
Expand Up @@ -70,43 +70,49 @@ class RSS {

}

domEntry = entry.parse();
var title = dom.find('h1').first().text();

domEntry.find('guid').setText( id );
domEntry.find('link').setText( id );
domEntry.find('title').setText( dom.find('h1').first().text() );
domEntry.find('description').setText( dom.find('p').first().text() );
domEntry.find('pubDate').setText( DateTools.format( file.stats.ctime, '%a, %d %b %Y %H:%M:%S GMT' ) );

domFeed.find('pubDate').setText( DateTools.format( file.stats.ctime, '%a, %d %b %Y %H:%M:%S GMT' ) );
domFeed.find('lastBuildDate').setText( DateTools.format( file.stats.mtime, '%a, %d %b %Y %H:%M:%S GMT' ) );
domFeed.find('ttl').next().setAttr('href', 'http://haxe.io/$path');

domFeed.find('channel').append( null, domEntry );

xmlCache.set( path, domFeed );

if (!xmlCache.exists( html + 'index.html' )) {
xmlCache.set( html + 'index.html', dom );
}

var result = domFeed.html();
var lowered = ['pubdate>' => 'pubDate>', 'lastbuilddate>' => 'lastBuildDate>'];

for (key in lowered.keys()) {
result = result.replace(key, lowered.get( key ));
}

while (result.indexOf('&amp;') > -1) {
result = result.replace('&amp;', '&');
}

for (key in Markdown.characters.keys()) {
result = result.replace(Markdown.characters.get( key ), key );
if (title != '') {

domEntry = entry.parse();

domEntry.find('guid').setText( id );
domEntry.find('link').setText( id );
domEntry.find('title').setText( title );
domEntry.find('description').setText( dom.find('p').first().text() );
domEntry.find('pubDate').setText( DateTools.format( file.stats.ctime, '%a, %d %b %Y %H:%M:%S GMT' ) );

domFeed.find('pubDate').setText( DateTools.format( file.stats.ctime, '%a, %d %b %Y %H:%M:%S GMT' ) );
domFeed.find('lastBuildDate').setText( DateTools.format( file.stats.mtime, '%a, %d %b %Y %H:%M:%S GMT' ) );
domFeed.find('ttl').next().setAttr('href', 'http://haxe.io/$path');

domFeed.find('channel').append( null, domEntry );

xmlCache.set( path, domFeed );

if (!xmlCache.exists( html + 'index.html' )) {
xmlCache.set( html + 'index.html', dom );
}

var result = domFeed.html();
var lowered = ['pubdate>' => 'pubDate>', 'lastbuilddate>' => 'lastBuildDate>'];

for (key in lowered.keys()) {
result = result.replace(key, lowered.get( key ));
}

while (result.indexOf('&amp;') > -1) {
result = result.replace('&amp;', '&');
}

for (key in Markdown.characters.keys()) {
result = result.replace(Markdown.characters.get( key ), key );
}

Tuli.fileCache.set( path, result );

}

Tuli.fileCache.set( path, result );

dom = null;
domFeed = null;
domEntry = null;
Expand Down

0 comments on commit b606066

Please sign in to comment.