diff --git a/.gitignore b/.gitignore index 705c21e..e7045b6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.pyc *.egg-info/ .eggs/ +.ruff_cache build/ dist/ pip-wheel-metadata/ diff --git a/verse/describer/describe_files.py b/verse/describer/describe_files.py index f64b763..31a8e79 100644 --- a/verse/describer/describe_files.py +++ b/verse/describer/describe_files.py @@ -1,4 +1,10 @@ -from flask import Blueprint, render_template, redirect, url_for +from flask import ( + Blueprint, + render_template, + redirect, + url_for, + send_from_directory, +) from flask_login import current_user, login_required from models.distribusi_model import Distribusis from models.distribusi_file_model import DistribusiFiles @@ -31,7 +37,9 @@ def show_distribusi_files(distribusiname): @login_required def describe_file(file_id): distribusi_file = DistribusiFiles.query.filter_by(id=file_id).first() - describe_form = DescribeFilesForm(distribusi_file.id, distribusi_file.path) + describe_form = DescribeFilesForm( + distribusi_file.id, distribusi_file.path, distribusi_file.type + ) print( f"file: {describe_form.file_path} description: {describe_form.description.data}" ) @@ -41,14 +49,20 @@ def describe_file(file_id): print( f"file: {describe_form.file_path} alttext: {describe_form.alttext.data}" ) - distribusi_file_forms = get_distribusi_file_forms( - distribusi_file.distribusi - ) - return render_template( - "describe.html", - distribusi_file_forms=distribusi_file_forms, + distribusi = Distribusis.query.filter_by( + id=distribusi_file.distribusi + ).first() + return redirect( + url_for( + "describer.show_distribusi_files", + distribusiname=distribusi.distribusiname, + ) ) +@describer.route("/stash/") +def send_stash_file(path): + return send_from_directory("stash", path) + def get_distribusi_file_forms(distribusi_id): distribusi_file_forms = {} @@ -57,7 +71,7 @@ def get_distribusi_file_forms(distribusi_id): ).all() for distribusi_file in distribusi_files: describe_form = DescribeFilesForm( - distribusi_file.id, distribusi_file.path + distribusi_file.id, distribusi_file.path, distribusi_file.type ) describe_form.description.data = distribusi_file.description describe_form.alttext.data = distribusi_file.alttext diff --git a/verse/describer/forms/describe_files_form.py b/verse/describer/forms/describe_files_form.py index f127751..517b818 100644 --- a/verse/describer/forms/describe_files_form.py +++ b/verse/describer/forms/describe_files_form.py @@ -30,10 +30,11 @@ class DescribeFilesForm(FlaskForm): ) save = SubmitField("Save") - def __init__(self, id, file_path=None): + def __init__(self, id, file_path=None, type=None): super(DescribeFilesForm, self).__init__() self.id = id self.file_path = file_path + self.type = type self.alttext.id = f"alttext-{id}" self.searchtags.id = f"searchtags-{id}" self.description.id = f"description-{id}" diff --git a/verse/describer/templates/describe_files/describe.html b/verse/describer/templates/describe_files/describe.html index 5b3276e..db3e72e 100644 --- a/verse/describer/templates/describe_files/describe.html +++ b/verse/describer/templates/describe_files/describe.html @@ -28,10 +28,19 @@
{% for id, describe_form in distribusi_file_forms.items() %} +
+ {% if describe_form.type == "image" %} + + {% elif describe_form.type == "video" %} + + {% elif describe_form.type == "audio" %} + + {% else %} + file: {{describe_form.file_path}} + {% endif %}
{{ describe_form.csrf_token }} -

{{describe_form.id}}

-

{{describe_form.file_path}}

+

File path: {{describe_form.file_path}}

{{ describe_form.description.label }} {{ describe_form.description }} @@ -57,6 +66,7 @@ {{ describe_form.save }}
+
{% endfor%}
diff --git a/verse/static/css/style.css b/verse/static/css/style.css index 2f772a8..900ee56 100644 --- a/verse/static/css/style.css +++ b/verse/static/css/style.css @@ -174,6 +174,23 @@ a:active { content: "$ "; } +.distribusi_file { + margin-top: 1em; + padding: 0.5em; + padding-left: auto; + padding-right: auto; + width: 45em; + background-color:#fdfdfd; + text-decoration: none; + scroll-behavior: smooth; + border-style: outset; +} + +.distribusi_file > img, video { + max-width: 100%; + max-height: 100%; +} + @media (prefers-reduced-motion: no-preference) { @keyframes flash { 50% { opacity: 0; }