schema_info_part.html 3.24 KB
Newer Older
1
{% macro html(schema_info, schema_versions, schema_current_version, doc_url) %}
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
    <h6>Contributeur{% if schema_info.contributors|length > 1 %}s{% endif %} :</h6>
    <ul>
        {% for contributor in schema_info.contributors %}
        <li>
20 21 22 23
            {{ contributor.title }}{% if contributor.title and contributor.organisation %}, {% endif %}
            {% if contributor.organisation %}{{ contributor.organisation }}{% endif %}
            
            {# role #}
24 25 26 27 28
            {% if contributor.role == 'author' %}(auteur){% endif %}
            {% if contributor.role == 'contributor' %}(contributeur){% endif %}
        </li>
        {% endfor %}
    </ul>
Pierre Dittgen's avatar
Pierre Dittgen committed
29 30
</p>
{% endif %}
31
{% if schema_info.homepage or schema_info.url %}
Pierre Dittgen's avatar
Pierre Dittgen committed
32
<p>
33 34
    {% if schema_info.homepage %}
    Site : <a href="{{ schema_info.homepage }}" target="_blank" title="{{ schema_info.homepage }}" class="card-link">{{ schema_info.homepage | truncate(40) }}</a>
Pierre Dittgen's avatar
Pierre Dittgen committed
35
    {% endif %}
36 37
    {#
    {% if schema_info.homepage and schema_info.url %}<br />{% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
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 %}
41
    #}
Pierre Dittgen's avatar
Pierre Dittgen committed
42 43 44 45
</p>
{% endif %}
{% if schema_versions %}
<p>
46
    Changer de version Git :
Pierre Dittgen's avatar
Pierre Dittgen committed
47 48
    <select id="version_select">
        {% for sv in schema_versions %}
Christophe Benz's avatar
Christophe Benz committed
49
        <option{% if sv.name == schema_current_version %} selected="selected"{% endif %}>{{ sv.name }}</option>
Pierre Dittgen's avatar
Pierre Dittgen committed
50 51
        {% endfor %}
    </select>
52 53 54 55
    {% if schema_current_version == 'master' %}
    <br />
    <a href="{{ doc_url }}" target="_blank">Documentation</a>
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
56
</p>
57 58
{% endif %}
{% endmacro %}
Christophe Benz's avatar
Christophe Benz committed
59

60
{% macro script() %}
Pierre Dittgen's avatar
Pierre Dittgen committed
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 87 88 89 90 91 92 93 94 95
<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>
96
{% endmacro %}