001 (ns ^{:doc "Route which handles the saving of world state the client."
002 :author "Simon Brooke"}
003 mw-ui.routes.save
004 (:require [clojure.pprint :refer [pprint]]
005 [noir.session :as session]
006 [noir.response :as response]))
007
008 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
009 ;;;;
010 ;;;; mw-ui: a servlet user/visualisation interface for MicroWorld.
011 ;;;;
012 ;;;; This program is free software; you can redistribute it and/or
013 ;;;; modify it under the terms of the GNU General Public License
014 ;;;; as published by the Free Software Foundation; either version 2
015 ;;;; of the License, or (at your option) any later version.
016 ;;;;
017 ;;;; This program is distributed in the hope that it will be useful,
018 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
019 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020 ;;;; GNU General Public License for more details.
021 ;;;;
022 ;;;; You should have received a copy of the GNU General Public License
023 ;;;; along with this program; if not, write to the Free Software
024 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
025 ;;;; USA.
026 ;;;;
027 ;;;; Copyright (C) 2014 Simon Brooke
028 ;;;;
029 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
030
031
032 (defn save-page
033 "Save the current world to the browser, using our own custom mime-type in
034 an attempt to prevent the browser trying to do anything clever with it.
035 Note that it is saved as a raw Clojure data structure, not as XML or
036 any proprietary format."
037 []
038 (response/content-type
039 "application/journeyman-mwm; charset=utf-8"
040 (with-out-str (pprint (session/get :world)))))
041