{% extends 'editor/editor.html' %}

{% block css %}
    <link href = "{{ url('static_assets', filename='js/codemirror/lib/codemirror.css') }}"
          rel  = "stylesheet" />
    
    {{ super() }}
{% endblock %}

{% block javascript %}
    {{ super() }}
    
    <script src="{{ url('static_assets', filename='js/codemirror/lib/codemirror.js') }}"></script>
    <script src="{{ url('static_assets', filename='js/codemirror/mode/jinja2/jinja2.js') }}"></script>
    <script src="{{ url('static_assets', filename='js/codemirror/mode/markdown/markdown.js') }}"></script>
    <script src="{{ url('static_assets', filename='js/codemirror/mode/sparql/sparql.js') }}"></script>
    <script src="{{ url('static_assets', filename='js/codemirror/mode/turtle/turtle.js') }}"></script>
    <script src="{{ url('static_assets', filename='js/commonmark.js') }}"></script>
    
    <script src="{{ url('static_assets', filename='js/editor/revision.js') }}" id="editor_script" data-type="{{ type }}"></script>
{% endblock %}

{% block main %}
    
    <div class="old_revision">
        <div class="info">
            <p>
                {% if revision['dokk:revision_number'] == current_revision['dokk:revision_number'] %}
                    This is the current revision
                {% else %}
                    This is an old revision
                {% endif %}
                
                of the page <strong>{{ page_name }}</strong>,
                as edited by <strong>{{ revision['author'] }}</strong> at
                <strong>{{ revision['datetime']|simple_date }}</strong>.
                You can also look at the
                <a href="{{ url('revisions', type=type, id=node_id) }}">complete history</a>
                of this page.
                <br />
                Revisions cannot be modified; but you can
                <a href="{{ url('edit', type=type, id=node_id) }}">create a new one</a>.
            </p>
        </div>
        
        <div class="edit_summary">
            <strong>#{{ revision['dokk:revision_number'] }}</strong> <em>{{ revision['edit_summary'] }}</em>
        </div>
    </div>
    
    {% if type == 'article' %}
        <div class="article">
            <div>
                <textarea id="content" maxlength="10485760">{{ revision['content'] }}</textarea>
            </div>
            <div id="preview"></div>
        </div>
    {% endif %}

    {% if type == 'file' %}
        <div class="file">
            <textarea id="content" maxlength="10485760">{{ revision['content'] }}</textarea>
        </div>
    {% endif %}

    {% if type == 'query' %}
        <div class="query">
            <textarea id="content" maxlength="10485760">{{ revision['content'] }}</textarea>
        </div>
    {% endif %}

    {% if type == 'template' %}
        <div class="template">
            <textarea id="content" maxlength="10485760">{{ revision['content'] }}</textarea>
        </div>
    {% endif %}

    {% if type == 'topic' %}
        <div class="topic">
            <textarea id="content" maxlength="10485760">{{ revision['content'] }}</textarea>
        </div>
    {% endif %}
    
{% endblock %}
