Add nice whole file support

This commit is contained in:
Skia
2016-08-10 05:48:06 +02:00
parent 6fbf607492
commit 792d66da33
51 changed files with 35202 additions and 119 deletions

View File

@ -6,14 +6,15 @@
<link rel="stylesheet" href="{{ static('core/base.css') }}">
<link rel="stylesheet" href="{{ static('core/form.css') }}">
<link rel="stylesheet" href="{{ static('core/style.css') }}">
<script src="{{ static('core/script.js') }}"></script>
<link rel="stylesheet" href="{{ static('core/multiple-select.css') }}">
<link rel="stylesheet" href="{{ static('core/js/ui/jquery-ui.min.css') }}">
{% endblock %}
</head>
<body>
{% block header %}
<div id="logo"><a href="{{ url('core:index') }}"><img src="{{ static('core/img/logo.png') }}"
alt="{% trans %}Logo{% endtrans %}" /></a></div>
{% block header %}
<header>
{% if not user.is_authenticated() %}
<a href="{{ url('core:login') }}">{% trans %}Login{% endtrans %}</a> |
@ -25,6 +26,7 @@
{% endif %}
</header>
{% endblock %}
{% block nav %}
<nav>
<a href="{{ url('core:user_list') }}">{% trans %}Users{% endtrans %}</a>
<a href="{{ url('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
@ -32,6 +34,7 @@
<a href="{{ url('club:club_list') }}">{% trans %}Clubs{% endtrans %}</a>
<a href="{{ url('core:page', "Services") }}">{% trans %}Services{% endtrans %}</a>
</nav>
{% endblock %}
<div id="content">
{% if error %}
@ -51,5 +54,24 @@
{{ tests }}
{% endblock %}
-->
<script src="{{ static('core/js/jquery-3.1.0.min.js') }}"></script>
<script src="{{ static('core/js/ui/jquery-ui.min.js') }}"></script>
<script src="{{ static('core/js/multiple-select.js') }}"></script>
<script src="{{ static('core/js/script.js') }}"></script>
<script>
$('select').multipleSelect({
filter: true,
single: true,
{% if not popup %}
position: 'top',
{% endif %}
});
$('select[multiple=multiple]').multipleSelect({
filter: true,
{% if not popup %}
position: 'top',
{% endif %}
});
</script>
</body>
</html>

View File

@ -0,0 +1,61 @@
{% extends "core/base.jinja" %}
{% block title %}
{% if file %}
{{ file.get_display_name() }}
{% elif file_list %}
{% trans %}File list{% endtrans %}
{% elif new_file %}
{% trans %}New file{% endtrans %}
{% else %}
{% trans %}Not found{% endtrans %}
{% endif %}
{% endblock %}
{% macro print_file_name(file) %}
{% if file %}
{{ print_file_name(file.parent) }} >
<a href="{{ url('core:file_detail', file_id=file.id, popup=popup) }}">{{ file.get_display_name() }}</a>
{% else %}
<a href="{{ url('core:file_list', popup) }}">{% trans %}Files{% endtrans %}</a>
{% endif %}
{% endmacro %}
{% block header %}
{% if popup != "" %}
<div id="popupheader">{{ user.get_display_name() }}</div>
{% else %}
{{ super() }}
{% endif %}
{% endblock %}
{% block nav %}
{% if popup != "" %}
{% else %}
{{ super() }}
{% endif %}
{% endblock %}
{% block content %}
{{ print_file_name(file) }}
<div class="tool-bar">
<div class="tools">
{% if file %}
<a href="{{ url('core:file_detail', file.id, popup) }}">{% trans %}View{% endtrans %}</a>
{% if can_edit(file, user) %}
<a href="{{ url('core:file_edit', file_id=file.id, popup=popup) }}">{% trans %}Edit{% endtrans %}</a>
{% endif %}
{% if can_edit_prop(file, user) %}
<a href="{{ url('core:file_prop', file_id=file.id, popup=popup) }}">{% trans %}Prop{% endtrans %}</a>
{% endif %}
{% endif %}
</div>
</div>
<hr>
{% if file %}
{% block file %}
{% endblock %}
{% endif %}
{% endblock %}

View File

@ -0,0 +1,14 @@
{% extends "core/file.jinja" %}
{% block file %}
<h2>{% trans %}Delete confirmation{% endtrans %}</h2>
<form action="" method="post">{% csrf_token %}
<p>{% trans obj=object %}Are you sure you want to delete "{{ obj }}"?{% endtrans %}</p>
<input type="submit" value="{% trans %}Confirm{% endtrans %}" />
<input type="submit" name="cancel" value="{% trans %}Cancel{% endtrans %}" />
</form>
{% endblock %}

View File

@ -0,0 +1,45 @@
{% extends "core/file.jinja" %}
{% block file %}
<h3>
{% if file.is_folder %}
&#x1f4c1;
{% else %}
&#128462;
{% endif %}
{{ file.get_display_name() }}
</h3>
<p>{% trans %}Owner: {% endtrans %}{{ file.owner.get_display_name() }}</p>
{% if file.is_folder %}
<form action="" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p() }}
<p><input type="submit" value="{% trans %}Add{% endtrans %}"></p>
</form>
<ul>
{% for f in file.children.order_by('-is_folder', 'name').all() %}
<li>
{% if f.is_folder %}
&#x1f4c1;
{% else %}
&#128462;
{% endif %}
<a href="{{ url('core:file_detail', file_id=f.id, popup=popup) }}">{{ f.get_display_name() }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>{% trans %}Real name: {% endtrans %}{{ file.file.name.split('/')[-1] }}</p>
<p>{% trans %}Date: {% endtrans %}{{ file.date|localtime|date(DATETIME_FORMAT) }} -
{{ file.date|localtime|time(DATETIME_FORMAT) }}</p>
<p>{% trans %}Type: {% endtrans %}{{ file.mime_type }}</p>
<p>{% trans %}Size: {% endtrans %}{{ file.size }} {% trans %}bytes{% endtrans %}</p>
<p><a href="{{ url('core:download', file_id=file.id) }}">{% trans %}Download{% endtrans %}</a></p>
{% endif %}
<p><a href="{{ url('core:file_delete', file_id=file.id, popup=popup) }}">{% trans %}Delete{% endtrans %}</a></p>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends "core/file.jinja" %}
{% block file %}
<h2>{% trans obj=object %}Edit {{ obj }}{% endtrans %}</h2>
<form action="" method="post">
{% csrf_token %}
{{ form.as_p() }}
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
</form>
{% endblock %}

View File

@ -0,0 +1,29 @@
{% extends "core/file.jinja" %}
{% block content %}
{{ super() }}
<form action="" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p() }}
<p><input type="submit" value="{% trans %}Add{% endtrans %}"></p>
</form>
{% if file_list %}
<h3>{% trans %}File list{% endtrans %}</h3>
<ul>
{% for f in file_list %}
<li>
{% if f.is_folder %}
&#x1f4c1;
{% else %}
&#128462;
{% endif %}
<a href="{{ url('core:file_detail', file_id=f.id, popup=popup) }}">{{ f.name }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>{% trans %}There is no file in this website.{% endtrans %}</p>
{% endif %}
{% endblock %}

View File

@ -5,7 +5,7 @@
<script>
function make_preview() {
$.ajax({
url: "{{ url('core:api_markdown') }}",
url: "{{ url('api:api_markdown') }}",
method: "GET",
data: { text: $("#id_content").val() }
}).done(function (msg) {