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
let AboutUsPage = | |
View.Page "About Us" [ | |
Div [Text "TODO: describe us."] | |
Div [new Client.ButtonControl("Click me!")] | |
] | |
|> Sitelet.Content "/about" AboutUs |
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
namespace WebSharperSiteletsProject | |
open System | |
open System.IO | |
open System.Web | |
open IntelliFactory.Html | |
open IntelliFactory.WebSharper | |
open IntelliFactory.WebSharper.Sitelets | |
type Action = |
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
type Id = int | |
type Action = | |
| ShowRecentBlogs | |
| CreateBlog | |
| ReadBlog of Id | |
| UpdateBlog of Id | |
| DeleteBlog of Id |
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
let Router : Router<Action> = | |
let route = function | |
| GET (_, SPLIT_BY '/' []) -> | |
Some ShowRecentBlogs | |
| GET (_, SPLIT_BY '/' ["create"]) -> | |
Some CreateBlog | |
| GET (_, SPLIT_BY '/' ["read"; INT id]) -> | |
Some (ReadBlog id) | |
| GET (_, SPLIT_BY '/' ["update"; INT id]) -> | |
Some (UpdateBlog id) |
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
let Router : Router<Action> = Router.Infer() |
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
ShowRecentBlogs <=> /ShowRecentBlogs | |
CreateBlog <=> /CreateBlog | |
ReadBlog $x <=> /ReadBlog/$x | |
UpdateBlog $x <=> /UpdateBlog/$x | |
DeleteBlog $x <=> /DeleteBlog/$x | |
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
let Router : Router<Action> = | |
Router.Table [ShowRecentBlogs, "/"] | |
<|> Router.Infer() |
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
let Controller = | |
let handle = function | |
| ShowRecentBlogs -> | |
let blogs = Model.WithBlogs <| fun db -> db.GetRecentBlogs() | |
View.ShowRecentBlogs blogs | |
| CreateBlog -> | |
View.CreateBlog () | |
| ReadBlog id -> | |
let blog = Model.WithBlogs <| fun db -> db.ReadBlog id | |
match blog with |
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
let Main : Sitelet<Action> = | |
{ | |
Controller = Controller | |
Router = Router | |
} |
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
module Client = | |
open IntelliFactory.WebSharper | |
open IntelliFactory.WebSharper.Formlet | |
[<Rpc>] | |
let CreateBlog blog = | |
Model.WithBlogs <| fun db -> | |
db.CreateBlog { blog with Date = DateTime.UtcNow } | |
[<Rpc>] |