-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
0dfc1f5
commit a238f33
Showing
6 changed files
with
96 additions
and
2 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,26 @@ | ||
module FreyaMusicStore.Albums | ||
|
||
open System | ||
|
||
open Arachne.Http | ||
|
||
open Freya.Core | ||
open Freya.Router | ||
open Freya.Machine | ||
open Freya.Machine.Extensions.Http | ||
|
||
type Albums = | ||
{ Albums : Album.AlbumDetails [] } | ||
|
||
let get = | ||
freya { | ||
let ctx = Db.getContext() | ||
let albums = Db.getAlbumsDetails ctx |> Array.map Album.AlbumDetails.fromDb | ||
return! write ("albums", { Albums = albums } ) | ||
} | ||
|
||
let pipe = | ||
freyaMachine { | ||
including common | ||
methodsSupported ( freya { return [ GET ] } ) | ||
handleOk (fun _ -> get) } |> FreyaMachine.toPipeline |
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
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
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
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,59 @@ | ||
@{ | ||
Layout = "mylayout"; | ||
} | ||
|
||
@helper Truncate(string input, int length) | ||
{ | ||
if (input.Length <= length) | ||
{ | ||
@input | ||
} | ||
else | ||
{ | ||
@input.Substring(0, length)<text>...</text> | ||
} | ||
} | ||
|
||
@section Main | ||
{ | ||
<h2>Index</h2> | ||
<table> | ||
<tr> | ||
<th> | ||
Genre | ||
</th> | ||
<th> | ||
Artist | ||
</th> | ||
<th> | ||
Title | ||
</th> | ||
<th> | ||
Price | ||
</th> | ||
<th></th> | ||
</tr> | ||
|
||
@foreach (var item in Model.Albums) | ||
{ | ||
<tr> | ||
<td> | ||
@item.Genre | ||
</td> | ||
<td> | ||
@Truncate(item.Artist, 25) | ||
</td> | ||
<td> | ||
@Truncate(item.Title, 25) | ||
</td> | ||
<td> | ||
@item.Price | ||
</td> | ||
<td> | ||
|
||
</td> | ||
</tr> | ||
} | ||
|
||
</table> | ||
} |
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