[Library]: [Bug fix] Strip html tags for titles and descriptions and show them as innerHTML.

1. dataProvider.component.ts & organization.component.ts & project.component.ts & resultLanding.component.ts & orcid-work.component.ts: Commented unused @ViewChild fields.
2. dataProvider.service.ts & project.service.ts & resultLanding.service.ts: Strip html tags from title.
3. resultLanding.component.ts: [Bug fix] resultLanding.description is string, not array.
4. orcidWork.ts: [Bug fix] resultLanding.description is string, not array & strip html tags from description.
5. refineFieldResults.service.ts: In method "getSearchAPIURLForEntity()", for entityType "result" set suffix to "results/".
6. searchDataproviders.service.ts & searchOrganizations.service.ts & searchProjects.service.ts & searchResearchResults.service.ts: Strip html tags from title | Do not cut description (multi line ellipsis is used in html).
7. jsonld-document-serializer.service.ts: [Bug fix] resultLanding.description is string, not array.
8. result-preview.component.html: Show description as innerHTML to properly display special characters.
This commit is contained in:
Konstantina Galouni 2022-11-28 19:22:01 +02:00
parent f935e81959
commit e9e2ee9f3a
17 changed files with 101 additions and 78 deletions

View File

@ -68,8 +68,8 @@ export class DataProviderComponent {
// Statistics tab variables
public statsClicked: boolean = false;
@ViewChild('statisticsModal') statisticsModal;
@ViewChild('relatedDatasourcesModal') relatedDatasourcesModal;
// @ViewChild('statisticsModal') statisticsModal;
// @ViewChild('relatedDatasourcesModal') relatedDatasourcesModal;
@ViewChild('addThisModal') addThisModal
// Variables for publications, research data, projects, datasources, related datasources tabs
@ -672,21 +672,21 @@ export class DataProviderComponent {
return !(this.totalViews != null && this.totalDownloads != null && this.pageViews != null) || this.totalViews > 0 || this.totalDownloads > 0 || this.pageViews > 0;
}
public openStatistics() {
this.statsClicked = true;
this.statisticsModal.cancelButton = false;
this.statisticsModal.okButton = false;
this.statisticsModal.alertTitle = "Statistics of";
this.statisticsModal.open();
}
public openRelatedDatasources() {
this.searchRelatedDatasources(1, 0);
this.relatedDatasourcesModal.cancelButton = false;
this.relatedDatasourcesModal.okButton = false;
this.relatedDatasourcesModal.alertTitle = "Related "+this.openaireEntities.DATASOURCES+" of";
this.relatedDatasourcesModal.open();
}
// public openStatistics() {
// this.statsClicked = true;
// this.statisticsModal.cancelButton = false;
// this.statisticsModal.okButton = false;
// this.statisticsModal.alertTitle = "Statistics of";
// this.statisticsModal.open();
// }
//
// public openRelatedDatasources() {
// this.searchRelatedDatasources(1, 0);
// this.relatedDatasourcesModal.cancelButton = false;
// this.relatedDatasourcesModal.okButton = false;
// this.relatedDatasourcesModal.alertTitle = "Related "+this.openaireEntities.DATASOURCES+" of";
// this.relatedDatasourcesModal.open();
// }
public openAddThisModal() {
this.addThisModal.cancelButton = false;

View File

@ -6,7 +6,7 @@ import{EnvProperties} from '../../utils/properties/env-properties';
import {map} from "rxjs/operators";
import {ParsingFunctions} from "../landing-utils/parsingFunctions.class";
import {OpenaireEntities} from "../../utils/properties/searchFields";
import {Identifier} from "../../utils/string-utils.class";
import {Identifier, StringUtils} from "../../utils/string-utils.class";
import {properties} from "../../../../environments/environment";
@ -138,8 +138,14 @@ export class DataProviderService {
this.dataProviderInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.dataProviderInfo.record, "datasource");
if(data[0] != null) {
this.dataProviderInfo.title = {"name": (data[0].englishname)?data[0].englishname: data[0].officialname, "url": data[0].websiteurl};
this.dataProviderInfo.officialName = data[0].officialname;
this.dataProviderInfo.title = {"name": "", "url": data[0].websiteurl};
if(data[0].officialname) {
this.dataProviderInfo.title.name = StringUtils.HTMLToString(String(data[0].officialname));
this.dataProviderInfo.officialName = StringUtils.HTMLToString(String(data[0].officialname));
}
if(data[0].englishname) {
this.dataProviderInfo.title.name = StringUtils.HTMLToString(String(data[0].englishname));
}
var pattern = /.{12}::.+/;
var originalIds =(data[0].originalId)?data[0].originalId:"";

View File

@ -802,7 +802,7 @@ export class ParsingFunctions {
if(stripHTML) {
return abstracts.join(' ');
} else {
return abstracts.length > 0 ? ('<p>' + abstracts.join('</p><p>') + '</p>') : abstracts.join(' ');
return abstracts.length > 0 ? ('<p>' + abstracts.join('</p> <p>') + '</p>') : abstracts.join(' ');
}
}
}

View File

@ -70,8 +70,8 @@ export class OrganizationComponent {
public activeTab: string = "";
@ViewChild('downloadReportsModal') downloadReportsModal;
@ViewChild('downloadReportModal') downloadReportModal;
@ViewChild('downloadFunderReportModal') downloadFunderReportModal;
// @ViewChild('downloadReportModal') downloadReportModal;
// @ViewChild('downloadFunderReportModal') downloadFunderReportModal;
@ViewChild('addThisModal') addThisModal;
@ViewChild(ModalLoading) loading: ModalLoading;
@ -118,7 +118,7 @@ export class OrganizationComponent {
public feedbackFields: string [] = ['Name', 'Country', 'Other'];
@ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
@ViewChild('projectsModal') projectsModal;
// @ViewChild('projectsModal') projectsModal;
public deleteByInferenceOpened: boolean = false;

View File

@ -80,8 +80,8 @@ export class ProjectComponent {
// Active tab variable for responsiveness
public activeTab: string = "";
@ViewChild('statisticsModal') statisticsModal;
@ViewChild('linkProjectModal') linkProjectModal;
// @ViewChild('statisticsModal') statisticsModal;
// @ViewChild('linkProjectModal') linkProjectModal;
@ViewChild('embedResultsModal') embedResultsModal;
@ViewChild('downloadReportModal') downloadReportModal;
@ViewChild('addThisModal') addThisModal

View File

@ -9,6 +9,7 @@ import{EnvProperties} from '../../utils/properties/env-properties';
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
import {map} from "rxjs/operators";
import {StringUtils} from "../../utils/string-utils.class";
@Injectable()
export class ProjectService {
@ -123,7 +124,11 @@ export class ProjectService {
// ['result']['metadata']['oaf:entity']['oaf:project']
if(data[0] != null) {
this.projectInfo.acronym = data[0].acronym;
this.projectInfo.title = Array.isArray(data[0]['title']) ? data[0].title[0] : data[0].title;
if(data[0]['title']) {
this.projectInfo.title = Array.isArray(data[0]['title']) ? StringUtils.HTMLToString(String(data[0].title[0])) : StringUtils.HTMLToString(String(data[0].title));
} else {
this.projectInfo.title = "";
}
this.projectInfo.funding.code = data[0].code;
if(data[0].startdate) {
let date: number = Date.parse(data[0].startdate);

View File

@ -37,11 +37,11 @@ export class ResultLandingComponent {
@Input() piwikSiteId = properties.piwikSiteId;
@Input() communityId = null;
enermapsId;
@ViewChild('linkModal') linkModal;
// @ViewChild('linkModal') linkModal;
@ViewChild('citeModal') citeModal;
@ViewChild('addThisModal') addThisModal;
@ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
@ViewChild('relationModal') relationModal;
// @ViewChild('relationModal') relationModal;
public deleteByInferenceOpened: boolean = false;
@Input() public resultFromInput: boolean = false;
@Input() public resultLandingInfo: ResultLandingInfo;
@ -118,7 +118,7 @@ export class ResultLandingComponent {
public isLoggedIn: boolean = false;
public pid: string;
@ViewChild("annotation") annotation: AnnotationComponent;
// @ViewChild("annotation") annotation: AnnotationComponent;
public contextsWithLink: any;
public relatedClassFilters: Option[]=[{"label": "All relations", "value": ""}];
@ -743,12 +743,12 @@ export class ResultLandingComponent {
}
}
public openLinkModal() {
this.linkModal.cancelButton = false;
this.linkModal.okButton = false;
this.linkModal.alertTitle = "Link this " + this.getTypeName() + " to";
this.linkModal.open();
}
// public openLinkModal() {
// this.linkModal.cancelButton = false;
// this.linkModal.okButton = false;
// this.linkModal.alertTitle = "Link this " + this.getTypeName() + " to";
// this.linkModal.open();
// }
public openCiteModal() {
this.citeThisClicked = true;
@ -804,7 +804,7 @@ export class ResultLandingComponent {
let abstract_words = ["operacao-feliz-natal.blogspot.com", "moviedouban.site", "hack-expert-solution.link"];
allow = allow && !(
(this.hasKeyword(resultLandingInfo.title,title_authors_words) || (resultLandingInfo.authors && this.hasKeyword(resultLandingInfo.authors.map(o => o.fullName).join(" "),title_authors_words))
|| (resultLandingInfo.description && resultLandingInfo.description[0] && this.hasKeyword(resultLandingInfo.description[0],abstract_words))
|| (resultLandingInfo.description && this.hasKeyword(resultLandingInfo.description,abstract_words))
) &&
((resultLandingInfo.publisher && resultLandingInfo.publisher.toLowerCase() == "zenodo") ||
(resultLandingInfo.hostedBy_collectedFrom && resultLandingInfo.hostedBy_collectedFrom.filter(value => {
@ -816,7 +816,7 @@ export class ResultLandingComponent {
let common_abstract = ["international audience","n/a","peer reviewed","national audience","info:eu-repo/semantics/published","-",".","graphical abstract","met lit. opg","international audience; no abstract",'<jats:p>.</jats:p>',"politics","info:eu-repo/semantics/publishedversion","copia digital. madrid : ministerio de educación, cultura y deporte, 2016",'<jats:p />',"peer-reviewed","copia digital. madrid : ministerio de educación, cultura y deporte. subdirección general de coordinación bibliotecaria, 2015","<jats:p>-</jats:p>","imperial users only","yüksek lisans"];
let common_authors = ["[s.n.]","null &na;","nn","(:unap)","(:null)","null anonymous","anonymous"];
allow = allow && !(
this.isKeyword(resultLandingInfo.title,common_titles) || (resultLandingInfo.description && resultLandingInfo.description[0] && this.isKeyword(resultLandingInfo.description[0],common_abstract)) ||
this.isKeyword(resultLandingInfo.title,common_titles) || (resultLandingInfo.description && this.isKeyword(resultLandingInfo.description,common_abstract)) ||
(resultLandingInfo.authors && this.hasKeyword("_"+resultLandingInfo.authors.map(o => o.fullName).join("_")+"_",common_authors, "_"))
);
// console.log("common content " + allow)

View File

@ -153,10 +153,10 @@ export class ResultLandingService {
for(let i=0; i<data[1].length; i++) {
if(data[1][i] && data[1][i].content) {
if(!this.resultLandingInfo.title || data[1][i].classid == "main title") {
this.resultLandingInfo.title = String(data[1][i].content);
this.resultLandingInfo.title = StringUtils.HTMLToString(String(data[1][i].content));
}
if(!this.resultLandingInfo.subtitle && data[1][i].classid === 'subtitle') {
this.resultLandingInfo.subtitle = String(data[1][i].content);
this.resultLandingInfo.subtitle = StringUtils.HTMLToString(String(data[1][i].content));
}
// if(data[1][i].classid == "main title") {
// break;
@ -171,7 +171,7 @@ export class ResultLandingService {
}
// this.resultLandingInfo.title = (data[1][0] && data[1][0].content) ? String(data[1][0].content) : "";
} else {
this.resultLandingInfo.title = (data[1] && data[1].content) ? String(data[1].content) : "";
this.resultLandingInfo.title = (data[1] && data[1].content) ? StringUtils.HTMLToString(String(data[1].content)) : "";
}
}

View File

@ -302,9 +302,9 @@ export class OrcidWorkComponent {
public subscriptions: Subscription[] = [];
@ViewChild('workModal') workModal;
@ViewChild('saveWorkModal') saveWorkModal;
// @ViewChild('saveWorkModal') saveWorkModal;
@ViewChild('grantModal') grantModal;
@ViewChild('messageModal') messageModal;
// @ViewChild('messageModal') messageModal;
@ViewChild('propagationModal') propagationModal;
public requestGrant: boolean = false;
@ -723,16 +723,16 @@ export class OrcidWorkComponent {
this.workModal.cancel();
}
openMessageModal(title: string) {
this.messageModal.cancelButton = false;
this.messageModal.okButton = false;
this.messageModal.alertTitle = title;
this.messageModal.open();
}
closeMessageModal() {
this.messageModal.cancel();
}
// openMessageModal(title: string) {
// this.messageModal.cancelButton = false;
// this.messageModal.okButton = false;
// this.messageModal.alertTitle = title;
// this.messageModal.open();
// }
//
// closeMessageModal() {
// this.messageModal.cancel();
// }
openPropagationModal(title: string) {
this.propagationModal.cancelButton = true;

View File

@ -1,5 +1,6 @@
import {ResultLandingInfo} from "../utils/entities/resultLandingInfo";
import {ResultPreview} from "../utils/result-preview/result-preview";
import {StringUtils} from "../utils/string-utils.class";
export class WorkV3_0 {
// automatically filled by orcid?
@ -107,7 +108,8 @@ export class WorkV3_0 {
}
if(resultLandingInfo.description && resultLandingInfo.description.length < description_limit) {
work['short-description'] = resultLandingInfo.description.length > 0 ? resultLandingInfo.description[0] : "";
resultLandingInfo.description = StringUtils.HTMLToString(resultLandingInfo.description);
work['short-description'] = resultLandingInfo.description.substring(0, description_limit-1);
}
// citation (Citation, optional),

View File

@ -77,7 +77,7 @@ export class RefineFieldResultsService {
}else if(entityType == "person"){
suffix="people/";
}else if(entityType == "result"){
suffix="publications/";
suffix="results/";
}
return suffix;
}

View File

@ -106,8 +106,14 @@ export class SearchDataprovidersService {
result['title'] = {"name": '', "accessMode": ''};
result['title'].name = resData.officialname;
result['englishname'] = resData.englishname;
if(resData.officialname) {
result['title'].name = StringUtils.HTMLToString(String(resData.officialname));
}
if(resData.englishname) {
result['englishname'] = StringUtils.HTMLToString(String(resData.englishname));
} else {
result['englishname'] = "";
}
//result['title'].url = OpenaireProperties.getsearchLinkToDataProvider();
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
@ -125,9 +131,9 @@ export class SearchDataprovidersService {
let abstracts = this.parsingFunctions.parseDescription(resData.description, true);
result.description = abstracts;
if (result.description && result.description.length > this.sizeOfDescription) {
result.description = result.description.substring(0, this.sizeOfDescription) + "...";
}
// if (result.description && result.description.length > this.sizeOfDescription) {
// result.description = result.description.substring(0, this.sizeOfDescription) + "...";
// }
let typeid: string = resData['datasourcetype'].classid;
if(typeid != "entityregistry" && typeid != "entityregistry::projects" && typeid != "entityregistry::repositories") {

View File

@ -94,9 +94,11 @@ export class SearchOrganizationsService {
result['title'] = {"name": '', "accessMode": ''};
result['title'].name = resData.legalshortname;
if(resData.legalshortname) {
result['title'].name = StringUtils.HTMLToString(String(resData.legalshortname));
}
if(!result['title'].name || result['title'].name == '') {
result['title'].name = resData.legalname;
result['title'].name = StringUtils.HTMLToString(String(resData.legalname));
}
//result['title'].url = OpenaireProperties.getsearchLinkToOrganization();

View File

@ -135,11 +135,15 @@ export class SearchProjectsService {
// if(resData['acronym'] != undefined && resData['acronym'] != "") {
// result['title'].name = resData['acronym'] + " - ";
// }
if(Array.isArray(resData['title'])) {
result['title'].name += resData['title'][0];
if(resData['title']) {
if (Array.isArray(resData['title'])) {
result['title'].name += StringUtils.HTMLToString(String(resData['title'][0]));
} else {
result['title'].name += resData['title'];
result['title'].name += StringUtils.HTMLToString(String(resData['title']));
}
} else {
result['title'].name = "";
}
// if(result['title'].name != '') {
// result['title'].name += " ("+resData['code']+")"
@ -160,9 +164,9 @@ export class SearchProjectsService {
let abstracts = this.parsingFunctions.parseDescription(resData.summary, true);
result.description = abstracts;
if (result.description && result.description.length > this.sizeOfDescription) {
result.description = result.description.substring(0, this.sizeOfDescription) + "...";
}
// if (result.description && result.description.length > this.sizeOfDescription) {
// result.description = result.description.substring(0, this.sizeOfDescription) + "...";
// }
if(resData['rels'].hasOwnProperty("rel")) {
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;

View File

@ -299,7 +299,7 @@ export class SearchResearchResultsService {
for (let i = 0; i < resData['title'].length; i++) {
if (resData['title'][i] && resData['title'][i].content) {
if (!result.title.name || resData['title'][i].classid == "main title") {
result['title'].name = String(resData['title'][i].content);
result['title'].name = StringUtils.HTMLToString(String(resData['title'][i].content));
}
if (resData['title'][i].classid == "main title") {
break;
@ -311,7 +311,7 @@ export class SearchResearchResultsService {
}
// result['title'].name = (resData['title'][0] && resData['title'][0].content) ? String(resData['title'][0].content) : "";
} else {
result['title'].name = (resData['title'] && resData['title'].content) ? String(resData['title'].content) : "";
result['title'].name = (resData['title'] && resData['title'].content) ? StringUtils.HTMLToString(String(resData['title'].content)) : "";
}
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
@ -373,9 +373,9 @@ export class SearchResearchResultsService {
let abstracts = this.parsingFunctions.parseDescription(resData.description, true);
result.description = abstracts;
if (result.description && result.description.length > this.sizeOfDescription) {
result.description = result.description.substring(0, this.sizeOfDescription) + "...";
}
// if (result.description && result.description.length > this.sizeOfDescription) {
// result.description = result.description.substring(0, this.sizeOfDescription) + "...";
// }
if (resData.embargoenddate && resData.embargoenddate != '') {
result.embargoEndDate = Dates.getDate(resData.embargoenddate);

View File

@ -117,8 +117,8 @@ export class JsonldDocumentSerializerService {
}
serializeDescription(doc, buffer){
if(doc.description && doc.description[0]) {
buffer["description"] = doc.description[0];
if(doc.description) {
buffer["description"] = doc.description;
}
}
serializeIdentifier(doc, buffer){

View File

@ -285,9 +285,7 @@
<div class="section4 uk-text-small">
<!-- Description -->
<div *ngIf="result.description" class="multi-line-ellipsis lines-3">
<p class="uk-text-meta">
{{result.description}}
</p>
<p class="uk-text-meta" [innerHTML]="result.description"></p>
</div>
</div>
<!-- 5th section(deposit only) -->