From a1725d99bf115febbc233a2440e0a3ba0ea3b287 Mon Sep 17 00:00:00 2001 From: Skial Bainn Date: Sun, 26 Jun 2016 08:44:13 +0100 Subject: [PATCH 1/8] Initial patreon web scraper to build mini profiles. --- all-html.sh | 2 +- electron-characters/build.hxml | 2 +- electron-checkmissing/build.hxml | 2 +- electron-controller/build.hxml | 4 +- electron-linkqueue/build.hxml | 2 +- electron-patreon/PatreonController.hx | 101 +++++++++++++++++++++++ electron-patreon/PatreonScraper.hx | 97 ++++++++++++++++++++++ electron-patreon/build.hxml | 18 ++++ electron-screengrab/build.hxml | 2 +- electron-sitemap/build.hxml | 2 +- electron-version/build.hxml | 2 +- js-community-patreon/CommunityPatreon.hx | 38 +++++++++ js-community-patreon/build.hxml | 4 + package.json | 3 +- src/data/patreons.json | 1 + src/data/patreons.original.json | 31 +++++++ 16 files changed, 301 insertions(+), 10 deletions(-) create mode 100644 electron-patreon/PatreonController.hx create mode 100644 electron-patreon/PatreonScraper.hx create mode 100644 electron-patreon/build.hxml create mode 100644 js-community-patreon/CommunityPatreon.hx create mode 100644 js-community-patreon/build.hxml create mode 100644 src/data/patreons.json create mode 100644 src/data/patreons.original.json diff --git a/all-html.sh b/all-html.sh index 97742d27..01fefae0 100644 --- a/all-html.sh +++ b/all-html.sh @@ -1,4 +1,4 @@ INPUT="$@" -electron --enable-logging . -w 1920 -h 1080 --input "//$INPUT/index.html" --script ./script.js --outputDir "//bin" --show \ +electron --enable-logging ./site/ -w 1920 -h 1080 --input "//$INPUT/index.html" --script ./script.js --outputDir "//bin" --show \ --scripts linkqueue.js checkmissing.js font.characters.js sitemap.js screengrab.js version.js find $INPUT -name "*.html" | xargs -P 6 -n 1 htmlmin.sh diff --git a/electron-characters/build.hxml b/electron-characters/build.hxml index 2e4ab5b4..0e64a9fc 100644 --- a/electron-characters/build.hxml +++ b/electron-characters/build.hxml @@ -9,4 +9,4 @@ --each -main FontCharacters --js ../font.characters.js +-js ../site/font.characters.js diff --git a/electron-checkmissing/build.hxml b/electron-checkmissing/build.hxml index 80293162..e817037d 100644 --- a/electron-checkmissing/build.hxml +++ b/electron-checkmissing/build.hxml @@ -9,4 +9,4 @@ --each -main CheckMissing --js ../checkmissing.js +-js ../site/checkmissing.js diff --git a/electron-controller/build.hxml b/electron-controller/build.hxml index d69ddb06..7358b9aa 100644 --- a/electron-controller/build.hxml +++ b/electron-controller/build.hxml @@ -8,9 +8,9 @@ --each -main Main --js ../index.js +-js ../site/index.js --next -main Script --js ../script.js +-js ../site/script.js diff --git a/electron-linkqueue/build.hxml b/electron-linkqueue/build.hxml index 651076a4..78ad46c5 100644 --- a/electron-linkqueue/build.hxml +++ b/electron-linkqueue/build.hxml @@ -9,4 +9,4 @@ --each -main LinkQueue --js ../linkqueue.js +-js ../site/linkqueue.js diff --git a/electron-patreon/PatreonController.hx b/electron-patreon/PatreonController.hx new file mode 100644 index 00000000..906e5d0d --- /dev/null +++ b/electron-patreon/PatreonController.hx @@ -0,0 +1,101 @@ +package ; + +import js.Node.*; +import tink.Json.*; +import js.node.Fs.*; +import js.Node.process; +import js.node.Crypto.*; +import haxe.Serializer; +import haxe.Unserializer; +import haxe.ds.StringMap; +import haxe.Constraints.Function; + +import CommunityPatreon.PatreonData; +import CommunityPatreon.PatreonPayload; +import CommunityPatreon.PatreonDuration; + +using StringTools; +using haxe.io.Path; + +@:cmd +class PatreonController { + + private static var app:Dynamic; + private static var electron:Dynamic; + private static var ipcMain:{on:String->Function->Dynamic}; + + public static function main() { + electron = require('electron'); + app = electron.app; + ipcMain = electron.ipcMain; + trace( 'starting'); + app.on('ready', function() { + var m = new PatreonController( Sys.args() ); + } ); + + app.on('window-all-closed', function() { + if (process.platform != 'darwin') { + app.quit(); + } + }); + } + + @alias('d') public var data:String; + @alias('s') public var script:String; + private var cwd = Sys.getCwd(); + private var config:Dynamic = { webPreferences:{} }; + private var payload:PatreonPayload; + private var counter:Int = 0; + + public function new(args:Array) { + @:cmd _; + + if (script != null) config.webPreferences.preload = '$cwd/$script'.normalize(); + if (data == null) app.quit(); + + readFile( '$cwd/$data'.normalize(), {encoding:'utf8'}, function(e, d) { + if (e != null) throw e; + process( payload = parse(d) ); + } ); + } + + private function process(payload:PatreonPayload):Void { + for (page in payload.data) { + counter++; + var browser = untyped __js__('new {0}', electron.BrowserWindow)( config ); + ipcMain.on(page.uri, updatePayload.bind(browser, page.uri, _, _)); + browser.on('closed', function() browser = null ); + browser.webContents.on('did-finish-load', onLoad.bind(browser, page)); + browser.loadURL( page.uri ); + + } + + } + + private function onLoad(browser:Dynamic, data:PatreonData):Void { + trace( 'loaded ' + data.uri ); + browser.webContents.openDevTools(); + browser.webContents.send('payload', stringify(data)); + } + + private function updatePayload(browser:Dynamic, uri:String, event:Dynamic, json:String):Void { + for (i in 0...payload.data.length) if (payload.data[i].uri == uri) { + trace( uri ); + payload.data[i] = parse(json); + break; + + } + counter--; + browser.close(); + if (counter < 1) { + trace( 'saving $data' ); + writeFile( '$cwd/$data'.normalize(), stringify(payload), function(error) { + if (error != null) trace( error ); + trace( 'exiting' ); + app.quit(); + } ); + + } + } + +} diff --git a/electron-patreon/PatreonScraper.hx b/electron-patreon/PatreonScraper.hx new file mode 100644 index 00000000..20cd4b9e --- /dev/null +++ b/electron-patreon/PatreonScraper.hx @@ -0,0 +1,97 @@ +package ; + +import js.Node.*; +import js.node.Fs; +import tink.Json.*; +import js.Browser.*; +import js.html.Node; +import js.html.Element; +import haxe.Serializer; +import haxe.extern.Rest; +import haxe.Unserializer; +import haxe.ds.StringMap; +import haxe.DynamicAccess; +import js.html.DOMElement; +import haxe.Constraints.Function; + +import CommunityPatreon.PatreonData; +import CommunityPatreon.PatreonPayload; +import CommunityPatreon.PatreonDuration; + +using StringTools; + +class PatreonScraper { + + private var electron:Dynamic; + private var ipcRenderer:{on:String->Function->Dynamic, once:String->Function->Dynamic, send:String->Rest->Void}; + + public static function main() { + var con:PatreonScraper = null; + + switch (window.document.readyState) { + case 'complete': + con = new PatreonScraper(); + + case _: + window.document.addEventListener( + 'DOMContentLoaded', + function() con = new PatreonScraper(), + false + ); + + } + } + + public function new() { + trace( window.location ); + electron = require('electron'); + ipcRenderer = electron.ipcRenderer; + if (window.document.documentElement.outerHTML != '
') {
+			ipcRenderer.on('payload', function(e, d) process( parse(d) ));
+			
+		}
+		
+	}
+	
+	private function process(data:PatreonData):Void {
+		trace( 'recieved payload' );
+		inline function qsa(selector:String):Array {
+			return [for (n in window.document.querySelectorAll( selector )) n];
+		}
+		
+		var status:Array = qsa( '[class*="creatorInfoValue"], [class*="creatorInfoLabel"]' );
+		while (status.length > 0) {
+			var pair = [status.pop().textContent, status.pop().textContent];
+			switch (pair) {
+				case [count, 'patrons'] | ['patrons', count]:
+					trace( count, 'patrons' );
+					data.patrons = Std.parseInt( count );
+					
+				case [value = _.startsWith('$') => true, duration] | [duration, value = _.startsWith('$') => true]:
+					trace( pair[0], pair[1] );
+					data.income = Std.parseFloat( value.substring(1) );
+					data.duration = duration;
+					
+				case [_, _]:
+					trace( pair );
+			}
+			
+		}
+		
+		var name = qsa( '[class*="creatorTitleName"]' )[0];
+		var isCreating = qsa( '[class*="IsCreating"]' )[0];
+		var lastUpdated = qsa( '[class*="timestamp"]' )[0];
+		var socials = qsa( '[class*="social"][href]' );
+		var description = qsa( '[class*="ToggleableContent"][class*="stackable"]' )[0];
+		
+		if (name != null) data.name = name.textContent.htmlUnescape().trim();
+		if (isCreating != null) data.summary = isCreating.textContent.trim();
+		if (lastUpdated != null) data.update = lastUpdated.textContent.trim();
+		data.links = [for (social in socials) cast (social,DOMElement).getAttribute('href')];
+		
+		trace( data );
+		trace( stringify(data) );
+		ipcRenderer.send(data.uri, stringify(data));
+	}
+	
+}
diff --git a/electron-patreon/build.hxml b/electron-patreon/build.hxml
new file mode 100644
index 00000000..974af4ba
--- /dev/null
+++ b/electron-patreon/build.hxml
@@ -0,0 +1,18 @@
+-cp ../js-community-patreon/
+-lib cmd
+-lib hxnodejs
+-lib thx.core
+-lib tink_json
+-D dce=full
+-cp .
+#--no-traces
+
+--each 
+
+-main PatreonController
+-js ../patreon/index.js
+
+--next
+
+-main PatreonScraper
+-js ../patreon/scraper.js
diff --git a/electron-screengrab/build.hxml b/electron-screengrab/build.hxml
index a08a11a8..c6426ecd 100644
--- a/electron-screengrab/build.hxml
+++ b/electron-screengrab/build.hxml
@@ -9,4 +9,4 @@
 --each 
 
 -main ScreenGrab
