Skip to content

Commit

Permalink
Adds Dimensions badge (alshedivat#1086)
Browse files Browse the repository at this point in the history
This adds a dimension badge as requested in alshedivat#987.

This separates the the links from the badges, in case more badges need to be added in the future.
  • Loading branch information
rohandebsarkar authored and chokevin8 committed Aug 7, 2023
1 parent 2d2c3dd commit afa10f9
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ There are several custom bibtex keywords that you can use to affect how the entr
- `poster`: Adds a "Poster" button redirecting to a specified file (if a full link is not specified, the file will be assumed to be placed in the /assets/pdf/ directory)
- `slides`: Adds a "Slides" button redirecting to a specified file (if a full link is not specified, the file will be assumed to be placed in the /assets/pdf/ directory)
- `website`: Adds a "Website" button redirecting to the specified link
- `altmetric`: Adds an [Altmetric](https://www.altmetric.com/) badge (Note: only add the altmetric identifier here - the link is generated automatically)
- `altmetric`: Adds an [Altmetric](https://www.altmetric.com/) badge (Note: if DOI is provided just use `true`, otherwise only add the altmetric identifier here - the link is generated automatically)
- `dimensions`: Adds an [Dimensions](https://www.dimensions.ai/) badge (Note: if DOI or PMID is provided just use `true`, otherwise only add the dimensions identifier here - the link is generated automatically)

You can implement your own buttons by editing the bib.html file.

Expand Down
1 change: 1 addition & 0 deletions _bibliography/papers.bib
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ @article{PhysRev.47.777
html={https://journals.aps.org/pr/abstract/10.1103/PhysRev.47.777},
pdf={example_pdf.pdf},
altmetric={248277},
dimensions={true},
selected={true}
}

Expand Down
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ scholar:

query: "@*"

badges: # Display different badges for your pulications
altmetric_badge: true # Altmetric badge (https://www.altmetric.com/products/altmetric-badges/)
dimensions_badge: true # Dimensions badge (https://badge.dimensions.ai/)

# Filter out certain bibtex entry keywords used internally from the bib output
filtered_bibtex_keywords: [abbr, abstract, arxiv, bibtex_show, html, pdf, selected, supp, blog, code, poster, slides, website, preview, altmetric]

Expand Down
6 changes: 6 additions & 0 deletions _includes/scripts/badges.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{%- if site.badges.altmetric_badge %}
<script async src="https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js"></script>
{%- endif %}
{%- if site.badges.dimensions_badge %}
<script async src="https://badge.dimensions.ai/badge.js"></script>
{%- endif %}
11 changes: 9 additions & 2 deletions _layouts/bib.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,17 @@
{%- if entry.website %}
<a href="{{ entry.website }}" class="btn btn-sm z-depth-0" role="button">Website</a>
{%- endif %}
{%- if entry.altmetric %}
<script type="text/javascript" src="https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js"></script><div data-altmetric-id="{{ entry.altmetric }}" class="altmetric-embed" data-hide-no-mentions="true" data-hide-less-than="15" data-badge-popover="right" data-badge-type="2" style="display:inline"></div>
</div>
{% if site.badges %}
<div class="badges">
{%- if site.badges.altmetric_badge or entry.altmetric %}
<span class="altmetric-embed" {% if entry.doi %}data-doi="{{ entry.doi }}"{% else %}data-altmetric-id="{{ entry.altmetric }}"{% endif %} data-hide-no-mentions="true" data-hide-less-than="15" data-badge-type="2" data-badge-popover="right"></span>
{%- endif %}
{%- if site.badges.dimensions_badge or entry.dimensions %}
<span class="__dimensions_badge_embed__" {% if entry.doi %}data-doi="{{ entry.doi }}"{% else if entry.pmid %}data-pmid="{{ entry.pmid }}"{% else %}data-id="{{ entry.dimensions }}"{% endif %} data-hide-zero-citations="true" data-style="small_rectangle" data-legend="hover-right" style="margin-bottom: 6px;"></span>
{%- endif %}
</div>
{%- endif %}

{% if entry.abstract -%}
<!-- Hidden abstract block -->
Expand Down
1 change: 1 addition & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
{% include scripts/bootstrap.html %}
{% include scripts/masonry.html %}
{% include scripts/misc.html %}
{% include scripts/badges.html %}
{% include scripts/mathjax.html %}
{% include scripts/analytics.html %}
{% include scripts/progressBar.html %}
Expand Down
12 changes: 12 additions & 0 deletions _sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,18 @@ footer.sticky-bottom {
}
}
}
.badges {
span {
display: inline-block;
color: $black-color;
height: 100%;
padding-left: 0.5rem;
vertical-align: middle;
&:hover {
text-decoration: underline;
}
}
}
.hidden {
font-size: 0.875rem;
max-height: 0px;
Expand Down

0 comments on commit afa10f9

Please sign in to comment.