diff --git a/app/assets/stylesheets/application.sass.scss b/app/assets/stylesheets/application.sass.scss index b326b3d2..4ad9fa13 100644 --- a/app/assets/stylesheets/application.sass.scss +++ b/app/assets/stylesheets/application.sass.scss @@ -24,3 +24,7 @@ .record-metadata { margin-bottom: 2em; } + +.altmetric-embed a { + border-bottom: none; +} diff --git a/app/views/purl/_stats.html.erb b/app/views/purl/_stats.html.erb new file mode 100644 index 00000000..b9e02d56 --- /dev/null +++ b/app/views/purl/_stats.html.erb @@ -0,0 +1,11 @@ +<% if document.doi.present? %> +
+
+

Usage metrics

+
+
+

Altmetric tracks online attention to this work. A badge is shown only when online mentions are found.

+
+
+
+<% end %> diff --git a/app/views/purl/show.html.erb b/app/views/purl/show.html.erb index 45698d60..ed44ce19 100644 --- a/app/views/purl/show.html.erb +++ b/app/views/purl/show.html.erb @@ -9,9 +9,13 @@ <%= tag :link, rel: "alternate", title: "MODS XML", type: 'application/xml', href: purl_url(@purl, format: 'mods') if @purl.mods? %> <%= tag :link, rel: "alternate", title: "IIIF Manifest", type: 'application/json', href: iiif_manifest_url(@purl) if @purl.iiif_manifest? %> <%= tag :link, rel: "up", href: purl_url(@purl.containing_collections.first) if @purl.containing_collections.present? %> - <%= tag :meta, name: 'citation_doi', content: @purl.doi_id if @purl.doi.present? %> <%= tag :meta, name: 'citation_title', content: @purl.title %> <%= tag :meta, name: 'robots', content: 'noindex' unless @purl.rights.world_downloadable? %> + + <% if @purl.doi %> + + <%= tag :meta, name: 'citation_doi', content: @purl.doi_id %> + <% end %> <% end %> <% keywords(@purl.mods.subject.compact.map(&:values).join(',')) if @purl.mods? && @purl.mods.subject %> @@ -50,5 +54,7 @@ end <% if @purl.mods? %> <%= render 'mods_metadata_sections', document: @purl %> <% end %> + + <%= render 'stats', document: @purl %> diff --git a/spec/features/integration_spec.rb b/spec/features/integration_spec.rb index 40bae9af..64ef0eac 100644 --- a/spec/features/integration_spec.rb +++ b/spec/features/integration_spec.rb @@ -172,10 +172,13 @@ end context 'item with a DOI' do - it 'includes citation_doi meta tag' do + it 'includes altmetrics' do visit '/bb051dp0564' + expect(page).to have_selector 'meta[name="citation_doi"][content="10.25740/bb051dp0564"]', visible: :hidden expect(page).to have_selector 'meta[name="citation_title"][content="The Distinct Impacts of Content Moderation"]', visible: :hidden + expect(page).to have_selector 'script[src="https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js"]', visible: :hidden + expect(page).to have_css '.altmetric-embed' end end