Skip to content

Commit

Permalink
tool-card fork/stars for github gist and gitlab
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <[email protected]>
  • Loading branch information
jkowalleck committed Jun 25, 2024
1 parent 26ff0be commit b8c30ef
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ gem "jekyll-sitemap"
gem "jekyll-last-modified-at"
gem 'jekyll-feed'
gem 'jekyll-redirect-from'
gem 'jekyll-regex-replace'
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ GEM
posix-spawn (~> 0.3.9)
jekyll-redirect-from (0.16.0)
jekyll (>= 3.3, < 5.0)
jekyll-regex-replace (1.1.0)
jekyll-sass-converter (2.1.0)
sassc (> 2.0.1, < 3.0)
jekyll-sitemap (1.4.0)
Expand Down Expand Up @@ -80,7 +81,8 @@ DEPENDENCIES
jekyll-feed
jekyll-last-modified-at
jekyll-redirect-from
jekyll-regex-replace
jekyll-sitemap

BUNDLED WITH
2.2.30
2.3.25
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ plugins:
- jekyll-last-modified-at
- jekyll-feed
- jekyll-redirect-from
- jekyll-regex-replace
defaults:
-
scope:
Expand Down
42 changes: 34 additions & 8 deletions theme/_includes/tool-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,39 @@
<div class="card-body">{{tool.description | truncate:250}}</div>
<div style="line-height: 3.0rem">&nbsp;</div>
<div class="card-footer">
{% assign url_prefix = tool.repoUrl | slice:0,19 %}
{% if url_prefix == 'https://github.com/' %}
{%comment%}repo holds the "org/repo" name, for eg anchore/syft{%endcomment%}
{% assign repo = tool.repoUrl | replace:'https://github.com/','' | replace: '.git','' %}
<img src="https://img.shields.io/github/forks/{{repo}}.svg?style=social&label=Forks">&nbsp;
<img src="https://img.shields.io/github/stars/{{repo}}.svg?style=social&label=Stars">
{% endif%}
{% if tool.repoUrl contains '://github.com/' %}
{%comment%}
repo holds the "org/repo" name, for eg:
https://github.com/anchore/syft
https://github.com/anchore/syft/
https://github.com/anchore/syft.git
{%endcomment%}
{% assign repo = tool.repoUrl | regex_replace:'^https?://github.com/','' | regex_replace:'(.git|/)$','' %}
<img src="https://img.shields.io/github/forks/{{repo}}?style=social&label=Forks" alt="#forks"/>&nbsp;
<img src="https://img.shields.io/github/stars/{{repo}}?style=social&label=Stars" alt="#starts"/>
{% elsif tool.repoUrl contains '://gist.github.com/' %}
{%comment%}
repo holds the "gistID" as last path-part segment, for eg:
https://gist.github.com/jkowalleck/a0f874ee0a8af9a56a0e887631fc53d1
https://gist.github.com/a0f874ee0a8af9a56a0e887631fc53d1
https://gist.github.com/a0f874ee0a8af9a56a0e887631fc53d1/
https://gist.github.com/a0f874ee0a8af9a56a0e887631fc53d1.git
{%endcomment%}
{% assign gistID = tool.repoUrl | regex_replace:'^https?://gist.github.com/','' | regex_replace:'(.git|/)$','' | split:'/' | last %}
<img src="https://img.shields.io/github/gist/stars/{{gistID}}?style=social&label=Stars" alt="#stars"/>
{% elsif tool.repoUrl contains '://gitlab.com/' %}
{%comment%}
repo holds the "org/repo" name, for eg:
https://gitlab.com/expliot_framework/expliot
https://gitlab.com/expliot_framework/expliot/
https://gitlab.com/expliot_framework/expliot.git
{%endcomment%}
{% assign repo = tool.repoUrl | regex_replace:'^https?://gitlab.com/','' | regex_replace:'(.git|/)$','' %}
<img src="https://img.shields.io/gitlab/forks/{{repo|url_encode}}?style=social&label=Forks" alt="#forks"/>&nbsp;
<img src="https://img.shields.io/gitlab/stars/{{repo|url_encode}}?style=social&label=Stars" alt="#starts"/>
{% elsif tool.repoUrl contains '://bitbucket.org/' %}
{%comment%}noting we can do for this repo hoster.{%endcomment%}
{% endif %}
</div>
</a>
</div>
</div>

0 comments on commit b8c30ef

Please sign in to comment.