forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from lzambra2/7.6.0
Adding Altmetrics + Plumx and other
- Loading branch information
Showing
52 changed files
with
1,107 additions
and
2,203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,4 @@ package-lock.json | |
junit.xml | ||
|
||
/src/mirador-viewer/config.local.js | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
config.*.yml | ||
!config.example.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
themes: | ||
- name: yorkspace | ||
headTags: | ||
- tagName: link | ||
attributes: | ||
rel: icon | ||
href: https://www.yorku.ca/wp-content/themes/york2020/favicon.ico | ||
sizes: any | ||
- tagName: link | ||
attributes: | ||
rel: apple-touch-icon | ||
href: https://www.yorku.ca/wp-content/themes/york2020/apple-touch-icon.png | ||
languages: | ||
- code: en | ||
label: English | ||
active: true | ||
- code: fr | ||
label: Français | ||
active: true | ||
homePage: | ||
recentSubmissions: | ||
# The number of item showing in recent submission components | ||
pageSize: 5 | ||
# Sort record of recent submission | ||
sortField: 'dc.date.accessioned' | ||
topLevelCommunityList: | ||
# No. of communities to list per page on the home page | ||
# This will always round to the nearest number from the list of page sizes. e.g. if you set it to 7 it'll use 10 | ||
pageSize: 5000 | ||
communityList: | ||
# No. of communities to list per expansion (show more) | ||
pageSize: 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...nts/specific-field/metrics/item-page-metrics-field/item-page-metrics-field.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<ng-container *ngIf="!metrics.disabled"> | ||
<div data-badge-type='medium-donut' class='altmetric-embed' data-badge-details='right' [attr.data-doi]='metrics.url'> | ||
</div> | ||
<a id="plumx" class="plumx-plum-print-popup" href="https://plu.mx/plum/a/?doi={{metrics.url}}" data-popup="right" | ||
data-hide-when-empty="true"></a> | ||
</ng-container> |
57 changes: 57 additions & 0 deletions
57
.../specific-field/metrics/item-page-metrics-field/item-page-metrics-field.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { Item } from 'src/app/core/shared/item.model'; | ||
import { of as observableOf } from 'rxjs'; | ||
import { ItemPageMetricsFieldComponent } from './item-page-metrics-field.component'; | ||
import { APP_CONFIG } from 'src/config/app-config.interface'; | ||
|
||
describe('ItemPageMetricsFieldComponent', () => { | ||
let component: ItemPageMetricsFieldComponent; | ||
let fixture: ComponentFixture<ItemPageMetricsFieldComponent>; | ||
const URI = '/10.13039/501100000289'; | ||
|
||
const appConfigProvider = { | ||
provide: APP_CONFIG, | ||
useValue: { ui: { altmetric: 'altmetric-url', plumx: 'plumx-url' } } | ||
}; | ||
|
||
beforeEach(async () => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ItemPageMetricsFieldComponent], | ||
providers: [appConfigProvider], | ||
}); | ||
|
||
fixture = TestBed.createComponent(ItemPageMetricsFieldComponent); | ||
component = fixture.componentInstance; | ||
|
||
const mockItem: Item = Object.assign(new Item(), { | ||
bundles: observableOf({}), | ||
metadata: { | ||
'dc.title': [ | ||
{ | ||
language: 'en_US', | ||
value: 'This is just another title', | ||
}, | ||
], | ||
'dc.identifier.uri': [{ value: 'http://dx.doi.org' + URI }], | ||
}, | ||
}); | ||
|
||
component.item = mockItem; | ||
|
||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should set data-doi attribute correctly', () => { | ||
const doiAttribute = fixture.nativeElement.querySelector('.altmetric-embed').getAttribute('data-doi'); | ||
expect(doiAttribute).toBe(URI); | ||
}); | ||
|
||
it('should generate a valid anchor element', () => { | ||
const metricsFieldElement = fixture.nativeElement; | ||
const anchorElement = metricsFieldElement.querySelector('a'); | ||
expect(anchorElement).not.toBeNull(); | ||
|
||
const expectedHref = 'https://plu.mx/plum/a/?doi=' + URI; | ||
expect(anchorElement.getAttribute('href')).toBe(expectedHref); | ||
}); | ||
}); |
49 changes: 49 additions & 0 deletions
49
...nents/specific-field/metrics/item-page-metrics-field/item-page-metrics-field.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Component, Input, Inject, OnInit } from '@angular/core'; | ||
import { AltmetricMenuItemModel } from 'src/app/shared/menu/menu-item/models/altmetric.model'; | ||
import { Item } from 'src/app/core/shared/item.model'; | ||
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface'; | ||
|
||
@Component({ | ||
selector: 'ds-item-page-metrics-field', | ||
templateUrl: './item-page-metrics-field.component.html', | ||
}) | ||
export class ItemPageMetricsFieldComponent implements OnInit { | ||
|
||
@Input() metrics = { url: '', disabled: true } as AltmetricMenuItemModel; | ||
@Input() item: Item; | ||
|
||
constructor(@Inject(APP_CONFIG) private appConfig: AppConfig) {} | ||
|
||
ngOnInit() { | ||
this.metrics.url = this.item.firstMetadataValue('dc.identifier.uri') ? (new URL(this.item.firstMetadataValue('dc.identifier.uri')).pathname) : ''; | ||
if (this.metrics.url !== '') { | ||
this.metrics.disabled = false; | ||
} | ||
|
||
this.loadExternalScript(this.appConfig.ui.altmetric) | ||
.catch(error => console.error('Script loading error:', error)); | ||
|
||
this.loadExternalScript(this.appConfig.ui.plumx) | ||
.catch(error => console.error('Script loading error:', error)); | ||
} | ||
|
||
private loadExternalScript(scriptUrl: string): Promise<void> { | ||
return new Promise<void>((resolve, reject) => { | ||
if (!this.metrics.disabled) { | ||
const script = document.createElement('script'); | ||
script.src = scriptUrl; | ||
script.onload = () => { | ||
console.log('External script has been loaded: ' + scriptUrl); | ||
resolve(); | ||
}; | ||
script.onerror = (error) => { | ||
this.metrics.disabled = true; | ||
reject(error); | ||
}; | ||
document.body.appendChild(script); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.