Improve uploading/downloading files

This commit is contained in:
Joakim Hellsén 2024-03-17 19:39:22 +01:00
commit 7005490bf4
No known key found for this signature in database
GPG key ID: D196AE66FEBE1DC9
18 changed files with 4596 additions and 134 deletions

View file

@ -13,4 +13,38 @@
</li>
{% endfor %}
</ul>
<h3>Uploads</h3>
{% if user_uploads %}
<p>Uploaded files:</p>
{% else %}
<p>No uploaded files yet.</p>
{% endif %}
<ul id="uploads-list">
{% for upload in user_uploads %}
<li id="upload-{{ upload.id }}">
<a href="{{ upload.get_absolute_url }}">{{ upload }}</a>
<p>
Description: <span id="description-{{ upload.id }}">{{ upload.description|default:"No description" }}</span>
{% if upload.notes %}
<br>
Notes: {{ upload.notes }}
{% endif %}
</p>
<form method="post" action="{% url 'delete_upload' %}">
{% csrf_token %}
<input type="hidden" name="file_id" value="{{ upload.id }}">
<button type="submit">Delete</button>
</form>
<form method="post"
hx-post="{% url 'edit_description' %}"
hx-target="#description-{{ upload.id }}"
hx-swap="innerHTML">
{% csrf_token %}
<input type="hidden" name="file_id" value="{{ upload.id }}">
<input type="text" name="description" placeholder="New description" required>
<button type="submit">Edit description</button>
</form>
</li>
{% endfor %}
</ul>
{% endblock %}

View file

@ -1,3 +1,4 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
@ -7,11 +8,8 @@
{% if keywords %}<meta name="keywords" content="{{ keywords }}" />{% endif %}
{% if author %}<meta name="author" content="{{ author }}" />{% endif %}
{% if canonical %}<link rel="canonical" href="{{ canonical }}" />{% endif %}
{% if title %}
<title>{{ title }}</title>
{% else %}
<title>FeedVault</title>
{% endif %}
<title>{{ title|default:"FeedVault" }}</title>
<script src="{% static 'htmx.min.js' %}"></script>
<style>
html {
max-width: 88ch;
@ -70,6 +68,10 @@
.success {
color: green;
}
.warning {
color: orange;
}
</style>
</head>
<body>

View file

@ -4,6 +4,7 @@
{% if feeds %}
{% for feed in feeds %}
<a href="{% url 'feed' feed.id %}">{{ feed.feed_url|default:"Unknown Feed" }} →</a>
<br>
{% endfor %}
{% else %}
<p>No feeds yet. Time to add some!</p>

View file

@ -14,16 +14,29 @@
<h2>Upload</h2>
<p>
You can also upload files containing the feeds you wish to archive.
Currently supported file formats: .opml, .xml, .json. Your file will be parsed in the future if not currently supported. Feel free to upload databases, backups, or any other files containing feeds. The service will parse the files and add the feeds to the archive.
Currently supported file formats: .opml, .xml, .json.
Your file will be parsed in the future if not currently supported.
Feel free to upload databases, backups, or any other files containing feeds.
</p>
<form enctype="multipart/form-data"
method="post"
action="{% url 'upload' %}">
{% csrf_token %}
<p>
<label for="file">Choose a file to upload</label>
<br>
<br>
<input type="file" name="file" id="file" required>
<br>
<br>
<label for="description">Description (optional)</label>
<input type="text"
name="description"
id="description"
size="80"
placeholder="Description (optional)">
</p>
<button type="submit">Upload feeds</button>
<button type="submit">Upload file</button>
</form>
{% else %}
<h2>Welcome to FeedVault!</h2>