login

meta.html 6KiB

This page in this page ...

download lastest submit new version

Preview text/html

{% load sass_tags  %}
{% load bootstrap3 %}

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link href="{% sass_src 'css/preview.scss' %}" rel="stylesheet" type="text/css" />
    <link href="{% sass_src 'css/highlight.scss' %}" rel="stylesheet" type="text/css" />
    {% bootstrap_css %}

    <title>File: {{ file.name }}</title>
  </head>
  <body>
    <!-- Upload modal -->
    <div class="modal fade" id="upload-modal" tabindex="-1" role="dialog">
      <div class="modal-dialog" role="document">
        <form class="modal-content" action="{% url 'upload' file_id=file.id %}" method="POST" enctype="multipart/form-data">
          {% csrf_token %}
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">Upload a new version</h4>
          </div>
          <div class="modal-body">
            <div class="form-horizontal">
              {% if not perms.droper.add_upload %}
                <div class="alert alert-warning alert-dismissible" role="alert">
                  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                  <strong>You won't be able to upload</strong> files as long as you don't <a class="alert-link" href="{% url 'login' %}">connect</a>
                </div>
              {% endif %}
              <div class="form-group">
                <label class="control-label col-md-3">Name</label>
                <div class="col-md-9">
                  <p class="form-control-static">{{ file.name }}</p>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-md-3">Description</label>
                <div class="col-md-9">
                  <p class="form-control-static">{{ file.description }}</p>
                </div>
              </div>
              {% bootstrap_form upload_form layout='horizontal' %}
            </div>
          </div>
          <div class="modal-footer">
            {% buttons %}
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
              <button type="submit" class="btn btn-primary">Upload</button>
            {% endbuttons %}
          </div>
        </form>
      </div>
    </div>

    <!-- Page head -->
    <div class="jumbotron">
      <div class="container">
        {% if user.is_authenticated %}
          <a class="pull-right" href="{% url 'logout' %}" title="Disconnect" data-toggle="tooltip">
            {% bootstrap_icon 'log-out' %}
            {{ user.first_name }} {{ user.last_name }}
          </a>
        {% else %}
          <a class="pull-right" href="{% url 'login' %}">
            {% bootstrap_icon 'log-in' %}
            login
          </a>
        {% endif %}
        <h1>{{ file.name }} <small>{{ file.last_upload.get_size }}</small></h1>
        <p>{{ file.description }}</p>
        <p>
          <a class="btn btn-primary btn-lg" href="{% url 'download' upload_id=file.last_upload.id %}" role="button">download lastest</a>
          <a class="btn btn-lg" data-toggle="modal" data-target="#upload-modal" role="button">submit new version</a>
        </p>
      </div>
    </div>

    <!-- Navigation -->
    <div class="container">
      <ol class="breadcrumb">
        <li><a href="{% url 'index' %}">Home</a></li>
        <li class="active">{{ file.name }}</li>
      </ol>
    </div>

    {% if render %}
    <!-- Preview -->
      {% if filetype == 'text' %}
        <div class="container">
          <div class="panel panel-default panel-code">
            <div class="panel-heading">
              <h3 class="panel-title">
                {% bootstrap_icon 'file' %}
                Preview
                <span class="pull-right">{{ mime }}</span>
              </h3>
            </div>
            <div class="panel-body">
              {{ content | safe }}
              <!-- <pre>{% for line in content %}<span>{{ line }}</span><br />{% endfor %}</pre> -->
              <style>
                .panel-code .panel-body pre span:before {
                  width: {{line_num_cols | add:1}}ch;
                }
              </style>
            </div>
          </div>
        </div>
      {% elif filetype == 'image' %}
        <div class="container">
          <div class="panel panel-default panel-image">
            <div class="panel-heading">
              <h3 class="panel-title">
                {% bootstrap_icon 'picture' %}
                Preview
                <span class="pull-right">{{ mime }}</span>
              </h3>
            </div>
            <div class="panel-body">
              <img src="{% url 'download' upload_id=file.last_upload.id %}"
            </div>
          </div>
        </div>
      {% endif %}
    {% endif %}

    <!-- Uploads history -->
    <div class="container">
      <table class="table table-hover">
        <caption>Uploads history for this file</caption>
        <thead>
          <tr>
            <th class="col-md-9">label</th>
            <th>date of upload</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          {% for upload in uploads %}
            <tr>
              <td>{{ upload.label }}</td>
              <td>{{ upload.date }}</td>
              <td>
                <a href="{% url 'download' upload_id=upload.id %}">
                  {% bootstrap_icon 'download-alt' %}
                  {{ upload.get_size }}
                </a>
              </td>
            </tr>
          {% endfor %}
        </tbody>
      </table>

      <hr>

      <footer>
        <p>&copy; 2018 Rémi Dupré</p>
      </footer>
    </div>

    {% bootstrap_javascript jquery=1 %}
  </body>
</html>
Uploads history for this file
label date of upload
Initial version Feb. 9, 2018, 4:20 p.m. 6KiB