Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vincent Landgraf
committed
Apr 29, 2010
1 parent
4dfde73
commit 7caab5d
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$LOAD_PATH.unshift(File.join("..", "..", "lib")) | ||
require "rlisp" | ||
|
||
interpreter = Lisp::Interpreter.new | ||
interpreter.import("web.lisp") | ||
|
||
app =lambda do |env| | ||
[ | ||
200, | ||
{'Content-Type' => 'text/html'}, | ||
interpreter.eval([:rack_handler, env]) | ||
] | ||
end | ||
|
||
run app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
;; Helper | ||
|
||
(defmacro (defun) | ||
(defun name parameter expr) | ||
(label name (lambda parameter expr))) | ||
|
||
(defun tag (name text) (string "<" name ">" text "</" name ">")) | ||
|
||
(defun tag_class (name class text) ( | ||
string "<" name " class='" class "'>" text "</" name ">")) | ||
|
||
(defun h1 (text) (tag h1 text)) | ||
|
||
(defun para (text) (tag p text)) | ||
|
||
(defun div (class text) (tag_class div class text)) | ||
|
||
(defun pre (text) (tag pre text)) | ||
|
||
(defun html (title text) | ||
(string | ||
(tag html | ||
(string | ||
(tag head (tag "title" title)) | ||
(tag body text) | ||
) | ||
) | ||
) | ||
) | ||
|
||
;; Website | ||
|
||
(setq TITLE "RLISP Webserver") | ||
|
||
(defun template (content) | ||
(html TITLE | ||
(string | ||
(div container content) | ||
) | ||
) | ||
) | ||
|
||
(defun start_page(env) | ||
(template | ||
(string | ||
(h1 TITLE) | ||
(para "Welcome to the first rlisp site!") | ||
(para "It's very cool") | ||
(para (string (+ 23 42))) | ||
) | ||
) | ||
) | ||
|
||
(defun rack_handler (env) (start_page env)) |