Skip to content

Commit ce92bf7

Browse files
committed
feat: automate some customizations related to printing, prefixes
These customizations were previously applied manually in the differ, see for e.g. meaningfy-ws/rdf-differ-ws#100. They add proper printing functionality and a table of namespace and prefix mappings. Automating this saves the headache of reapplying them following the patching approach.
1 parent a267d26 commit ce92bf7

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

dqgen/resources/html_templates/main.jinja2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@
3232
{% endfor %}
3333
{% endfor %}
3434
{% raw %}
35+
<h1>Prefixes</h1>
36+
<section class="ui basic segment">
37+
{{ mc.render_namespaces(namespaces.namespaces_as_dict()) }}
38+
</section>
3539
{% endblock %}
3640
{% endraw %}

dqgen/resources/html_templates/static/layout.html

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@
4848
margin: revert !important;
4949
}
5050

51+
#printButton{
52+
float: right;
53+
margin-top: 0.5em;
54+
}
5155

5256
@media print {
5357
#toc {
5458
visibility: hidden;
5559
}
5660

5761
#print-container {
58-
width: 90% !important;
62+
width: 100% !important;
5963
position: absolute;
6064
left: 0;
6165
top: 0;
@@ -64,6 +68,13 @@
6468
footer {
6569
display: none;
6670
}
71+
#printButton {
72+
visibility: hidden;
73+
}
74+
.dataTables_length, .dataTables_filter, .dt-buttons {
75+
visibility: hidden !important;
76+
}
77+
@page {size: landscape !important}
6778
}
6879

6980
</style>
@@ -74,7 +85,9 @@
7485
<div class="three wide column">
7586
<div id="toc"></div>
7687
</div>
88+
7789
<div id="print-container" class="ten wide column">
90+
<button class="ui button" id="printButton">Print report</button>
7891
<h1 class="ui header center aligned reportTitle" id="skip-toc">{{ conf.title }}</h1>
7992
{% block content %}
8093
< empty >
@@ -131,7 +144,7 @@ <h1 class="ui header center aligned reportTitle" id="skip-toc">{{ conf.title }}<
131144
$(this).next().remove()
132145
$(this).remove();
133146
});
134-
$("#print-container").append("<p><strong>Datasets are identical and no differences were found</strong></p>")
147+
$("#print-container").append("<p><strong>Datasets are identical and no difference was found</strong></p>")
135148
}
136149

137150
$(function () {
@@ -145,6 +158,13 @@ <h1 class="ui header center aligned reportTitle" id="skip-toc">{{ conf.title }}<
145158
});
146159
});
147160

161+
$(function () {
162+
$("#printButton").click(function () {
163+
$("table.display").DataTable().page.len(-1).draw()
164+
window.print()
165+
})
166+
})
167+
148168

149169
});
150170

dqgen/resources/html_templates/static/macros.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
{% macro pandas_table(df, caption, column_labels={}) -%}
2929
{% if (df is defined) and (df is not none) %}
30+
{% set df = df.fillna(value="") %}
3031
<table class="display">
3132
<thead class="center aligned">
3233
<tr>
@@ -69,4 +70,24 @@
6970
{% endfor %}
7071

7172
{% endfor %}
73+
{% endmacro %}
74+
75+
{% macro render_namespaces(namesapces_dist) %}
76+
<table class="display">
77+
<thead class="center aligned">
78+
<tr>
79+
<th>Namespace</th>
80+
<th>URI</th>
81+
</tr>
82+
</thead>
83+
<tbody>
84+
{% for prefix, uri in namesapces_dist|dictsort %}
85+
<tr>
86+
<td>{{ prefix }}</td>
87+
<td>{{ uri }}</td>
88+
</tr>
89+
{% endfor %}
90+
</tbody>
91+
<caption>Prefixes</caption>
92+
</table>
7293
{% endmacro %}

0 commit comments

Comments
 (0)