@@ -26,52 +26,51 @@ <h3 class="sidebar-section__title">Project links</h3>
26
26
</ div >
27
27
{% endif %}
28
28
29
+ {% macro statistic_item(title, json_data_key, json_base_url_key=None, url_ending=None, icon=None) %}
30
+ {% if not icon %}
31
+ {% if title == 'Stars' %}
32
+ {% set icon = 'fa-star' %}
33
+ {% elif title == 'Forks' %}
34
+ {% set icon = 'fa-code-branch' %}
35
+ {% elif title == 'Open issues/PRs' %}
36
+ {% set icon = 'fa-exclamation-circle' %}
37
+ {% endif %}
38
+ {% endif %}
39
+ {% if json_base_url_key %}
40
+ < a class ="vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed repo-info__item "
41
+ data-key ="{{ json_base_url_key }} " data-attr ="href " data-supplement ="{{ url_ending }} "
42
+ rel ="noopener " target ="_blank ">
43
+ {% else %}
44
+ < span class ="vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed repo-info__item ">
45
+ {% endif %}
46
+ < i class ="fa {{ icon }} " aria-hidden ="true "> </ i >
47
+ < strong > {{ title }}: </ strong >
48
+ < span class ="repo-info__item " data-key ="{{ json_data_key }} "> </ span >
49
+ {% if json_base_url_key %}
50
+ </ a >
51
+ {% else %}
52
+ </ span>
53
+ {% endif %}
54
+ {% endmacro %}
55
+
29
56
< div class ="sidebar-section ">
30
57
< h3 class ="sidebar-section__title "> Statistics</ h3 >
31
58
{% if release.github_repo_info_url %}
32
59
< div class ="repo-info hidden " data-url ="{{release.github_repo_info_url}} ">
33
60
< em > GitHub statistics:</ em >
34
- < a class ="vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed repo-info__item "
35
- data-key ="html_url " data-attr ="href " data-supplement ="/stargazers " rel ="noopener "
36
- target ="_blank ">
37
- < i class ="fa fa-star " aria-hidden ="true "> </ i >
38
- < strong > Stars: </ strong >
39
- < span class ="repo-info__item " data-key ="stargazers_count "> </ span >
40
- </ a >
41
- < a class ="vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed repo-info__item "
42
- data-key ="html_url " data-attr ="href " data-supplement ="/network " rel ="noopener "
43
- target ="_blank ">
44
- < i class ="fa fa-code-branch " aria-hidden ="true "> </ i >
45
- < strong > Forks: </ strong >
46
- < span class ="repo-info__item " data-key ="forks_count "> </ span >
47
- </ a >
48
- < a class ="vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed repo-info__item "
49
- data-key ="html_url " data-attr ="href " data-supplement ="/issues " rel ="noopener "
50
- target ="_blank ">
51
- < i class ="fa fa-exclamation-circle " aria-hidden ="true "> </ i >
52
- < strong > Open issues/PRs: </ strong >
53
- < span class ="repo-info__item " data-key ="open_issues_count "> </ span >
54
- </ a >
61
+ {{ statistic_item('Stars', 'stargazers_count', 'html_url', '/stargazers') }}
62
+ {{ statistic_item('Forks', 'forks_count', 'html_url', '/network') }}
63
+ {{ statistic_item('Open issues/PRs', 'open_issues_count', 'html_url', '/issues') }}
55
64
</ div >
56
65
{% elif release.gitlab_repo_info_url %}
57
66
< div class ="repo-info hidden " data-url ="{{release.gitlab_repo_info_url}} ">
58
67
< em > GitLab statistics:</ em >
59
- < span class ="vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed repo-info__item ">
60
- < i class ="fa fa-star " aria-hidden ="true "> </ i >
61
- < strong > Stars: </ strong >
62
- < span class ="repo-info__item " data-key ="star_count "> </ span >
63
- </ span >
64
- < a class ="vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed repo-info__item "
65
- data-key ="web_url " data-attr ="href " data-supplement ="/forks " rel ="noopener "
66
- target ="_blank ">
67
- < i class ="fa fa-code-branch " aria-hidden ="true "> </ i >
68
- < strong > Forks: </ strong >
69
- < span class ="repo-info__item " data-key ="forks_count "> </ span >
70
- </ a >
68
+ {{ statistic_item('Stars', 'star_count') }}
69
+ {{ statistic_item('Forks', 'forks_count', 'web_url', '/forks') }}
71
70
</ div >
72
71
{% endif %}
73
72
< p > View statistics for this project via < a
74
- href ="https://libraries.io/pypi/{{ release.project.name }} "> Libraries.io</ a > , or by using
73
+ href ="https://libraries.io/pypi/{{ release.project.name }} "> Libraries.io</ a > , or by using
75
74
< a href ="https://packaging.python.org/guides/analyzing-pypi-package-downloads/ "> Google
76
75
BigQuery</ a > </ p >
77
76
</ div >
0 commit comments