diff --git a/resources/templates/upload.html b/resources/templates/upload.html index bc469b4..3e63f17 100644 --- a/resources/templates/upload.html +++ b/resources/templates/upload.html @@ -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"> diff --git a/src/smeagol/routes/wiki.clj b/src/smeagol/routes/wiki.clj index c21e81b..95c1828 100644 --- a/src/smeagol/routes/wiki.clj +++ b/src/smeagol/routes/wiki.clj @@ -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 diff --git a/src/smeagol/uploads.clj b/src/smeagol/uploads.clj index 2adb69f..34f43c3 100644 --- a/src/smeagol/uploads.clj +++ b/src/smeagol/uploads.clj @@ -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] @@ -80,13 +81,13 @@ for the file with this `filename` on this `path`, provided that it is a scalable image and is larger than the size." ([^String path ^String filename] - (if - (image? filename) - (let [original (buffered-image (File. (str path filename)))] ;; fs/file? - (map - #(auto-thumbnail path filename % original) - (keys (config :thumbnails)))) - (log/info filename " cannot be thumbnailed."))) + (if + (image? filename) + (let [original (buffered-image (File. (str path filename)))] ;; fs/file? + (map + #(auto-thumbnail path filename % original) + (keys (config :thumbnails)))) + (log/info filename " cannot be thumbnailed."))) ([^String path ^String filename size ^RenderedImage image] (let [s (-> config :thumbnails size) d (dimensions image) @@ -117,14 +118,16 @@ (try (let [p (io/file path filename)] (.renameTo tmp-file p) - (remove - nil? - (cons - {:size :original - :filename filename - :location (str p) - :is-image (and (image? filename) true)} - (remove nil? (or (auto-thumbnail path filename) '()))))) + (map + #(assoc % :resource (subs (:location %) (inc (count util/content-dir)))) + (remove + nil? + (cons + {:size :original + :filename filename + :location (str p) + :is-image (and (image? filename) true)} + (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)))