From cc55391a7544b0ce0cc37b8aa628dc8f9a46db49 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 2 Oct 2017 15:50:06 +0200 Subject: Website updated to list supporters on the website. --- .gitignore | 3 +- build.xml | 13 +- buildScripts/ivy.xml | 15 ++- buildScripts/supporters.ant.xml | 57 ++++++++ buildScripts/website.ant.xml | 12 +- website/resources/css/custom.css | 23 ++++ website/resources/files/supporters.json | 13 ++ website/resources/img/spinner.gif | Bin 0 -> 828 bytes website/resources/js/order-license.js | 102 ++++++++++++++ website/resources/js/supporters.js | 214 ++++++++++++++++++++++++++++++ website/templates/main.html | 1 + website/templates/order-license-info.html | 24 ++++ website/templates/order-license.html | 78 +++++++++++ website/templates/supporters.html | 10 ++ 14 files changed, 554 insertions(+), 11 deletions(-) create mode 100644 buildScripts/supporters.ant.xml create mode 100644 website/resources/files/supporters.json create mode 100644 website/resources/img/spinner.gif create mode 100644 website/resources/js/order-license.js create mode 100644 website/resources/js/supporters.js create mode 100644 website/templates/order-license-info.html create mode 100644 website/templates/order-license.html create mode 100644 website/templates/supporters.html diff --git a/.gitignore b/.gitignore index b05ce2c6..49316515 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ /junit*.properties /eclipse.location /.apt_generated/ -/out \ No newline at end of file +/out +/website/lombokSupporters diff --git a/build.xml b/build.xml index 14d67ffc..629db4a6 100644 --- a/build.xml +++ b/build.xml @@ -118,6 +118,11 @@ the common tasks and can be called on to run the main aspects of all the sub-scr + + + + + @@ -889,7 +894,11 @@ You can also create your own by writing a 'testenvironment.properties' file. The - + + + + @@ -897,7 +906,7 @@ You can also create your own by writing a 'testenvironment.properties' file. The - diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml index 81f50f4c..cf62377e 100644 --- a/buildScripts/ivy.xml +++ b/buildScripts/ivy.xml @@ -14,6 +14,7 @@ + @@ -22,10 +23,10 @@ - - - - + + + + @@ -56,5 +57,11 @@ + + + + + + diff --git a/buildScripts/supporters.ant.xml b/buildScripts/supporters.ant.xml new file mode 100644 index 00000000..d19e0bb6 --- /dev/null +++ b/buildScripts/supporters.ant.xml @@ -0,0 +1,57 @@ + + + +This buildfile is part of projectlombok.org. It is responsible for updating/maintaining the separate git repository +containing the status of lombok's supporters. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml index 15a0f95f..5c996fc6 100644 --- a/buildScripts/website.ant.xml +++ b/buildScripts/website.ant.xml @@ -37,13 +37,17 @@ such as applying the templates to produce the website, converting the changelog - + - + + + + + lombok.version already set. @@ -134,8 +138,8 @@ such as applying the templates to produce the website, converting the changelog - - + + "); + img.css({ + "max-width": "500px", + "max-height": "300px" + }); + $("#logoCnt").append(img).show(); + img.attr("src", dataUrl); + }); + } catch (e) { + if (console && console.log) console.log(e); + } + } + + function processImageUpload(fnc) { + var f = $("#logo")[0].files[0]; + if (!f) return; + if (f.size > 10000000) return "Logo too large; please give us a logo below 10MiB in size."; + var imageType = /^image\//; + if (!imageType.test(f.type)) return "Please upload an image, for example in PNG format."; + var reader = new FileReader(); + reader.onload = function(e) { + imgDataUrl = e.target.result; + if (fnc) fnc(e.target.result); + }; + reader.readAsDataURL(f); + return null; + } + + $(applyLicense); +})(); diff --git a/website/resources/js/supporters.js b/website/resources/js/supporters.js new file mode 100644 index 00000000..5ec1b057 --- /dev/null +++ b/website/resources/js/supporters.js @@ -0,0 +1,214 @@ +"use strict"; + +(function($) { + var supporters = {}; + var weights = {}; + var types = ["patron", "professional", "enterprise"]; + + function shuffle(array) { + var i = 0, j = 0, temp = null; + for (i = array.length - 1; i > 0; i -= 1) { + j = Math.floor(Math.random() * (i + 1)); + temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + } + + function pad(number) { + return number < 10 ? '0' + number : number; + } + + function fromDate(d) { + return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()); + + } + + function toDate(s) { + var x = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s); + if (x) return new Date(parseInt(x[1]), parseInt(x[2]), parseInt(x[3])); + return null; + } + + function Supporter(type, json) { + this.type = type; + this.name = json.name; + this.logo = json.logo; + this.url = json.url; + this.showName = json.showName; + this.start = json.range ? toDate(json.range[0]) : null; + this.end = json.range ? toDate(json.range[1]) : null; + this.weight = (!json.weight && json.weight !== 0.0) ? 1.0 : json.weight; + } + + Supporter.prototype.inRange = function(d) { + return (!this.start || this.start <= d) && (!this.end || this.end > d); + }; + + Supporter.prototype.render = function() { + var d = $("
").addClass("supportItem").addClass(this.type); + var a = d; + if (this.url) { + a = $("").attr("href", this.url).attr("rel", "noopener"); + d.append(a); + } + var n = $("").text(this.name); + a.append(n); + + if (this.logo) { + a.addClass("logo"); + var i = new Image(); + var showName = this.showName; + i.onload = function() { + var w = i.width; + var h = i.height; + var wf = w / 162; + var hf = h / 80; + var f = hf > wf ? hf : wf; + var wt = Math.round(w / f); + var ht = Math.round(h / f); + i.width = wt; + i.height = ht; + if (!showName) a.empty(); + a.prepend(i); + }; + i.src = 'files/' + this.logo; + } + return d; + } + + function errorHandler(xhr, statusText, err) { + var errMsg = "Can't connect to projectlombok.org to fetch the list of licensees and supporters."; + if (console && console.log) { + console.log("AJAX error for loading list of supporters:"); + console.log(err); + } + var errBox = $("
").addClass("errorBox").text(errMsg); + $(".supporters").text("").append(errBox); + } + + function successHandler(data) { + $.each(types, function() { + var t = this; + supporters[t] = []; + if (data && data[t]) $.each(data[t], function() { + supporters[t].push(new Supporter(t, this)); + }); + }); + weights = data.modWeight; + if (typeof weights !== 'object') weights = {}; + updatePage(); + } + + function build() { + var spinner = $("").attr("title", "loading").attr("src", "/img/spinner.gif").addClass("spinner"); + $(".supporters").append(spinner); + $.ajax({ + url: "/files/supporters.json", + dataType: "json", + cache: true, + error: errorHandler, + success: function(data) { + spinner.remove(); + successHandler(data); + } + }); + } + + function applySupporters() { + build(); + } + + function updatePage() { + updateSupporters(); + updateSupporterBar(); + } + + var supPerBar = 4; + function updateSupporterBar() { + var s = $(".supporterBar"); + s.find(".introText").show(); + s.append($("
").addClass("sbCnt")); + s = s.find(".sbCnt"); + var now = new Date(); + var list = []; + $.each(types, function() { + var t = this; + $.each(supporters[t], function() { + if (this.inRange(now)) { + var w = weights[t] ? weights[t] : 1.0; + if (this.weight) w = w * this.weight; + for (var i = 0; i < w; i++) list.push(this); + } + }); + }); + + shuffle(list); + + var len = list.length; + var pos = 0; + var c = [], cd = []; + for (var i = 0; i < supPerBar; i++) { + c[i] = null; + cd[i] = $("
").addClass("barItem"); + } + + var upd = function() { + var nw = [], a = [], fo = $(), fi = $(); + var sPos = pos; + for (var i = 0; i < supPerBar; i++) { + if (++pos === len) pos = 0; + var z = false; + for (var j = 0; j < i; j++) if (nw[j] === list[pos]) z = true; + if (z) i--; + else nw[i] = list[pos]; + if (pos === sPos) break; + } + for (var i = 0; i < supPerBar; i++) a[i] = (nw[i] === c[i] || !nw[i]) ? null : nw[i].render(i + 1).hide(); + for (var i = 0; i < supPerBar; i++) { + if (a[i]) { + fi = fi.add(a[i]); + fo = fo.add(cd[i].children()); + if (cd[i].parent().length === 0) s.append(cd[i]); + cd[i].append(a[i]); + c[i] = nw[i]; + } + } + + if (fo.length === 0) fi.fadeIn(); + else { + fo.fadeOut("normal", function() { + fi.fadeIn(); + fo.remove(); + }); + } + }; + + setInterval(upd, 10000); + upd(); + } + + function updateSupporters() { + var s = $(".supporters"); + s.empty(); + var now = new Date(); + $.each(types, function() { + var t = this; + var d = $("
").addClass("row"); + var h = $("

