Multi-tweet responses in web interface.

This commit is contained in:
Simon Brooke 2019-03-09 12:03:23 +00:00
parent ab873fb6c9
commit 80e850ef04
3 changed files with 21 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

View file

@ -2,6 +2,7 @@
(:require [cemerick.url :refer (url-decode)]
[clojure.tools.logging :as log]
[compojure.api.sweet :refer :all]
[ireadit.splitter :refer [split-into-tweets]]
[ireadit.tesseractor :refer [ocr]]
[ring.util.http-response :refer :all]
[schema.core :as s]))
@ -42,9 +43,9 @@
:tags ["tesseractor"]
(POST "/ocr/:uri" []
:return String
:return {:tweets [String]}
:path-params [uri :- String]
(ok (let [decoded (url-decode uri)
text (ocr decoded)]
(log/info (str "ocr '" decoded "' => '" text "'"))
text))))))
tweets (split-into-tweets (ocr decoded))]
(log/info (str "ocr '" decoded "' => '" tweets "'"))
{:tweets tweets}))))))

View file

@ -17,7 +17,6 @@
(assoc m :disabled "disabled")
m))
(defn form-page []
[:div.container-fluid {:id "main-container"}
[:h1 "Transcribe the text of an image"]
@ -35,10 +34,20 @@
[:div.col-sm-9
[b/Button (maybe-disable {:id "send" :on-click #(rf/dispatch [:fetch-transcription])}) "Transcribe!"]]]
[b/Row]
[b/Row
[:div.col-sm-12 {:class (if @(rf/subscribe [:transcription]) "visible" "hidden")}
[b/Alert {:color "success"} @(rf/subscribe [:transcription])]]]
[b/Row
[:div.col-sm-12 {:class (if @(rf/subscribe [:error]) "visible" "hidden")}
[b/Alert {:color "warning"} @(rf/subscribe [:error])]]]]])
(map #(vector
:div.tweet {:class "row"}
[:div.col-sm-1
[:img {:src "/img/ireadit.png"
:width "64"
:height "64"
:class "rounded-circle"
:alt "Please don't post text as images to social media"}]]
[:div.col-sm-1]
[:div.col-sm-10 [:div [:b "IReadIt"]] %])
(let [m @(rf/subscribe [:transcription])]
(when (map? m) (m "tweets"))))
[b/Collapse {:class (if @(rf/subscribe [:error]) "col-sm-12 show" "hide")}
[b/Alert {:color "warning"} @(rf/subscribe [:error])]]]])
(vector 'div.foo "foo")