           (fn [request]
             (:script (st/story-match-by request)))))
 
+(defn wrap-parse-script [handler]
+  (fn [request]
+    (let [script (get-in request [:params :script])
+          script (clojure.string/replace script "\r" "")
+          data (js/parse-script script)
+          request (-> request
+                      (assoc-in [:params :script] script)
+                      (assoc-in [:params :data] data))]
+      (handler request))))
+
 ;; TODO: GET, POST and others actually can take a 
 ;; function directly instead of an expresssion.
 ;; Thus, rewrite to obliterate redundancies.

  (when-not (sess/logged-in? request)
    {:error "You must be logged in"}))

(def story-ownership-rules
  (one-by-one
    user-is-logged-in
    user-owns-story))

(def story-creation-rules
  (one-by-one

    [storemi.session :as sess]
    [storemi.models.story :as st]
    [storemi.urlfor :as url]
    [storemi.js :as js]
    [storemi.routes.policies :refer
     [enforce-story
      enforce-user
