 ;;    (content-type "text/html; charset=UTF-8")))
 
 (defn launch []
-   (run-jetty app {:port 18080 :join? false :route "public"}))
+  (run-jetty app {:port 18080 :join? false :route "public"}))
 
 (defn -main
   "启动web应用程序"

(defn global-response [resp]
  (-> resp response (content-type "text/html; charset=UTF-8")))

(defn home [req] (render-file "home.html"
                      {
                       :title "Home"
                       :nav-items [{:label "Home" :url "/"}
                                   {:label "New Product" :url "/new-product"}
                                   {:label "About" :url "/about"}]
                       :product-list-header ["图片" "名称" "数量" "尺寸" "型号"  "颜色"  "详情"]
                       :product-list (let [conn (mg/connect)
                                           db   (mg/get-db conn "sls")
                                           u "sls"
                                           p (.toCharArray (str 666666))
                                           coll "products"]
                                       (mc/find-maps db coll))
                       }))

(defroutes main-routes
  (route/files "/")
  (GET "/" [req] (home req))
  (GET "/new-product" [req] (render-file "new-product.html" {:title (json/write-str req)}))
  (GET "/about" [] (response "This is a private system."))
  (route/not-found "Page not found")
  )

(def app (compojure.core/routes main-routes))


;; sudo mongod

(let [conn (mg/connect)
      ;; mongodb://[username:password@]host1[:port1][,host2[:port2],…[,hostN[:portN]]][/[database][?options]]
      db   (mg/connect-via-uri (str "mongodb://sls:666666@localhost/sls"))
      u "sls"
      p (.toCharArray (str 666666))
      coll "products"]
  
  ;; (mg/authenticate db u p)
  ;; (mc/insert-and-return db "products" {:name "ksj" :color "黄" :count 50 :size 40 :label "default"})
  ;; (mc/find db coll {:count {"$gt" 10 "$lt" 99}})
