#47, #49: Auto-thumbnailing now working and configurable

Not yet documented.
This commit is contained in:
Simon Brooke 2020-02-10 22:51:59 +00:00
parent 40f4f13667
commit ba45ea5163
No known key found for this signature in database
GPG key ID: A7A4F18D1D4DF987
3 changed files with 24 additions and 20 deletions

View file

@ -1,14 +1,14 @@
{% extends "templates/base.html" %}
{% block content %}
<div id="content" class="auth">
{% if has-uploaded %}
{% if uploaded|not-empty %}
{% for upload in uploaded %}
{{upload.filename}}
{% if upload.is-image %)
{% if upload.is-image %}
<p>
<img id="uploaded-image" alt="Uploaded image" src="{{upload.resource}}"/>
{% i18n file-upload-link-text %}:
<!-- TODO: i18n needed -->
This is the {{upload.size|name}} file. {% i18n file-upload-link-text %}:
<code>![{{upload.filename}}]({{upload.resource}})</code>
</p>
@ -19,6 +19,8 @@
<code>[{{upload.filename}}]({{upload.resource}})</code>
</p>
{% endif %}
<br clear="right"/>
<hr/>
{% endfor %}
{% else %}
<form action="{{servlet-context}}/upload" enctype="multipart/form-data" method="POST">

View file

@ -250,7 +250,6 @@
(layout/render "upload.html"
(merge (util/standard-params request)
{:title (util/get-message :file-upload-title request)
:has-uploaded (not (empty? uploaded))
:uploaded uploaded}))))
(defn version-page

View file

@ -8,6 +8,7 @@
[me.raynes.fs :as fs]
[noir.io :as nio]
[smeagol.configuration :refer [config]]
[smeagol.util :as util]
[taoensso.timbre :as log])
(:import [java.io File]
[java.awt Image]
@ -117,6 +118,8 @@
(try
(let [p (io/file path filename)]
(.renameTo tmp-file p)
(map
#(assoc % :resource (subs (:location %) (inc (count util/content-dir))))
(remove
nil?
(cons
@ -124,7 +127,7 @@
:filename filename
:location (str p)
:is-image (and (image? filename) true)}
(remove nil? (or (auto-thumbnail path filename) '())))))
(remove nil? (or (auto-thumbnail path filename) '()))))))
(catch Exception x
(log/error (str "Failed to move " tmp-file " to " path filename "; " (type x) ": " (.getMessage x)))
(throw x)))