").text(t); + d.append(h); + $.each(supporters[t], function() { + if (this.inRange(now)) d.append(this.render()); + }); + if (d.children().length > 1) s.append(d); + }); + if (s.children().length < 1) { + var x = $("
").addClass("noSupportersBox").html( + "We don't have any supporters yet this month.
Become a patron " + + "or order a professional or enterprise license today!"); + s.append(x); + } + } + + $(applySupporters); +})($); \ No newline at end of file diff --git a/website/templates/main.html b/website/templates/main.html index 2089cb5e..df096955 100644 --- a/website/templates/main.html +++ b/website/templates/main.html @@ -29,6 +29,7 @@

+
diff --git a/website/templates/order-license-info.html b/website/templates/order-license-info.html new file mode 100644 index 00000000..b465eaf0 --- /dev/null +++ b/website/templates/order-license-info.html @@ -0,0 +1,24 @@ +<#import "/_scaffold.html" as main> + +<@main.scaffold> + + diff --git a/website/templates/order-license.html b/website/templates/order-license.html new file mode 100644 index 00000000..4d52d93a --- /dev/null +++ b/website/templates/order-license.html @@ -0,0 +1,78 @@ +<#import "/_scaffold.html" as main> + +<@main.scaffold load=["/js/order-license.js"]> + +
+Form fields: + +* EU / US / Elders +* Naam bedrijf +* Do you want to be mentioned? +* Link to logo +* Link to website +* Professional of enterprise +* # of developers +* Email of contact.sta +* In EU: VAT Number +* In EU: How would you like to pay? IBAN or Payoneer +* In US: How would you like to pay? International wire transfer, or Payoneer (default = payoneer). +* Elders: We’ll get back to you.. +
+ diff --git a/website/templates/supporters.html b/website/templates/supporters.html new file mode 100644 index 00000000..2003a23f --- /dev/null +++ b/website/templates/supporters.html @@ -0,0 +1,10 @@ +<#import "/_scaffold.html" as main> + +<@main.scaffold load=["js/supporters.js"]> + + -- cgit