Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the replaceBaseURI method to form fragment identifiers instead of the vocabularyLabel #75

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/oslo-generator-html/lib/HtmlGenerationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class HtmlGenerationService implements IService {
public constructor(
@inject(ServiceIdentifier.Logger) logger: Logger,
@inject(ServiceIdentifier.Configuration)
config: HtmlGenerationServiceConfiguration
config: HtmlGenerationServiceConfiguration,
) {
this.logger = logger;
this.configuration = config;
Expand All @@ -38,6 +38,7 @@ export class HtmlGenerationService implements IService {
}

const env = nj.configure(this.dirs);
env.addFilter('replaceBaseURI', this.replaceBaseURI);
env.addGlobal('getAnchorTag', this.getAnchorTag);
}

Expand All @@ -61,6 +62,7 @@ export class HtmlGenerationService implements IService {
let data: any = {};

const {
baseURI,
entities,
inPackageClasses,
inPackageDataTypes,
Expand All @@ -72,6 +74,7 @@ export class HtmlGenerationService implements IService {

data = {
...data,
baseURI,
entities,
inPackageMerged,
inPackageClasses,
Expand Down Expand Up @@ -104,6 +107,10 @@ export class HtmlGenerationService implements IService {
return domain;
};

private replaceBaseURI = (input: string, baseURI: string): string => {
return input.replace(new RegExp(baseURI, 'g'), '');
};

private async readConfigFile(file: string): Promise<any> {
try {
const buffer: Buffer = await fetchFileOrUrl(file);
Expand Down
14 changes: 7 additions & 7 deletions packages/oslo-generator-html/lib/templates/voc2.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="{{ language }}" lang="{{ language }}" dir="ltr" typeof="bibo:Document " about="" property="dcterms:language" content="{{ language }}" prefix="dcterms: http://purl.org/dc/terms/ bibo: http://purl.org/ontology/bibo/ schema: http://schema.org/ w3p:
http://www.w3.org/2001/02pd/rec54#" xmlns="http://www.w3.org/1999/xhtml">
http://www.w3.org/2001/02pd/rec54#" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{{ data.metadata.title }}</title>
<meta charset='utf-8'/>
Expand Down Expand Up @@ -301,7 +301,7 @@
<p>
|
{% for class in data.inPackageMerged %}
<a href="#{{ class.vocabularyLabel[language] }}" rel="class">{{ class.vocabularyLabel[language] }}</a>
<a href="#{{ class.id | replaceBaseURI(data.baseURI) }}" rel="class">{{ class.vocabularyLabel[language] }}</a>
|
{% endfor %}
</p>
Expand All @@ -315,7 +315,7 @@
<p>
|
{% for prop in data.inPackageProperties %}
<a href="#{{ prop.vocabularyLabel[language] }}" rel="property">{{ prop.vocabularyLabel[language] }}</a>
<a href="#{{ prop.id | replaceBaseURI(data.baseURI) }}" rel="property">{{ prop.vocabularyLabel[language] }}</a>
|
{% endfor %}
</p>
Expand All @@ -329,7 +329,7 @@
<p>
|
{% for prop in data.externalProperties %}
<a href="#{{ prop.vocabularyLabel[language] }}" rel="property">{{ prop.vocabularyLabel[language] }}</a>
<a href="#{{ prop.id | replaceBaseURI(data.baseURI) }}" rel="property">{{ prop.vocabularyLabel[language] }}</a>
|
{% endfor %}
</p>
Expand All @@ -349,7 +349,7 @@
</div>
{% for class in data.inPackageMerged %}
<div class="region region--no-space-top">
<h3 class="h3" id="{{ class.vocabularyLabel[language] }}">Klasse
<h3 class="h3" id="{{ class.id | replaceBaseURI(data.baseURI) }}">Klasse
<em>{{ class.vocabularyLabel[language] }}</em>
</h3>
<table class="definition">
Expand Down Expand Up @@ -427,7 +427,7 @@
</div>
{% for property in data.inPackageProperties %}
<div class="region region--no-space-top">
<h3 class="h3" id="{{ property.vocabularyLabel[language] }}">Eigenschap
<h3 class="h3" id="{{ property.id | replaceBaseURI(data.baseURI) }}">Eigenschap
<em>{{ property.vocabularyLabel[language] }}</em>
</h3>
<table class="definition">
Expand Down Expand Up @@ -533,7 +533,7 @@
</tr>
{% for external in data.externalProperties %}
<tr>
<td id="{{ external.vocabularyLabel[language] }}">
<td id="{{ external.id | replaceBaseURI(data.baseURI) }}">
<strong>
<a href="{{ external.id }}" data-toggle="tooltip" data-content="{{ external.id }}">{{ external.vocabularyLabel[language] }}</a>
</strong>
Expand Down
2 changes: 1 addition & 1 deletion packages/oslo-generator-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oslo-flanders/html-generator",
"version": "0.0.21-alpha.0",
"version": "0.0.22-alpha.0",
"description": "Generates an HTML file using an OSLO webuniversum config",
"author": "Digitaal Vlaanderen <https://data.vlaanderen.be/id/organisatie/OVO002949>",
"homepage": "https://github.com/informatievlaanderen/OSLO-UML-Transformer/tree/main/packages/oslo-generator-html#readme",
Expand Down
Loading