Update metadataservice citation tag to refer to new download page

This commit is contained in:
Yana De Pauw
2021-02-12 10:01:08 +01:00
committed by Art Lowel
parent 69c29407a2
commit 99a96451b1
4 changed files with 12 additions and 20 deletions

View File

@@ -6,6 +6,7 @@ import { getCommunityPageRoute } from './+community-page/community-page-routing-
import { getCollectionPageRoute } from './+collection-page/collection-page-routing-paths';
import { getItemPageRoute } from './+item-page/item-page-routing-paths';
import { hasValue } from './shared/empty.util';
import { URLCombiner } from './core/url-combiner/url-combiner';
export const BITSTREAM_MODULE_PATH = 'bitstreams';
@@ -13,6 +14,10 @@ export function getBitstreamModuleRoute() {
return `/${BITSTREAM_MODULE_PATH}`;
}
export function getBitstreamDownloadRoute(bitstream) : string{
return new URLCombiner(getBitstreamModuleRoute(), bitstream.uuid, 'download').toString();
}
export const ADMIN_MODULE_PATH = 'admin';
export function getAdminModuleRoute() {

View File

@@ -222,7 +222,7 @@ describe('MetadataService', () => {
expect(tagStore.get('citation_dissertation_name')[0].content).toEqual('Test PowerPoint Document');
expect(tagStore.get('citation_dissertation_institution')[0].content).toEqual('Mock Publisher');
expect(tagStore.get('citation_abstract_html_url')[0].content).toEqual([environment.ui.baseUrl, router.url].join(''));
expect(tagStore.get('citation_pdf_url')[0].content).toEqual('https://dspace7.4science.it/dspace-spring-rest/api/core/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28/content');
expect(tagStore.get('citation_pdf_url')[0].content).toEqual('/bitstreams/99b00f3c-1cc6-4689-8158-91965bee6b28/download');
}));
it('items page should set meta tags as published Technical Report', fakeAsync(() => {

View File

@@ -22,6 +22,8 @@ import { Item } from '../shared/item.model';
import { getFirstSucceededRemoteDataPayload, getFirstSucceededRemoteListPayload } from '../shared/operators';
import { environment } from '../../../environments/environment';
import { RootDataService } from '../data/root-data.service';
import { URLCombiner } from '../url-combiner/url-combiner';
import { getBitstreamDownloadRoute, getBitstreamModuleRoute } from '../../app-routing-paths';
@Injectable()
export class MetadataService {
@@ -40,7 +42,6 @@ export class MetadataService {
private dsoNameService: DSONameService,
private bitstreamDataService: BitstreamDataService,
private bitstreamFormatDataService: BitstreamFormatDataService,
private redirectService: HardRedirectService,
private rootService: RootDataService
) {
// TODO: determine what open graph meta tags are needed and whether
@@ -286,7 +287,8 @@ export class MetadataService {
getFirstSucceededRemoteDataPayload()
).subscribe((format: BitstreamFormat) => {
if (format.mimetype === 'application/pdf') {
this.addMetaTag('citation_pdf_url', bitstream._links.content.href);
const bitstreamLink = getBitstreamDownloadRoute(bitstream);
this.addMetaTag('citation_pdf_url', bitstreamLink);
}
});
}

View File

@@ -1,10 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { FileService } from '../../core/shared/file.service';
import { Observable } from 'rxjs';
import { AuthService } from '../../core/auth/auth.service';
import { Bitstream } from '../../core/shared/bitstream.model';
import { getBitstreamModuleRoute } from '../../app-routing-paths';
import { URLCombiner } from '../../core/url-combiner/url-combiner';
import { getBitstreamDownloadRoute } from '../../app-routing-paths';
@Component({
selector: 'ds-file-download-link',
@@ -24,22 +20,11 @@ export class FileDownloadLinkComponent implements OnInit {
@Input() bitstream: Bitstream;
bitstreamPath: string;
/**
* Whether or not the current user is authenticated
*/
isAuthenticated$: Observable<boolean>;
constructor(private fileService: FileService,
private authService: AuthService,
) {
}
ngOnInit() {
this.isAuthenticated$ = this.authService.isAuthenticated();
this.bitstreamPath = this.getBitstreamPath();
}
getBitstreamPath() {
return new URLCombiner(getBitstreamModuleRoute(), this.bitstream.uuid, 'download').toString();
return getBitstreamDownloadRoute(this.bitstream);
}
}