schema_info_part.html 2.85 KB
Newer Older
Pierre Dittgen's avatar
Pierre Dittgen committed
1
{% macro html(schema_info, schema_versions, schema_current_version) %}
Pierre Dittgen's avatar
Pierre Dittgen committed
2
3
<h5 class="card-title">
    Schéma
4
5
    {% if schema_info.title %}
    « {{ schema_info.title }} »
Pierre Dittgen's avatar
Pierre Dittgen committed
6
    {% endif %}
7
8
    {% if schema_info.version %}
    <span class="badge badge-primary">{{ schema_info.version }}</span>
Pierre Dittgen's avatar
Pierre Dittgen committed
9
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
10
</h5>
11
12
{% if schema_info.description %}
<h6 class="card-subtitle mb-2 text-muted">{{ schema_info.description }}</h6>
Pierre Dittgen's avatar
Pierre Dittgen committed
13
{% endif %}
14
{% if schema_info.contributors %}
Pierre Dittgen's avatar
Pierre Dittgen committed
15
<p>
16
17
18
19
20
21
22
23
24
25
26
    <h6>Contributeur{% if schema_info.contributors|length > 1 %}s{% endif %} :</h6>
    <ul>
        {% for contributor in schema_info.contributors %}
        <li>
            {{ contributor.title }}
            {% if contributor.organisation %} <strong>{{ contributor.organisation }}</strong> {% endif %}
            {% if contributor.role == 'author' %}(auteur){% endif %}
            {% if contributor.role == 'contributor' %}(contributeur){% endif %}
        </li>
        {% endfor %}
    </ul>
Pierre Dittgen's avatar
Pierre Dittgen committed
27
28
</p>
{% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
29
{% if schema_info.doc_url or schema_info.url %}
Pierre Dittgen's avatar
Pierre Dittgen committed
30
<p>
31
32
    {% if schema_info.doc_url %}
    <a href="{{ schema_info.doc_url }}" target="_blank" class="card-link">Documentation</a>
Pierre Dittgen's avatar
Pierre Dittgen committed
33
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
34
35
36
37
38
39
40
    {% if schema_info.url %}
    Source : <a href="{{ schema_info.url }}" target="_blank" title="{{ schema_info.url }}" class="card-link">{{ schema_info.url | truncate(40) }}</a>
    {% endif %}
</p>
{% endif %}
{% if schema_versions %}
<p>
41
    Changer de version Git :
Pierre Dittgen's avatar
Pierre Dittgen committed
42
43
44
45
46
    <select id="version_select">
        {% for sv in schema_versions %}
        <option{% if sv == schema_current_version %} selected="selected"{% endif %}>{{ sv }}</option>
        {% endfor %}
    </select>
Pierre Dittgen's avatar
Pierre Dittgen committed
47
</p>
48
49
{% endif %}
{% endmacro %}
Christophe Benz's avatar
Christophe Benz committed
50

51
{% macro script() %}
Pierre Dittgen's avatar
Pierre Dittgen committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<script>
    var vbox = $('#version_select');
    vbox.on('change', function() {

        // Extract base url and query string
        var current_url = document.location.href;
        var base_url = current_url;
        var query_string = "";
        var qidx = current_url.indexOf('?');
        if (qidx != -1) {
            query_string = current_url.substring(qidx+1);
            base_url = current_url.substring(0, qidx);
        }

        // Transforms query string into parameter dictionary
        // ignoring schema_ref parameter if exists
        var params = query_string.split("&");
        var param_dict = {};
        for (var i=0; i<params.length; i++) {
            var pair = params[i].split('=');
            if (pair[0] != 'schema_ref') {
                param_dict[pair[0]] = pair[1];
            }
        }
        param_dict['schema_ref'] = encodeURIComponent(vbox.val());

        // Build new URL to redirect to
        var param_list = [];
        for (p in param_dict) {
            param_list.push(p + '=' + param_dict[p]);
        }
        var new_url = base_url + '?' + param_list.join('&');
        document.location.href = new_url;
    })
</script>
87
{% endmacro %}