Skip to content

Commit

Permalink
Merge pull request #1 from lzambra2/7.6.0
Browse files Browse the repository at this point in the history
Adding Altmetrics + Plumx and other
  • Loading branch information
lzambra2 authored Oct 24, 2023
2 parents 404ccd9 + ba08147 commit 56cfb16
Show file tree
Hide file tree
Showing 52 changed files with 1,107 additions and 2,203 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ package-lock.json
junit.xml

/src/mirador-viewer/config.local.js
yarn.lock
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ The same settings can also be overwritten by setting system environment variable
```bash
export DSPACE_HOST=api7.dspace.org
export DSPACE_UI_PORT=4200
export DSPACE_UI_ALTMETRIC=https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js
export DSPACE_UI_PLUMX=https://cdn.plu.mx/widget-popup.js
```

The priority works as follows: **environment variable** overrides **variable in `.env` file** overrides external config set by `DSPACE_APP_CONFIG_PATH` overrides **`config.(prod or dev).yml`**
Expand Down
5 changes: 5 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
"input": "src/themes/dspace/styles/theme.scss",
"inject": false,
"bundleName": "dspace-theme"
},
{
"input": "src/themes/yorkspace/styles/theme.scss",
"inject": false,
"bundleName": "yorkspace-theme"
}
],
"scripts": [],
Expand Down
1 change: 0 additions & 1 deletion config/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
config.*.yml
!config.example.yml
32 changes: 32 additions & 0 deletions config/config.dev.yml
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
3 changes: 3 additions & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ rest:
host: api7.dspace.org
port: 443
nameSpace: /server
ui:
altmetric: https://d1bxh8uas1mnw7.cloudfront.net/assets/embed.js
plumx: https://cdn.plu.mx/widget-popup.js
53 changes: 6 additions & 47 deletions src/app/footer/footer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,7 @@
<div *ngIf="showTopFooter" class="top-footer">
<!-- Grid container -->
<div class=" container p-4">
<!--Grid row-->
<div class="row">

<!--Grid column-->
<div class="col-lg-4 col-md-6 mb-4 mb-lg-0">
<h5 class="text-uppercase">Footer Content</h5>

<ul class="list-unstyled mb-0">
<li>
<a routerLink="./" class="">Lorem ipsum</a>
</li>
<li>
<a routerLink="./" class="">Ut facilisis</a>
</li>
<li>
<a routerLink="./" class="">Aenean sit</a>
</li>
</ul>
</div>
<!--Grid column-->

<!--Grid column-->
<div class="col-lg-4 col-md-6 mb-4 mb-lg-0">
<h5 class="text-uppercase">Footer Content</h5>

<ul class="list-unstyled mb-0">
<li>
<a routerLink="./" class="">Suspendisse potenti</a>
</li>
</ul>
</div>
<!--Grid column-->

<!--Grid column-->
<div class="col-lg-4 col-md-12 mb-4 mb-md-0">
<h5 class="text-uppercase">Footer Content</h5>

<p>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Iste atque ea quis
molestias. Fugiat pariatur maxime quis culpa corporis vitae repudiandae aliquam
voluptatem veniam, est atque cumque eum delectus sint!
</p>
</div>
<!--Grid column-->
</div>
<!--Grid row-->
<p>{{ 'yorkspace.footer.copyright' | translate}}</p>
</div>
</div>
<!-- Grid container -->
Expand All @@ -56,17 +11,21 @@ <h5 class="text-uppercase">Footer Content</h5>
<div class="bottom-footer p-1 d-flex justify-content-center align-items-center text-white">
<div class="content-container">
<p class="m-0">
<!--
<a class="text-white"
href="http://www.dspace.org/">{{ 'footer.link.dspace' | translate}}</a>
{{ 'footer.copyright' | translate:{year: dateObj | date:'y'} }}
<a class="text-white"
href="https://www.lyrasis.org/">{{ 'footer.link.lyrasis' | translate}}</a>
-->
</p>
<ul class="footer-info list-unstyled small d-flex justify-content-center mb-0">
<!--
<li>
<a class="text-white" href="javascript:void(0);"
(click)="showCookieSettings()">{{ 'footer.link.cookies' | translate}}</a>
</li>
-->
<li *ngIf="showPrivacyPolicy">
<a class="text-white"
routerLink="info/privacy">{{ 'footer.link.privacy-policy' | translate}}</a>
Expand All @@ -75,7 +34,7 @@ <h5 class="text-uppercase">Footer Content</h5>
<a class="text-white"
routerLink="info/end-user-agreement">{{ 'footer.link.end-user-agreement' | translate}}</a>
</li>
<li *ngIf="showSendFeedback$ | async">
<li>
<a class="text-white"
routerLink="info/feedback">{{ 'footer.link.feedback' | translate}}</a>
</li>
Expand Down
19 changes: 4 additions & 15 deletions src/app/footer/footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { Component, Optional } from '@angular/core';
import { hasValue } from '../shared/empty.util';

