Skip to content

Commit a968557

Browse files
Adds Dimensions badge (alshedivat#1086)
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.
1 parent e7b83a7 commit a968557

File tree

7 files changed

+35
-3
lines changed

7 files changed

+35
-3
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ There are several custom bibtex keywords that you can use to affect how the entr
418418
- `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)
419419
- `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)
420420
- `website`: Adds a "Website" button redirecting to the specified link
421-
- `altmetric`: Adds an [Altmetric](https://www.altmetric.com/) badge (Note: only add the altmetric identifier here - the link is generated automatically)
421+
- `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)
422+
- `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)
422423

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

_bibliography/papers.bib

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ @article{PhysRev.47.777
4343
html={https://journals.aps.org/pr/abstract/10.1103/PhysRev.47.777},
4444
pdf={example_pdf.pdf},
4545
altmetric={248277},
46+
dimensions={true},
4647
selected={true}
4748
}
4849

_config.yml

+4
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ scholar:
273273

274274
query: "@*"
275275

276+
badges: # Display different badges for your pulications
277+
altmetric_badge: true # Altmetric badge (https://www.altmetric.com/products/altmetric-badges/)
278+
dimensions_badge: true # Dimensions badge (https://badge.dimensions.ai/)
279+
276280
# Filter out certain bibtex entry keywords used internally from the bib output
277281
filtered_bibtex_keywords: [abbr, abstract, arxiv, bibtex_show, html, pdf, selected, supp, blog, code, poster, slides, website, preview, altmetric]
278282

_includes/scripts/badges.html

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{%- if site.badges.altmetric_badge %}
2+
<script async src="https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js"></script>
3+
{%- endif %}
4+
{%- if site.badges.dimensions_badge %}
5+
<script async src="https://badge.dimensions.ai/badge.js"></script>
6+
{%- endif %}

_layouts/bib.html

+9-2
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,17 @@
180180
{%- if entry.website %}
181181
<a href="{{ entry.website }}" class="btn btn-sm z-depth-0" role="button">Website</a>
182182
{%- endif %}
183-
{%- if entry.altmetric %}
184-
<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>
183+
</div>
184+
{% if site.badges %}
185+
<div class="badges">
186+
{%- if site.badges.altmetric_badge or entry.altmetric %}
187+
<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>
188+
{%- endif %}
189+
{%- if site.badges.dimensions_badge or entry.dimensions %}
190+
<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>
185191
{%- endif %}
186192
</div>
193+
{%- endif %}
187194

188195
{% if entry.abstract -%}
189196
<!-- Hidden abstract block -->

_layouts/default.html

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
{% include scripts/bootstrap.html %}
2929
{% include scripts/masonry.html %}
3030
{% include scripts/misc.html %}
31+
{% include scripts/badges.html %}
3132
{% include scripts/mathjax.html %}
3233
{% include scripts/analytics.html %}
3334
{% include scripts/progressBar.html %}

_sass/_base.scss

+12
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,18 @@ footer.sticky-bottom {
557557
}
558558
}
559559
}
560+
.badges {
561+
span {
562+
display: inline-block;
563+
color: $black-color;
564+
height: 100%;
565+
padding-left: 0.5rem;
566+
vertical-align: middle;
567+
&:hover {
568+
text-decoration: underline;
569+
}
570+
}
571+
}
560572
.hidden {
561573
font-size: 0.875rem;
562574
max-height: 0px;

0 commit comments

Comments
 (0)