Multi-tweet responses in web interface.
This commit is contained in:
		
							parent
							
								
									ab873fb6c9
								
							
						
					
					
						commit
						80e850ef04
					
				
							
								
								
									
										
											BIN
										
									
								
								resources/public/img/ireadit.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								resources/public/img/ireadit.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 70 KiB | 
|  | @ -2,6 +2,7 @@ | ||||||
|   (:require [cemerick.url :refer (url-decode)] |   (:require [cemerick.url :refer (url-decode)] | ||||||
|             [clojure.tools.logging :as log] |             [clojure.tools.logging :as log] | ||||||
|             [compojure.api.sweet :refer :all] |             [compojure.api.sweet :refer :all] | ||||||
|  |             [ireadit.splitter :refer [split-into-tweets]] | ||||||
|             [ireadit.tesseractor :refer [ocr]] |             [ireadit.tesseractor :refer [ocr]] | ||||||
|             [ring.util.http-response :refer :all] |             [ring.util.http-response :refer :all] | ||||||
|             [schema.core :as s])) |             [schema.core :as s])) | ||||||
|  | @ -42,9 +43,9 @@ | ||||||
|             :tags ["tesseractor"] |             :tags ["tesseractor"] | ||||||
| 
 | 
 | ||||||
|             (POST "/ocr/:uri" [] |             (POST "/ocr/:uri" [] | ||||||
|                   :return       String |                   :return      {:tweets [String]} | ||||||
|                   :path-params [uri :- String] |                   :path-params [uri :- String] | ||||||
|                   (ok (let [decoded (url-decode uri) |                   (ok (let [decoded (url-decode uri) | ||||||
|                             text (ocr decoded)] |                             tweets (split-into-tweets (ocr decoded))] | ||||||
|                         (log/info (str "ocr '" decoded "' => '" text "'")) |                         (log/info (str "ocr '" decoded "' => '" tweets "'")) | ||||||
|                         text)))))) |                         {:tweets tweets})))))) | ||||||
|  |  | ||||||
|  | @ -17,7 +17,6 @@ | ||||||
|     (assoc m :disabled "disabled") |     (assoc m :disabled "disabled") | ||||||
|     m)) |     m)) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| (defn form-page [] | (defn form-page [] | ||||||
|   [:div.container-fluid {:id "main-container"} |   [:div.container-fluid {:id "main-container"} | ||||||
|    [:h1 "Transcribe the text of an image"] |    [:h1 "Transcribe the text of an image"] | ||||||
|  | @ -35,10 +34,20 @@ | ||||||
|      [:div.col-sm-9 |      [:div.col-sm-9 | ||||||
|       [b/Button (maybe-disable {:id "send" :on-click #(rf/dispatch [:fetch-transcription])}) "Transcribe!"]]] |       [b/Button (maybe-disable {:id "send" :on-click #(rf/dispatch [:fetch-transcription])}) "Transcribe!"]]] | ||||||
|     [b/Row] |     [b/Row] | ||||||
|     [b/Row |      (map #(vector | ||||||
|      [:div.col-sm-12 {:class (if @(rf/subscribe [:transcription]) "visible" "hidden")} |             :div.tweet {:class "row"} | ||||||
|       [b/Alert {:color "success"} @(rf/subscribe [:transcription])]]] |             [:div.col-sm-1 | ||||||
|     [b/Row |                    [:img {:src "/img/ireadit.png" | ||||||
|      [:div.col-sm-12 {:class (if @(rf/subscribe [:error]) "visible" "hidden")} |                           :width "64" | ||||||
|       [b/Alert {:color "warning"} @(rf/subscribe [:error])]]]]]) |                           :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") | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue