mirror of https://github.com/tdwg/dwc.git
commit
1f5d351a55
|
@ -5,13 +5,14 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import io
|
import io
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import csv
|
import csv
|
||||||
import sys
|
import sys
|
||||||
import codecs
|
import codecs
|
||||||
|
|
||||||
from urllib import request
|
from urllib import request
|
||||||
from Cheetah.Template import Template
|
from jinja2 import FileSystemLoader, Environment
|
||||||
|
|
||||||
NAMESPACES = {
|
NAMESPACES = {
|
||||||
'http://rs.tdwg.org/dwc/iri/' : 'dwciri',
|
'http://rs.tdwg.org/dwc/iri/' : 'dwciri',
|
||||||
|
@ -244,7 +245,7 @@ class DwcDigester(object):
|
||||||
Parameters
|
Parameters
|
||||||
-----------
|
-----------
|
||||||
html_template : str
|
html_template : str
|
||||||
relative path and filename to the [Cheetah3](http://cheetahtemplate.org/) compatible
|
relative path and filename to the Jinja2 compatible
|
||||||
template
|
template
|
||||||
html_output : str
|
html_output : str
|
||||||
relative path and filename to write the resulting index.html
|
relative path and filename to write the resulting index.html
|
||||||
|
@ -252,7 +253,10 @@ class DwcDigester(object):
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
data["class_groups"] = self.template_data
|
data["class_groups"] = self.template_data
|
||||||
html = Template(file=html_template, searchList=[data])
|
|
||||||
|
env = Environment(loader = FileSystemLoader(os.path.dirname(html_template)))
|
||||||
|
template = env.get_template(os.path.basename(html_template))
|
||||||
|
html = template.render(data)
|
||||||
|
|
||||||
index_page = open(html_output, "w")
|
index_page = open(html_output, "w")
|
||||||
index_page.write(str(html))
|
index_page.write(str(html))
|
||||||
|
|
|
@ -47,11 +47,11 @@
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<nav id="sidebar" class="mb-4">
|
<nav id="sidebar" class="mb-4">
|
||||||
<ul class="nav flex-md-column nav-pills">
|
<ul class="nav flex-md-column nav-pills">
|
||||||
#for $class_group in $class_groups
|
{% for class_group in class_groups %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link py-1" href="#$class_group.label">$class_group.label</a><!-- anchor to class_group -->
|
<a class="nav-link py-1" href="#{{ class_group.label }}">{{ class_group.label }}</a><!-- anchor to class_group -->
|
||||||
</li>
|
</li>
|
||||||
#end for
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,40 +60,40 @@
|
||||||
<h1>Darwin Core quick reference guide</h1>
|
<h1>Darwin Core quick reference guide</h1>
|
||||||
<p class="lead">This page provides a list of all currently recommended terms of the Darwin Core standard. Categories such as <code>Occurrence</code>, <code>Event</code> correspond to Darwin Core classes, which group other terms. Convenient <a href="https://github.com/tdwg/dwc/tree/master/dist"> files of these terms</a> and <a href="https://github.com/tdwg/dwc/blob/master/vocabulary/term_versions.csv"> their full history</a> can be found in the <a href="https://github.com/tdwg/dwc">Darwin Core repository</a>.</p>
|
<p class="lead">This page provides a list of all currently recommended terms of the Darwin Core standard. Categories such as <code>Occurrence</code>, <code>Event</code> correspond to Darwin Core classes, which group other terms. Convenient <a href="https://github.com/tdwg/dwc/tree/master/dist"> files of these terms</a> and <a href="https://github.com/tdwg/dwc/blob/master/vocabulary/term_versions.csv"> their full history</a> can be found in the <a href="https://github.com/tdwg/dwc">Darwin Core repository</a>.</p>
|
||||||
|
|
||||||
#for $class_group in $class_groups
|
{% for class_group in class_groups %}
|
||||||
<section id="$class_group.label" class="anchor mb-4"><!-- anchor to class_group -->
|
<section id="{{ class_group.label }}" class="anchor mb-4"><!-- anchor to class_group -->
|
||||||
<h2>$class_group.label</h2>
|
<h2>{{ class_group.label }}</h2>
|
||||||
<div class="my-4">
|
<div class="my-4">
|
||||||
#for $term in $class_group.terms
|
{% for term in class_group.terms %}
|
||||||
<a class="btn btn-sm btn-outline-dark m-1" href="#$term.namespace:$term.label">$term.label</a><!-- link to term -->
|
<a class="btn btn-sm btn-outline-dark m-1" href="#{{ term.namespace}}:{{ term.label }}">{{ term.label }}</a><!-- link to term -->
|
||||||
#end for
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
#if $class_group.iri is not None
|
{% if class_group.iri is not none %}
|
||||||
## The above will exclude the Record-level class_group
|
{# The above will exclude the Record-level class_group #}
|
||||||
<table class="table table-sm border mb-3">
|
<table class="table table-sm border mb-3">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="table-primary"><th colspan="2">$class_group.label <span class="badge badge-primary float-right">Class</span></th></tr>
|
<tr class="table-primary"><th colspan="2">{{ class_group.label }}<span class="badge badge-primary float-right">Class</span></th></tr>
|
||||||
<tr><td class="label">Identifier</td><td><a href="$class_group.iri">$class_group.iri</a></td></tr>
|
<tr><td class="label">Identifier</td><td><a href="{{ class_group.iri }}">{{ class_group.iri }}</a></td></tr>
|
||||||
<tr><td class="label">Definition</td><td>$class_group.definition</td></tr>
|
<tr><td class="label">Definition</td><td>{{class_group.definition}}</td></tr>
|
||||||
<tr><td class="label">Comments</td><td>$class_group.comments</td></tr>
|
<tr><td class="label">Comments</td><td>{{class_group.comments}}</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
#end if
|
{%endif %}
|
||||||
|
|
||||||
#for $term in $class_group.terms
|
{% for term in class_group.terms %}
|
||||||
<a id="$term.namespace:$term.label" class="anchor"></a><!-- anchor to term -->
|
<a id="{{ term.namespace}}:{{ term.label }}" class="anchor"></a><!-- anchor to term -->
|
||||||
<table class="table table-sm border mb-3">
|
<table class="table table-sm border mb-3">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="table-secondary"><th colspan="2">$term.label <span class="badge badge-secondary float-right">Property</span></th></tr>
|
<tr class="table-secondary"><th colspan="2">{{ term.label }}<span class="badge badge-secondary float-right">Property</span></th></tr>
|
||||||
<tr><td class="label">Identifier</td><td><a href="$term.iri">$term.iri</a></td></tr>
|
<tr><td class="label">Identifier</td><td><a href="{{ term.iri }}">{{ term.iri }}</a></td></tr>
|
||||||
<tr><td class="label">Definition</td><td>$term.definition</td></tr>
|
<tr><td class="label">Definition</td><td>{{ term.definition }}</td></tr>
|
||||||
<tr><td class="label">Comments</td><td>$term.comments</td></tr>
|
<tr><td class="label">Comments</td><td>{{ term.comments }}</td></tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
#end for
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
#end for
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
Cheetah3
|
jinja2
|
||||||
PyYAML
|
PyYAML
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue