Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

A hasty implementation of a server

Just open http://localhost:3003/03 to browse the third lecture.

Apart from that, the code needs some serious reworking :)
  • Loading branch information...
commit b7c7d9c60d65fbc05f126b16c771769e5bd79f47 1 parent 3d42d47
@skanev skanev authored
Showing with 26 additions and 0 deletions.
  1. +5 −0 project.clj
  2. +10 −0 src/lectures/compile.clj
  3. +11 −0 src/lectures/server.clj
View
5 project.clj
@@ -5,8 +5,13 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.0"]
[org.blancas/kern "0.5.0"]
+ [ring "1.2.1"]
+ [compojure "1.1.6"]
[hiccup "1.0.2"]
[clj-yaml "0.4.0"]
[me.raynes/fs "1.4.0"]
[cheshire "5.0.2"]]
+ :plugins [[lein-ring "0.8.10"]]
+ :ring {:handler lectures.server/app
+ :port 3003}
:main lectures.core)
View
10 src/lectures/compile.clj
@@ -46,6 +46,16 @@
(fs/copy-dir "resources/js" target-dir)
(fs/copy "lectures/index.yml" (target-file-name "index.yml")))
+(defn compiled
+ "Compiles a single lecture and returns the generated HTML"
+ [number]
+ (let [index (read-lectures-index)
+ lecture-key (-> number str keyword)
+ {:keys [title date lecture-ast slug]} (lecture-key index)
+ source-file (str "lectures/" slug ".lecture")
+ lecture-ast (-> source-file slurp parse)]
+ (generate-lecture title date lecture-ast)))
+
(defn recompile
"Recompiles a single lecture."
[number]
View
11 src/lectures/server.clj
@@ -0,0 +1,11 @@
+(ns lectures.server
+ (:use compojure.core
+ [lectures.compile :only (compiled)])
+ (:require [compojure.route :as route]))
+
+(defroutes lecture-routes
+ (GET "/:lecture" [lecture] (compiled lecture))
+ (route/resources "/" {:root nil})
+ (route/not-found "This needs <strong>way</strong> more work ;)"))
+
+(def app (routes lecture-routes))
Please sign in to comment.
Something went wrong with that request. Please try again.