-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display Altmetric badges on simple item view #2496
base: main
Are you sure you want to change the base?
Conversation
* Separating the badge component from the item page section "Metrics", now you can add more badges there from other services in the future
Hi @sergius02, |
@sergius02 I'd like to test this on our dspace-7.6 instance. Could you please make a patch against dspace-7.6 tag? Thanks! |
Never mind, I applied the patch and it is working on dspace-7.6 tag. Thanks! |
We have this feature in DSpace-CRIS. It is part of a larger feature that allow to track/visualize metrics about the item so it is not something "small" to be ported so the fact that the feature exists in DSpace-CRIS should definitively not prevent us to consider this PR. |
Regarding GDPR, we are already loading fonts from Google Fonts, which was apparently found to be a breach of GDPR in January, 2022. So that's not great...
Yes I agree that they should be off by default as they were in DSpace 6.x, see # Is the Altmetric.com badge enabled?
#altmetric.enabled = false |
Hi, just to help with the test, the article referenced by @alanorth in the issue related to the PR as a nice Altmetrics badge and have both a DOI (10.1126/science.1259855 ; to add in dc.identifier.doi metadata of an item) and a Pubmed ID (25592418 ; to add in a dc.identifier.pubmedid metadata of an item). Just 2 questions to test this feature: where on the page should the Altmetrics Badge be displayed? For the metadata, can both the ID and the URI (ex for DOI: 10.1126/science.1259855 or https://doi.org/10.1126/science.1259855) be used, or only the ID? |
Ok, i've made some changes. There's a new configuration under item section in the config.yml named showAltmetricBadge (false by default). When it's false the script will be never be loaded |
export const ExternalScriptsList: ExternalScript[] = [ | ||
{ | ||
name: ExternalScriptsNames.ALTMETRIC, | ||
src: 'https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't had a chance to test this yet, but I wanted to quickly note that we'll need to make this URL configurable in some manner. This sort of external CDN may not be compatible with GDPR. It's also unclear to me if this is an "official" CDN for the altmetric badges or something else?
Basically, it'd unclear to me whether this would be GDPR compliant or not. So, we need a way to change this URL via configuration easily if sites need that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's taken from the oficial docs: https://badge-docs.altmetric.com/getting-started.html#quick-start
<script type='text/javascript' src='https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js'></script>
I can try to make it configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergius02 : Right, I understand this came from the official AltMetric documentation. If you prefer to leave it as-is, we can do so. But, I do think it's easier to maintain this code if the URL is configurable. Consider this an optional request.
I also have realized that my feedback here is similar to the feedback in this comment above.
The main point is that this external CDN (cloudfront.net) may not be GDPR compliant...but it doesn't appear there's any way to fix that issue since Altmetric requires you to use this CDN in order to use their badges.
So, in the end, we may need to simply add warnings on enabling Altmetric to the documentation since it requires usage of an external CDN (and we cannot make guarantees ourselves that the external CDN is GDPR compliant).
Hi @sergius02, |
@sergius02 : If you have a chance in the next few days, could you rebase this to resolve the merge conflicts? Our 8.0 feature PR merger deadline is Friday, Feb 23 and we are still hoping that we can include this PR. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergius02 : I tested this today and it seems to be somehow enabled by default? We need it to be disabled by default.
Currently with default configurations I can see the script is downloaded & the request to https://api.altmetric.com
occurs...and that's not what we want to happen. This call also occurs if I set:
item:
showAltmetricBadge: false
So, it appears that something is causing this to run whether it's disabled or not. (It might be your changes to config/config.yml
?)
A few other notes inline below.
@@ -284,6 +284,8 @@ item: | |||
# Rounded to the nearest size in the list of selectable sizes on the | |||
# settings menu. See pageSizeOptions in 'pagination-component-options.model.ts'. | |||
pageSize: 5 | |||
# Show the Altmetric badge in the simple item page. | |||
showAltmetricBadge: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to false
because the default value is false.
@@ -3,3 +3,5 @@ rest: | |||
host: sandbox.dspace.org | |||
port: 443 | |||
nameSpace: /server | |||
item: | |||
showAltmetricBadge: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed as it shouldn't be necessary. All default config values are only in app/config/default-app-config.ts
. (That's why this file has very few configurations in it)
return [ | ||
{ | ||
name: 'data-doi', | ||
value: this.item.firstMetadataValue('dc.identifier.doi'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this is correct. Currently DSpace is storing DOIs in dc.identifier.uri
and/or dc.identifier
based on this ticket DSpace/DSpace#5565
Maybe we need a way to check for DOIs in all three of these fields? I'm OK with the first check being dc.identifier.doi
...but if not found there, we may want to check other fields for DOIs too.
Hi @sergius02, |
Hi @tdonohue , sorry for the late response, im working on it now but with the migration to the new standalone components i have to do some changes to this PR. Im facing a problem that i don't know why occurs and don't know how to solve. I've made the ItemPageMetricsFieldComponent standalone adding this to the Component decorator standalone: true,
imports: [TranslateModule, MetadataFieldWrapperComponent, ItemPageAltmetricFieldComponent] Then in PublicationComponent and UntypedComponent, i've added to the imports: imports: [..., AsyncPipe, TranslateModule, ItemPageMetricsFieldComponent], Everything seems to be ok, but this error appears in publication.component.html and untyped.component.html
|
* We ensure that the badge is visible after the script is loaded | ||
* @param data The data returned from the promise | ||
*/ | ||
private reloadBadge(data: any[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to point out that I was trying to implement this, but instead of for Altmetrics, for Dimensions. I basically cp/pt'd the files that were Altmetric specific, but renamed them and some of the variables/constants in the code to "dimensions." I had it working except that when I left the item page and then came back to the page the badge was gone. The issue came from this method. I thought that I could use _dimensison_embed_init as the method, but not that did not work. That method does not exists in the Dimensions' javascript. I reached out to the community and @sergius02 told me to change this method to this:
private reloadBadge(data: any[]) {
if (data.find((element) => this.isLoaded(element))) {
const initClass = '__dimensions_embed';
const initMethod = 'addBadges';
window[initClass][initMethod]();
}
}
Then it worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sergius02, I've tried this method but for Plumx. The PlumX developer page says to call this method window.__plumX.widgets.init();
but unfortunately if I navigate away from the page and return later, I received a TypeError: window[initClass] is undefined
error. I tried replacing the value of initClass above with __plumX.widgets.init
but the error persists. Any ideas how to resolve this issue?
@sergius02 : This still has merge conflicts. If you have a chance to find a fix prior to 8.0, we can still consider this. Otherwise, if you still need help/support, we'll likely need to reschedule for 9.0 (unless anyone else finds time to help...I won't be available until 8.0 is complete unfortunately). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this in my local 7_x instance and it worked. It would be nice to also include Dimensions and PlumX metrics. Right now I have no idea how to load the cdn of PlumX to co-exist with Altmetrics here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this in my local 7_x instance and it worked. It would be nice to also include Dimensions and PlumX metrics. Right now I have no idea how to load the cdn of PlumX to co-exist with Altmetrics here.
I solved this using the code from SO which was also referenced in this pull request: https://stackoverflow.com/a/42766146. My code now looked like this:
export enum ExternalScriptsNames {
ALTMETRIC = 'altmetric-embed',
DIMENSIONS = '__dimensions_badge_embed__',
PLUMX = 'plumx-details'
}
...
export const ExternalScriptsList: ExternalScript[] = [
{name: ExternalScriptsNames.ALTMETRIC, src: 'https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js'},
{name: ExternalScriptsNames.DIMENSIONS, src: 'https://badge.dimensions.ai/badge.js'},
{name: ExternalScriptsNames.PLUMX, src: 'https://cdn.plu.mx/widget-details.js'},
];
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to use this for PlumX, however, the format for PlumX used this format: <a href="https://plu.mx/plum/a/?doi=10.1371/journal.pone.0056506" class="plumx-details"></a>
References
Description
Displays the Altmetric donut in the simple item page. It use diferent identifiers to do that, DOI, Handle, PMID, ISBN, ARXIV or URI.
Instructions for Reviewers
List of changes in this PR:
Checklist
yarn lint
yarn check-circ-deps
)package.json
), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.