Skip to content

Commit

Permalink
Merge pull request evt-project#99 from evt-project/feature/incurable-…
Browse files Browse the repository at this point in the history
…corruptions

Feature/incurable corruptions
  • Loading branch information
giuliac89 authored Nov 26, 2020
2 parents 5323387 + d6fa692 commit a11a563
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated to Angular 9

### Added
- Incurable corruptions visualization
- Verses/Prose toggler
- Addition vizualization
- Known and unknown gaps. Support for "char", "line" and "word" as unit
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { PageSelectorComponent } from './components/page-selector/page-selector.
import { PageComponent } from './components/page/page.component';
import { ParagraphComponent } from './components/paragraph/paragraph.component';
import { ReadingComponent } from './components/reading/reading.component';
import { SicComponent } from './components/sic/sic.component';
import { SuppliedComponent } from './components/supplied/supplied.component';
import { SurplusComponent } from './components/surplus/surplus.component';
import { TextComponent } from './components/text/text.component';
Expand Down Expand Up @@ -134,6 +135,7 @@ export function initializeApp(appConfig: AppConfig) {
ReadingComponent,
ReadingTextComponent,
ShortcutsComponent,
SicComponent,
SourcesPanelComponent,
StartsWithPipe,
SuppliedComponent,
Expand Down
4 changes: 4 additions & 0 deletions src/app/components/sic/sic.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<span class="{{data.class}}" [evtHighlight]="highlightData" [evtEditorialConventionLayout]="editorialConventionData">
<evt-content-viewer *ngFor="let element of data.content" [content]="element" [editionLevel]="editionLevel"
[itemsToHighlight]="itemsToHighlight"></evt-content-viewer>
</span>
Empty file.
25 changes: 25 additions & 0 deletions src/app/components/sic/sic.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { SicComponent } from './sic.component';

describe('SicComponent', () => {
let component: SicComponent;
let fixture: ComponentFixture<SicComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SicComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(SicComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
36 changes: 36 additions & 0 deletions src/app/components/sic/sic.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Component, Input } from '@angular/core';
import { EditorialConventionDefaults } from 'src/app/services/editorial-conventions.service';

import { EditorialConventionLayoutData } from '../../directives/editorial-convention-layout.directive';
import { Sic } from '../../models/evt-models';
import { register } from '../../services/component-register.service';
import { EditionlevelSusceptible, Highlightable } from '../components-mixins';

export interface SicComponent extends EditionlevelSusceptible, Highlightable { }

@Component({
selector: 'evt-sic',
templateUrl: './sic.component.html',
styleUrls: ['./sic.component.scss'],
})
@register(Sic)
export class SicComponent {

@Input() data: Sic;

get editorialConventionData(): EditorialConventionLayoutData {
return {
name: 'sic',
attributes: this.data?.attributes || {},
editionLevel: this.editionLevel,
defaultsKey: this.defaultsKey,
};
}

get defaultsKey(): EditorialConventionDefaults {
switch (this.data.sicType) {
case 'crux':
return 'sicCrux';
}
}
}
4 changes: 2 additions & 2 deletions src/app/directives/editorial-convention-layout.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ export class EditorialConventionLayoutDirective implements OnInit, OnChanges {
if (editionLayout.pre) {
const preEl = document.createElement('span');
preEl.classList.add('pre');
preEl.textContent = editionLayout.pre;
preEl.innerHTML = editionLayout.pre;
this.el.nativeElement.prepend(preEl);
}

if (editionLayout.post) {
const postEl = document.createElement('span');
postEl.classList.add('post');
postEl.textContent = editionLayout.post;
postEl.innerHTML = editionLayout.post;
this.renderer.appendChild(this.el.nativeElement, postEl);
}

Expand Down
5 changes: 5 additions & 0 deletions src/app/models/evt-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,8 @@ export type PlacementType = 'above' | 'below' | 'inline' | 'left' | 'right'
export class Addition extends GenericElement {
place: PlacementType;
}

export type SicType = 'crux'; // sic types supported in specific ways
export class Sic extends GenericElement {
sicType?: SicType | string;
}
16 changes: 15 additions & 1 deletion src/app/services/editorial-conventions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EditorialConvention, EditorialConventionLayouts } from '../models/evt-m

// List of handled editorial convention
export type EditorialConventionDefaults = 'addition' | 'additionAbove' | 'additionBelow' | 'additionInline' | 'additionLeft' | 'additionRight' |
'damage' | 'surplus';
'damage' | 'sicCrux' | 'surplus';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -90,6 +90,20 @@ export class EditorialConventionsService {
},
},
},
sicCrux: {
diplomatic: {
pre: '&dagger;',
post: '&dagger;',
},
interpretative: {
pre: '&dagger;',
post: '&dagger;',
},
critical: {
pre: '&dagger;',
post: '&dagger;',
},
},
surplus: {
diplomatic: {
pre: '{',
Expand Down
18 changes: 17 additions & 1 deletion src/app/services/xml-parsers/editorial-parsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Surplus, XMLElement } from '../../models/evt-models';
import { Sic, Surplus, XMLElement } from '../../models/evt-models';
import { AttributeParser, EmptyParser } from './basic-parsers';
import { createParser, getClass, parseChildren, Parser } from './parser-models';

Expand All @@ -17,3 +17,19 @@ export class SurplusParser extends EmptyParser implements Parser<XMLElement> {
};
}
}

export class SicParser extends EmptyParser implements Parser<XMLElement> {
attributeParser = createParser(AttributeParser, this.genericParse);
parse(xml: XMLElement): Sic {
const attributes = this.attributeParser.parse(xml);
const { type } = attributes;

return {
type: Sic,
sicType: type || '',
class: getClass(xml),
content: parseChildren(xml, this.genericParse),
attributes,
};
}
}
5 changes: 3 additions & 2 deletions src/app/services/xml-parsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from './basic-parsers';
import { CharParser, GlyphParser, GParser } from './character-declarations-parser';
import { ChoiceParser } from './choice-parser';
import { SurplusParser } from './editorial-parsers';
import { SicParser, SurplusParser } from './editorial-parsers';
import { GraphicParser, SurfaceParser, ZoneParser } from './facsimile-parser';
import {
NamedEntityRefParser, OrganizationParser,
Expand All @@ -15,7 +15,7 @@ import {
import { createParser, Parser, ParseResult } from './parser-models';

type SupportedTagNames = 'add' | 'app' | 'char' | 'choice' | 'damage' | 'event' | 'g' | 'gap' | 'geogname' | 'glyph' | 'graphic' | 'l' | 'lb' |
'lem' | 'note' | 'orgname' | 'p' | 'persname' | 'placename' | 'ptr' | 'person' | 'personGrp' | 'place' | 'org' | 'rdg' | 'surface' |
'lem' | 'note' | 'orgname' | 'p' | 'persname' | 'placename' | 'ptr' | 'person' | 'personGrp' | 'place' | 'org' | 'rdg' | 'sic' | 'surface' |
'supplied' | 'surplus' | 'zone';

export const parseF: { [T in SupportedTagNames]: Parser<XMLElement> } = {
Expand Down Expand Up @@ -45,6 +45,7 @@ export const parseF: { [T in SupportedTagNames]: Parser<XMLElement> } = {
place: createParser(PlaceParser, parse),
rdg: createParser(RdgParser, parse),
// event: createParser(EventParser), // TODO: check event parser
sic: createParser(SicParser, parse),
surface: createParser(SurfaceParser, parse),
supplied: createParser(SuppliedParser, parse),
surplus: createParser(SurplusParser, parse),
Expand Down

0 comments on commit a11a563

Please sign in to comment.