-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathmacros.html
More file actions
154 lines (139 loc) · 6.17 KB
/
Copy pathmacros.html
File metadata and controls
154 lines (139 loc) · 6.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
{% macro info(item, section) %}
{% if item.name %}
{% set name = item.name %}
{% endif %}
{% if item.source %}
{% if item.source == 'crates' %}
{% set data = load_data(url = "https://crates.io/api/v1/crates/" ~ item.name ~ "?include=", format="json", headers=["User-Agent=arewegameyet (gamedev-wg@rust-lang.org)"]) %}
{# human readable name #}
{% set name = data.crate.name %}
{# Github/Gitlab/Etc. repository #}
{% set repository_url = data.crate.repository %}
{% set crate_url = 'https://crates.io/crates/' ~ name %}
{% set description = data.crate.description %}
{% if data.crate.homepage %}
{% set homepage_url = data.crate.homepage %}
{% endif %}
{% elif item.source == 'github' %}
{% set data = load_data(url="https://api.github.com/repos/" ~ item.name, format="json") %}
{% set name = data.name %}
{% set repository_url = data.html_url %}
{% if data.homepage != "" %}
{% set homepage_url = data.homepage %}
{% endif %}
{% set description = data.description %}
{% endif %}
{% endif %}
{# OVERRIDES: If specified in the config file, the above can be rewritten. #}
{% if item.repository_url %} {% set repository_url = item.repository_url %} {% endif %}
{% if item.crate_url %} {% set crate_url = item.crate_url %} {% endif %}
{% if item.homepage_url %} {% set homepage_url = item.homepage_url %} {% endif %}
{% if item.gitter_url %} {% set gitter_url = item.gitter_url %} {% endif %}
{% if item.description %} {% set description = item.description %} {% endif %}
{# Simple heuristic for picking the 'main' URL for an entry - might need a way of overriding #}
{% if crate_url %}
{% set primary_url = crate_url %}
{% elif homepage_url %}
{% set primary_url = homepage_url %}
{% elif repository_url %}
{% set primary_url = repository_url %}
{% endif %}
<li class="ui card">
{% if item.image %}
{% if primary_url %}
<a class="image" href="{{ primary_url }}">
{% else %}
<div class="image">
{% endif %}
<img src="{{ item.image }}" alt="Picture of {{ name }}">
{% if primary_url %}
</a>
{% else %}
</div>
{% endif %}
{% endif %}
<div class="content">
<a href="#{{ name | slugify }}" id="{{ name | slugify }}" aria-label="Permanent link for {{ name }}">
<i class="right floated hashtag icon"></i>
</a>
{% if repository_url %}
<a href="{{ repository_url }}" aria-label="Github link for {{ name }}">
<i class="right floated github icon"></i>
</a>
{% endif %}
{% if crate_url %}
<a href="{{ crate_url }}" aria-label="Crates.io link for {{ name }}">
<i class="right floated cube icon"></i>
</a>
{% endif %}
{% if homepage_url %}
<a href="{{ homepage_url }}" aria-label="Website link for {{ name }}">
<i class="right floated home icon"></i>
</a>
{% endif %}
<div class="header">
{% if primary_url %}
<a href="{{ primary_url }}">{{ name }}</a>
{% else %}
{{ name }}
{% endif %}
</div>
<div class="meta">
{% for category in item.categories %}
{% set category_data = get_page(path=section.path ~ category ~ ".md") %}
<a href="{{ category_data.permalink }}">{{ category_data.title }}</a>
{% if not loop.last %}<span>·</span>{% endif %}
{% endfor %}
</div>
<div class="description">
<p>{{ description }}</p>
</div>
</div>
{% if item.source and item.source == 'crates' or gitter_url %}
<div class="extra content">
{# only projects hosted on crates get badges for now #}
<div class="ui horizontal list">
{% if item.source and item.source == 'crates' %}
<div class="item">
<div class="content">
<a href="https://crates.io/crates/{{name}}">
<img src="https://img.shields.io/crates/v/{{name}}.svg?maxAge=2592000" alt="Crates.io link for {{ name }}">
</a>
</div>
</div>
<div class="item" aria-hidden="true">
<div class="content">
<a href="https://crates.io/crates/{{name}}">
<img src="https://img.shields.io/crates/d/{{name}}.svg?maxAge=2592000" alt="Download count for {{ name }}">
</a>
</div>
</div>
<div class="item" aria-hidden="true">
<div class="content">
<a href="https://crates.io/crates/{{name}}">
<img src="https://img.shields.io/crates/dr/{{name}}.svg?maxAge=2592000" alt="Recent download count for {{ name }}">
</a>
</div>
</div>
<div class="item" aria-hidden="true">
<div class="content">
<a href="https://crates.io/crates/{{name}}">
<img src="https://img.shields.io/crates/l/{{name}}.svg?maxAge=2592000" alt="License for {{ name }}">
</a>
</div>
</div>
{% endif %}
{% if gitter_url %}
<div class="item">
<div class="content">
<a href="{{ gitter_url }}" target="_blank">
<img src="/assets/badges/chat.svg"/>
</a>
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
</li>
{% endmacro info %}