mirror of
https://github.com/Xevion/simple-viewer.git
synced 2025-12-06 01:16:24 -06:00
added directory prefill shortcut creation
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import os
|
||||
from typing import Tuple, List
|
||||
from typing import List, Tuple
|
||||
|
||||
|
||||
def extra_listdir(path: str) -> List[Tuple[str, str]]:
|
||||
@@ -9,7 +9,14 @@ def extra_listdir(path: str) -> List[Tuple[str, str]]:
|
||||
:param path: The path to the directory.
|
||||
:return: A list of tuples, each containing two strings, the file or directory name, and the media type.
|
||||
"""
|
||||
return [(file, get_all_mediatype(file, path)) for file in os.listdir(path)]
|
||||
files = []
|
||||
for file in os.listdir(path):
|
||||
mediatype = get_all_mediatype(file, path)
|
||||
if mediatype == 'folder':
|
||||
files.append((file, mediatype, os.path.join(path, file)))
|
||||
else:
|
||||
files.append((file, mediatype))
|
||||
return files
|
||||
|
||||
|
||||
def get_all_mediatype(head: str, tail: str) -> str:
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<div class="field">
|
||||
<label class="label">Directory</label>
|
||||
<div class="control has-icons-left has-icons-right">
|
||||
<input class="input" type="text" name="path" required placeholder="Full Path">
|
||||
<input class="input" type="text" name="path" required placeholder="Full Path" {% if path_prefill %}value="{{ path_prefill }}"{% endif %}>
|
||||
<span class="icon is-small is-left">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
</span>
|
||||
|
||||
@@ -17,13 +17,22 @@
|
||||
<span class="panel-icon pr-4">
|
||||
<i class="fas fa-{{ file.1 }} fa-lg" aria-hidden="true"></i>
|
||||
</span>
|
||||
<a href="{% if file.1 != 'folder' %}{% url 'file' directory.id file.0 %}{% endif %}">
|
||||
{{ file.0 }}
|
||||
</a>
|
||||
{% if file.1 == 'folder' %}
|
||||
<a href="{% url 'add' %}?path={{ file.2 }}">
|
||||
{{ file.0 }}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url 'file' directory.id file.0 %}">
|
||||
{{ file.0 }}
|
||||
{{ file.0 }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"
|
||||
integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg=="
|
||||
crossorigin="anonymous"></script>
|
||||
{% load static %}
|
||||
<script src="{% static "hover.js" %}"></script>
|
||||
{% endblock content %}
|
||||
|
||||
@@ -58,7 +58,10 @@ def file(request, directory_id, file):
|
||||
|
||||
|
||||
def add(request):
|
||||
return render(request, 'add.html', {'title': 'Add New Directory'})
|
||||
context = {'title': 'Add New Directory'}
|
||||
if 'path' in request.GET.keys():
|
||||
context['path_prefill'] = request.GET['path']
|
||||
return render(request, 'add.html', context)
|
||||
|
||||
|
||||
def submit_new(request):
|
||||
|
||||
Reference in New Issue
Block a user