mirror of
https://github.com/Xevion/simple-viewer.git
synced 2025-12-06 03:16:32 -06:00
added directory prefill shortcut creation
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
from typing import Tuple, List
|
from typing import List, Tuple
|
||||||
|
|
||||||
|
|
||||||
def extra_listdir(path: str) -> List[Tuple[str, str]]:
|
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.
|
: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: 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:
|
def get_all_mediatype(head: str, tail: str) -> str:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Directory</label>
|
<label class="label">Directory</label>
|
||||||
<div class="control has-icons-left has-icons-right">
|
<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">
|
<span class="icon is-small is-left">
|
||||||
<i class="fas fa-folder-open"></i>
|
<i class="fas fa-folder-open"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -17,13 +17,22 @@
|
|||||||
<span class="panel-icon pr-4">
|
<span class="panel-icon pr-4">
|
||||||
<i class="fas fa-{{ file.1 }} fa-lg" aria-hidden="true"></i>
|
<i class="fas fa-{{ file.1 }} fa-lg" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
<a href="{% if file.1 != 'folder' %}{% url 'file' directory.id file.0 %}{% endif %}">
|
{% if file.1 == 'folder' %}
|
||||||
|
<a href="{% url 'add' %}?path={{ file.2 }}">
|
||||||
{{ file.0 }}
|
{{ file.0 }}
|
||||||
</a>
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{% url 'file' directory.id file.0 %}">
|
||||||
|
{{ file.0 }}
|
||||||
|
{{ file.0 }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</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 %}
|
{% load static %}
|
||||||
<script src="{% static "hover.js" %}"></script>
|
<script src="{% static "hover.js" %}"></script>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|||||||
@@ -58,7 +58,10 @@ def file(request, directory_id, file):
|
|||||||
|
|
||||||
|
|
||||||
def add(request):
|
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):
|
def submit_new(request):
|
||||||
|
|||||||
Reference in New Issue
Block a user