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

Render sponsors from Open Collective REST API #3972

Merged
merged 2 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 33 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,51 +36,39 @@ information about how you can get involved as a developer. If you are looking fo

### Financial Contributors

[Become a financial contributor](https://opencollective.com/typelevel) and help us sustain our community. Donations directly support office hour for maintainers, better documentation and strategic initiatives.



### Gold Sponsors

Gold Sponsors are those who have pledged $5,000 to $10,000.

<a href="http://47deg.com"><img src="https://typelevel.org/img/media/sponsors/47_degrees.png" style="margin-left: 10px; margin-right: 10px" /></a>
<a href="https://www.iteratorshq.com"><img src="https://typelevel.org/img/media/sponsors/iterators.png" style="margin-bottom:8px;margin-left: 10px; margin-right: 10px"/></a>
<a href="https://triplequote.com/"><img src="https://typelevel.org/img/media/sponsors/triplequote.png" style="margin-bottom:9px; margin-right: 10px" /></a>
<a href="http://underscore.io"><img src="https://typelevel.org/img/media/sponsors/underscore.png" style="margin-bottom:5px;margin-left: 10px; margin-right: 10px"/></a>



### Silver Sponsors

Silver Sponsors are those who have pledged $2,000 to $5,000.

<a href="https://www.ebiznext.com/"><img src="https://typelevel.org/img/media/sponsors/ebiznext.png" style="margin-bottom:15px; margin-right: 10px" /></a>
<a href="https://www.inner-product.com/"><img src="https://typelevel.org/img/media/sponsors/inner-product.png" style="margin-bottom:10px; margin-right: 10px"/></a>
<a href="https://evolutiongaming.com/"><img src="https://typelevel.org/img/media/sponsors/evolution_gaming_engineering.png" style="margin-bottom:10px; margin-right: 10px"/></a>


#### Other Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/typelevel/contribute)]

<a href="https://opencollective.com/typelevel/organization/0/website"><img src="https://opencollective.com/typelevel/organization/0/avatar.svg"></a>
<a href="https://opencollective.com/typelevel/organization/1/website"><img src="https://opencollective.com/typelevel/organization/1/avatar.svg"></a>
<a href="https://opencollective.com/typelevel/organization/2/website"><img src="https://opencollective.com/typelevel/organization/2/avatar.svg"></a>
<a href="https://opencollective.com/typelevel/organization/3/website"><img src="https://opencollective.com/typelevel/organization/3/avatar.svg"></a>
<a href="https://opencollective.com/typelevel/organization/4/website"><img src="https://opencollective.com/typelevel/organization/4/avatar.svg"></a>
<a href="https://opencollective.com/typelevel/organization/5/website"><img src="https://opencollective.com/typelevel/organization/5/avatar.svg"></a>
<a href="https://opencollective.com/typelevel/organization/6/website"><img src="https://opencollective.com/typelevel/organization/6/avatar.svg"></a>
<a href="https://opencollective.com/typelevel/organization/7/website"><img src="https://opencollective.com/typelevel/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/typelevel/organization/8/website"><img src="https://opencollective.com/typelevel/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/typelevel/organization/9/website"><img src="https://opencollective.com/typelevel/organization/9/avatar.svg"></a>


#### Individuals

<a href="https://opencollective.com/typelevel"><img src="https://opencollective.com/typelevel/individuals.svg?width=890"></a>


[Become a financial contributor](https://opencollective.com/typelevel) and help us sustain our community. Donations directly support office hours for maintainers, better documentation and strategic initiatives.

<h4>Platinum Sponsors</h4>
<a href="https://opencollective.com/typelevel/contribute/platinum-sposor-12420/checkout">Platinum sponsorship</a> starts at $950 USD/month.
<div id="platinum-sponsors">
<noscript>Platinum Sponsors appear here at <a href="https://typelevel.org/cats/">https://typelevel.org/cats</a></noscript>
</div>

<h4>Gold Sponsors</h4>
<a href="https://opencollective.com/typelevel/contribute/gold-sponsor-12419/checkout">Gold Sponsorship</a> starts at $420 USD/month.
<div id="gold-sponsors">
<noscript>Gold Sponsors appear here at <a href="https://typelevel.org/cats/">https://typelevel.org/cats</a></noscript>
</div>

<h4>Silver Sponsors</h4>
<a href="https://opencollective.com/typelevel/contribute/silver-sponsor-11780/checkout">Silver Sponsorship</a> starts at $180 USD/month.
<div id="silver-sponsors">
<noscript>Silver Sponsors appear here at <a href="https://typelevel.org/cats/">https://typelevel.org/cats</a></noscript>
</div>

<h4>Backers</h4>
Become a <a href="https://opencollective.com/typelevel/contribute/backer-11779/checkout">Backer</a> with a recurring donation of just $5 USD/month.
<div id="backers">
<noscript>Backers appear here at <a href="https://typelevel.org/cats/">https://typelevel.org/cats</a></noscript>
</div>

<h4>Other contributors</h4>
We thankfully accept <a href="https://opencollective.com/typelevel/donate">one-time and recurring</a> contributions as well.
<div id="other-contributors">
<noscript>Other contributors appear here at <a href="https://typelevel.org/cats/">https://typelevel.org/cats</a></noscript>
</div>

<script src="/cats/js/sponsors.js"></script>

### Getting Started

Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ lazy val docSettings = Seq(
),
micrositeGithubRepo := "cats",
micrositeImgDirectory := (LocalRootProject / baseDirectory).value / "docs" / "src" / "main" / "resources" / "microsite" / "img",
micrositeJsDirectory := (LocalRootProject / baseDirectory).value / "docs" / "src" / "main" / "resources" / "microsite" / "js",
micrositeTheme := "pattern",
micrositePalette := Map(
"brand-primary" -> "#5B5988",
Expand Down
22 changes: 22 additions & 0 deletions docs/src/main/resources/microsite/img/missing-avatar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions docs/src/main/resources/microsite/js/sponsors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
function addSponsor(divId, member, size) {
div = document.getElementById(divId);
var a = document.createElement('a');
a.setAttribute('href', member.website || member.profile || '#');
var img = document.createElement('img');
img.setAttribute('src', member.image || 'img/missing-avatar.svg');
if (size) {
img.setAttribute('height', size);
img.setAttribute('width', size);
}
img.setAttribute('alt', member.name);
img.setAttribute('style', 'margin:6px;');
if (member.marginBottom)
img.setAttribute('style', img.getAttribute('style') + 'margin-bottom:' + member.marginBottom + 'px;')
a.appendChild(img);
div.appendChild(a);
};

const PlatinumSize = 98;
const GoldSize = 76;
const SilverSize = 60;
const BackerSize = 45;
const ContributorSize = 36;

var sponsors = function() {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://opencollective.com/typelevel/members/all.json', true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
for(i = 0; i < xhr.response.length; i++) {
var member = xhr.response[i];
if (member.isActive) {
switch (member.tier) {
case 'Platinum Sponsor':
addSponsor('platinum-sponsors', member, PlatinumSize);
case 'Gold Sponsor':
addSponsor('gold-sponsors', member, GoldSize);
case 'Silver Sponsor':
addSponsor('silver-sponsors', member, SilverSize);
case 'backer':
addSponsor('backers', member, BackerSize);
break;
default:
if (member.totalAmountDonated > 0) {
addSponsor('other-contributors', member, ContributorSize);
}
}
};
}
}
};
xhr.send();
};
Comment on lines +25 to +55
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NBD, but fetch is the modern way. Something like this I think:

Suggested change
var sponsors = function() {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://opencollective.com/typelevel/members/all.json', true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
for(i = 0; i < xhr.response.length; i++) {
var member = xhr.response[i];
if (member.isActive) {
switch (member.tier) {
case 'Platinum Sponsor':
addSponsor('platinum-sponsors', member, PlatinumSize);
case 'Gold Sponsor':
addSponsor('gold-sponsors', member, GoldSize);
case 'Silver Sponsor':
addSponsor('silver-sponsors', member, SilverSize);
case 'backer':
addSponsor('backers', member, BackerSize);
break;
default:
if (member.totalAmountDonated > 0) {
addSponsor('other-contributors', member, ContributorSize);
}
}
};
}
}
};
xhr.send();
};
var sponsors = async function() {
var response = await fetch('https://opencollective.com/typelevel/members/all.json');
if (response.ok) {
var members = await response.json();
for(i = 0; i < members.length; i++) {
var member = members[i];
if (member.isActive) {
switch (member.tier) {
case 'Platinum Sponsor':
addSponsor('platinum-sponsors', member, PlatinumSize);
case 'Gold Sponsor':
addSponsor('gold-sponsors', member, GoldSize);
case 'Silver Sponsor':
addSponsor('silver-sponsors', member, SilverSize);
case 'backer':
addSponsor('backers', member, BackerSize);
break;
default:
if (member.totalAmountDonated > 0) {
addSponsor('other-contributors', member, ContributorSize);
}
}
}
}
}
};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I don't know and I don't have time to retest it, but if a knowledgeable reviewer agrees, please feel free to commit it!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it ain't broke don't fix it! 😆

