Skip to content

Add ability to display GitHub stars #51

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

Merged
merged 1 commit into from
Jul 20, 2020
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
3 changes: 3 additions & 0 deletions _sass/ecosystem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@
li {
display: inline;
}
li.github-stars-count-whole-number {
display: none;
}
}


Expand Down
11 changes: 10 additions & 1 deletion assets/github-stars.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
var githubStarsScript = $("script[src*=github-stars]");
var starCountCallDate = githubStarsScript.attr("star-count-call-date");
var starCountData = githubStarsScript.attr("star-count-data");
var ecosystemStars = githubStarsScript.attr("ecosystem");
var cloudfrontUrl = "";

if (ecosystemStars == "true") {
cloudfrontUrl = "https://d2ze5o8gurgoho.cloudfront.net/star-count";
}
else {
cloudfrontUrl = "https://du4l4liqvfo92.cloudfront.net/star-count";
}

var today = new Date();
var starCountCallDateParsed = new Date(
Expand All @@ -19,7 +28,7 @@ if (

function updateStarCount() {
console.log("Updated star count fetched");
$.getJSON("https://du4l4liqvfo92.cloudfront.net/star-count", function (data) {
$.getJSON(cloudfrontUrl, function (data) {
localStorage.setItem(starCountCallDate, Date.parse(today));
localStorage.setItem(starCountData, JSON.stringify(data));

Expand Down
5 changes: 3 additions & 2 deletions ecosystem/ecosystem.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h1>
{% assign ecosystem = site.ecosystem | sort_natural: "title" %}

{% for item in ecosystem %}
<div class="col-md-6 ecosystem-card-wrapper" id="ecosystemCards" data-categories="{{ item.category | join: "," }}" data-date-added="{{ item.date-added }}">
<div class="col-md-6 ecosystem-card-wrapper" id="ecosystemCards" data-categories="{{ item.category | join: "," }}" data-date-added="{{ item.date-added }}" data-id="{{ item.github-id }}">
<div class="card ecosystem-card">
<a href="{{ item.link }}" target="_blank">
<div class="card-body {{ item.logo-class }} {% if item.experimental %}experimental{% endif %}">
Expand All @@ -44,6 +44,7 @@ <h1>
<div class="icon-count-container">
<li><img class="github-logo" src="/assets/images/logo-github.svg"></li>
<li class="github-stars-count"></li>
<li class="github-stars-count-whole-number"></li>
</div>
</ul>
{% if item.experimental %}
Expand Down Expand Up @@ -122,6 +123,6 @@ <h1>
</script>

<script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
<script star-count-call-date="ecosystemStarCountCallDate" star-count-data="ecosystemStarCountData" src="{{ site.baseurl }}/assets/github-stars.js"></script>
<script id="filter-script" ecosystem="true" star-count-call-date="ecosystemStarCountCallDate" star-count-data="ecosystemStarCountData" src="{{ site.baseurl }}/assets/github-stars.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/list.js/1.5.0/list.min.js"></script>
<script list-id="ecosystem-index-cards" display-count="100" pagination="false" src="{{ site.baseurl }}/assets/filter-hub-tags.js"></script>