Sync installation stats show on site

This commit is contained in:
Brandon Keepers
2017-10-19 09:37:42 -05:00
parent 284c76f79f
commit dd7cb283b8
6 changed files with 27 additions and 5 deletions

View File

@@ -54,6 +54,8 @@ screenshots:
authors: [ your-username, other-usernames ]
# The repository where the code is located
repository: your-username/your-app
# The address where this app is deployed
host: https://my-probot-app.awesomecloudhost.com
---
Any documentation can go here. Many apps just use their README.md here.

View File

@@ -4,6 +4,9 @@
<p class="text-gray lh-condensed px-3 pb-3">{{ app.description }}</p>
<div class="text-gray-light pl-3 pr-2 py-2 bg-gray-light border-top" style="margin-top: auto;">
<div class="d-flex flex-row">
{% if app.installations %}
<div class="col-3 tooltipped tooltipped-s" aria-label="{{ app.installations }} installations">{% octicon cloud-download heigh:16 class:"v-align-middle" %} <span class="">{{ app.installations }}</span></div>
{% endif %}
<div class="col-3 tooltipped tooltipped-s" aria-label="{{ app.stars }} stars">{% octicon star heigh:16 class:"v-align-middle" %} <span class="">{{ app.stars }}</span></div>
<div class="col-9 text-right">
{% for author in app.authors %}

View File

@@ -15,6 +15,9 @@ layout: default
Add to GitHub
</a>
<div class="text-gray-light">
{% if page.installations %}
<div class="mr-2 d-inline tooltipped tooltipped-s" aria-label="{{ page.installations }} installations">{% octicon cloud-download heigh:16 class:"v-align-middle" %} <span class="">{{ page.installations }}</span></div>
{% endif %}
<div class="d-inline tooltipped tooltipped-s" aria-label="{{ page.stars }} stars">{% octicon star heigh:16 class:"v-align-middle" %} <span class="">{{ page.stars }}</span></div>
</div>
</div>
@@ -69,6 +72,16 @@ layout: default
{{ content }}
</div>
</div>
<div class="col-md-3">
{% if page.organizations %}
<h4 class="mb-1 alt-h4 text-gray">Used By</h4>
{% for org in page.organizations %}
<a href="https://github.com/{{ org }}" aria-label="{{ org }}" class="tooltipped tooltipped-n avatar-group-item">
<img class="avatar" src="https://github.com/{{ org }}.png" alt-"{{ org }}" width="35" height="35">
</a>
{% endfor %}
{% endif %}
</div>
</div>
</div>
</div>

View File

@@ -8,7 +8,7 @@ title: Featured Apps
<h1 class="alt-h2">{{ page.title }}</h1>
<div class="d-md-flex flex-wrap gutter flex-auto">
{% assign apps = site.apps | sort: 'stars' | reverse %}
{% assign apps = site.apps | sort: 'installations' | reverse %}
{% for app in apps %}
{% include app.html app=app %}
{% endfor %}

View File

@@ -31,7 +31,7 @@ layout: default
</p>
<div class="d-md-flex flex-wrap gutter flex-auto">
{% assign apps = site.apps | sort: 'stars' | reverse %}
{% assign apps = site.apps | sort: 'installations' | reverse %}
{% for app in apps limit:6 %}
{% include app.html app=app %}
{% endfor %}

View File

@@ -18,9 +18,13 @@ files.each do |path|
app['updated'] = repo[:pushed_at].to_s
if app['host']
stats = JSON.parse(URI(app['host'] + '/stats').open.read)
app['installations'] = stats['installations']
app['organizations'] = stats['popular'].map { |org| org['login'] }
begin
stats = JSON.parse(URI(app['host'] + '/probot/stats').open.read)
app['installations'] = stats['installations']
app['organizations'] = stats['popular'].map { |org| org['login'] }
rescue => e
warn e.message
end
end
content = File.read(path)