diff --git a/app/app.py b/app/app.py index aa6ee12..0fe2b81 100644 --- a/app/app.py +++ b/app/app.py @@ -741,6 +741,41 @@ def trash_restore(): return redirect(url_for("browse", subpath=parent) if parent != "." else url_for("browse")) +@app.route("/trash/preview/") +def trash_preview(subpath): + redir = _require_admin() + if redir: + return redir + target = (TRASH_ROOT / subpath).resolve() + if not str(target).startswith(str(TRASH_ROOT)): + abort(400) + if not target.is_file(): + abort(404) + stat = target.stat() + ext = target.suffix.lower() + ctx = dict( + subpath = subpath, + filename = target.name, + filesize = _humansize(stat.st_size), + mtime = datetime.fromtimestamp(stat.st_mtime), + raw_url = url_for("trash_raw", subpath=subpath), + parent_path= None, + prev_path = None, + next_path = None, + sibling_pos= "", + ext = ext, + from_trash = True, + ) + if ext in IMAGE_EXT: + ctx["meta"] = _image_meta(target) + return render_template("preview_image.html", **ctx) + if ext in TEXT_EXT: + return render_template("preview_text.html", + content=target.read_text(errors="replace"), + lang=ext.lstrip("."), **ctx) + return render_template("preview_other.html", **ctx) + + @app.route("/trash/empty", methods=["POST"]) def trash_empty(): redir = _require_admin() diff --git a/app/templates/_file_table.html b/app/templates/_file_table.html index 0484641..4768481 100644 --- a/app/templates/_file_table.html +++ b/app/templates/_file_table.html @@ -61,7 +61,7 @@ alt="{{ e.name }}" loading="lazy"> {% endif %} {% if mode == 'trash' %} - {{ e.name }} + {{ e.name }} {% else %} {{ e.name }}{% if e.is_dir %}/{% endif %} diff --git a/app/templates/base.html b/app/templates/base.html index 3a672c2..41769b2 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -16,8 +16,6 @@ Alpinux Static