Check failure on line 2 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'hasValue' is defined but never used

Check failure on line 2 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

'hasValue' is defined but never used

Check failure on line 2 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'hasValue' is defined but never used

Check failure on line 2 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

'hasValue' is defined but never used

Check failure on line 2 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'hasValue' is defined but never used

Check failure on line 2 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

'hasValue' is defined but never used
import { KlaroService } from '../shared/cookies/klaro.service';
import { environment } from '../../environments/environment';

Check failure on line 4 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'environment' is defined but never used

Check failure on line 4 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

'environment' is defined but never used

Check failure on line 4 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'environment' is defined but never used

Check failure on line 4 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

'environment' is defined but never used

Check failure on line 4 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

'environment' is defined but never used

Check failure on line 4 in src/app/footer/footer.component.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

'environment' is defined but never used
import { Observable } from 'rxjs';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../core/data/feature-authorization/feature-id';

@Component({
selector: 'ds-footer',
Expand All @@ -17,22 +14,14 @@ export class FooterComponent {
/**
* A boolean representing if to show or not the top footer container
*/
showTopFooter = false;
showPrivacyPolicy = environment.info.enablePrivacyStatement;
showEndUserAgreement = environment.info.enableEndUserAgreement;
showSendFeedback$: Observable<boolean>;
showTopFooter = true;
showPrivacyPolicy = false;
showEndUserAgreement = false;

constructor(
@Optional() private cookies: KlaroService,
private authorizationService: AuthorizationDataService,
) {
this.showSendFeedback$ = this.authorizationService.isAuthorized(FeatureID.CanSendFeedback);
constructor(@Optional() private cookies: KlaroService) {
}

showCookieSettings() {
if (hasValue(this.cookies)) {
this.cookies.showSettings();
}
return false;
}
}
2 changes: 2 additions & 0 deletions src/app/item-page/item-page.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { ThemedItemAlertsComponent } from './alerts/themed-item-alerts.component
import {
ThemedFullFileSectionComponent
} from './full/field-components/file-section/themed-full-file-section.component';
import { ItemPageMetricsFieldComponent } from './simple/field-components/specific-field/metrics/item-page-metrics-field/item-page-metrics-field.component';

const ENTRY_COMPONENTS = [
// put only entry components that use custom decorator
Expand Down Expand Up @@ -102,6 +103,7 @@ const DECLARATIONS = [
OrcidQueueComponent,
ItemAlertsComponent,
ThemedItemAlertsComponent,
ItemPageMetricsFieldComponent,
BitstreamRequestACopyPageComponent,
];

Expand Down
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>
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);
});
});
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();
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
[fields]="['dc.publisher']"
[label]="'publication.page.publisher'">
</ds-generic-item-page-field>
<ds-item-page-metrics-field [item]="object">
</ds-item-page-metrics-field>
</div>

<div class="col-xs-12 col-md-7">
<ds-related-items
[parentItem]="object"
Expand Down
1 change: 0 additions & 1 deletion src/app/login-page/login-page.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div class="container w-100 h-100">
<div class="text-center mt-5 row justify-content-center">
<div>
<img class="mb-4 login-logo" src="assets/images/dspace-logo.png" alt="{{'repository.image.logo' | translate}}">
<h1 class="h3 mb-0 font-weight-normal">{{"login.form.header" | translate}}</h1>
<ds-log-in
[isStandalonePage]="true"></ds-log-in>
Expand Down
Loading

0 comments on commit 56cfb16

Please sign in to comment.