Skip to content

Instantly share code, notes, and snippets.

@t0yv0
Created January 21, 2011 13:32
Show Gist options
  • Save t0yv0/789678 to your computer and use it in GitHub Desktop.
Save t0yv0/789678 to your computer and use it in GitHub Desktop.
namespace WebSharperSiteletsProject
open System
open System.IO
open System.Web
open IntelliFactory.Html
open IntelliFactory.WebSharper
open IntelliFactory.WebSharper.Sitelets
type Action =
| Home
| AboutUs
module View =
let ( => ) a b =
A [HRef b] -< [Text a]
let Page title body =
PageContent <| fun ctx ->
{
Page.Default with
Title = Some title
Body =
H1 [Text title]
::
UL [
LI ["Home" => ctx.Link Home]
LI ["AboutUs" => ctx.Link AboutUs]
]
::
body
}
module Client =
open IntelliFactory.WebSharper.Html
[<JavaScript>]
let Button label =
Button [Text label]
|>! OnClick (fun button _ ->
button.Text <- "CLICKED")
type ButtonControl(label: string) =
inherit Web.Control()
new () = new ButtonControl("unlabelled")
[<JavaScript>]
override this.Body = Button label :> _
module Site =
let HomePage =
View.Page "Home" [
Div [Text "Welcome to our website!"]
]
|> Sitelet.Content "/" Home
let AboutUsPage =
View.Page "About Us" [
Div [Text "TODO: describe us."]
Div [new Client.ButtonControl("Click me!")]
]
|> Sitelet.Content "/about" AboutUs
let Main =
Sitelet.Sum [
HomePage
AboutUsPage
]
type Website() =
interface IWebsite<Action> with
member this.Actions = []
member this.Sitelet = Site.Main
[<assembly: WebsiteAttribute(typeof<Website>)>]
do ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment