mirror of
https://github.com/journeyman-cc/smeagol.git
synced 2026-04-12 18:05:06 +00:00
Not yet documented.
This commit is contained in:
parent
40f4f13667
commit
ba45ea5163
3 changed files with 24 additions and 20 deletions
|
|
@ -1,14 +1,14 @@
|
||||||
{% extends "templates/base.html" %}
|
{% extends "templates/base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="content" class="auth">
|
<div id="content" class="auth">
|
||||||
{% if has-uploaded %}
|
{% if uploaded|not-empty %}
|
||||||
{% for upload in uploaded %}
|
{% for upload in uploaded %}
|
||||||
{{upload.filename}}
|
{% if upload.is-image %}
|
||||||
{% if upload.is-image %)
|
|
||||||
<p>
|
<p>
|
||||||
<img id="uploaded-image" alt="Uploaded image" src="{{upload.resource}}"/>
|
<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></code>
|
<code></code>
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
<code>[{{upload.filename}}]({{upload.resource}})</code>
|
<code>[{{upload.filename}}]({{upload.resource}})</code>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<br clear="right"/>
|
||||||
|
<hr/>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<form action="{{servlet-context}}/upload" enctype="multipart/form-data" method="POST">
|
<form action="{{servlet-context}}/upload" enctype="multipart/form-data" method="POST">
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,6 @@
|
||||||
(layout/render "upload.html"
|
(layout/render "upload.html"
|
||||||
(merge (util/standard-params request)
|
(merge (util/standard-params request)
|
||||||
{:title (util/get-message :file-upload-title request)
|
{:title (util/get-message :file-upload-title request)
|
||||||
:has-uploaded (not (empty? uploaded))
|
|
||||||
:uploaded uploaded}))))
|
:uploaded uploaded}))))
|
||||||
|
|
||||||
(defn version-page
|
(defn version-page
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
[me.raynes.fs :as fs]
|
[me.raynes.fs :as fs]
|
||||||
[noir.io :as nio]
|
[noir.io :as nio]
|
||||||
[smeagol.configuration :refer [config]]
|
[smeagol.configuration :refer [config]]
|
||||||
|
[smeagol.util :as util]
|
||||||
[taoensso.timbre :as log])
|
[taoensso.timbre :as log])
|
||||||
(:import [java.io File]
|
(:import [java.io File]
|
||||||
[java.awt Image]
|
[java.awt Image]
|
||||||
|
|
@ -80,13 +81,13 @@
|
||||||
for the file with this `filename` on this `path`, provided that it is a
|
for the file with this `filename` on this `path`, provided that it is a
|
||||||
scalable image and is larger than the size."
|
scalable image and is larger than the size."
|
||||||
([^String path ^String filename]
|
([^String path ^String filename]
|
||||||
(if
|
(if
|
||||||
(image? filename)
|
(image? filename)
|
||||||
(let [original (buffered-image (File. (str path filename)))] ;; fs/file?
|
(let [original (buffered-image (File. (str path filename)))] ;; fs/file?
|
||||||
(map
|
(map
|
||||||
#(auto-thumbnail path filename % original)
|
#(auto-thumbnail path filename % original)
|
||||||
(keys (config :thumbnails))))
|
(keys (config :thumbnails))))
|
||||||
(log/info filename " cannot be thumbnailed.")))
|
(log/info filename " cannot be thumbnailed.")))
|
||||||
([^String path ^String filename size ^RenderedImage image]
|
([^String path ^String filename size ^RenderedImage image]
|
||||||
(let [s (-> config :thumbnails size)
|
(let [s (-> config :thumbnails size)
|
||||||
d (dimensions image)
|
d (dimensions image)
|
||||||
|
|
@ -117,14 +118,16 @@
|
||||||
(try
|
(try
|
||||||
(let [p (io/file path filename)]
|
(let [p (io/file path filename)]
|
||||||
(.renameTo tmp-file p)
|
(.renameTo tmp-file p)
|
||||||
(remove
|
(map
|
||||||
nil?
|
#(assoc % :resource (subs (:location %) (inc (count util/content-dir))))
|
||||||
(cons
|
(remove
|
||||||
{:size :original
|
nil?
|
||||||
:filename filename
|
(cons
|
||||||
:location (str p)
|
{:size :original
|
||||||
:is-image (and (image? filename) true)}
|
:filename filename
|
||||||
(remove nil? (or (auto-thumbnail path filename) '())))))
|
:location (str p)
|
||||||
|
:is-image (and (image? filename) true)}
|
||||||
|
(remove nil? (or (auto-thumbnail path filename) '()))))))
|
||||||
(catch Exception x
|
(catch Exception x
|
||||||
(log/error (str "Failed to move " tmp-file " to " path filename "; " (type x) ": " (.getMessage x)))
|
(log/error (str "Failed to move " tmp-file " to " path filename "; " (type x) ": " (.getMessage x)))
|
||||||
(throw x)))
|
(throw x)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue