File: metadata_converter.twig

package info (click to toggle)
simplesamlphp 1.19.7-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 42,920 kB
  • sloc: php: 202,044; javascript: 14,867; xml: 2,700; sh: 225; perl: 82; makefile: 70; python: 5
file content (71 lines) | stat: -rw-r--r-- 2,616 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{% set pagetitle = 'Metadata parser'|trans %}
{% set frontpage_section = 'federation' %}
{% extends "base.twig" %}

{%  set i=1 %}
{% block content %}
    {%- include "@admin/includes/menu.twig" %}

    <h2>{{ pagetitle }}</h2>
    <form method="post" class="pure-form" enctype="multipart/form-data" action="#converted">
        <h3> {% trans 'XML metadata' %}</h3>
        <div class="pure-control-group">
            <textarea name="xmldata" rows="20" class="text-area edge xmldata">{{ xmldata }}</textarea>
        </div>
        <br>
        <div class="center">
            <div class="pure-button-group two-elements" role="group">
                <label class="pure-button">
                    <span class="fa fa-folder-open"></span>{{ 'or select a file:'|trans }}
                    <input type="file" name="xmlfile" class="hidden" id="file-input">
                </label>
                <label id="show-file" class="pure-button hollow show-files" disabled>{{ 'No file selected.'|trans }}</label>
            </div>
            <br>
            <button class="pure-button pure-button-red pure-input-1-3">{{ 'Parse'|trans }}</button>
        </div>
    </form>

    {% if output -%}
    <br>
    <h2 id="converted">{{ 'Converted metadata'|trans }}</h2>
        {% for type, text in output if text -%}
{# spaceless is to work around a clipboard.js bug that would add extra whitespace #}
{% spaceless %}
    <div class="code-box">
        <div class="code-box-title">
            <h3>{{ type }}</h3>
            <button data-clipboard-target="#metadata{{ loop.index }}" id="btn{{ loop.index }}" class="pure-button right clipboard-btn copy">
                <i class="fa fa-copy"></i>
            </button>
        </div>
        <div class="code-box-content">
            <pre id="metadata{{ loop.index }}">{{ text|escape }}</pre>
        </div>
    </div>
{% endspaceless %}
            <br><br>
            {%- set i=i+1 %}
        {%- endfor -%}
    {% elseif error is not null %}
    <br>
    <h2 id="error">{{ 'An error occured'|trans }}</h2>
    <div class="code-box">
        <div class="code-box-content">
            <pre id="error" class="fa fa-warning">&nbsp;&nbsp;{{ error }}</pre>
        </div>
    </div>
    {% endif -%}
{% endblock content -%}
{% block postload %}
<script>
    $('body').on('change', '#file-input', function () {
        var files = this.files;
        var fileNames = [];
        for (var i = 0; i < files.length; i++) {
            fileNames.push(files.item(i).name);
        }
        $('#show-file').html(fileNames.join(", "));
    });
</script>
{% endblock postload %}