   [resp filename]
   (response/header resp "Content-Disposition" (format "attachment; filename=%s" filename)))
 
+(defn- download-response
+  "Create a response with proper content-type and content-disposition
+  for given `file`, `mime-type` and `filename`"
+  [file mime-type filename]
+  (-> file
+   response/response
+   (response/content-type mime-type)
+   (content-disposition filename)))
+
 (defn- pdf-response
   "Create a response with proper content-type and content-disposition
   for given pdf `file` and `filename`"
   [file filename]
-  (-> file
-   response/response
-   (response/content-type "application/pdf")
-   (content-disposition (str filename ".pdf"))))
+  (download-response file "application/pdf" (str filename ".pdf")))
 
 (defn- xml-response
   "Create a response with proper content-type and content-disposition
   for given `body` and `filename`"
   [body filename]
-  (-> body
-   response/response
-   (response/content-type "application/xml")
-   (content-disposition (str filename ".xml"))))
+  (download-response body "application/xml" (str filename ".xml")))
+
+(defn- text-response
+  "Create a response with proper content-type and content-disposition
+  for given `body` and `filename`"
+  [body filename]
+  (download-response body "text/plain" (str filename ".txt")))
 
 (defn neu-im-sortiment [year issue]
   (let [filename (file-name :catalog-all year issue)

    {:class "form-control"} "fmt"
    [["PDF" :pdf]
     ["Grossdruck" :grossdruck]
     ["Braille" :braille]]
    selected)])

(defn custom-form [request year issue & [errors]]

             [common :refer [translations]]
             [dtbook :as layout.dtbook]
             [fop :as layout.fop]
             [obi :as layout.obi]
             [text :as layout.text]]
            [catalog.web.layout :as layout]
            [cemerick.friend :as friend]
            [clj-time
