Permalink
Browse files

Switching to full server (with connection id) & adding favicon.

Though there seem to be some problems with the favicon... will have
to investigate.
  • Loading branch information...
1 parent 13f37dc commit 98f4dfb9847250c5eb710d4ee3bee3f283795698 @akoprow akoprow committed Mar 31, 2011
Showing with 28 additions and 15 deletions.
  1. +1 −0 src/.gitignore
  2. BIN src/img/favicon.png
  3. +24 −12 src/main.opa
  4. +3 −3 src/pages.opa
View
@@ -1,3 +1,4 @@
+opa-debug
_tracks
_build
*.exe
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -9,18 +9,30 @@ package mlstate.twopenny
* {1 Server definition, URL dispatching}
**/
+twopenny_page((title, body))(_conn) =
+ Resource.full_page(title, body,
+ <link rel="icon" type="image/png" href="./img/favicon.png" />,
+ {success}, [])
+
+urls : Parser.general_parser(connexion_id -> resource) =
+ parser
+ | "user/" user=(.*) ->
+ Text.to_string(user)
+ |> User.mk_ref(_)
+ |> Pages.user_page(_)
+ |> twopenny_page(_)
+ | "label/" label=(.*) ->
+ Text.to_string(label)
+ |> Label.mk_ref(_)
+ |> Pages.label_page(_)
+ |> twopenny_page(_)
+ | .* ->
+ Pages.main_page()
+ |> twopenny_page(_)
+
+resources = @static_include_directory("img")
+
/**
* The Twopenny server
*/
-server =
- urls = parser
- | "/" -> Pages.main_page()
- | "/user/" user=(.*) ->
- Text.to_string(user)
- |> User.mk_ref(_)
- |> Pages.user_page(_)
- | "/label/" label=(.*) ->
- Text.to_string(label)
- |> Label.mk_ref(_)
- |> Pages.label_page(_)
- Server.simple_server(urls)
+server = Server.make(Resource.add_auto_server(resources, urls))
View
@@ -17,7 +17,7 @@ Pages = {{
</>
main_page() =
- html("Twopenny", unimplemented)
+ ("Twopenny", unimplemented)
@client setup_msg_updates(_) =
show_new_message(msg) =
@@ -33,9 +33,9 @@ Pages = {{
{submission}
<div id=#msgs onready={setup_msg_updates} />
</>
- html("Twopenny :: {user}", content)
+ ("Twopenny :: {user}", content)
label_page(label) =
- html("Twopenny :: {label}", unimplemented)
+ ("Twopenny :: {label}", unimplemented)
}}

0 comments on commit 98f4dfb

Please sign in to comment.