|
1 | 1 | {% macro info(item, section, archived=false) %} |
2 | 2 |
|
| 3 | +{% set github_token = get_env(name="GITHUB_TOKEN") %} |
| 4 | + |
3 | 5 | {% if item.name %} |
4 | 6 | {% set name = item.name %} |
5 | 7 | {% endif %} |
6 | 8 |
|
7 | | -{% if item.source %} |
8 | | - {% if item.source == 'crates' %} |
9 | | - {% set data = load_data(url = "https://crates.io/api/v1/crates/" ~ item.name ~ "?include=downloads", format="json", headers=["User-Agent=arewegameyet ( [email protected])"]) %} |
10 | | - {# human readable name #} |
11 | | - {% set name = data.crate.name %} |
12 | | - {# Github/Gitlab/Etc. repository #} |
13 | | - {% set repository_url = data.crate.repository %} |
14 | | - {% set crate_url = 'https://crates.io/crates/' ~ name %} |
15 | | - {% set description = data.crate.description %} |
16 | | - {% set latest_version = data.crate.default_version %} |
17 | | - {% set downloads = data.crate.downloads %} |
18 | | - {% set recent_downloads = data.crate.recent_downloads %} |
19 | | - {% if data.crate.homepage %} |
20 | | - {% set homepage_url = data.crate.homepage %} |
21 | | - {% endif %} |
22 | | - {% elif item.source == 'github' %} |
23 | | - {% set data = load_data(url="https://api.github.com/repos/" ~ item.name, format="json") %} |
24 | | - {% set name = data.name %} |
25 | | - {% set repository_url = data.html_url %} |
26 | | - {# Org or User name #} |
27 | | - {% set owner = data.owner.login %} |
28 | | - {% if data.homepage != "" %} |
29 | | - {% set homepage_url = data.homepage %} |
30 | | - {% endif %} |
31 | | - {% set description = data.description %} |
32 | | - {% set stars = data.stargazers_count %} |
33 | | - {% set last_commit = data.pushed_at %} |
| 9 | +{% if item.source and item.source == 'crates' %} |
| 10 | + {% set data = load_data(url = "https://crates.io/api/v1/crates/" ~ item.name ~ "?include=downloads,default_version", format="json", headers=["User-Agent=arewegameyet ( [email protected])"]) %} |
| 11 | + |
| 12 | + {% set name = data.crate.name %} |
| 13 | + {% set description = data.crate.description %} |
| 14 | + {% set repository_url = data.crate.repository %} |
| 15 | + {% set crate_url = 'https://crates.io/crates/' ~ name %} |
| 16 | + {% set latest_version = data.crate.default_version %} |
| 17 | + {% set downloads = data.crate.downloads %} |
| 18 | + {% set recent_downloads = data.crate.recent_downloads %} |
| 19 | + {% set license = data.versions | first | get(key="license") %} |
| 20 | + |
| 21 | + {% if data.crate.homepage %} |
| 22 | + {% set homepage_url = data.crate.homepage %} |
| 23 | + {% endif %} |
| 24 | +{% elif item.source and item.source == 'github' %} |
| 25 | + {% set data = load_data(url="https://api.github.com/repos/" ~ item.name, headers=["Authorization=Bearer " ~ github_token], format="json") %} |
| 26 | + |
| 27 | + {% set name = data.name %} |
| 28 | + {% set description = data.description %} |
| 29 | + {% set repository_url = data.html_url %} |
| 30 | + |
| 31 | + {% if data.license %} |
| 32 | + {% set license = data.license.name %} |
| 33 | + {% endif %} |
| 34 | + |
| 35 | + {% if data.homepage %} |
| 36 | + {% set homepage_url = data.homepage %} |
34 | 37 | {% endif %} |
35 | 38 | {% endif %} |
36 | 39 |
|
|
50 | 53 | {% set primary_url = repository_url %} |
51 | 54 | {% endif %} |
52 | 55 |
|
| 56 | +{% if repository_url and repository_url is containing("github.com/") %} |
| 57 | + {% set repo_id = repository_url | split(pat="github.com/") | last %} |
| 58 | + |
| 59 | + {% set data = load_data(url="https://api.github.com/repos/" ~ repo_id, headers=["Authorization=Bearer " ~ github_token], format="json", required=false) %} |
| 60 | + {% if data %} |
| 61 | + {% set stars = data.stargazers_count %} |
| 62 | + {% set last_activity = data.pushed_at %} |
| 63 | + {% endif %} |
| 64 | +{% elif repository_url and repository_url is containing("gitlab.com/") %} |
| 65 | + {% set repo_id = repository_url | split(pat="gitlab.com/") | last | urlencode_strict %} |
| 66 | + |
| 67 | + {% set data = load_data(url="https://gitlab.com/api/v4/projects/" ~ repo_id, format="json", required=false) %} |
| 68 | + {% if data %} |
| 69 | + {% set stars = data.star_count %} |
| 70 | + {% set last_activity = data.last_activity_at %} |
| 71 | + {% endif %} |
| 72 | +{% endif %} |
| 73 | + |
53 | 74 | <li class="ui card{% if archived %} archived{% endif %}"> |
54 | 75 | {% if item.image %} |
55 | 76 | {% if primary_url %} |
|
66 | 87 | {% endif %} |
67 | 88 |
|
68 | 89 | <div class="content"> |
69 | | - <a href="#{{ name | slugify }}" id="{{ name | slugify }}" aria-label="Permanent link for {{ name }}"> |
70 | | - <i class="right floated hashtag icon"></i> |
| 90 | + <a class="right floated" href="#{{ name | slugify }}" id="{{ name | slugify }}" aria-label="Permanent link for {{ name }}"> |
| 91 | + <i class="hashtag icon" aria-hidden="true"></i> |
71 | 92 | </a> |
72 | 93 |
|
73 | 94 | {% if repository_url %} |
74 | | - <a href="{{ repository_url }}" aria-label="Github link for {{ name }}"> |
75 | | - <i class="right floated github icon"></i> |
| 95 | + <a class="right floated" href="{{ repository_url }}" aria-label="Github link for {{ name }}"> |
| 96 | + <i class="github icon" aria-hidden="true"></i> |
76 | 97 | </a> |
77 | 98 | {% endif %} |
78 | 99 |
|
79 | 100 | {% if crate_url %} |
80 | | - <a href="{{ crate_url }}" aria-label="Crates.io link for {{ name }}"> |
81 | | - <i class="right floated cube icon"></i> |
| 101 | + <a class="right floated" href="{{ crate_url }}" aria-label="Crates.io link for {{ name }}"> |
| 102 | + <i class="cube icon" aria-hidden="true"></i> |
82 | 103 | </a> |
83 | 104 | {% endif %} |
84 | 105 |
|
85 | 106 | {% if homepage_url %} |
86 | | - <a href="{{ homepage_url }}" aria-label="Website link for {{ name }}"> |
87 | | - <i class="right floated home icon"></i> |
| 107 | + <a class="right floated" href="{{ homepage_url }}" aria-label="Website link for {{ name }}"> |
| 108 | + <i class="home icon" aria-hidden="true"></i> |
88 | 109 | </a> |
89 | 110 | {% endif %} |
90 | | - |
| 111 | + |
91 | 112 | <div class="header"> |
92 | 113 | {% if primary_url %} |
93 | 114 | <a href="{{ primary_url }}">{{ name }}</a> |
|
112 | 133 |
|
113 | 134 | {% if item.source or gitter_url %} |
114 | 135 | <div class="extra content"> |
115 | | - |
116 | 136 | <div class="ui horizontal list"> |
117 | | - {% if item.source and item.source == 'crates' %} |
| 137 | + {% if gitter_url %} |
118 | 138 | <div class="item"> |
119 | 139 | <div class="content"> |
120 | | - <a href="https://crates.io/crates/{{name}}"> |
121 | | - <img src="https://img.shields.io/crates/v/{{name}}.svg?maxAge=2592000" alt="Latest version: {{ latest_version }}"> |
| 140 | + <a class="ui blue label" href="{{ gitter_url }}" target="_blank"> |
| 141 | + <i class="chat icon" aria-hidden="true"></i> |
| 142 | + Chat on Gitter |
122 | 143 | </a> |
123 | 144 | </div> |
124 | 145 | </div> |
| 146 | + {% endif %} |
| 147 | + {% if latest_version %} |
125 | 148 | <div class="item"> |
126 | 149 | <div class="content"> |
127 | | - <a href="https://crates.io/crates/{{name}}"> |
128 | | - <img src="https://img.shields.io/crates/d/{{name}}.svg?maxAge=2592000" alt="Downloads: {{ downloads }}"> |
129 | | - </a> |
| 150 | + <div class="ui basic label"> |
| 151 | + <i class="code icon" aria-hidden="true"></i> |
| 152 | + Latest version: |
| 153 | + <div class="detail">{{ latest_version }}</div> |
| 154 | + </div> |
130 | 155 | </div> |
131 | 156 | </div> |
| 157 | + {% endif %} |
| 158 | + {% if downloads %} |
132 | 159 | <div class="item"> |
133 | 160 | <div class="content"> |
134 | | - <a href="https://crates.io/crates/{{name}}"> |
135 | | - <img src="https://img.shields.io/crates/dr/{{name}}.svg?maxAge=2592000" alt="Recent downloads: {{ recent_downloads }}"> |
136 | | - </a> |
| 161 | + <div class="ui basic label"> |
| 162 | + <i class="download icon" aria-hidden="true"></i> |
| 163 | + Downloads: |
| 164 | + <div class="detail">{{ downloads | num_format }}</div> |
| 165 | + </div> |
137 | 166 | </div> |
138 | 167 | </div> |
| 168 | + {% endif %} |
| 169 | + {% if recent_downloads %} |
139 | 170 | <div class="item"> |
140 | 171 | <div class="content"> |
141 | | - <a href="https://crates.io/crates/{{name}}"> |
142 | | - <img src="https://img.shields.io/crates/l/{{name}}.svg?maxAge=2592000" alt="View license for {{ name }}"> |
143 | | - </a> |
| 172 | + <div class="ui basic label"> |
| 173 | + <i class="clock icon" aria-hidden="true"></i> |
| 174 | + Recent downloads: |
| 175 | + <div class="detail">{{ recent_downloads | num_format }}</div> |
| 176 | + </div> |
144 | 177 | </div> |
145 | 178 | </div> |
146 | 179 | {% endif %} |
147 | | - {% if item.source and item.source == 'github' %} |
| 180 | + {% if license %} |
148 | 181 | <div class="item"> |
149 | 182 | <div class="content"> |
150 | | - <a href="https://github.com/{{owner}}/{{name}}"> |
151 | | - <img src="https://img.shields.io/github/stars/{{owner}}/{{name}}?style=flat" alt="Github Stars: {{ stars }}"> |
152 | | - </a> |
| 183 | + <div class="ui basic label"> |
| 184 | + <i class="balance scale icon" aria-hidden="true"></i> |
| 185 | + License: |
| 186 | + <div class="detail">{{ license }}</div> |
| 187 | + </div> |
153 | 188 | </div> |
154 | 189 | </div> |
| 190 | + {% endif %} |
| 191 | + {% if stars %} |
155 | 192 | <div class="item"> |
156 | 193 | <div class="content"> |
157 | | - <a href="https://github.com/{{owner}}/{{name}}"> |
158 | | - <img src="https://img.shields.io/github/last-commit/{{owner}}/{{name}}" alt="Last commit date: {{ last_commit | date }}"> |
159 | | - </a> |
| 194 | + <div class="ui basic label"> |
| 195 | + <i class="star icon" aria-hidden="true"></i> |
| 196 | + Stars: |
| 197 | + <div class="detail">{{ stars }}</div> |
| 198 | + </div> |
160 | 199 | </div> |
161 | 200 | </div> |
162 | 201 | {% endif %} |
163 | | - {% if gitter_url %} |
| 202 | + {% if last_activity %} |
164 | 203 | <div class="item"> |
165 | 204 | <div class="content"> |
166 | | - <a href="{{ gitter_url }}" target="_blank"> |
167 | | - <img src="/assets/badges/chat.svg"/> |
168 | | - </a> |
| 205 | + <div class="ui basic label"> |
| 206 | + <i class="calendar icon" aria-hidden="true"></i> |
| 207 | + Last activity: |
| 208 | + <div class="detail">{{ last_activity | date(format="%Y-%m-%d") }}</div> |
| 209 | + </div> |
169 | 210 | </div> |
170 | 211 | </div> |
171 | 212 | {% endif %} |
|
0 commit comments