begin working on add directory functionality, finished bulma frontend form design

This commit is contained in:
Xevion
2020-10-31 18:03:25 -05:00
parent 5d6d21e97d
commit 4cc1402d21
4 changed files with 80 additions and 4 deletions

64
viewer/templates/add.html Normal file
View File

@@ -0,0 +1,64 @@
{% extends 'base.html' %}
{% block content %}
<div class="card">
<header class="card-header">
<p class="card-header-title">
Add New Directory
</p>
</header>
<div class="card-content">
<div class="content">
<p>
Adds a new Directory to be served by the server.
<br>
If specified, a <a href="https://en.wikipedia.org/wiki/Regular_expression#Syntax">RegEx pattern</a> can be used to filter files and will only display the ones you want.
<br>
RegEx patterns can be configured below to match against the entire path or just the filename.
<br>
Additionally, files can be matched <i>recursively</i> if you so wish. Please note that this functionality may create anomalous behavior around duplicate files.
</p>
<form action="{% url 'add_submit' %}">
{% csrf_token %}
<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">
<span class="icon is-small is-left">
<i class="fas fa-folder-open"></i>
</span>
</div>
<p class="help">
We recommend that you use a full path. Do not escape the path or use a relative path for best results.
</p>
</div>
<div class="field">
<label class="label">Filter Files</label>
<div class="control has-icons-left has-icons-right">
<input class="input" type="text" name="regex" placeholder="RegEx Pattern">
<span class="icon is-small is-left">
<i class="fas fa-search"></i>
</span>
</div>
<p class="help">
This is optional. Do not enter anything if you wish to disable RegEx matching and simply add all files.
</p>
</div>
<label class="checkbox pt-1 pb-3 pr-3">
<input type="checkbox" name="match_filename">
Match Against Filename?
</label>
<label class="checkbox pt-1 pb-3 pr-3">
<input type="checkbox" name="recursive">
Recursively Match
</label>
<div class="field">
<div class="control">
<button class="button is-link">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
{% endblock content %}

View File

@@ -20,7 +20,9 @@
<div class="navbar-end">
<div class="navbar-item">
<span class="icon">
<a href="{% url 'add' %}">
<i class="fas fa-plus"></i>
</a>
</span>
</div>
</div>

View File

@@ -4,6 +4,8 @@ from . import views
urlpatterns = [
path('', views.index, name='index'),
path('/<uuid:directory_id>/', views.browse, name='browse'),
path('/<uuid:directory_id>/<str:file>/', views.file, name='file')
path('add/', views.add, name='add'),
path('add/submit', views.submit_new, name='add_submit'),
path('<uuid:directory_id>/', views.browse, name='browse'),
path('<uuid:directory_id>/<str:file>/', views.file, name='file')
]

View File

@@ -1,6 +1,6 @@
import os
from django.http import FileResponse
from django.http import FileResponse, HttpResponse
from django.shortcuts import render, get_object_or_404
from viewer.helpers import extra_listdir
@@ -54,3 +54,11 @@ def file(request, directory_id, file):
)
}
return render(request, 'message.html', context, status=500)
def add(request):
return render(request, 'add.html', {'title': 'Add New Directory'})
def submit_new(request):
return HttpResponse('')