diff --git a/ogc/bblocks/postprocess.py b/ogc/bblocks/postprocess.py
index 64e7e38..3c961a8 100644
--- a/ogc/bblocks/postprocess.py
+++ b/ogc/bblocks/postprocess.py
@@ -321,7 +321,9 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
print(f"Writing full validation report to {test_outputs_path / 'report.html'}", file=sys.stderr)
if base_url:
full_validation_report_url = f"{base_url}{os.path.relpath(Path(test_outputs_path).resolve(), cwd)}/report.html"
- report_to_html(json_reports=validation_reports, report_fn=test_outputs_path / 'report.html')
+ report_to_html(json_reports=validation_reports,
+ report_fn=test_outputs_path / 'report.html',
+ base_url=base_url)
if output_file and (not steps or 'register' in steps):
diff --git a/ogc/bblocks/validate.py b/ogc/bblocks/validate.py
index 33283ce..91988d4 100644
--- a/ogc/bblocks/validate.py
+++ b/ogc/bblocks/validate.py
@@ -22,7 +22,6 @@
from mako import exceptions as mako_exceptions, template as mako_template
import requests
from jsonschema.validators import validator_for
-from ogc.na.annotate_schema import SchemaResolver
from ogc.na.util import load_yaml, is_url, copy_triples
from pyparsing import ParseBaseException
from rdflib import Graph
@@ -175,7 +174,7 @@ def report_to_dict(bblock: BuildingBlock,
if item.source.filename:
source['filename'] = str(os.path.relpath(item.source.filename, cwd))
if base_url:
- source['filename'] = urljoin(base_url, source['filename'])
+ source['url'] = urljoin(base_url, source['filename'])
if item.source.example_index:
source['exampleIndex'] = item.source.example_index
if item.source.snippet_index:
@@ -236,6 +235,7 @@ def report_to_dict(bblock: BuildingBlock,
def report_to_html(json_reports: list[dict],
+ base_url: str | None = None,
report_fn: Path | None = None) -> str | None:
pass_count = sum(r['result'] for r in json_reports)
@@ -246,7 +246,7 @@ def report_to_html(json_reports: list[dict],
}
template = mako_template.Template(filename=str(Path(__file__).parent / 'validation/report.html.mako'))
try:
- result = template.render(reports=json_reports, counts=counts)
+ result = template.render(reports=json_reports, counts=counts, report_fn=report_fn, base_url=base_url)
except:
raise ValueError(mako_exceptions.text_error_template().render())
diff --git a/ogc/bblocks/validation/report.html.mako b/ogc/bblocks/validation/report.html.mako
index 56983e1..61abad4 100644
--- a/ogc/bblocks/validation/report.html.mako
+++ b/ogc/bblocks/validation/report.html.mako
@@ -2,7 +2,7 @@
from html import escape as e
from datetime import datetime, timezone
from urllib.parse import urlparse, urljoin
-from os.path import basename
+from os.path import basename, relpath
from pathlib import Path
from ogc.na.util import is_url
import re
@@ -16,6 +16,18 @@ def get_uid():
last_uid = f"uid-{globals()['uid']}"
return last_uid
get_filename = lambda s: basename(urlparse(s).path)
+%>
+<%
+def get_source_url(source):
+ if source.get('sourceUrl'):
+ return source['sourceUrl']
+ source_fn = source['filename']
+ if is_url(source_fn) or not report_fn:
+ return source_fn
+ if report_fn:
+ return os.path.relpath(source_fn, report_fn.resolve().parent)
+ return source.get('url', source_fn)
+
%>
@@ -114,7 +126,7 @@ get_filename = lambda s: basename(urlparse(s).path)
Details
- ${e(re.sub(r'.*/', '', item['source']['filename']))}
+ ${e(re.sub(r'.*/', '', item['source']['filename']))}
${e(item['source']['type'].replace('_', ' ').capitalize())}
% if item['source']['requireFail']:
Requires fail