Copy link
Member

@ChristopherDavenport ChristopherDavenport Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move forward with this, and then we can PR this. We want to fix whats here most importantly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 My CSS is dated and my JS was never competent, and would be delighted to see either improved once the fire is out.

sponsors();
// Add sponsors who predate open collective
addSponsor('gold-sponsors', {
name: "47 Degrees",
website: "https://47deg.com",
image: "https://typelevel.org/cats/img/sponsors/47_degree.png"
});
addSponsor('gold-sponsors', {
name: "Iterators",
website: "https://iteratorshq.com",
image: "https://typelevel.org/cats/img/sponsors/iterators.png",
marginBottom: 20
});
addSponsor('gold-sponsors', {
name: "Triplequote",
website: "https://triplequote.com",
image: "https://typelevel.org/cats/img/sponsors/triplequote.png",
marginBottom: 20
});
addSponsor('gold-sponsors', {
name: "Underscore",
website: "https://underscore.com",
image: "https://typelevel.org/cats/img/sponsors/underscore.png",
marginBottom: 10
});
addSponsor('silver-sponsors', {
name: "Ebiznext",
website: "https://ebiznext.com",
image: "https://typelevel.org/cats/img/sponsors/ebiznext.png",
marginBottom: 10
});
addSponsor('silver-sponsors', {
name: "Inner Product",
website: "https://inner-product.com",
image: "https://typelevel.org/cats/img/sponsors/inner-product.png"
});
addSponsor('silver-sponsors', {
name: "Evolution Gaming Engineering",
website: "https://evolutiongaming.com",
image: "https://typelevel.org/cats/img/sponsors/evolution_gaming_engineering.png"
});