--js ../screengrab.js
+-js ../site/screengrab.js
diff --git a/electron-sitemap/build.hxml b/electron-sitemap/build.hxml
index ea24cf74..652fa035 100644
--- a/electron-sitemap/build.hxml
+++ b/electron-sitemap/build.hxml
@@ -9,4 +9,4 @@
 --each 
 
 -main Sitemap
--js ../sitemap.js
+-js ../site/sitemap.js
diff --git a/electron-version/build.hxml b/electron-version/build.hxml
index df49ae74..08fd9656 100644
--- a/electron-version/build.hxml
+++ b/electron-version/build.hxml
@@ -9,4 +9,4 @@
 --each 
 
 -main Version
--js ../version.js
+-js ../site/version.js
diff --git a/js-community-patreon/CommunityPatreon.hx b/js-community-patreon/CommunityPatreon.hx
new file mode 100644
index 00000000..947ff393
--- /dev/null
+++ b/js-community-patreon/CommunityPatreon.hx
@@ -0,0 +1,38 @@
+package ;
+
+import tink.Json.*;
+
+typedef PatreonPayload = {
+	var data:Array;
+}
+
+typedef PatreonData = {
+	var uri:String;
+	@:optional var name:String;
+	@:optional var patrons:Int;
+	@:optional var income:Float;
+	@:optional var profile:String;
+	@:optional var summary:String;
+	@:optional var description:String;
+	@:optional var update:Null;
+	@:optional var links:Array;
+	@:optional var keywords:Array;
+	@:optional var duration:PatreonDuration;
+}
+
+@:enum abstract PatreonDuration(String) from String to String {
+	public var Month = 'per month';
+	public var Creation = 'per creation';
+}
+
+class CommunityPatreon {
+	
+	public static function main() {
+		new CommunityPatreon();
+	}
+	
+	public function new() {
+		
+	}
+	
+}
diff --git a/js-community-patreon/build.hxml b/js-community-patreon/build.hxml
new file mode 100644
index 00000000..ae3c866c
--- /dev/null
+++ b/js-community-patreon/build.hxml
@@ -0,0 +1,4 @@
+-debug
+-lib tink_json
+-main CommunityPatreon
+-js ../src/js/communitypatreon.js
diff --git a/package.json b/package.json
index 1e608546..72dd9250 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,8 @@
 {
   "name": "haxe.io",
-  "repo": "https://github.com/skial/haxe.io",
+  "repository": "https://github.com/skial/haxe.io",
   "version": "0.0.1",
+	"license": "GPL-3.0+",
   "devDependencies": {
 		"onchange": "latest",
 		"http-server": "latest",
diff --git a/src/data/patreons.json b/src/data/patreons.json
new file mode 100644
index 00000000..b53de2c5
--- /dev/null
+++ b/src/data/patreons.json
@@ -0,0 +1 @@
+{"data":[{"description":null,"duration":"per\u00A0month","income":421,"keywords":null,"links":["https://www.facebook.com/OpenFL","https://twitter.com/open_fl"],"name":"OpenFL\u00A0","patrons":61,"profile":null,"summary":"is creating Free Open-Source\u00A0Software","update":null,"uri":"https://www.patreon.com/openfl?ty=h"},{"description":null,"duration":"per\u00A0month","income":149,"keywords":null,"links":["https://twitter.com/HaxeFlixel"],"name":"HaxeFlixel\u00A0","patrons":29,"profile":null,"summary":"is creating An Open Source, Cross-Platform 2D Game\u00A0Engine","update":"Feb 15 at 8:06pm","uri":"https://www.patreon.com/haxeflixel?ty=h"},{"description":null,"duration":"per\u00A0month","income":82,"keywords":null,"links":["https://twitter.com/jeff__ward"],"name":"hxScout\u00A0","patrons":12,"profile":null,"summary":"is creating Free\u00A0Software","update":null,"uri":"https://www.patreon.com/hxscout?ty=h"},{"description":null,"duration":"per\u00A0month","income":34,"keywords":null,"links":["https://www.facebook.com/haxeui","https://twitter.com/IanHarrigan1982"],"name":"HaxeUI\u00A0","patrons":7,"profile":null,"summary":"is creating Open source user interface\u00A0libraries","update":null,"uri":"https://www.patreon.com/haxeui?ty=h"},{"description":null,"duration":"per\u00A0month","income":222,"keywords":null,"links":["https://twitter.com/snowkitorg"],"name":"sn\u00F5wkit\u00A0","patrons":25,"profile":null,"summary":"is creating a collective for\u00A0Haxe","update":"Feb 24 at 8:55am","uri":"https://www.patreon.com/snowkit?ty=h"},{"description":null,"duration":"per\u00A0month","income":17,"keywords":null,"links":["https://www.facebook.com/x01010111","https://twitter.com/x01010111","https://www.youtube.com/user/UltraWill"],"name":"Will Blanton\u00A0","patrons":5,"profile":null,"summary":"is creating HaxeFlixel\u00A0Tutorials","update":"Mar 21 at 5:24pm","uri":"https://www.patreon.com/x01010111?ty=h"},{"description":null,"duration":"per tutorials, code,\u00A0videos","income":6,"keywords":null,"links":["https://twitter.com/lewislepton","https://www.youtube.com/c/lewislepton"],"name":"Lewis Lepton\u00A0","patrons":3,"profile":null,"summary":"is creating tutorials, code,\u00A0videos","update":"May 3 at 7:04pm","uri":"https://www.patreon.com/lewislepton?ty=h"},{"description":null,"duration":"per\u00A0month","income":0,"keywords":null,"links":["https://twitter.com/nadako"],"name":"Dan Korostelev\u00A0","patrons":0,"profile":null,"summary":"is creating\u00A0Haxe","update":null,"uri":"https://www.patreon.com/nadako"},{"description":null,"duration":"per\u00A0month","income":56,"keywords":null,"links":["https://twitter.com/the_august_late"],"name":"August Late\u00A0","patrons":13,"profile":null,"summary":"is creating unique 2d lighting\u00A0tech.","update":null,"uri":"http://www.patreon.com/augustlate"}]}
\ No newline at end of file
diff --git a/src/data/patreons.original.json b/src/data/patreons.original.json
new file mode 100644
index 00000000..6d763a00
--- /dev/null
+++ b/src/data/patreons.original.json
@@ -0,0 +1,31 @@
+{
+	"data":[
+		{
+			"uri": "https://www.patreon.com/openfl?ty=h"
+		},
+		{
+			"uri": "https://www.patreon.com/haxeflixel?ty=h"
+		},
+		{
+			"uri": "https://www.patreon.com/hxscout?ty=h"
+		},
+		{
+			"uri": "https://www.patreon.com/haxeui?ty=h"
+		},
+		{
+			"uri": "https://www.patreon.com/snowkit?ty=h"
+		},
+		{
+			"uri": "https://www.patreon.com/x01010111?ty=h"
+		},
+		{
+			"uri": "https://www.patreon.com/lewislepton?ty=h"
+		},
+		{
+			"uri": "https://www.patreon.com/nadako"
+		},
+		{
+			"uri": "http://www.patreon.com/augustlate"
+		}
+	]
+}

From 9565b63df473f285e1ff1cf7932507d8b6ddf503 Mon Sep 17 00:00:00 2001
From: Skial Bainn 
Date: Sun, 26 Jun 2016 10:31:27 +0100
Subject: [PATCH 2/8] Update.

---
 src/data/patreons.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/data/patreons.json b/src/data/patreons.json
index b53de2c5..75d3368a 100644
--- a/src/data/patreons.json
+++ b/src/data/patreons.json
@@ -1 +1 @@
-{"data":[{"description":null,"duration":"per\u00A0month","income":421,"keywords":null,"links":["https://www.facebook.com/OpenFL","https://twitter.com/open_fl"],"name":"OpenFL\u00A0","patrons":61,"profile":null,"summary":"is creating Free Open-Source\u00A0Software","update":null,"uri":"https://www.patreon.com/openfl?ty=h"},{"description":null,"duration":"per\u00A0month","income":149,"keywords":null,"links":["https://twitter.com/HaxeFlixel"],"name":"HaxeFlixel\u00A0","patrons":29,"profile":null,"summary":"is creating An Open Source, Cross-Platform 2D Game\u00A0Engine","update":"Feb 15 at 8:06pm","uri":"https://www.patreon.com/haxeflixel?ty=h"},{"description":null,"duration":"per\u00A0month","income":82,"keywords":null,"links":["https://twitter.com/jeff__ward"],"name":"hxScout\u00A0","patrons":12,"profile":null,"summary":"is creating Free\u00A0Software","update":null,"uri":"https://www.patreon.com/hxscout?ty=h"},{"description":null,"duration":"per\u00A0month","income":34,"keywords":null,"links":["https://www.facebook.com/haxeui","https://twitter.com/IanHarrigan1982"],"name":"HaxeUI\u00A0","patrons":7,"profile":null,"summary":"is creating Open source user interface\u00A0libraries","update":null,"uri":"https://www.patreon.com/haxeui?ty=h"},{"description":null,"duration":"per\u00A0month","income":222,"keywords":null,"links":["https://twitter.com/snowkitorg"],"name":"sn\u00F5wkit\u00A0","patrons":25,"profile":null,"summary":"is creating a collective for\u00A0Haxe","update":"Feb 24 at 8:55am","uri":"https://www.patreon.com/snowkit?ty=h"},{"description":null,"duration":"per\u00A0month","income":17,"keywords":null,"links":["https://www.facebook.com/x01010111","https://twitter.com/x01010111","https://www.youtube.com/user/UltraWill"],"name":"Will Blanton\u00A0","patrons":5,"profile":null,"summary":"is creating HaxeFlixel\u00A0Tutorials","update":"Mar 21 at 5:24pm","uri":"https://www.patreon.com/x01010111?ty=h"},{"description":null,"duration":"per tutorials, code,\u00A0videos","income":6,"keywords":null,"links":["https://twitter.com/lewislepton","https://www.youtube.com/c/lewislepton"],"name":"Lewis Lepton\u00A0","patrons":3,"profile":null,"summary":"is creating tutorials, code,\u00A0videos","update":"May 3 at 7:04pm","uri":"https://www.patreon.com/lewislepton?ty=h"},{"description":null,"duration":"per\u00A0month","income":0,"keywords":null,"links":["https://twitter.com/nadako"],"name":"Dan Korostelev\u00A0","patrons":0,"profile":null,"summary":"is creating\u00A0Haxe","update":null,"uri":"https://www.patreon.com/nadako"},{"description":null,"duration":"per\u00A0month","income":56,"keywords":null,"links":["https://twitter.com/the_august_late"],"name":"August Late\u00A0","patrons":13,"profile":null,"summary":"is creating unique 2d lighting\u00A0tech.","update":null,"uri":"http://www.patreon.com/augustlate"}]}
\ No newline at end of file
+{"data":[{"description":null,"duration":"per\u00A0month","income":421,"keywords":null,"links":["https://www.facebook.com/OpenFL","https://twitter.com/open_fl"],"name":"OpenFL\u00A0","patrons":61,"profile":null,"summary":"is creating Free Open-Source\u00A0Software","update":null,"uri":"https://www.patreon.com/openfl?ty=h"},{"description":null,"duration":"per\u00A0month","income":149,"keywords":null,"links":["https://twitter.com/HaxeFlixel"],"name":"HaxeFlixel\u00A0","patrons":29,"profile":null,"summary":"is creating An Open Source, Cross-Platform 2D Game\u00A0Engine","update":"Feb 15 at 8:06pm","uri":"https://www.patreon.com/haxeflixel?ty=h"},{"description":null,"duration":"per\u00A0month","income":74,"keywords":null,"links":["https://twitter.com/jeff__ward"],"name":"hxScout\u00A0","patrons":11,"profile":null,"summary":"is creating Free\u00A0Software","update":null,"uri":"https://www.patreon.com/hxscout?ty=h"},{"description":null,"duration":"per\u00A0month","income":34,"keywords":null,"links":["https://www.facebook.com/haxeui","https://twitter.com/IanHarrigan1982"],"name":"HaxeUI\u00A0","patrons":7,"profile":null,"summary":"is creating Open source user interface\u00A0libraries","update":null,"uri":"https://www.patreon.com/haxeui?ty=h"},{"description":null,"duration":"per\u00A0month","income":222,"keywords":null,"links":["https://twitter.com/snowkitorg"],"name":"sn\u00F5wkit\u00A0","patrons":25,"profile":null,"summary":"is creating a collective for\u00A0Haxe","update":"Feb 24 at 8:55am","uri":"https://www.patreon.com/snowkit?ty=h"},{"description":null,"duration":"per\u00A0month","income":17,"keywords":null,"links":["https://www.facebook.com/x01010111","https://twitter.com/x01010111","https://www.youtube.com/user/UltraWill"],"name":"Will Blanton\u00A0","patrons":5,"profile":null,"summary":"is creating HaxeFlixel\u00A0Tutorials","update":"Mar 21 at 5:24pm","uri":"https://www.patreon.com/x01010111?ty=h"},{"description":null,"duration":"per tutorials, code,\u00A0videos","income":6,"keywords":null,"links":["https://twitter.com/lewislepton","https://www.youtube.com/c/lewislepton"],"name":"Lewis Lepton\u00A0","patrons":3,"profile":null,"summary":"is creating tutorials, code,\u00A0videos","update":"May 3 at 7:04pm","uri":"https://www.patreon.com/lewislepton?ty=h"},{"description":null,"duration":"per\u00A0month","income":0,"keywords":null,"links":["https://twitter.com/nadako"],"name":"Dan Korostelev\u00A0","patrons":0,"profile":null,"summary":"is creating\u00A0Haxe","update":null,"uri":"https://www.patreon.com/nadako"},{"description":null,"duration":"per\u00A0month","income":56,"keywords":null,"links":["https://twitter.com/the_august_late"],"name":"August Late\u00A0","patrons":13,"profile":null,"summary":"is creating unique 2d lighting\u00A0tech.","update":"May 28 at 6:26pm","uri":"http://www.patreon.com/augustlate"}]}

From 0f873f1792924f7c65c8ebc558ddba954c1ab3c3 Mon Sep 17 00:00:00 2001
From: Skial Bainn 
Date: Sun, 26 Jun 2016 19:15:18 +0100
Subject: [PATCH 3/8] Slow progress.

---
 all-html.sh                              |   2 +-
 electron-characters/FontCharacters.hx    |  13 +-
 electron-checkmissing/CheckMissing.hx    |   2 +-
 electron-controller/Main.hx              |   1 +
 electron-controller/Script.hx            |   3 +-
 electron-controller/build.hxml           |   1 +
 electron-linkqueue/build.hxml            |   2 +-
 electron-patreon/PatreonController.hx    |  11 +-
 electron-patreon/PatreonScraper.hx       |  20 +++-
 electron-patreon/build.hxml              |   1 +
 js-community-patreon/CommunityPatreon.hx |  70 +++++++++++
 js-community-patreon/build.hxml          |   2 +-
 jsmin.sh                                 |   4 +-
 patreonscraper.sh                        |   1 +
 src/css/haxe.io.css                      |  41 +++++++
 src/data/patreons.json                   | 145 ++++++++++++++++++++++-
 src/js/SiteScript.hx                     |  15 +++
 src/js/build.hxml                        |  10 ++
 18 files changed, 316 insertions(+), 28 deletions(-)
 create mode 100644 patreonscraper.sh
 create mode 100644 src/js/SiteScript.hx
 create mode 100644 src/js/build.hxml

diff --git a/all-html.sh b/all-html.sh
index 01fefae0..a1798d77 100644
--- a/all-html.sh
+++ b/all-html.sh
@@ -1,4 +1,4 @@
 INPUT="$@"
-electron --enable-logging ./site/ -w 1920 -h 1080 --input "//$INPUT/index.html" --script ./script.js --outputDir "//bin" --show \
+electron --enable-logging ./site/ -w 1920 -h 1080 --input "//$INPUT/index.html" --script ./site/script.js --outputDir "//bin" --show \
 --scripts linkqueue.js checkmissing.js font.characters.js sitemap.js screengrab.js version.js
 find $INPUT -name "*.html" | xargs -P 6 -n 1 htmlmin.sh
diff --git a/electron-characters/FontCharacters.hx b/electron-characters/FontCharacters.hx
index b9b510cc..e91153b9 100644
--- a/electron-characters/FontCharacters.hx
+++ b/electron-characters/FontCharacters.hx
@@ -12,17 +12,8 @@ import electron.main.App;
 class FontCharacters {
 	
 	public static function main() {
-		console.log( 'loading...' );
-		/*if( window.document.readyState == 'complete' ) {
-			var m = new Script();
-			
-		} else {
-			window.document.addEventListener('DOMContentLoaded', function() {
-				trace( 'dom loaded' );*/
-				var fs = new FontCharacters();
-			/*}, false);
-			
-		}*/
+		trace( 'loading...' );
+		var fs = new FontCharacters();
 	}
 	
 	public function new() {
diff --git a/electron-checkmissing/CheckMissing.hx b/electron-checkmissing/CheckMissing.hx
index b08108d4..89e888c1 100644
--- a/electron-checkmissing/CheckMissing.hx
+++ b/electron-checkmissing/CheckMissing.hx
@@ -51,7 +51,7 @@ class CheckMissing {
 			[{tag:'meta', name:'msapplication-TileColor', content:"#f15922"}, {}],
 			[{tag:'meta', name:'msapplication-TileImage'}, {content:"/mstile-144x144.png?v=wAANbdxLQn"}],
 			[{tag:'meta', name:'theme-color', content:"#ffffff"}, {}],
-			[{tag:'script', src:'/js/haxe.io.js'}, {async:'async', defer:'defer'}],
+			[{tag:'script', src:'/js/haxe.io.js'}, {async:'async', defer:'defer', 'data-community-patreons':'/data/patreons.json'}],
 			[{tag:'script', src:'/js/outbound-link-tracker.js'}, {async:'async', defer:'defer'}],
 			[{tag:'script', type:'text/javascript'}, {innerHTML:"(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
 				(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
diff --git a/electron-controller/Main.hx b/electron-controller/Main.hx
index b226bf29..22d39e03 100644
--- a/electron-controller/Main.hx
+++ b/electron-controller/Main.hx
@@ -112,6 +112,7 @@ class Main {
 		var inputDir = input.directory();
 		var ipcMain = require('electron').ipcMain;
 		var server = require('node-static');
+		trace( 'server root => ' + (Sys.getCwd() + '$inputDir').normalize() );
 		var files = untyped __js__("new {0}", server.Server((Sys.getCwd() + '$inputDir').normalize(), {headers:{'Content-Security-Policy': 'script-src \'none\';'}}) );
 		
 		var ns = require('http').createServer(function (request, response) {
diff --git a/electron-controller/Script.hx b/electron-controller/Script.hx
index 41e62d4c..6d577ffd 100644
--- a/electron-controller/Script.hx
+++ b/electron-controller/Script.hx
@@ -53,7 +53,8 @@ class Script {
 		
 		for (script in scripts) {
 			var name = script.withoutExtension();
-			loaded.set( script, require( '$__dirname/$script' ) );
+			trace( name );
+			loaded.set( script, require( '$__dirname/$script'.normalize() ) );
 			
 		}
 
diff --git a/electron-controller/build.hxml b/electron-controller/build.hxml
index 7358b9aa..2d2e03d0 100644
--- a/electron-controller/build.hxml
+++ b/electron-controller/build.hxml
@@ -12,5 +12,6 @@
 
 --next
 
+--no-traces
 -main Script
 -js ../site/script.js
diff --git a/electron-linkqueue/build.hxml b/electron-linkqueue/build.hxml
index 78ad46c5..0454f56b 100644
--- a/electron-linkqueue/build.hxml
+++ b/electron-linkqueue/build.hxml
@@ -4,7 +4,7 @@
 -lib cmd
 -D dce=full
 -cp .
---no-traces
+#--no-traces
 
 --each 
 
diff --git a/electron-patreon/PatreonController.hx b/electron-patreon/PatreonController.hx
index 906e5d0d..d850fd9c 100644
--- a/electron-patreon/PatreonController.hx
+++ b/electron-patreon/PatreonController.hx
@@ -40,7 +40,8 @@ class PatreonController {
 		});
 	}
 	
-	@alias('d') public var data:String;
+	@alias('i') public var input:String;
+	@alias('o') public var output:String;
 	@alias('s') public var script:String;
 	private var cwd = Sys.getCwd();
 	private var config:Dynamic = { webPreferences:{} };
@@ -51,9 +52,9 @@ class PatreonController {
 		@:cmd _;
 		
 		if (script != null) config.webPreferences.preload = '$cwd/$script'.normalize();
-		if (data == null) app.quit();
+		if (input == null) app.quit();
 		
-		readFile( '$cwd/$data'.normalize(), {encoding:'utf8'}, function(e, d) {
+		readFile( '$cwd/$input'.normalize(), {encoding:'utf8'}, function(e, d) {
 			if (e != null) throw e;
 			process( payload = parse(d) );
 		} );
@@ -88,8 +89,8 @@ class PatreonController {
 		counter--;
 		browser.close();
 		if (counter < 1) {
-			trace( 'saving $data' );
-			writeFile( '$cwd/$data'.normalize(), stringify(payload), function(error) {
+			trace( 'saving $input' );
+			writeFile( '$cwd/$output'.normalize(), stringify(payload), function(error) {
 				if (error != null) trace( error );
 				trace( 'exiting' );
 				app.quit();
diff --git a/electron-patreon/PatreonScraper.hx b/electron-patreon/PatreonScraper.hx
index 20cd4b9e..86a97224 100644
--- a/electron-patreon/PatreonScraper.hx
+++ b/electron-patreon/PatreonScraper.hx
@@ -5,6 +5,7 @@ import js.node.Fs;
 import tink.Json.*;
 import js.Browser.*;
 import js.html.Node;
+import uhx.sys.Seri;
 import js.html.Element;
 import haxe.Serializer;
 import haxe.extern.Rest;
@@ -19,9 +20,11 @@ import CommunityPatreon.PatreonPayload;
 import CommunityPatreon.PatreonDuration;
 
 using StringTools;
+using unifill.Unifill;
 
 class PatreonScraper {
 	
+	private static var whitespace = [for (codepoint in Seri.getCategory('Zs')) codepoint];
 	private var electron:Dynamic;
 	private var ipcRenderer:{on:String->Function->Dynamic, once:String->Function->Dynamic, send:String->Rest->Void};
 	
@@ -70,7 +73,7 @@ class PatreonScraper {
 				case [value = _.startsWith('$') => true, duration] | [duration, value = _.startsWith('$') => true]:
 					trace( pair[0], pair[1] );
 					data.income = Std.parseFloat( value.substring(1) );
-					data.duration = duration;
+					data.duration = cleanWhitespace( duration );
 					
 				case [_, _]:
 					trace( pair );
@@ -84,9 +87,9 @@ class PatreonScraper {
 		var socials = qsa( '[class*="social"][href]' );
 		var description = qsa( '[class*="ToggleableContent"][class*="stackable"]' )[0];
 		
-		if (name != null) data.name = name.textContent.htmlUnescape().trim();
-		if (isCreating != null) data.summary = isCreating.textContent.trim();
-		if (lastUpdated != null) data.update = lastUpdated.textContent.trim();
+		if (name != null) data.name = cleanWhitespace( name.textContent.trim() );
+		if (isCreating != null) data.summary = cleanWhitespace( isCreating.textContent.trim() );
+		if (lastUpdated != null) data.update = cleanWhitespace( lastUpdated.textContent.trim() );
 		data.links = [for (social in socials) cast (social,DOMElement).getAttribute('href')];
 		
 		trace( data );
@@ -94,4 +97,13 @@ class PatreonScraper {
 		ipcRenderer.send(data.uri, stringify(data));
 	}
 	
+	private static function cleanWhitespace(value:String):String {
+		for (codepoint in whitespace) {
+			value = value.uSplit( codepoint ).join(' ');
+			
+		}
+		
+		return value.trim();
+	}
+	
 }
diff --git a/electron-patreon/build.hxml b/electron-patreon/build.hxml
index 974af4ba..e7eaa319 100644
--- a/electron-patreon/build.hxml
+++ b/electron-patreon/build.hxml
@@ -3,6 +3,7 @@
 -lib hxnodejs
 -lib thx.core
 -lib tink_json
+-lib seri
 -D dce=full
 -cp .
 #--no-traces
diff --git a/js-community-patreon/CommunityPatreon.hx b/js-community-patreon/CommunityPatreon.hx
index 947ff393..6b73f543 100644
--- a/js-community-patreon/CommunityPatreon.hx
+++ b/js-community-patreon/CommunityPatreon.hx
@@ -1,6 +1,9 @@
 package ;
 
+import haxe.Http;
 import tink.Json.*;
+import js.Browser.*;
+import js.html.DOMElement;
 
 typedef PatreonPayload = {
 	var data:Array;
@@ -31,8 +34,75 @@ class CommunityPatreon {
 		new CommunityPatreon();
 	}
 	
+	private var locationSelectors:Map;
+	private var locationHandlers:MapDOMElement>;
+	
 	public function new() {
+		var url = window.document.querySelectorAll( 'script[data-community-patreons*=".json"]' )[0];
+		if (url != null) {
+			var href = '';
+			var http = new Http( href = cast (url, DOMElement).getAttribute('data-community-patreons') );
+			trace( href );
+			locationSelectors = ['/frontpage' => 'main ul li:nth-child(5)', '/roundups' => 'article aside :last-child'];
+			locationHandlers = [
+			'/frontpage' => function(data) {
+				trace( 'building /frontpage ${data.uri} dom' );
+				var ele = window.document.createLIElement();
+				ele.setAttribute('class', 'community patreon');
+				ele.innerHTML = '

${data.name} ${data.summary}

on Patreon

'; + return ele; + }, + '/roundups' => function (data) { + trace( 'building /roundups ${data.uri} dom' ); + var ele = window.document.createDivElement(); + ele.setAttribute('class', 'community patreon'); + ele.innerHTML = '

${data.name} ${data.summary}

on Patreon

'; + return ele; + } + ]; + + #if debug + http.onError = error; + #end + http.onData = recieved; + http.request(); + } + } + + private function recieved(data:String):Void { + trace( 'data recieved' ); + var payload:PatreonPayload = parse(data); + var location = untyped window.document.querySelectorAll( 'html[class]' )[0].classList; + var match:String = ''; + var target:Null = null; + trace( location ); + if (location != null && location.length > 0) { + for (key in locationSelectors.keys()) if (location.contains( key )) { + target = locationSelectors.get( match = key ); + break; + + } + + } + if (target != null) { + var targetEle = window.document.querySelectorAll( target )[0]; + var builder = locationHandlers.get( match ); + trace( target, match ); + if (targetEle != null) { + trace( 'adding patreon dom' ); + targetEle.parentNode.insertBefore( builder(payload.data[0]), targetEle.nextSibling ); + + } + + } + + } + + #if debug + private function error(reason:String):Void { + trace( reason ); } + #end } diff --git a/js-community-patreon/build.hxml b/js-community-patreon/build.hxml index ae3c866c..efbe56e1 100644 --- a/js-community-patreon/build.hxml +++ b/js-community-patreon/build.hxml @@ -1,4 +1,4 @@ -debug -lib tink_json -main CommunityPatreon --js ../src/js/communitypatreon.js +-js communitypatreon.js diff --git a/jsmin.sh b/jsmin.sh index f2e266da..5bb1c39d 100644 --- a/jsmin.sh +++ b/jsmin.sh @@ -28,5 +28,5 @@ cp $INPUT $BIN cp $BIN $MIN cp $MIN $OPT -java -jar $CLOSURE --js $INPUT --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file $BIN -java -jar $CLOSURE --js $INPUT --compilation_level ADVANCED_OPTIMIZATIONS --js_output_file $OPT +#java -jar $CLOSURE --js $INPUT --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file $BIN +#java -jar $CLOSURE --js $INPUT --compilation_level ADVANCED_OPTIMIZATIONS --js_output_file $OPT diff --git a/patreonscraper.sh b/patreonscraper.sh new file mode 100644 index 00000000..537df973 --- /dev/null +++ b/patreonscraper.sh @@ -0,0 +1 @@ +electron --enable-logging ./patreon/index.js -s ./patreon/scraper.js -o ./src/data/patreons.json -i ./src/data/patreons.original.json diff --git a/src/css/haxe.io.css b/src/css/haxe.io.css index ba9fa52d..805ead73 100644 --- a/src/css/haxe.io.css +++ b/src/css/haxe.io.css @@ -532,6 +532,47 @@ iframe[src*="eventbrite.com"] { min-height: 20em; } +.community.patreon { + padding: 0 1em; + background-color: rgba(230, 70, 26, 0.8); +} + +.community.patreon a, .community.patreon a:hover { + text-decoration: none; +} + +.community.patreon h1, .community.patreon h2 { + font-size: 1.5em; + color: white; +} + +.community.patreon a:hover h1, .community.patreon a:hover h2 { + text-decoration: underline; +} + +html[class*="/frontpage"] .community.patreon { + box-shadow: 1px 1px 1px 0px rgba(189, 189, 189, 0.3); +} + +html[class*="/roundups"] .community.patreon { + border-radius: 4px; + text-align: center; + background-color: rgba(230, 70, 26, 0.7); +} + +html[class*="/roundups"] .community.patreon:hover { + background-color: rgba(230, 70, 26, 0.8); +} + + +html[class*="/roundups"] .community.patreon h1 { + padding-top: 2em; +} + +html[class*="/roundups"] .community.patreon h2 { + padding-bottom: 2em; +} + @media (min-width: 400px) { .hero { /*margin: 1rem;*/ diff --git a/src/data/patreons.json b/src/data/patreons.json index 75d3368a..7f7bed02 100644 --- a/src/data/patreons.json +++ b/src/data/patreons.json @@ -1 +1,144 @@ -{"data":[{"description":null,"duration":"per\u00A0month","income":421,"keywords":null,"links":["https://www.facebook.com/OpenFL","https://twitter.com/open_fl"],"name":"OpenFL\u00A0","patrons":61,"profile":null,"summary":"is creating Free Open-Source\u00A0Software","update":null,"uri":"https://www.patreon.com/openfl?ty=h"},{"description":null,"duration":"per\u00A0month","income":149,"keywords":null,"links":["https://twitter.com/HaxeFlixel"],"name":"HaxeFlixel\u00A0","patrons":29,"profile":null,"summary":"is creating An Open Source, Cross-Platform 2D Game\u00A0Engine","update":"Feb 15 at 8:06pm","uri":"https://www.patreon.com/haxeflixel?ty=h"},{"description":null,"duration":"per\u00A0month","income":74,"keywords":null,"links":["https://twitter.com/jeff__ward"],"name":"hxScout\u00A0","patrons":11,"profile":null,"summary":"is creating Free\u00A0Software","update":null,"uri":"https://www.patreon.com/hxscout?ty=h"},{"description":null,"duration":"per\u00A0month","income":34,"keywords":null,"links":["https://www.facebook.com/haxeui","https://twitter.com/IanHarrigan1982"],"name":"HaxeUI\u00A0","patrons":7,"profile":null,"summary":"is creating Open source user interface\u00A0libraries","update":null,"uri":"https://www.patreon.com/haxeui?ty=h"},{"description":null,"duration":"per\u00A0month","income":222,"keywords":null,"links":["https://twitter.com/snowkitorg"],"name":"sn\u00F5wkit\u00A0","patrons":25,"profile":null,"summary":"is creating a collective for\u00A0Haxe","update":"Feb 24 at 8:55am","uri":"https://www.patreon.com/snowkit?ty=h"},{"description":null,"duration":"per\u00A0month","income":17,"keywords":null,"links":["https://www.facebook.com/x01010111","https://twitter.com/x01010111","https://www.youtube.com/user/UltraWill"],"name":"Will Blanton\u00A0","patrons":5,"profile":null,"summary":"is creating HaxeFlixel\u00A0Tutorials","update":"Mar 21 at 5:24pm","uri":"https://www.patreon.com/x01010111?ty=h"},{"description":null,"duration":"per tutorials, code,\u00A0videos","income":6,"keywords":null,"links":["https://twitter.com/lewislepton","https://www.youtube.com/c/lewislepton"],"name":"Lewis Lepton\u00A0","patrons":3,"profile":null,"summary":"is creating tutorials, code,\u00A0videos","update":"May 3 at 7:04pm","uri":"https://www.patreon.com/lewislepton?ty=h"},{"description":null,"duration":"per\u00A0month","income":0,"keywords":null,"links":["https://twitter.com/nadako"],"name":"Dan Korostelev\u00A0","patrons":0,"profile":null,"summary":"is creating\u00A0Haxe","update":null,"uri":"https://www.patreon.com/nadako"},{"description":null,"duration":"per\u00A0month","income":56,"keywords":null,"links":["https://twitter.com/the_august_late"],"name":"August Late\u00A0","patrons":13,"profile":null,"summary":"is creating unique 2d lighting\u00A0tech.","update":"May 28 at 6:26pm","uri":"http://www.patreon.com/augustlate"}]} +{ + "data": [ + { + "description": null, + "duration": "per month", + "income": 421, + "keywords": null, + "links": [ + "https://www.facebook.com/OpenFL", + "https://twitter.com/open_fl" + ], + "name": "OpenFL", + "patrons": 61, + "profile": null, + "summary": "is creating Free Open-Source Software", + "update": null, + "uri": "https://www.patreon.com/openfl?ty=h" + }, + { + "description": null, + "duration": "per month", + "income": 149, + "keywords": null, + "links": [ + "https://twitter.com/HaxeFlixel" + ], + "name": "HaxeFlixel", + "patrons": 29, + "profile": null, + "summary": "is creating An Open Source, Cross-Platform 2D Game Engine", + "update": "Feb 15 at 8:06pm", + "uri": "https://www.patreon.com/haxeflixel?ty=h" + }, + { + "description": null, + "duration": "per month", + "income": 74, + "keywords": null, + "links": [ + "https://twitter.com/jeff__ward" + ], + "name": "hxScout", + "patrons": 11, + "profile": null, + "summary": "is creating Free Software", + "update": null, + "uri": "https://www.patreon.com/hxscout?ty=h" + }, + { + "description": null, + "duration": "per month", + "income": 34, + "keywords": null, + "links": [ + "https://www.facebook.com/haxeui", + "https://twitter.com/IanHarrigan1982" + ], + "name": "HaxeUI", + "patrons": 7, + "profile": null, + "summary": "is creating Open source user interface libraries", + "update": null, + "uri": "https://www.patreon.com/haxeui?ty=h" + }, + { + "description": null, + "duration": "per month", + "income": 222, + "keywords": null, + "links": [ + "https://twitter.com/snowkitorg" + ], + "name": "snõwkit", + "patrons": 25, + "profile": null, + "summary": "is creating a collective for Haxe", + "update": "Feb 24 at 8:55am", + "uri": "https://www.patreon.com/snowkit?ty=h" + }, + { + "description": null, + "duration": "per month", + "income": 17, + "keywords": null, + "links": [ + "https://www.facebook.com/x01010111", + "https://twitter.com/x01010111", + "https://www.youtube.com/user/UltraWill" + ], + "name": "Will Blanton", + "patrons": 5, + "profile": null, + "summary": "is creating HaxeFlixel Tutorials", + "update": "Mar 21 at 5:24pm", + "uri": "https://www.patreon.com/x01010111?ty=h" + }, + { + "description": null, + "duration": "per tutorials, code, videos", + "income": 6, + "keywords": null, + "links": [ + "https://twitter.com/lewislepton", + "https://www.youtube.com/c/lewislepton" + ], + "name": "Lewis Lepton", + "patrons": 3, + "profile": null, + "summary": "is creating tutorials, code, videos", + "update": "May 3 at 7:04pm", + "uri": "https://www.patreon.com/lewislepton?ty=h" + }, + { + "description": null, + "duration": "per month", + "income": 0, + "keywords": null, + "links": [ + "https://twitter.com/nadako" + ], + "name": "Dan Korostelev", + "patrons": 0, + "profile": null, + "summary": "is creating Haxe", + "update": null, + "uri": "https://www.patreon.com/nadako" + }, + { + "description": null, + "duration": "per month", + "income": 56, + "keywords": null, + "links": [ + "https://twitter.com/the_august_late" + ], + "name": "August Late", + "patrons": 13, + "profile": null, + "summary": "is creating unique 2d lighting tech.", + "update": "May 28 at 6:26pm", + "uri": "http://www.patreon.com/augustlate" + } + ] +} diff --git a/src/js/SiteScript.hx b/src/js/SiteScript.hx new file mode 100644 index 00000000..16f373e7 --- /dev/null +++ b/src/js/SiteScript.hx @@ -0,0 +1,15 @@ +package ; + +import CommunityPatreon; + +class SiteScript { + + public static function main() { + var script = new SiteScript(); + } + + public function new() { + var communitypatreon = new CommunityPatreon(); + } + +} diff --git a/src/js/build.hxml b/src/js/build.hxml new file mode 100644 index 00000000..5861b196 --- /dev/null +++ b/src/js/build.hxml @@ -0,0 +1,10 @@ +-cp ../../js-community-patreon/ +-lib tink_json +-lib tink_core +-main SiteScript +-dce full + +--each + +-debug +-js haxe.io.js From 3ec34c9df940d6f40f55ac0d2caf2824d7b38175 Mon Sep 17 00:00:00 2001 From: Skial Bainn Date: Mon, 27 Jun 2016 11:11:19 +0100 Subject: [PATCH 4/8] Use patreons colours. --- js-community-patreon/CommunityPatreon.hx | 4 +- src/css/haxe.io.css | 58 +++++++++++++++--------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/js-community-patreon/CommunityPatreon.hx b/js-community-patreon/CommunityPatreon.hx index 6b73f543..7bf0438d 100644 --- a/js-community-patreon/CommunityPatreon.hx +++ b/js-community-patreon/CommunityPatreon.hx @@ -49,14 +49,14 @@ class CommunityPatreon { trace( 'building /frontpage ${data.uri} dom' ); var ele = window.document.createLIElement(); ele.setAttribute('class', 'community patreon'); - ele.innerHTML = '

${data.name} ${data.summary}

on Patreon

'; + ele.innerHTML = '
${data.name}

${data.summary}, supported by ${data.patrons} people.

Become a Patron'; return ele; }, '/roundups' => function (data) { trace( 'building /roundups ${data.uri} dom' ); var ele = window.document.createDivElement(); ele.setAttribute('class', 'community patreon'); - ele.innerHTML = '

${data.name} ${data.summary}

on Patreon

'; + ele.innerHTML = '
${data.name}

${data.summary}, supported by ${data.patrons} people.

Become a Patron'; return ele; } ]; diff --git a/src/css/haxe.io.css b/src/css/haxe.io.css index 805ead73..33920774 100644 --- a/src/css/haxe.io.css +++ b/src/css/haxe.io.css @@ -533,44 +533,60 @@ iframe[src*="eventbrite.com"] { } .community.patreon { - padding: 0 1em; - background-color: rgba(230, 70, 26, 0.8); + padding: 0; + color: white; + display: flex; + flex-direction: column; + font-family: 'Open Sans', sans-serif; + background-color: rgba(232, 81, 40, 0.9); } -.community.patreon a, .community.patreon a:hover { - text-decoration: none; +.community.patreon p { + margin-top: 0.1em; } -.community.patreon h1, .community.patreon h2 { - font-size: 1.5em; - color: white; +.community.patreon a { + flex-grow: 1; + display: flex; + color: inherit; + padding: 1.5em 1.5em 0; + flex-direction: column; + border-radius: inherit; + justify-content: center; } -.community.patreon a:hover h1, .community.patreon a:hover h2 { - text-decoration: underline; +.community.patreon a, .community.patreon a:hover { + text-decoration: none; } -html[class*="/frontpage"] .community.patreon { - box-shadow: 1px 1px 1px 0px rgba(189, 189, 189, 0.3); +.community.patreon a:hover h1, .community.patreon a:hover h2 { + text-decoration: underline; } -html[class*="/roundups"] .community.patreon { - border-radius: 4px; - text-align: center; - background-color: rgba(230, 70, 26, 0.7); +.community.patreon .name, .community.patreon .patrons { + font-weight: bold; } -html[class*="/roundups"] .community.patreon:hover { - background-color: rgba(230, 70, 26, 0.8); +.community.patreon .button { + width: 100%; + padding: 0 0 0.5em; + background-color: #00a875; } +.community.patreon:hover .button, .community.patreon .button:hover { + background-color: #00b780; + } -html[class*="/roundups"] .community.patreon h1 { - padding-top: 2em; +html[class*="/frontpage"] .community.patreon { + border-left: none; + box-shadow: 1px 1px 1px 0px rgba(189, 189, 189, 0.3); } -html[class*="/roundups"] .community.patreon h2 { - padding-bottom: 2em; +html[class*="/roundups"] .community.patreon { + margin-top: 1em; + min-height: 15em; + border-radius: 4px; + text-align: center; } @media (min-width: 400px) { From f3a9317fd9504882b88c3d6d61dffe93c1e41378 Mon Sep 17 00:00:00 2001 From: Skial Bainn Date: Mon, 27 Jun 2016 11:23:41 +0100 Subject: [PATCH 5/8] Tweaking. --- js-community-patreon/CommunityPatreon.hx | 8 ++++++-- src/css/haxe.io.css | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/js-community-patreon/CommunityPatreon.hx b/js-community-patreon/CommunityPatreon.hx index 7bf0438d..3f98e016 100644 --- a/js-community-patreon/CommunityPatreon.hx +++ b/js-community-patreon/CommunityPatreon.hx @@ -47,16 +47,20 @@ class CommunityPatreon { locationHandlers = [ '/frontpage' => function(data) { trace( 'building /frontpage ${data.uri} dom' ); + var action = data.patrons > 0 ? 'Become their next' : 'Be the first'; + var supported = data.patrons > 0 ? 'currently unsupported.' : 'supported by ${data.patrons} people.'; var ele = window.document.createLIElement(); ele.setAttribute('class', 'community patreon'); - ele.innerHTML = '
${data.name}

${data.summary}, supported by ${data.patrons} people.

Become a Patron'; + ele.innerHTML = '
${data.name}

${data.summary}, $supported

$action Patron'; return ele; }, '/roundups' => function (data) { trace( 'building /roundups ${data.uri} dom' ); + var action = data.patrons > 0 ? 'Become their next' : 'Be the first'; + var supported = data.patrons > 0 ? 'currently unsupported.' : 'supported by ${data.patrons} people.'; var ele = window.document.createDivElement(); ele.setAttribute('class', 'community patreon'); - ele.innerHTML = '
${data.name}

${data.summary}, supported by ${data.patrons} people.

Become a Patron'; + ele.innerHTML = '
${data.name}

${data.summary}, $supported

$action Patron'; return ele; } ]; diff --git a/src/css/haxe.io.css b/src/css/haxe.io.css index 33920774..10cdfd83 100644 --- a/src/css/haxe.io.css +++ b/src/css/haxe.io.css @@ -551,8 +551,9 @@ iframe[src*="eventbrite.com"] { color: inherit; padding: 1.5em 1.5em 0; flex-direction: column; - border-radius: inherit; justify-content: center; + border-bottom-left-radius: inherit; + border-bottom-right-radius: inherit; } .community.patreon a, .community.patreon a:hover { @@ -569,7 +570,9 @@ iframe[src*="eventbrite.com"] { .community.patreon .button { width: 100%; - padding: 0 0 0.5em; + word-wrap: break-word; + word-break: break-word; + padding: 0 1.5em 0.5em; background-color: #00a875; } From 49c15f9b629f4173c4b3beab7a4f8df34c7c6698 Mon Sep 17 00:00:00 2001 From: Skial Bainn Date: Mon, 27 Jun 2016 11:30:35 +0100 Subject: [PATCH 6/8] Fix selector. --- js-community-patreon/CommunityPatreon.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-community-patreon/CommunityPatreon.hx b/js-community-patreon/CommunityPatreon.hx index 3f98e016..7461c6c3 100644 --- a/js-community-patreon/CommunityPatreon.hx +++ b/js-community-patreon/CommunityPatreon.hx @@ -43,7 +43,7 @@ class CommunityPatreon { var href = ''; var http = new Http( href = cast (url, DOMElement).getAttribute('data-community-patreons') ); trace( href ); - locationSelectors = ['/frontpage' => 'main ul li:nth-child(5)', '/roundups' => 'article aside :last-child']; + locationSelectors = ['/frontpage' => 'main ul li:nth-child(5)', '/roundups' => 'article aside > :last-child']; locationHandlers = [ '/frontpage' => function(data) { trace( 'building /frontpage ${data.uri} dom' ); From c8ebbfe50b46e8f0ee0f413801c5937b36c57ced Mon Sep 17 00:00:00 2001 From: Skial Bainn Date: Mon, 27 Jun 2016 14:09:55 +0100 Subject: [PATCH 7/8] Patreon data selected with Math.random --- js-community-patreon/CommunityPatreon.hx | 18 ++++++++++-------- jsmin.sh | 4 ++-- src/js/build.hxml | 3 ++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/js-community-patreon/CommunityPatreon.hx b/js-community-patreon/CommunityPatreon.hx index 7461c6c3..69464971 100644 --- a/js-community-patreon/CommunityPatreon.hx +++ b/js-community-patreon/CommunityPatreon.hx @@ -47,20 +47,20 @@ class CommunityPatreon { locationHandlers = [ '/frontpage' => function(data) { trace( 'building /frontpage ${data.uri} dom' ); - var action = data.patrons > 0 ? 'Become their next' : 'Be the first'; - var supported = data.patrons > 0 ? 'currently unsupported.' : 'supported by ${data.patrons} people.'; + var action = data.patrons > 0 ? 'Become their next' : 'Be their first'; + var supported = data.patrons > 0 ? ', supported by ${data.patrons} people.' : '.'; var ele = window.document.createLIElement(); ele.setAttribute('class', 'community patreon'); - ele.innerHTML = '
${data.name}

${data.summary}, $supported

$action Patron'; + ele.innerHTML = '
${data.name}

${data.summary}$supported

$action Patron'; return ele; }, '/roundups' => function (data) { trace( 'building /roundups ${data.uri} dom' ); - var action = data.patrons > 0 ? 'Become their next' : 'Be the first'; - var supported = data.patrons > 0 ? 'currently unsupported.' : 'supported by ${data.patrons} people.'; + var action = data.patrons > 0 ? 'Become their next' : 'Be their first'; + var supported = data.patrons > 0 ? ', supported by ${data.patrons} people.' : '.'; var ele = window.document.createDivElement(); ele.setAttribute('class', 'community patreon'); - ele.innerHTML = '
${data.name}

${data.summary}, $supported

$action Patron'; + ele.innerHTML = '
${data.name}

${data.summary}$supported

$action Patron'; return ele; } ]; @@ -80,6 +80,7 @@ class CommunityPatreon { var match:String = ''; var target:Null = null; trace( location ); + trace( payload ); if (location != null && location.length > 0) { for (key in locationSelectors.keys()) if (location.contains( key )) { target = locationSelectors.get( match = key ); @@ -94,8 +95,9 @@ class CommunityPatreon { var builder = locationHandlers.get( match ); trace( target, match ); if (targetEle != null) { - trace( 'adding patreon dom' ); - targetEle.parentNode.insertBefore( builder(payload.data[0]), targetEle.nextSibling ); + var index = Math.round(Math.random() * (payload.data.length - 1)); + trace( 'adding patreon dom', payload.data.length, index, payload.data[index] ); + targetEle.parentNode.insertBefore( builder(payload.data[index]), targetEle.nextSibling ); } diff --git a/jsmin.sh b/jsmin.sh index 5bb1c39d..f2e266da 100644 --- a/jsmin.sh +++ b/jsmin.sh @@ -28,5 +28,5 @@ cp $INPUT $BIN cp $BIN $MIN cp $MIN $OPT -#java -jar $CLOSURE --js $INPUT --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file $BIN -#java -jar $CLOSURE --js $INPUT --compilation_level ADVANCED_OPTIMIZATIONS --js_output_file $OPT +java -jar $CLOSURE --js $INPUT --compilation_level SIMPLE_OPTIMIZATIONS --js_output_file $BIN +java -jar $CLOSURE --js $INPUT --compilation_level ADVANCED_OPTIMIZATIONS --js_output_file $OPT diff --git a/src/js/build.hxml b/src/js/build.hxml index 5861b196..e3fd2628 100644 --- a/src/js/build.hxml +++ b/src/js/build.hxml @@ -6,5 +6,6 @@ --each --debug +#-debug +--no-traces -js haxe.io.js From 803cb20f6117bf40fe431004fb2d44c636168bd3 Mon Sep 17 00:00:00 2001 From: Skial Bainn Date: Mon, 27 Jun 2016 14:18:08 +0100 Subject: [PATCH 8/8] Clean up patreon summary. --- electron-patreon/PatreonScraper.hx | 15 ++- src/data/patreons.json | 145 +---------------------------- 2 files changed, 11 insertions(+), 149 deletions(-) diff --git a/electron-patreon/PatreonScraper.hx b/electron-patreon/PatreonScraper.hx index 86a97224..dfa55cb2 100644 --- a/electron-patreon/PatreonScraper.hx +++ b/electron-patreon/PatreonScraper.hx @@ -73,7 +73,7 @@ class PatreonScraper { case [value = _.startsWith('$') => true, duration] | [duration, value = _.startsWith('$') => true]: trace( pair[0], pair[1] ); data.income = Std.parseFloat( value.substring(1) ); - data.duration = cleanWhitespace( duration ); + data.duration = clean( duration ); case [_, _]: trace( pair ); @@ -87,9 +87,9 @@ class PatreonScraper { var socials = qsa( '[class*="social"][href]' ); var description = qsa( '[class*="ToggleableContent"][class*="stackable"]' )[0]; - if (name != null) data.name = cleanWhitespace( name.textContent.trim() ); - if (isCreating != null) data.summary = cleanWhitespace( isCreating.textContent.trim() ); - if (lastUpdated != null) data.update = cleanWhitespace( lastUpdated.textContent.trim() ); + if (name != null) data.name = clean( name.textContent.trim() ); + if (isCreating != null) data.summary = clean( isCreating.textContent.trim() ); + if (lastUpdated != null) data.update = clean( lastUpdated.textContent.trim() ); data.links = [for (social in socials) cast (social,DOMElement).getAttribute('href')]; trace( data ); @@ -97,12 +97,17 @@ class PatreonScraper { ipcRenderer.send(data.uri, stringify(data)); } - private static function cleanWhitespace(value:String):String { + private static function clean(value:String):String { for (codepoint in whitespace) { value = value.uSplit( codepoint ).join(' '); } + for (char in [',', '.']) if (value.endsWith(char)) { + value = value.substring(0, value.length-1); + + } + return value.trim(); } diff --git a/src/data/patreons.json b/src/data/patreons.json index 7f7bed02..ca5781ec 100644 --- a/src/data/patreons.json +++ b/src/data/patreons.json @@ -1,144 +1 @@ -{ - "data": [ - { - "description": null, - "duration": "per month", - "income": 421, - "keywords": null, - "links": [ - "https://www.facebook.com/OpenFL", - "https://twitter.com/open_fl" - ], - "name": "OpenFL", - "patrons": 61, - "profile": null, - "summary": "is creating Free Open-Source Software", - "update": null, - "uri": "https://www.patreon.com/openfl?ty=h" - }, - { - "description": null, - "duration": "per month", - "income": 149, - "keywords": null, - "links": [ - "https://twitter.com/HaxeFlixel" - ], - "name": "HaxeFlixel", - "patrons": 29, - "profile": null, - "summary": "is creating An Open Source, Cross-Platform 2D Game Engine", - "update": "Feb 15 at 8:06pm", - "uri": "https://www.patreon.com/haxeflixel?ty=h" - }, - { - "description": null, - "duration": "per month", - "income": 74, - "keywords": null, - "links": [ - "https://twitter.com/jeff__ward" - ], - "name": "hxScout", - "patrons": 11, - "profile": null, - "summary": "is creating Free Software", - "update": null, - "uri": "https://www.patreon.com/hxscout?ty=h" - }, - { - "description": null, - "duration": "per month", - "income": 34, - "keywords": null, - "links": [ - "https://www.facebook.com/haxeui", - "https://twitter.com/IanHarrigan1982" - ], - "name": "HaxeUI", - "patrons": 7, - "profile": null, - "summary": "is creating Open source user interface libraries", - "update": null, - "uri": "https://www.patreon.com/haxeui?ty=h" - }, - { - "description": null, - "duration": "per month", - "income": 222, - "keywords": null, - "links": [ - "https://twitter.com/snowkitorg" - ], - "name": "snõwkit", - "patrons": 25, - "profile": null, - "summary": "is creating a collective for Haxe", - "update": "Feb 24 at 8:55am", - "uri": "https://www.patreon.com/snowkit?ty=h" - }, - { - "description": null, - "duration": "per month", - "income": 17, - "keywords": null, - "links": [ - "https://www.facebook.com/x01010111", - "https://twitter.com/x01010111", - "https://www.youtube.com/user/UltraWill" - ], - "name": "Will Blanton", - "patrons": 5, - "profile": null, - "summary": "is creating HaxeFlixel Tutorials", - "update": "Mar 21 at 5:24pm", - "uri": "https://www.patreon.com/x01010111?ty=h" - }, - { - "description": null, - "duration": "per tutorials, code, videos", - "income": 6, - "keywords": null, - "links": [ - "https://twitter.com/lewislepton", - "https://www.youtube.com/c/lewislepton" - ], - "name": "Lewis Lepton", - "patrons": 3, - "profile": null, - "summary": "is creating tutorials, code, videos", - "update": "May 3 at 7:04pm", - "uri": "https://www.patreon.com/lewislepton?ty=h" - }, - { - "description": null, - "duration": "per month", - "income": 0, - "keywords": null, - "links": [ - "https://twitter.com/nadako" - ], - "name": "Dan Korostelev", - "patrons": 0, - "profile": null, - "summary": "is creating Haxe", - "update": null, - "uri": "https://www.patreon.com/nadako" - }, - { - "description": null, - "duration": "per month", - "income": 56, - "keywords": null, - "links": [ - "https://twitter.com/the_august_late" - ], - "name": "August Late", - "patrons": 13, - "profile": null, - "summary": "is creating unique 2d lighting tech.", - "update": "May 28 at 6:26pm", - "uri": "http://www.patreon.com/augustlate" - } - ] -} +{"data":[{"description":null,"duration":"per month","income":422,"keywords":null,"links":["https://www.facebook.com/OpenFL","https://twitter.com/open_fl"],"name":"OpenFL","patrons":62,"profile":null,"summary":"is creating Free Open-Source Software","update":null,"uri":"https://www.patreon.com/openfl?ty=h"},{"description":null,"duration":"per month","income":149,"keywords":null,"links":["https://twitter.com/HaxeFlixel"],"name":"HaxeFlixel","patrons":29,"profile":null,"summary":"is creating An Open Source, Cross-Platform 2D Game Engine","update":"Feb 15 at 8:06pm","uri":"https://www.patreon.com/haxeflixel?ty=h"},{"description":null,"duration":"per month","income":74,"keywords":null,"links":["https://twitter.com/jeff__ward"],"name":"hxScout","patrons":11,"profile":null,"summary":"is creating Free Software","update":null,"uri":"https://www.patreon.com/hxscout?ty=h"},{"description":null,"duration":"per month","income":34,"keywords":null,"links":["https://www.facebook.com/haxeui","https://twitter.com/IanHarrigan1982"],"name":"HaxeUI","patrons":7,"profile":null,"summary":"is creating Open source user interface libraries","update":null,"uri":"https://www.patreon.com/haxeui?ty=h"},{"description":null,"duration":"per month","income":222,"keywords":null,"links":["https://twitter.com/snowkitorg"],"name":"sn\u00F5wkit","patrons":25,"profile":null,"summary":"is creating a collective for Haxe","update":null,"uri":"https://www.patreon.com/snowkit?ty=h"},{"description":null,"duration":"per month","income":17,"keywords":null,"links":["https://www.facebook.com/x01010111","https://twitter.com/x01010111","https://www.youtube.com/user/UltraWill"],"name":"Will Blanton","patrons":5,"profile":null,"summary":"is creating HaxeFlixel Tutorials","update":"Mar 21 at 5:24pm","uri":"https://www.patreon.com/x01010111?ty=h"},{"description":null,"duration":"per tutorials, code, videos","income":6,"keywords":null,"links":["https://twitter.com/lewislepton","https://www.youtube.com/c/lewislepton"],"name":"Lewis Lepton","patrons":3,"profile":null,"summary":"is creating tutorials, code, videos","update":"May 3 at 7:04pm","uri":"https://www.patreon.com/lewislepton?ty=h"},{"description":null,"duration":"per month","income":0,"keywords":null,"links":["https://twitter.com/nadako"],"name":"Dan Korostelev","patrons":0,"profile":null,"summary":"is creating Haxe","update":null,"uri":"https://www.patreon.com/nadako"},{"description":null,"duration":"per month","income":56,"keywords":null,"links":["https://twitter.com/the_august_late"],"name":"August Late","patrons":13,"profile":null,"summary":"is creating unique 2d lighting tech","update":"May 28 at 6:26pm","uri":"http://www.patreon.com/augustlate"}]}