From 9845f21035051dfcbf02b46a15df263598a16c23 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 25 Mar 2024 11:20:39 +0100 Subject: [PATCH 01/28] Add bibliographicDesc to projectInfo --- src/app/components/project-info/project-info.component.html | 1 + src/app/models/evt-models.ts | 6 ++++++ .../services/xml-parsers/prefatory-matter-parser.service.ts | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/components/project-info/project-info.component.html b/src/app/components/project-info/project-info.component.html index e16f40175..0bb4e5f30 100644 --- a/src/app/components/project-info/project-info.component.html +++ b/src/app/components/project-info/project-info.component.html @@ -5,6 +5,7 @@ +
diff --git a/src/app/models/evt-models.ts b/src/app/models/evt-models.ts index 32cbb46cb..1a06c40dd 100644 --- a/src/app/models/evt-models.ts +++ b/src/app/models/evt-models.ts @@ -1310,11 +1310,17 @@ export class RevisionDesc extends GenericElement { status?: Status | string; } +export class BibliographicDesc extends GenericElement { + biblioEntries: BibliographicEntry[]; + biblioStructEntries: BibliographicStructEntry[]; +} + export class ProjectInfo { fileDesc: FileDesc; encodingDesc: EncodingDesc; profileDesc: ProfileDesc; revisionDesc: RevisionDesc; + bibliographicDesc: BibliographicDesc; } export interface ViewerDataValue { diff --git a/src/app/services/xml-parsers/prefatory-matter-parser.service.ts b/src/app/services/xml-parsers/prefatory-matter-parser.service.ts index 807e6bbef..39334f5fc 100644 --- a/src/app/services/xml-parsers/prefatory-matter-parser.service.ts +++ b/src/app/services/xml-parsers/prefatory-matter-parser.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { map, shareReplay } from 'rxjs/operators'; -import { EncodingDesc, FileDesc, ProfileDesc, ProjectInfo, RevisionDesc, XMLElement } from '../../models/evt-models'; +import { BibliographicDesc, EncodingDesc, FileDesc, ProfileDesc, ProjectInfo, RevisionDesc, XMLElement } from '../../models/evt-models'; import { EditionDataService } from '../edition-data.service'; import { queryAndParseElement } from './basic-parsers'; @@ -35,6 +35,7 @@ export class PrefatoryMatterParserService { encodingDesc: queryAndParseElement(source, 'encodingDesc', true), profileDesc: queryAndParseElement(source, 'profileDesc', true), revisionDesc: queryAndParseElement(source, 'revisionDesc', true), + bibliographicDesc: queryAndParseElement(source, 'listBibl', true), }; } } From ee6ddae957843dcbc47bf7ae8bcbe16646fc806d Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Tue, 26 Mar 2024 11:25:35 +0100 Subject: [PATCH 02/28] Correct spelling mistake in bibliography-parser file name --- src/app/services/xml-parsers/analogue-parser.ts | 2 +- .../{bilbliography-parsers.ts => bibliography-parsers.ts} | 0 src/app/services/xml-parsers/quotes-parser.ts | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/app/services/xml-parsers/{bilbliography-parsers.ts => bibliography-parsers.ts} (100%) diff --git a/src/app/services/xml-parsers/analogue-parser.ts b/src/app/services/xml-parsers/analogue-parser.ts index e99ba434c..c70357792 100644 --- a/src/app/services/xml-parsers/analogue-parser.ts +++ b/src/app/services/xml-parsers/analogue-parser.ts @@ -4,7 +4,7 @@ import { Analogue, AnalogueClass, BibliographicEntry, BibliographicList, Generic import { AnchorParser, AttributeParser, GenericElemParser, MilestoneParser } from './basic-parsers'; import { createParser, getID, parseChildren, Parser } from './parser-models'; import { chainFirstChildTexts, getExternalElements, normalizeSpaces } from '../../utils/xml-utils'; -import { BibliographyParser } from './bilbliography-parsers'; +import { BibliographyParser } from './bibliography-parsers'; import { BasicParser } from './quotes-parser'; @xmlParser('evt-analogue-entry-parser', AnalogueParser) diff --git a/src/app/services/xml-parsers/bilbliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts similarity index 100% rename from src/app/services/xml-parsers/bilbliography-parsers.ts rename to src/app/services/xml-parsers/bibliography-parsers.ts diff --git a/src/app/services/xml-parsers/quotes-parser.ts b/src/app/services/xml-parsers/quotes-parser.ts index 28c6dfe25..3a007ebae 100644 --- a/src/app/services/xml-parsers/quotes-parser.ts +++ b/src/app/services/xml-parsers/quotes-parser.ts @@ -6,7 +6,7 @@ import { Analogue, BibliographicEntry, BibliographicList, BibliographicStructEnt import { AnalogueParser } from './analogue-parser'; import { createParser, getID, parseChildren, ParseFn, Parser } from './parser-models'; import { isAnalogue, isSource, normalizeSpaces } from 'src/app/utils/xml-utils'; -import { BibliographyParser } from './bilbliography-parsers'; +import { BibliographyParser } from './bibliography-parsers'; import { chainFirstChildTexts } from '../../utils/xml-utils'; import { GenericElemParser } from './basic-parsers'; From f5d2551e4d0e86e18f58a05bf7d6e49d549c19bc Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Thu, 4 Apr 2024 16:44:10 +0200 Subject: [PATCH 03/28] Add bibliographic sort & order labels --- src/assets/i18n/en.json | 13 ++++++++++--- src/assets/i18n/it.json | 11 +++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index ec14aae7d..65b25dce1 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -173,12 +173,12 @@ "omit": "omit.", "wit": "Wit:", "xml": "XML", - "criticalApparatus":"Critical Apparatus", + "criticalApparatus": "Critical Apparatus", "sources": "Sources", "analogues": "Analogues", "source": "Source", "analogue": "Analogue", - "notes":"Notes", + "notes": "Notes", "refBibl": "Bibliographic references", "quotedSources": "Quoted sources", "quotedText": "Text", @@ -186,5 +186,12 @@ "analogueIn": "Analogue in", "corresps": "Correspondences", "addImage": "Add image", - "removeImage": "Remove image" + "removeImage": "Remove image", + "bibliography": "Bibliografia", + "style": "Style", + "sortBy": "Sort by", + "year": "Year", + "order": "Order", + "asc": "Ascendent", + "desc": "Descendent" } \ No newline at end of file diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index c41fecfc8..79d2868b6 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -185,5 +185,12 @@ "analogueIn": "Passo parallelo in", "corresps": "Corrispondenze", "addImage": "Aggiungi immagine", - "removeImage": "Rimuovi immagine" -} + "removeImage": "Rimuovi immagine", + "bibliography": "Bibliografia", + "style": "Stile", + "sortBy": "Ordina per", + "year": "Anno", + "order": "Ordine", + "asc": "Crescente", + "desc": "Decrescente" +} \ No newline at end of file From 7cf7e6203d1f25ef5de1be3573d89e2544126227 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Thu, 4 Apr 2024 16:44:22 +0200 Subject: [PATCH 04/28] Add bibliographic styles to ui_config.js --- src/app/app.config.ts | 9 +++++++++ src/assets/config/ui_config.json | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/app/app.config.ts b/src/app/app.config.ts index cd009010e..2167bbfc0 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -92,9 +92,18 @@ export interface UiConfig { initNavBarOpened: boolean; thumbnailsButton: boolean; viscollButton: boolean; + defaultBibliographicStyle: BibliographicStyle, + allowedBibliographicStyles: { + [key: string]: { + id: BibliographicStyle, + label: string, + enabled: boolean + } + } theme: 'neutral' | 'modern' | 'classic'; syncZonesHighlightButton: boolean; } +export type BibliographicStyle = 'chicago' | 'apa' | 'mla' export interface EditionConfig { editionTitle: string; diff --git a/src/assets/config/ui_config.json b/src/assets/config/ui_config.json index 719443d92..91088df59 100644 --- a/src/assets/config/ui_config.json +++ b/src/assets/config/ui_config.json @@ -76,5 +76,20 @@ "thumbnailsButton": true, "viscollButton": true, "theme": "modern", - "syncZonesHighlightButton": true + "syncZonesHighlightButton": true, + "defaultBibliographicStyle": "Chicago", + "allowedBibliographicStyles": { + "Chicago": { + "label": "Chicago", + "enabled": true + }, + "APA": { + "label": "APA", + "enabled": false + }, + "MLA": { + "label": "MLA", + "enabled": true + } + } } \ No newline at end of file From e4f893eefdfffb81a02cb2ec855310b228a06aa8 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 8 Apr 2024 16:02:23 +0200 Subject: [PATCH 05/28] Move bibliographic entries' parsing --- .../project-info/project-info.component.html | 12 ++++++------ .../project-info/project-info.component.ts | 2 ++ src/app/models/evt-models.ts | 6 ++---- src/app/services/evt-model.service.ts | 7 +++++++ .../bibliographic-entries-parser.service.ts | 11 ++++++++++- .../xml-parsers/prefatory-matter-parser.service.ts | 3 +-- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/app/components/project-info/project-info.component.html b/src/app/components/project-info/project-info.component.html index 0bb4e5f30..971bd619b 100644 --- a/src/app/components/project-info/project-info.component.html +++ b/src/app/components/project-info/project-info.component.html @@ -1,11 +1,11 @@
- - - - - - + + + + + +
diff --git a/src/app/components/project-info/project-info.component.ts b/src/app/components/project-info/project-info.component.ts index ebfc2415d..61886fc47 100644 --- a/src/app/components/project-info/project-info.component.ts +++ b/src/app/components/project-info/project-info.component.ts @@ -14,6 +14,8 @@ export class ProjectInfoComponent { tap((info) => this.openSection('fileDesc', info.fileDesc)), ); + public bibliographicEntries$ = this.evtModelService.bibliographicEntries$; + public selectedSection: { key: string; content: GenericElement }; constructor( diff --git a/src/app/models/evt-models.ts b/src/app/models/evt-models.ts index 1a06c40dd..c11024f51 100644 --- a/src/app/models/evt-models.ts +++ b/src/app/models/evt-models.ts @@ -1310,9 +1310,8 @@ export class RevisionDesc extends GenericElement { status?: Status | string; } -export class BibliographicDesc extends GenericElement { - biblioEntries: BibliographicEntry[]; - biblioStructEntries: BibliographicStructEntry[]; +export class BibliographyInfo { + bibliographicEntries: Array; } export class ProjectInfo { @@ -1320,7 +1319,6 @@ export class ProjectInfo { encodingDesc: EncodingDesc; profileDesc: ProfileDesc; revisionDesc: RevisionDesc; - bibliographicDesc: BibliographicDesc; } export interface ViewerDataValue { diff --git a/src/app/services/evt-model.service.ts b/src/app/services/evt-model.service.ts index 1af3df499..ae4ef6fee 100644 --- a/src/app/services/evt-model.service.ts +++ b/src/app/services/evt-model.service.ts @@ -24,6 +24,7 @@ import { WitnessesParserService } from './xml-parsers/witnesses-parser.service'; import { SourceEntriesParserService } from './xml-parsers/source-entries-parser.service'; import { AnalogueEntriesParserService } from './xml-parsers/analogues-entries-parser.service'; import { AppConfig } from '../app.config'; +import { BibliographicEntriesParserService } from './xml-parsers/bibliographic-entries-parser.service'; @Injectable({ providedIn: 'root', @@ -348,6 +349,11 @@ export class EVTModelService { shareReplay(1), ); + public readonly bibliographicEntries$ = this.editionSource$.pipe( + map((source) => this.bibliographicEntriesParser.parseBibliographicEntries(source)), + shareReplay(1), + ) + constructor( private analogueParser: AnalogueEntriesParserService, private editionDataService: EditionDataService, @@ -361,6 +367,7 @@ export class EVTModelService { private linesVersesParser: LinesVersesParserService, private msDescParser: MsDescParserService, private sourceParser: SourceEntriesParserService, + private bibliographicEntriesParser: BibliographicEntriesParserService, ) { } diff --git a/src/app/services/xml-parsers/bibliographic-entries-parser.service.ts b/src/app/services/xml-parsers/bibliographic-entries-parser.service.ts index 71ea2801c..f5bc7dea9 100644 --- a/src/app/services/xml-parsers/bibliographic-entries-parser.service.ts +++ b/src/app/services/xml-parsers/bibliographic-entries-parser.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { ParserRegister } from '.'; -import { BibliographyClass, XMLElement } from '../../models/evt-models'; +import { BibliographyClass, BibliographyInfo, XMLElement } from '../../models/evt-models'; @Injectable({ providedIn: 'root', @@ -15,5 +15,14 @@ export class BibliographicEntriesParserService { .map((bib) => bibliographicParser.parse(bib)); } + parseBibliographicEntries(xml: XMLElement) { + const biblParser = ParserRegister.get(this.parserName); + + return { + type: BibliographyInfo, + bibliographicEntries: Array.from(xml.querySelectorAll('bibl')).map((s) => biblParser.parse(s)) + .concat(Array.from(xml.querySelectorAll('biblStruct')).map((s) => biblParser.parse(s))), + } + } } diff --git a/src/app/services/xml-parsers/prefatory-matter-parser.service.ts b/src/app/services/xml-parsers/prefatory-matter-parser.service.ts index 39334f5fc..807e6bbef 100644 --- a/src/app/services/xml-parsers/prefatory-matter-parser.service.ts +++ b/src/app/services/xml-parsers/prefatory-matter-parser.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { map, shareReplay } from 'rxjs/operators'; -import { BibliographicDesc, EncodingDesc, FileDesc, ProfileDesc, ProjectInfo, RevisionDesc, XMLElement } from '../../models/evt-models'; +import { EncodingDesc, FileDesc, ProfileDesc, ProjectInfo, RevisionDesc, XMLElement } from '../../models/evt-models'; import { EditionDataService } from '../edition-data.service'; import { queryAndParseElement } from './basic-parsers'; @@ -35,7 +35,6 @@ export class PrefatoryMatterParserService { encodingDesc: queryAndParseElement(source, 'encodingDesc', true), profileDesc: queryAndParseElement(source, 'profileDesc', true), revisionDesc: queryAndParseElement(source, 'revisionDesc', true), - bibliographicDesc: queryAndParseElement(source, 'listBibl', true), }; } } From 6ab9c24dc0ccdf34eea845ca992ae3a1fafb9fb3 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 8 Apr 2024 16:03:30 +0200 Subject: [PATCH 06/28] Add BibliographyInfo component --- src/app/app.module.ts | 2 ++ .../bibliography-info.component.html | 21 ++++++++++++++++ .../bibliography-info.component.scss | 12 +++++++++ .../bibliography-info.component.spec.ts | 25 +++++++++++++++++++ .../bibliography-info.component.ts | 18 +++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 src/app/components/bibliography-info/bibliography-info.component.html create mode 100644 src/app/components/bibliography-info/bibliography-info.component.scss create mode 100644 src/app/components/bibliography-info/bibliography-info.component.spec.ts create mode 100644 src/app/components/bibliography-info/bibliography-info.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d4b635ef6..05ee19885 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -33,6 +33,7 @@ import { ApparatusEntryComponent } from './components/apparatus-entry/apparatus- import { ApparatusEntryDetailComponent } from './components/apparatus-entry/apparatus-entry-detail/apparatus-entry-detail.component'; import { ApparatusEntryReadingsComponent } from './components/apparatus-entry/apparatus-entry-readings/apparatus-entry-readings.component'; import { BiblioEntryComponent } from './components/biblio/biblio.component'; +import { BibliographyInfoComponent } from './components/bibliography-info/bibliography-info.component'; import { BiblioListComponent } from './components/biblioList/biblio-list.component'; import { CharComponent } from './components/char/char.component'; import { ChoiceComponent } from './components/choice/choice.component'; @@ -208,6 +209,7 @@ const DynamicComponents = [ AnnotatorDirective, AppComponent, BiblioEntryComponent, + BibliographyInfoComponent, BiblioListComponent, CollationComponent, ContentViewerComponent, diff --git a/src/app/components/bibliography-info/bibliography-info.component.html b/src/app/components/bibliography-info/bibliography-info.component.html new file mode 100644 index 000000000..9f6d28ad9 --- /dev/null +++ b/src/app/components/bibliography-info/bibliography-info.component.html @@ -0,0 +1,21 @@ + +
+ + + + + + + + +
\ No newline at end of file diff --git a/src/app/components/bibliography-info/bibliography-info.component.scss b/src/app/components/bibliography-info/bibliography-info.component.scss new file mode 100644 index 000000000..f038883d0 --- /dev/null +++ b/src/app/components/bibliography-info/bibliography-info.component.scss @@ -0,0 +1,12 @@ +.bibliography_header { + position: relative; + margin-top: 0; + height: 45px; + max-height: 45px; + text-align: center; +} + +.bibliography_header>div { + display: flex; + align-content: center; +} \ No newline at end of file diff --git a/src/app/components/bibliography-info/bibliography-info.component.spec.ts b/src/app/components/bibliography-info/bibliography-info.component.spec.ts new file mode 100644 index 000000000..7b346c49a --- /dev/null +++ b/src/app/components/bibliography-info/bibliography-info.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BibliographyInfoComponent } from './bibliography-info.component'; + +describe('BibliographyInfoComponent', () => { + let component: BibliographyInfoComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ BibliographyInfoComponent ], + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(BibliographyInfoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/bibliography-info/bibliography-info.component.ts b/src/app/components/bibliography-info/bibliography-info.component.ts new file mode 100644 index 000000000..382889726 --- /dev/null +++ b/src/app/components/bibliography-info/bibliography-info.component.ts @@ -0,0 +1,18 @@ +import { Component, Input } from '@angular/core'; +import { BibliographicEntry, BibliographicStructEntry, BibliographyInfo } from 'src/app/models/evt-models'; +import { register } from 'src/app/services/component-register.service'; + +@Component({ + selector: 'evt-bibliography-info', + templateUrl: './bibliography-info.component.html', + styleUrls: ['./bibliography-info.component.scss'], +}) + +@register(BibliographyInfo) +export class BibliographyInfoComponent { + biblList : Array; + + @Input() set data(bd : BibliographyInfo){ + this.biblList=bd.bibliographicEntries; + }; +} From b9d59434c3c1129372bd7fce36a75676ef26ba22 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 8 Apr 2024 16:03:57 +0200 Subject: [PATCH 07/28] Add BibliographicStyleSelector component --- src/app/app.module.ts | 2 ++ ...ibliographic-style-selector.component.html | 4 +++ ...ibliographic-style-selector.component.scss | 0 ...iographic-style-selector.component.spec.ts | 25 +++++++++++++++++++ .../bibliographic-style-selector.ts | 25 +++++++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html create mode 100644 src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.scss create mode 100644 src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.spec.ts create mode 100644 src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 05ee19885..866e0da95 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -34,6 +34,7 @@ import { ApparatusEntryDetailComponent } from './components/apparatus-entry/appa import { ApparatusEntryReadingsComponent } from './components/apparatus-entry/apparatus-entry-readings/apparatus-entry-readings.component'; import { BiblioEntryComponent } from './components/biblio/biblio.component'; import { BibliographyInfoComponent } from './components/bibliography-info/bibliography-info.component'; +import { BibliographicStyleSelectorComponent } from './components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector'; import { BiblioListComponent } from './components/biblioList/biblio-list.component'; import { CharComponent } from './components/char/char.component'; import { ChoiceComponent } from './components/choice/choice.component'; @@ -210,6 +211,7 @@ const DynamicComponents = [ AppComponent, BiblioEntryComponent, BibliographyInfoComponent, + BibliographicStyleSelectorComponent, BiblioListComponent, CollationComponent, ContentViewerComponent, diff --git a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html new file mode 100644 index 000000000..16e280221 --- /dev/null +++ b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.scss b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.spec.ts b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.spec.ts new file mode 100644 index 000000000..820cc888b --- /dev/null +++ b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; + +import { BibliographicStyleSelectorComponent } from './bibliographic-style-selector'; + +describe('BibliographicStyleSelectorComponent', () => { + let component: BibliographicStyleSelectorComponent; + let fixture: ComponentFixture; + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [ BibliographicStyleSelectorComponent ], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(BibliographicStyleSelectorComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts new file mode 100644 index 000000000..cf8d724cd --- /dev/null +++ b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts @@ -0,0 +1,25 @@ +import { Component, Output } from '@angular/core'; +import { BehaviorSubject, combineLatest, distinctUntilChanged, filter, map, of } from 'rxjs'; +import { AppConfig, BibliographicStyle } from 'src/app/app.config'; + +@Component({ + selector: 'evt-bibliographic-style-selector', + templateUrl: './bibliographic-style-selector.component.html', + styleUrls: ['./bibliographic-style-selector.component.scss'], +}) +export class BibliographicStyleSelectorComponent { + public bibliographicStyles = (Object.values(AppConfig.evtSettings.ui.allowedBibliographicStyles) || []).filter((el) => el.enabled); + private _styleID = AppConfig.evtSettings.ui.defaultBibliographicStyle; + selectedStyle$ = new BehaviorSubject(this._styleID); + + @Output() selectionChange = combineLatest([of(this.bibliographicStyles), + this.selectedStyle$.pipe(distinctUntilChanged()), + ]).pipe( + filter(([styles, styleID]) => !!styleID && !!styles && styles.length > 0), + map(([styles, styleID]) => styles.find((p) => p.id === styleID)), + ) + + stopPropagation(event: MouseEvent) { + event.stopPropagation(); + } +} From d3eefcbb5246b4928f58051eb58d7c9f37cfff82 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 8 Apr 2024 16:05:07 +0200 Subject: [PATCH 08/28] Add StyledBiblioEntry component --- src/app/app.config.ts | 8 ++- src/app/app.module.ts | 2 + .../biblio-styled.component.html | 16 +++++ .../biblio-styled.component.scss | 0 .../biblio-styled.component.spec.ts | 25 ++++++++ .../biblio-styled/biblio-styled.component.ts | 25 ++++++++ src/assets/config/ui_config.json | 60 ++++++++++++++++--- 7 files changed, 128 insertions(+), 8 deletions(-) create mode 100644 src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html create mode 100644 src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss create mode 100644 src/app/components/bibliography-info/biblio-styled/biblio-styled.component.spec.ts create mode 100644 src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 2167bbfc0..2e912b96d 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -97,7 +97,13 @@ export interface UiConfig { [key: string]: { id: BibliographicStyle, label: string, - enabled: boolean + enabled: boolean, + propsOrder: string[], + properties: { + titleQuotes: boolean, + emphasized: string[], + inBrackets: string[] + } } } theme: 'neutral' | 'modern' | 'classic'; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 866e0da95..8d3df944f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -119,6 +119,7 @@ import { SourceNoteComponent } from './components/sources/source-note/source-not import { SourcesComponent } from './components/sources/sources.component'; import { SourcesPanelComponent } from './panels/sources-panel/sources-panel.component'; import { StartsWithPipe } from './pipes/starts-with.pipe'; +import { StyledBiblioEntryComponent } from './components/bibliography-info/biblio-styled/biblio-styled.component'; import { SuppliedComponent } from './components/supplied/supplied.component'; import { SurplusComponent } from './components/surplus/surplus.component'; import { TagsDeclComponent } from './components/tags-decl/tags-decl.component'; @@ -254,6 +255,7 @@ const DynamicComponents = [ SourcesComponent, SourcesPanelComponent, StartsWithPipe, + StyledBiblioEntryComponent, TextPanelComponent, TextSourcesComponent, TextTextComponent, diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html new file mode 100644 index 000000000..48f7cfafc --- /dev/null +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html @@ -0,0 +1,16 @@ + + + + {{element.value}}: + + ( + " + {{ data[element.value] }} " + ), + + + + {{ data.text }} + \ No newline at end of file diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.spec.ts b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.spec.ts new file mode 100644 index 000000000..85bcdfb3b --- /dev/null +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BiblioEntryComponent } from './biblio.component'; + +describe('BiblioComponent', () => { + let component: BiblioEntryComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ BiblioEntryComponent ], + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(BiblioEntryComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts new file mode 100644 index 000000000..8b33134e1 --- /dev/null +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts @@ -0,0 +1,25 @@ +import { Component, Input } from '@angular/core'; +import { AppConfig, BibliographicStyle } from 'src/app/app.config'; +import { BibliographicEntry } from 'src/app/models/evt-models'; + +@Component({ + selector: 'evt-styled-biblio-entry', + templateUrl: './biblio-styled.component.html', + styleUrls: ['./biblio-styled.component.scss'], +}) +export class StyledBiblioEntryComponent { + @Input() data: BibliographicEntry; + @Input() style: BibliographicStyle = 'chicago'; + + public showList = AppConfig.evtSettings.edition.biblView.propsToShow; + public showAttrNames = AppConfig.evtSettings.edition.biblView.showAttrNames; + public showEmptyValues = AppConfig.evtSettings.edition.biblView.showEmptyValues; + public inline = AppConfig.evtSettings.edition.biblView.inline; + public isCommaSeparated = AppConfig.evtSettings.edition.biblView.commaSeparated; + public showMainElemTextContent = AppConfig.evtSettings.edition.biblView.showMainElemTextContent; + + public styleProperties = AppConfig.evtSettings.ui.allowedBibliographicStyles[this.style]?.properties; + + +} + diff --git a/src/assets/config/ui_config.json b/src/assets/config/ui_config.json index 91088df59..5e3264121 100644 --- a/src/assets/config/ui_config.json +++ b/src/assets/config/ui_config.json @@ -77,19 +77,65 @@ "viscollButton": true, "theme": "modern", "syncZonesHighlightButton": true, - "defaultBibliographicStyle": "Chicago", + "defaultBibliographicStyle": "chicago", "allowedBibliographicStyles": { - "Chicago": { + "chicago": { + "id": "chicago", "label": "Chicago", - "enabled": true + "enabled": true, + "propsOrder": [ + "author", + "date", + "title", + "publisher", + "citedRange", + "biblScope", + "pubPlace", + "editor" + ], + "properties": { + "titleQuotes": true, + "empashized": [ + "publisher" + ], + "inBrackets": [ + "citedRange" + ] + } }, - "APA": { + "apa": { + "id": "apa", "label": "APA", - "enabled": false + "enabled": false, + "propsOrder": [ + "author", + "date", + "title", + "publisher", + "citedRange", + "biblScope", + "pubPlace", + "editor" + ], + "properties": { + "titleQuotes": false, + "empashized": [], + "inBrackets": [ + "date" + ] + } }, - "MLA": { + "mla": { + "id": "mla", "label": "MLA", - "enabled": true + "enabled": true, + "properties": { + "titleQuotes": false, + "empashized": [ + "publisher" + ], + "inBrackets": [] + } } } } \ No newline at end of file From 93fb4f59e10d1e5e403f5890c4367d6012f3c602 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Wed, 10 Apr 2024 11:57:08 +0200 Subject: [PATCH 09/28] Implement styling for bibliographic visualization --- .../biblio-styled.component.html | 22 +++++++++-------- .../biblio-styled.component.scss | 3 +++ .../biblio-styled/biblio-styled.component.ts | 16 +++++++++---- ...ibliographic-style-selector.component.html | 12 ++++++++-- .../bibliographic-style-selector.ts | 24 ++++++++++--------- .../bibliography-info.component.html | 16 +++++++------ .../bibliography-info.component.ts | 6 +++++ 7 files changed, 64 insertions(+), 35 deletions(-) diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html index 48f7cfafc..16e60c955 100644 --- a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html @@ -1,14 +1,16 @@ - - - {{element.value}}: - - ( - " - {{ data[element.value] }} " - ), + + + {{element}}: + + + ( + " + {{ data[element] }} + " + ) + , + diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss index e69de29bb..385b7f993 100644 --- a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss @@ -0,0 +1,3 @@ +.font-italic { + font-style: italic; +} \ No newline at end of file diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts index 8b33134e1..67f93f370 100644 --- a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; import { AppConfig, BibliographicStyle } from 'src/app/app.config'; import { BibliographicEntry } from 'src/app/models/evt-models'; @@ -7,18 +7,24 @@ import { BibliographicEntry } from 'src/app/models/evt-models'; templateUrl: './biblio-styled.component.html', styleUrls: ['./biblio-styled.component.scss'], }) -export class StyledBiblioEntryComponent { +export class StyledBiblioEntryComponent implements OnChanges{ @Input() data: BibliographicEntry; - @Input() style: BibliographicStyle = 'chicago'; + @Input() style: BibliographicStyle = AppConfig.evtSettings.ui.defaultBibliographicStyle; - public showList = AppConfig.evtSettings.edition.biblView.propsToShow; + public showList; public showAttrNames = AppConfig.evtSettings.edition.biblView.showAttrNames; public showEmptyValues = AppConfig.evtSettings.edition.biblView.showEmptyValues; public inline = AppConfig.evtSettings.edition.biblView.inline; public isCommaSeparated = AppConfig.evtSettings.edition.biblView.commaSeparated; public showMainElemTextContent = AppConfig.evtSettings.edition.biblView.showMainElemTextContent; + public styleProperties; - public styleProperties = AppConfig.evtSettings.ui.allowedBibliographicStyles[this.style]?.properties; + ngOnChanges(changes: SimpleChanges): void { + if(changes.style){ + this.showList = AppConfig.evtSettings.ui.allowedBibliographicStyles[this.style].propsOrder; + this.styleProperties = AppConfig.evtSettings.ui.allowedBibliographicStyles[this.style].properties; + } + } } diff --git a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html index 16e280221..e0be8681a 100644 --- a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html +++ b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html @@ -1,4 +1,12 @@ - + \ No newline at end of file diff --git a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts index cf8d724cd..f5f1b0610 100644 --- a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts +++ b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts @@ -1,5 +1,4 @@ -import { Component, Output } from '@angular/core'; -import { BehaviorSubject, combineLatest, distinctUntilChanged, filter, map, of } from 'rxjs'; +import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { AppConfig, BibliographicStyle } from 'src/app/app.config'; @Component({ @@ -7,19 +6,22 @@ import { AppConfig, BibliographicStyle } from 'src/app/app.config'; templateUrl: './bibliographic-style-selector.component.html', styleUrls: ['./bibliographic-style-selector.component.scss'], }) -export class BibliographicStyleSelectorComponent { +export class BibliographicStyleSelectorComponent implements OnInit { public bibliographicStyles = (Object.values(AppConfig.evtSettings.ui.allowedBibliographicStyles) || []).filter((el) => el.enabled); - private _styleID = AppConfig.evtSettings.ui.defaultBibliographicStyle; - selectedStyle$ = new BehaviorSubject(this._styleID); + public selectedStyleID : BibliographicStyle; - @Output() selectionChange = combineLatest([of(this.bibliographicStyles), - this.selectedStyle$.pipe(distinctUntilChanged()), - ]).pipe( - filter(([styles, styleID]) => !!styleID && !!styles && styles.length > 0), - map(([styles, styleID]) => styles.find((p) => p.id === styleID)), - ) + @Output() selectionChange: EventEmitter = new EventEmitter(); + + ngOnInit(){ + this.selectedStyleID = AppConfig.evtSettings.ui.defaultBibliographicStyle; + this.selectionChange.emit(this.selectedStyleID); + } stopPropagation(event: MouseEvent) { event.stopPropagation(); } + + changeStyle(){ + this.selectionChange.emit(this.selectedStyleID); + } } diff --git a/src/app/components/bibliography-info/bibliography-info.component.html b/src/app/components/bibliography-info/bibliography-info.component.html index 9f6d28ad9..9c4359efa 100644 --- a/src/app/components/bibliography-info/bibliography-info.component.html +++ b/src/app/components/bibliography-info/bibliography-info.component.html @@ -1,21 +1,23 @@ - +
+ +
- + - +
\ No newline at end of file diff --git a/src/app/components/bibliography-info/bibliography-info.component.ts b/src/app/components/bibliography-info/bibliography-info.component.ts index 382889726..f9ba8e444 100644 --- a/src/app/components/bibliography-info/bibliography-info.component.ts +++ b/src/app/components/bibliography-info/bibliography-info.component.ts @@ -1,4 +1,5 @@ import { Component, Input } from '@angular/core'; +import { BibliographicStyle } from 'src/app/app.config'; import { BibliographicEntry, BibliographicStructEntry, BibliographyInfo } from 'src/app/models/evt-models'; import { register } from 'src/app/services/component-register.service'; @@ -11,8 +12,13 @@ import { register } from 'src/app/services/component-register.service'; @register(BibliographyInfo) export class BibliographyInfoComponent { biblList : Array; + currentStyle : BibliographicStyle; @Input() set data(bd : BibliographyInfo){ this.biblList=bd.bibliographicEntries; }; + + setCurrentStyle(s: BibliographicStyle){ + this.currentStyle = s; + } } From 67e9bfd7c183af6185dd56814d236d1b1779470f Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Fri, 12 Apr 2024 16:08:54 +0200 Subject: [PATCH 10/28] Fix pubPlace typo in bibliography-parser.ts --- src/app/services/xml-parsers/bibliography-parsers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index 8dd144837..2e91b101f 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -58,7 +58,7 @@ export class BibliographyParser extends BasicParser implements Parser Date: Mon, 15 Apr 2024 15:14:29 +0200 Subject: [PATCH 11/28] Change getChildrenTextAndSpecificAttribute to prevent null strings --- src/app/services/xml-parsers/bibliography-parsers.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index 2e91b101f..a73636d3c 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -26,7 +26,10 @@ export class BibliographyParser extends BasicParser implements Parser(name)).map((x) => x.getAttribute(attribute)+' '+this.getTrimmedText(x)); + return Array.from(xml.querySelectorAll(name)).map((x) => + x.getAttribute(attribute) !== null ? + x.getAttribute(attribute)+' '+this.getTrimmedText(x) : + this.getTrimmedText(x)); } protected getQuoteElementText(element: XMLElement): string { From 3ea30188e960e6ef885f7114cf28714ecb1d3759 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 15 Apr 2024 15:18:48 +0200 Subject: [PATCH 12/28] Move space break insertion from bibliography parsing to visualization --- src/app/components/biblio/biblio.component.html | 2 +- src/app/services/xml-parsers/bibliography-parsers.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/components/biblio/biblio.component.html b/src/app/components/biblio/biblio.component.html index 3a28c67ee..9d909764d 100644 --- a/src/app/components/biblio/biblio.component.html +++ b/src/app/components/biblio/biblio.component.html @@ -3,7 +3,7 @@ {{element.value}}: - {{ data[element.value] }} , + {{ data[element.value] }} , 
diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index a73636d3c..cbadf7228 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -13,12 +13,12 @@ export class BibliographyParser extends BasicParser implements Parser(name)).map((x) => ' '+this.getTrimmedText(x)); + protected getChildrenTextByName = function(xml : XMLElement, name : string): string[] { + return Array.from(xml.querySelectorAll(name)).map((x) => this.getTrimmedText(x)); } protected getChildrenByNameOnFirstLevelOnly = function(xml : XMLElement, name : string) { From 77fb499a5757e2a343b07b3244a3aab8d2442a5a Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 15 Apr 2024 15:23:31 +0200 Subject: [PATCH 13/28] Add authorsDetails to BibliographicEntry parsing --- src/app/models/evt-models.ts | 7 +++++++ .../xml-parsers/bibliography-parsers.ts | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/app/models/evt-models.ts b/src/app/models/evt-models.ts index c11024f51..810fcb5bf 100644 --- a/src/app/models/evt-models.ts +++ b/src/app/models/evt-models.ts @@ -201,6 +201,13 @@ export class BibliographicList extends GenericElement { export class BibliographicEntry extends GenericElement { id: string; author: string[]; + authorsDetails: Array<{ + fullName: string, + forename: string, + forenameInitials: string, + surname: string, + nameLink: string, + }>; editor: string[]; title: string[]; date: string[]; diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index cbadf7228..ad84e5729 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -42,6 +42,23 @@ export class BibliographyParser extends BasicParser implements Parser { + const forename = this.getChildrenTextByName(el as XMLElement, 'forename').reduce((prev, f) => prev + prev ? ' ' : '' + f, ''); + const forenameInitials = forename.replace(/\B(\w+)/, '.'); + + return { + fullName: this.getTrimmedText(el), + forename, + forenameInitials, + surname: this.getChildrenTextByName(el as XMLElement, 'surname').reduce((prev, s) => prev + prev ? ' ' : '' + s, ''), + nameLink: this.getChildrenTextByName(el as XMLElement, 'nameLink'), + } + }); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any parse(xml: XMLElement): any { @@ -58,6 +75,7 @@ export class BibliographyParser extends BasicParser implements Parser Date: Mon, 15 Apr 2024 15:24:37 +0200 Subject: [PATCH 14/28] Add articleTitle and edition to BibliographyEntry parsing --- src/app/models/evt-models.ts | 2 ++ .../services/xml-parsers/bibliography-parsers.ts | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/models/evt-models.ts b/src/app/models/evt-models.ts index 810fcb5bf..d68ef2c6a 100644 --- a/src/app/models/evt-models.ts +++ b/src/app/models/evt-models.ts @@ -210,6 +210,8 @@ export class BibliographicEntry extends GenericElement { }>; editor: string[]; title: string[]; + articleTitle: string; + edition: string; date: string[]; publisher: string[]; pubPlace: string[]; diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index ad84e5729..8f2bfde27 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -42,6 +42,17 @@ export class BibliographyParser extends BasicParser implements Parser 0){ + title = titles.shift(); + titles.forEach((el) => { title = title.replace(el, `"${el}"`); }); + } + + return title; + } + protected getAuthorsDetails(element: XMLElement){ const authors = Array.from(element.querySelectorAll('author')); @@ -73,7 +84,9 @@ export class BibliographyParser extends BasicParser implements Parser Date: Mon, 15 Apr 2024 15:29:18 +0200 Subject: [PATCH 15/28] Expand citedRange and biblScope parsing --- .../xml-parsers/bibliography-parsers.ts | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index 8f2bfde27..a70f63058 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -53,6 +53,34 @@ export class BibliographyParser extends BasicParser implements Parser this.getCitingText(el, true)); + } + protected getAuthorsDetails(element: XMLElement){ const authors = Array.from(element.querySelectorAll('author')); @@ -93,8 +121,8 @@ export class BibliographyParser extends BasicParser implements Parser Date: Sun, 28 Apr 2024 12:40:19 +0200 Subject: [PATCH 16/28] Add idno, doi, volumeNumber, pageNumber and issueNumber to BibliographicStyle parsing --- src/app/models/evt-models.ts | 5 ++++ .../xml-parsers/bibliography-parsers.ts | 30 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/app/models/evt-models.ts b/src/app/models/evt-models.ts index d68ef2c6a..187a1a68f 100644 --- a/src/app/models/evt-models.ts +++ b/src/app/models/evt-models.ts @@ -212,10 +212,15 @@ export class BibliographicEntry extends GenericElement { title: string[]; articleTitle: string; edition: string; + idno: string[]; + doi: string; date: string[]; publisher: string[]; pubPlace: string[]; citedRange: string[]; + pageNumber: string; + volumeNumber: string; + issueNumber: string; biblScope: string[]; text: string; quotedText: string; diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index a70f63058..50edd4949 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -81,23 +81,44 @@ export class BibliographyParser extends BasicParser implements Parser this.getCitingText(el, true)); } + + /** + * + * @param element the parent XML element where to search the bibliographic reference scope + * @param pattern a substring to search in \@unit, as it does not have a standard value. + * For example, to get a volume number the best approach would be to search for the "vol" substring. + * @returns the text representation of the bibliographic scope, along with the unit name. + */ + protected getBibliographicReferenceByUnitMatching(element: XMLElement, pattern: string): string{ + const biblScopeElement = element.querySelector('biblScope[unit*="' + pattern + '"]') + const citedRangeElement = element.querySelector('citedRange[unit*="' + pattern + '"'); + if(biblScopeElement || citedRangeElement){ + return biblScopeElement ? this.getCitingText(biblScopeElement, false) : this.getCitingText(citedRangeElement, false); + } + + return ''; + } + protected getAuthorsDetails(element: XMLElement){ const authors = Array.from(element.querySelectorAll('author')); return authors.map((el) => { const forename = this.getChildrenTextByName(el as XMLElement, 'forename').reduce((prev, f) => prev + prev ? ' ' : '' + f, ''); - const forenameInitials = forename.replace(/\B(\w+)/, '.'); return { fullName: this.getTrimmedText(el), forename, - forenameInitials, + forenameInitials: forename.replace(/\B(\w+)/, '.'), surname: this.getChildrenTextByName(el as XMLElement, 'surname').reduce((prev, s) => prev + prev ? ' ' : '' + s, ''), nameLink: this.getChildrenTextByName(el as XMLElement, 'nameLink'), } }); } + protected getIdnoTextByType(element: XMLElement, type: string){ + return element.querySelector('idno[type="' + type + '" i]'); + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any parse(xml: XMLElement): any { @@ -115,6 +136,8 @@ export class BibliographyParser extends BasicParser implements Parser Date: Sun, 28 Apr 2024 14:56:22 +0200 Subject: [PATCH 17/28] Fix modal.component.ts error on path handling --- src/app/ui-components/modal/modal.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/ui-components/modal/modal.component.ts b/src/app/ui-components/modal/modal.component.ts index 544ee6c34..3fb00a1fb 100644 --- a/src/app/ui-components/modal/modal.component.ts +++ b/src/app/ui-components/modal/modal.component.ts @@ -49,7 +49,8 @@ export class ModalComponent implements OnInit { @HostListener('click', ['$event']) clickout(event) { const modal = this.modalDialog.nativeElement; - const internalClick: boolean = event.path.find((o) => o.className && o.className.indexOf && o.className.indexOf(modal.className) >= 0); + const path = event.composedPath ? event.composedPath() : event.path; + const internalClick: boolean = path.find((o) => o.className && o.className.indexOf && o.className.indexOf(modal.className) >= 0); if (this.closeOnShadow && !internalClick) { this.closeDialog(); } From 46f59f5d9a5f64988ed9d61336f8edbb26b7a7c7 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 29 Apr 2024 16:03:46 +0200 Subject: [PATCH 18/28] Refactor parsing methods in bibliography-parsers.ts --- .../services/xml-parsers/bibliography-parsers.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index 50edd4949..0cef49d16 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -108,7 +108,7 @@ export class BibliographyParser extends BasicParser implements Parser prev + prev ? ' ' : '' + s, ''), nameLink: this.getChildrenTextByName(el as XMLElement, 'nameLink'), } @@ -116,7 +116,14 @@ export class BibliographyParser extends BasicParser implements Parser('idno[type="' + type + '" i]'); + const idno = element.querySelector('idno[type="' + type + '" i]'); + + return idno ? this.getTrimmedText(idno) : null; + } + + protected getDate(xml: XMLElement){ + return Array.from(xml.querySelectorAll('date')) + .map((x) => x.getAttribute('when') && !x.textContent ? x.getAttribute('when') : this.getTrimmedText(x)); } // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -141,7 +148,7 @@ export class BibliographyParser extends BasicParser implements Parser Date: Mon, 29 Apr 2024 17:59:49 +0200 Subject: [PATCH 19/28] Rename BibliographicEntry type properties from articleTitle & edition to titleDetails & publication --- src/app/models/evt-models.ts | 7 +++++-- src/app/services/xml-parsers/bibliography-parsers.ts | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/models/evt-models.ts b/src/app/models/evt-models.ts index 187a1a68f..ea8074131 100644 --- a/src/app/models/evt-models.ts +++ b/src/app/models/evt-models.ts @@ -210,8 +210,11 @@ export class BibliographicEntry extends GenericElement { }>; editor: string[]; title: string[]; - articleTitle: string; - edition: string; + titleDetails: { + title: string; + level: string; + }; + publication: string; idno: string[]; doi: string; date: string[]; diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index 0cef49d16..b59cdb9b8 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -141,8 +141,8 @@ export class BibliographyParser extends BasicParser implements Parser Date: Tue, 30 Apr 2024 15:39:50 +0200 Subject: [PATCH 20/28] Change bibliographic styles id type to string to allow additional custom styles --- src/app/app.config.ts | 11 +++++------ .../biblio-styled/biblio-styled.component.ts | 4 ++-- .../bibliographic-style-selector.ts | 6 +++--- .../bibliography-info/bibliography-info.component.ts | 5 ++--- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 2e912b96d..bd39e315a 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -92,13 +92,13 @@ export interface UiConfig { initNavBarOpened: boolean; thumbnailsButton: boolean; viscollButton: boolean; - defaultBibliographicStyle: BibliographicStyle, + defaultBibliographicStyle: string; allowedBibliographicStyles: { [key: string]: { - id: BibliographicStyle, - label: string, - enabled: boolean, - propsOrder: string[], + id: string; + label: string; + enabled: boolean; + propsOrder: string[]; properties: { titleQuotes: boolean, emphasized: string[], @@ -109,7 +109,6 @@ export interface UiConfig { theme: 'neutral' | 'modern' | 'classic'; syncZonesHighlightButton: boolean; } -export type BibliographicStyle = 'chicago' | 'apa' | 'mla' export interface EditionConfig { editionTitle: string; diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts index 67f93f370..9d6d8baff 100644 --- a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts @@ -1,5 +1,5 @@ import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; -import { AppConfig, BibliographicStyle } from 'src/app/app.config'; +import { AppConfig } from 'src/app/app.config'; import { BibliographicEntry } from 'src/app/models/evt-models'; @Component({ @@ -9,7 +9,7 @@ import { BibliographicEntry } from 'src/app/models/evt-models'; }) export class StyledBiblioEntryComponent implements OnChanges{ @Input() data: BibliographicEntry; - @Input() style: BibliographicStyle = AppConfig.evtSettings.ui.defaultBibliographicStyle; + @Input() style: string = AppConfig.evtSettings.ui.defaultBibliographicStyle; public showList; public showAttrNames = AppConfig.evtSettings.edition.biblView.showAttrNames; diff --git a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts index f5f1b0610..722c0d6e6 100644 --- a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts +++ b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.ts @@ -1,5 +1,5 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core'; -import { AppConfig, BibliographicStyle } from 'src/app/app.config'; +import { AppConfig } from 'src/app/app.config'; @Component({ selector: 'evt-bibliographic-style-selector', @@ -8,9 +8,9 @@ import { AppConfig, BibliographicStyle } from 'src/app/app.config'; }) export class BibliographicStyleSelectorComponent implements OnInit { public bibliographicStyles = (Object.values(AppConfig.evtSettings.ui.allowedBibliographicStyles) || []).filter((el) => el.enabled); - public selectedStyleID : BibliographicStyle; + public selectedStyleID : string; - @Output() selectionChange: EventEmitter = new EventEmitter(); + @Output() selectionChange: EventEmitter = new EventEmitter(); ngOnInit(){ this.selectedStyleID = AppConfig.evtSettings.ui.defaultBibliographicStyle; diff --git a/src/app/components/bibliography-info/bibliography-info.component.ts b/src/app/components/bibliography-info/bibliography-info.component.ts index f9ba8e444..3b46b22b4 100644 --- a/src/app/components/bibliography-info/bibliography-info.component.ts +++ b/src/app/components/bibliography-info/bibliography-info.component.ts @@ -1,5 +1,4 @@ import { Component, Input } from '@angular/core'; -import { BibliographicStyle } from 'src/app/app.config'; import { BibliographicEntry, BibliographicStructEntry, BibliographyInfo } from 'src/app/models/evt-models'; import { register } from 'src/app/services/component-register.service'; @@ -12,13 +11,13 @@ import { register } from 'src/app/services/component-register.service'; @register(BibliographyInfo) export class BibliographyInfoComponent { biblList : Array; - currentStyle : BibliographicStyle; + currentStyle : string; @Input() set data(bd : BibliographyInfo){ this.biblList=bd.bibliographicEntries; }; - setCurrentStyle(s: BibliographicStyle){ + setCurrentStyle(s: string){ this.currentStyle = s; } } From 353c277c9451f4f9f04a4aa6ec19cd231cef846d Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Tue, 30 Apr 2024 15:42:46 +0200 Subject: [PATCH 21/28] Add reprintedIn and editedBy labels for bibliographic visualization --- src/assets/i18n/en.json | 4 +++- src/assets/i18n/it.json | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 65b25dce1..69818cfc9 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -193,5 +193,7 @@ "year": "Year", "order": "Order", "asc": "Ascendent", - "desc": "Descendent" + "desc": "Descendent", + "reprintedIn": "Repr. in", + "editedBy": "Edited by" } \ No newline at end of file diff --git a/src/assets/i18n/it.json b/src/assets/i18n/it.json index 79d2868b6..746e62f31 100644 --- a/src/assets/i18n/it.json +++ b/src/assets/i18n/it.json @@ -192,5 +192,7 @@ "year": "Anno", "order": "Ordine", "asc": "Crescente", - "desc": "Decrescente" + "desc": "Decrescente", + "reprintedIn": "Rist. in", + "editedBy": "A cura di" } \ No newline at end of file From 418be258fdf23169698fac1867df5a52403a2f03 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Tue, 30 Apr 2024 15:44:21 +0200 Subject: [PATCH 22/28] Refactor allowedBibliographicStyle in ui_config --- src/app/app.config.ts | 33 +++++++++++++---- src/assets/config/ui_config.json | 63 ++++++++++++++++++++------------ 2 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/app/app.config.ts b/src/app/app.config.ts index bd39e315a..fc4d4e669 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -98,17 +98,34 @@ export interface UiConfig { id: string; label: string; enabled: boolean; - propsOrder: string[]; - properties: { - titleQuotes: boolean, - emphasized: string[], - inBrackets: string[] - } - } - } + propsOrder: BibliographicProperties[]; + properties: BibliographicStyle; + } + }; theme: 'neutral' | 'modern' | 'classic'; syncZonesHighlightButton: boolean; } +export type CitingRanges = 'issue' | 'volume' | 'page'; +export type BibliographicProperties = 'author'| 'date'| 'title'| 'editor' | 'publication' | 'pubPlace' | 'publisher' | 'doi'; +export type BibliographicStyle = Partial<{ + propsDelimiter: string; + authorStyle: Partial<{ + forenameInitials: boolean; + delimiter: string; + lastDelimiter: string; + order: Array<'forename' | 'surname'>; + maxAuthors: string; + }>; + publicationStyle: Partial<{ + citingAcronym: 'all' | 'none' | CitingRanges[]; + includeEditor: boolean; + inBrackets: CitingRanges[]; + }>; + dateInsidePublication: boolean + titleQuotes: boolean; + emphasized: BibliographicProperties[]; + inBrackets: BibliographicProperties[]; +}>; export interface EditionConfig { editionTitle: string; diff --git a/src/assets/config/ui_config.json b/src/assets/config/ui_config.json index 5e3264121..97e6c0a43 100644 --- a/src/assets/config/ui_config.json +++ b/src/assets/config/ui_config.json @@ -81,60 +81,75 @@ "allowedBibliographicStyles": { "chicago": { "id": "chicago", - "label": "Chicago", + "label": "Chicago (Author-Date)", "enabled": true, "propsOrder": [ "author", "date", "title", - "publisher", - "citedRange", - "biblScope", + "editor", + "publication", "pubPlace", - "editor" + "publisher", + "doi" ], "properties": { "titleQuotes": true, - "empashized": [ - "publisher" - ], - "inBrackets": [ - "citedRange" - ] + "emphasized": [ "publisher" ] } }, "apa": { "id": "apa", "label": "APA", - "enabled": false, + "enabled": true, "propsOrder": [ "author", "date", "title", + "publication", "publisher", - "citedRange", - "biblScope", - "pubPlace", - "editor" + "doi" ], "properties": { + "authorStyle": { + "delimiter": ",", + "forenameInitials": true, + "maxAuthors": 3 + }, + "publicationStyle": { + "citingAcronym": "none", + "inBrackets": [ "issue" ] + }, + "propsDelimiter": ".", "titleQuotes": false, - "empashized": [], - "inBrackets": [ - "date" - ] + "emphasized": [ "publication" ], + "inBrackets": [ "date" ] } }, "mla": { "id": "mla", "label": "MLA", "enabled": true, + "propsOrder": [ + "author", + "title", + "publication", + "publisher", + "doi" + ], "properties": { + "propsDelimiter": ".", + "authorStyle": { + "delimiter": "," + }, + "publicationStyle": { + "citingAcronym": "all", + "inBrackets": [ "issue" ], + "includeEditor": true + }, + "dateInsidePublication": true, "titleQuotes": false, - "empashized": [ - "publisher" - ], - "inBrackets": [] + "emphasized": [ "publication" ] } } } From a18a0fe15ff797d64c4508b8ace8bdb58ea1be11 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Tue, 30 Apr 2024 15:46:15 +0200 Subject: [PATCH 23/28] Add BiblStructEntry handling in StyledBiblio component --- .../biblio-styled.component.html | 75 ++++++++++--- .../biblio-styled.component.scss | 4 + .../biblio-styled/biblio-styled.component.ts | 100 ++++++++++++++++-- .../bibliography-info.component.html | 15 +-- 4 files changed, 156 insertions(+), 38 deletions(-) diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html index 16e60c955..fd52d3f34 100644 --- a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.html @@ -1,18 +1,63 @@ - + + + + + + + {{ biblEntry.text }} + + - - {{element}}: - - - ( - " - {{ data[element] }} - " - ) - , - + + + + + + + + (){{styleProperties?.propsDelimiter || ","}} + + + + + +«{{ entries[0]?.titleDetails ? entries[0].titleDetails.title : entries[0].title }}» + + + + + + {{name === "forename" && styleProperties.authorStyle?.forenameInitials ? author.forenameInitials : author[name] }} - + {{ author.fullName }} + {{ index < count - 2 ? (styleProperties.authorStyle?.delimiter || ',') : (styleProperties.authorStyle?.lastDelimiter || " and") }}  + + + + + + {{ monogr.publication }} +  vol. {{monogr.volumeNumber}} + + , , + {{ styleProperties.publicationStyle?.inBrackets && styleProperties.publicationStyle?.inBrackets.includes('issue') ? '(' : ', ' }}no. {{styleProperties?.publicationStyle?.inBrackets && styleProperties.publicationStyle?.inBrackets.includes('issue')? monogr.issueNumber + ')' : monogr.issueNumber }} + () + : pp. {{monogr.pageNumber}} + , {{monogr[property]}}: +  {{ "reprintedIn" | translate }}  + + + + +{{ entries[0].date[0] || 's.d.' }} + +{{ entries[0].publisher }} + +{{ entries[0].pubPlace }} + + + {{ "editedBy" | translate}} {{editor}}, - {{ data.text }} - \ No newline at end of file + + +https://doi.org/{{entry.doi}} \ No newline at end of file diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss index 385b7f993..b6da677de 100644 --- a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.scss @@ -1,3 +1,7 @@ .font-italic { font-style: italic; +} + +.font-normal { + font-style: normal !important; } \ No newline at end of file diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts index 9d6d8baff..876d7c62c 100644 --- a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts @@ -1,31 +1,113 @@ -import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; -import { AppConfig } from 'src/app/app.config'; -import { BibliographicEntry } from 'src/app/models/evt-models'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { AfterViewInit, ChangeDetectorRef, Component, Input, OnChanges, SimpleChanges, TemplateRef, ViewChild } from '@angular/core'; +import { AppConfig, BibliographicStyle, CitingRanges } from 'src/app/app.config'; +import { BibliographicEntry, BibliographicStructEntry } from 'src/app/models/evt-models'; @Component({ selector: 'evt-styled-biblio-entry', templateUrl: './biblio-styled.component.html', styleUrls: ['./biblio-styled.component.scss'], }) -export class StyledBiblioEntryComponent implements OnChanges{ - @Input() data: BibliographicEntry; +export class StyledBiblioEntryComponent implements OnChanges, AfterViewInit { + + @ViewChild('title', { static: false }) title: TemplateRef; + @ViewChild('author', { static: false }) author: TemplateRef; + @ViewChild('publication', { static: false }) publication: TemplateRef; + @ViewChild('editor', { static: false }) editor: TemplateRef; + @ViewChild('date', { static: false }) date: TemplateRef; + @ViewChild('pubPlace', { static: false }) pubPlace: TemplateRef; + @ViewChild('publisher', { static: false }) publisher: TemplateRef; + @ViewChild('doi', { static: false }) doi: TemplateRef; + + + @Input() data: BibliographicEntry | BibliographicStructEntry; @Input() style: string = AppConfig.evtSettings.ui.defaultBibliographicStyle; - public showList; + public biblEntry; + public showList: string[]; public showAttrNames = AppConfig.evtSettings.edition.biblView.showAttrNames; public showEmptyValues = AppConfig.evtSettings.edition.biblView.showEmptyValues; public inline = AppConfig.evtSettings.edition.biblView.inline; public isCommaSeparated = AppConfig.evtSettings.edition.biblView.commaSeparated; public showMainElemTextContent = AppConfig.evtSettings.edition.biblView.showMainElemTextContent; - public styleProperties; + public styleProperties : BibliographicStyle; + + flattenBiblStruct(entry: BibliographicStructEntry): BibliographicEntry[] { + return entry.analytic.concat(entry.monogrs.concat(entry.series)); + } + + getContextForElement(element: string, structEntry: BibliographicStructEntry): BibliographicEntry[]{ + let context; + switch(element){ + case 'title': + context = structEntry.analytic; + break; + case 'publication': + case 'date': + case 'publPlace': + case 'publisher': + case 'editor': + context = structEntry.monogrs; + break; + default: + context = this.flattenBiblStruct(structEntry); + break; + } + + return context; + } + + firstContainsProperty(entries: BibliographicEntry[], element:string){ + const elementInFirstEntry = entries[0]?.[element]; + + return elementInFirstEntry && elementInFirstEntry.length > 0; + } + + containsOnlyEmptyValues(arr: string[]){ + return arr.reduce((prev, x) => (x === '') && prev, true); + } + + requiresAcronym(elem: CitingRanges){ + const publicationStyle = this.styleProperties.publicationStyle || { citingAcronym: 'none' }; + if(!publicationStyle?.citingAcronym) { return false; } + + if(publicationStyle.citingAcronym === 'all'){ + return true; + }else if(publicationStyle.citingAcronym === 'none'){ + return false; + } + + return publicationStyle.citingAcronym.includes(elem); + } + + getPublisherDetailsOrder(){ + return this.showList.filter((x) => x === 'publisher' || x === 'pubPlace'); + } + + getAuthorsDetails(entries: BibliographicEntry[]){ + return entries.reduce((prev, e) => prev.concat(e.authorsDetails), []); + } + + isStructured(entry: BibliographicEntry){ + // searching for the most relevant signs of a structured entry. + return entry.originalEncoding.querySelectorAll('title, author, date').length > 0; + } ngOnChanges(changes: SimpleChanges): void { + if(this.data.type && this.data.type === BibliographicEntry){ + this.biblEntry = this.data as BibliographicEntry; + } + if(this.data.type && this.data.type === BibliographicStructEntry){ + this.biblEntry = this.data as BibliographicStructEntry; + } if(changes.style){ this.showList = AppConfig.evtSettings.ui.allowedBibliographicStyles[this.style].propsOrder; this.styleProperties = AppConfig.evtSettings.ui.allowedBibliographicStyles[this.style].properties; } } - + constructor(private cd: ChangeDetectorRef){} + ngAfterViewInit(): void { + this.cd.detectChanges(); + } } - diff --git a/src/app/components/bibliography-info/bibliography-info.component.html b/src/app/components/bibliography-info/bibliography-info.component.html index 9c4359efa..c57905a49 100644 --- a/src/app/components/bibliography-info/bibliography-info.component.html +++ b/src/app/components/bibliography-info/bibliography-info.component.html @@ -4,20 +4,7 @@
- - - - - - - - - - - - - - +
\ No newline at end of file From 4efd33579a6af2497baaa276e5bb0aa12b144d37 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 20 May 2024 10:47:31 +0200 Subject: [PATCH 24/28] Add return type to functions in biblio-styled.component.ts --- .../biblio-styled/biblio-styled.component.ts | 16 ++++++++-------- src/app/models/evt-models.ts | 15 ++++++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts index 876d7c62c..099e23341 100644 --- a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { AfterViewInit, ChangeDetectorRef, Component, Input, OnChanges, SimpleChanges, TemplateRef, ViewChild } from '@angular/core'; import { AppConfig, BibliographicStyle, CitingRanges } from 'src/app/app.config'; -import { BibliographicEntry, BibliographicStructEntry } from 'src/app/models/evt-models'; +import { AuthorDetail, BibliographicEntry, BibliographicStructEntry } from 'src/app/models/evt-models'; @Component({ selector: 'evt-styled-biblio-entry', @@ -37,7 +37,7 @@ export class StyledBiblioEntryComponent implements OnChanges, AfterViewInit { } getContextForElement(element: string, structEntry: BibliographicStructEntry): BibliographicEntry[]{ - let context; + let context: BibliographicEntry[]; switch(element){ case 'title': context = structEntry.analytic; @@ -57,17 +57,17 @@ export class StyledBiblioEntryComponent implements OnChanges, AfterViewInit { return context; } - firstContainsProperty(entries: BibliographicEntry[], element:string){ + firstContainsProperty(entries: BibliographicEntry[], element:string): boolean{ const elementInFirstEntry = entries[0]?.[element]; return elementInFirstEntry && elementInFirstEntry.length > 0; } - containsOnlyEmptyValues(arr: string[]){ + containsOnlyEmptyValues(arr: string[]): boolean{ return arr.reduce((prev, x) => (x === '') && prev, true); } - requiresAcronym(elem: CitingRanges){ + requiresAcronym(elem: CitingRanges): boolean{ const publicationStyle = this.styleProperties.publicationStyle || { citingAcronym: 'none' }; if(!publicationStyle?.citingAcronym) { return false; } @@ -80,15 +80,15 @@ export class StyledBiblioEntryComponent implements OnChanges, AfterViewInit { return publicationStyle.citingAcronym.includes(elem); } - getPublisherDetailsOrder(){ + getPublisherDetailsOrder(): string[]{ return this.showList.filter((x) => x === 'publisher' || x === 'pubPlace'); } - getAuthorsDetails(entries: BibliographicEntry[]){ + getAuthorsDetails(entries: BibliographicEntry[]): AuthorDetail[]{ return entries.reduce((prev, e) => prev.concat(e.authorsDetails), []); } - isStructured(entry: BibliographicEntry){ + isStructured(entry: BibliographicEntry): boolean{ // searching for the most relevant signs of a structured entry. return entry.originalEncoding.querySelectorAll('title, author, date').length > 0; } diff --git a/src/app/models/evt-models.ts b/src/app/models/evt-models.ts index ea8074131..f2e74f701 100644 --- a/src/app/models/evt-models.ts +++ b/src/app/models/evt-models.ts @@ -198,16 +198,17 @@ export class BibliographicList extends GenericElement { sources: BibliographicEntry[]; } +export interface AuthorDetail { + fullName: string; + forename: string; + forenameInitials: string; + surname: string; + nameLink: string[]; +} export class BibliographicEntry extends GenericElement { id: string; author: string[]; - authorsDetails: Array<{ - fullName: string, - forename: string, - forenameInitials: string, - surname: string, - nameLink: string, - }>; + authorsDetails: AuthorDetail[]; editor: string[]; title: string[]; titleDetails: { From f082bb47a36b3259b7504ee36ba99c2af2898406 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Mon, 20 May 2024 11:00:54 +0200 Subject: [PATCH 25/28] Add return functions type for bibliography-parser.ts --- .../services/xml-parsers/bibliography-parsers.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index b59cdb9b8..cdbb59a12 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -1,6 +1,7 @@ import { normalizeSpaces } from 'src/app/utils/xml-utils'; import { parse, xmlParser } from '.'; -import { BibliographicEntry, BibliographicList, BibliographicStructEntry, BibliographyClass, XMLElement } from '../../models/evt-models'; +// eslint-disable-next-line max-len +import { AuthorDetail, BibliographicEntry, BibliographicList, BibliographicStructEntry, BibliographyClass, XMLElement } from '../../models/evt-models'; import { AttributeParser, GenericElemParser } from './basic-parsers'; import { createParser, getID, parseChildren, Parser } from './parser-models'; import { BasicParser } from './quotes-parser'; @@ -25,7 +26,7 @@ export class BibliographyParser extends BasicParser implements Parser(':scope > '+name)).map((x) => this.getTrimmedText(x)); } - protected getChildrenTextAndSpecificAttribute = function(xml: XMLElement, name: string, attribute: string) { + protected getChildrenTextAndSpecificAttribute = function(xml: XMLElement, name: string, attribute: string): string[] { return Array.from(xml.querySelectorAll(name)).map((x) => x.getAttribute(attribute) !== null ? x.getAttribute(attribute)+' '+this.getTrimmedText(x) : @@ -53,7 +54,7 @@ export class BibliographyParser extends BasicParser implements Parser { @@ -115,13 +116,13 @@ export class BibliographyParser extends BasicParser implements Parser('idno[type="' + type + '" i]'); return idno ? this.getTrimmedText(idno) : null; } - protected getDate(xml: XMLElement){ + protected getDate(xml: XMLElement): string[]{ return Array.from(xml.querySelectorAll('date')) .map((x) => x.getAttribute('when') && !x.textContent ? x.getAttribute('when') : this.getTrimmedText(x)); } From 437d6fd1608cfe1d2f6bc966e159ce71e2adc46f Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Fri, 21 Jun 2024 16:22:55 +0200 Subject: [PATCH 26/28] Add type annotations to bibliography visualization variables --- .../bibliography-info/biblio-styled/biblio-styled.component.ts | 2 +- src/app/services/xml-parsers/bibliography-parsers.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts index 099e23341..99ce5dcd5 100644 --- a/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts +++ b/src/app/components/bibliography-info/biblio-styled/biblio-styled.component.ts @@ -23,7 +23,7 @@ export class StyledBiblioEntryComponent implements OnChanges, AfterViewInit { @Input() data: BibliographicEntry | BibliographicStructEntry; @Input() style: string = AppConfig.evtSettings.ui.defaultBibliographicStyle; - public biblEntry; + public biblEntry: any; public showList: string[]; public showAttrNames = AppConfig.evtSettings.edition.biblView.showAttrNames; public showEmptyValues = AppConfig.evtSettings.edition.biblView.showEmptyValues; diff --git a/src/app/services/xml-parsers/bibliography-parsers.ts b/src/app/services/xml-parsers/bibliography-parsers.ts index cdbb59a12..b7cb5bbeb 100644 --- a/src/app/services/xml-parsers/bibliography-parsers.ts +++ b/src/app/services/xml-parsers/bibliography-parsers.ts @@ -14,7 +14,7 @@ export class BibliographyParser extends BasicParser implements Parser Date: Fri, 21 Jun 2024 16:23:21 +0200 Subject: [PATCH 27/28] Style bibliographic style selector --- ...ibliographic-style-selector.component.html | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html index e0be8681a..d68940e51 100644 --- a/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html +++ b/src/app/components/bibliography-info/bibliographic-style-selector/bibliographic-style-selector.component.html @@ -1,12 +1,19 @@ - - - \ No newline at end of file +
+
+ +
+ + +
+
+
\ No newline at end of file From d70e2cd3a2077bfca784296f9639101d7e1dd175 Mon Sep 17 00:00:00 2001 From: Lorenzo Bafunno Date: Thu, 27 Jun 2024 11:32:33 +0200 Subject: [PATCH 28/28] Lint code --- src/app/app.config.ts | 2 +- src/app/components/sources/source-note/source-note.component.ts | 2 +- src/app/services/xml-parsers/analogue-parser.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/app.config.ts b/src/app/app.config.ts index fc4d4e669..f8f4b8cd9 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -121,7 +121,7 @@ export type BibliographicStyle = Partial<{ includeEditor: boolean; inBrackets: CitingRanges[]; }>; - dateInsidePublication: boolean + dateInsidePublication: boolean; titleQuotes: boolean; emphasized: BibliographicProperties[]; inBrackets: BibliographicProperties[]; diff --git a/src/app/components/sources/source-note/source-note.component.ts b/src/app/components/sources/source-note/source-note.component.ts index d53dfda40..559d1b07e 100644 --- a/src/app/components/sources/source-note/source-note.component.ts +++ b/src/app/components/sources/source-note/source-note.component.ts @@ -18,7 +18,7 @@ export class SourceNoteComponent implements OnInit { createNote(v, type): Note { const item = v[type]; - let content = item.extSources || []; + const content = item.extSources || []; if (type === 'analogue') { content.push( item.extLinkedElements ); content.push( item.sources ); diff --git a/src/app/services/xml-parsers/analogue-parser.ts b/src/app/services/xml-parsers/analogue-parser.ts index c70357792..edacff601 100644 --- a/src/app/services/xml-parsers/analogue-parser.ts +++ b/src/app/services/xml-parsers/analogue-parser.ts @@ -123,7 +123,7 @@ export class AnalogueParser extends BasicParser implements Parser { } private getQuotedTextFromElements(sources: BibliographicEntry[], elements: XMLElement[]): [{id: string, quote: string}] { - let quotesInSources = this.getQuotedTextFromSources(sources); + const quotesInSources = this.getQuotedTextFromSources(sources); const notDisplayedInText = ['Note','BibliographicList','BibliographicEntry','BibliographicStructEntry','Analogue','MsDesc']; elements.forEach((el: XMLElement) => { if (!notDisplayedInText.includes(el['type'])) { quotesInSources.push( { id: el.id, quote: el })} });