-Paket -TutorialFiles
Removed Paket files (could not get reliable builds; we may revisit once .NET core has stablizied); removed extraneous tutorial files; currently blocked getting Auth0 Lock to load from within Aurelia app
This commit is contained in:
@@ -78,8 +78,7 @@ let schemeHostPort (req : HttpRequest) =
|
||||
/// Authorization functions
|
||||
module Auth =
|
||||
|
||||
open Views
|
||||
|
||||
(*
|
||||
let exchangeCodeForToken code = context (fun ctx ->
|
||||
async {
|
||||
let client = AuthenticationApiClient (Uri (sprintf "https://%s" cfg.Auth0.Domain))
|
||||
@@ -120,7 +119,7 @@ module Auth =
|
||||
match ctx |> HttpContext.state with
|
||||
| Some state -> state.set "auth-key" null
|
||||
| _ -> succeed
|
||||
>=> FOUND (sprintf "%s/" (schemeHostPort ctx.request)))
|
||||
>=> FOUND (sprintf "%s/" (schemeHostPort ctx.request))) *)
|
||||
|
||||
let cw (x : string) = Console.WriteLine x
|
||||
|
||||
@@ -152,7 +151,7 @@ module Auth =
|
||||
| _ -> Writers.setUserData "user" None)
|
||||
|
||||
/// Create a user context for the currently assigned user
|
||||
let userCtx ctx = { Id = ctx.userState.["user"] :?> string option }
|
||||
//let userCtx ctx = { Id = ctx.userState.["user"] :?> string option }
|
||||
|
||||
/// Read an item from the user state, downcast to the expected type
|
||||
let read ctx key : 'value =
|
||||
@@ -164,17 +163,17 @@ let dataCtx () =
|
||||
|
||||
/// Return an HTML page
|
||||
let html ctx content =
|
||||
Views.page (Auth.userCtx ctx) content
|
||||
""//Views.page (Auth.userCtx ctx) content
|
||||
|
||||
/// Home page
|
||||
let viewHome = warbler (fun ctx -> OK (Views.home |> html ctx))
|
||||
let viewHome = warbler (fun ctx -> OK ("" (*Views.home*) |> html ctx))
|
||||
|
||||
/// Journal page
|
||||
let viewJournal =
|
||||
context (fun ctx ->
|
||||
use dataCtx = dataCtx ()
|
||||
let reqs = Data.Requests.allForUser (defaultArg (read ctx "user") "") dataCtx
|
||||
OK (Views.journal reqs |> html ctx))
|
||||
OK ("" (*Views.journal reqs*) |> html ctx))
|
||||
|
||||
let idx =
|
||||
context (fun ctx ->
|
||||
@@ -187,8 +186,8 @@ let app =
|
||||
>=> choose [
|
||||
path Route.home >=> Files.browseFileHome "index.html"
|
||||
path Route.journal >=> viewJournal
|
||||
path Route.User.logOn >=> Auth.handleSignIn
|
||||
path Route.User.logOff >=> Auth.handleSignOut
|
||||
//path Route.User.logOn >=> Auth.handleSignIn
|
||||
//path Route.User.logOff >=> Auth.handleSignOut
|
||||
Writers.setHeader "Cache-Control" "no-cache" >=> Files.browseHome
|
||||
NOT_FOUND "Page not found."
|
||||
]
|
||||
@@ -214,14 +213,7 @@ let main argv =
|
||||
// Establish the data environment
|
||||
//liftDep getConn (Data.establishEnvironment >> Async.RunSynchronously)
|
||||
//|> run deps
|
||||
let writeKey key = File.WriteAllText ("key.txt", key)
|
||||
Crypto.generateKey Crypto.KeySize
|
||||
|> Convert.ToBase64String
|
||||
|> writeKey
|
||||
|
||||
ensureDatabase ()
|
||||
startWebServer suaveCfg app
|
||||
0
|
||||
(*
|
||||
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2Rqcy1jb25zdWx0aW5nLmF1dGgwLmNvbS8iLCJzdWIiOiJ3aW5kb3dzbGl2ZXw3OTMyNGZhMTM4MzZlZGNiIiwiYXVkIjoiT2YyczBSUUNRM210M2R3SWtPQlk1aDg1SjlzWGJGMm4iLCJleHAiOjE0OTI5MDc1OTAsImlhdCI6MTQ5Mjg3MTU5MH0.61JPm3Hz7XW-iaSq8Esv1cajQPbK0o9L5xz-RHIYq9g
|
||||
*)
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<VersionPrefix>0.8.1</VersionPrefix>
|
||||
@@ -17,7 +17,6 @@
|
||||
<Compile Include="Migrations/20170104023341_InitialDb.fs" />
|
||||
<Compile Include="Migrations/DataContextModelSnapshot.fs" />
|
||||
<Compile Include="Route.fs" />
|
||||
<Compile Include="Views.fs" />
|
||||
<Compile Include="App.fs" />
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -27,9 +26,31 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\..\packages\FSharp.NET.Sdk\build\FSharp.NET.Core.Sdk.targets" />
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
|
||||
<!-- Import Project="..\..\.paket\Paket.Restore.targets" / -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Auth0.AuthenticationApi">
|
||||
<Version>4.1.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FSharp.Core">
|
||||
<Version>4.1.17</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="FSharp.NET.Sdk">
|
||||
<Version>1.0.5</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="jose-jwt">
|
||||
<Version>2.3.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
<Version>10.0.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL">
|
||||
<Version>1.1.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Suave">
|
||||
<Version>2.1.0</Version>
|
||||
</PackageReference>
|
||||
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
113
src/api/Views.fs
113
src/api/Views.fs
@@ -1,113 +0,0 @@
|
||||
module MyPrayerJournal.Views
|
||||
|
||||
//open Suave.Html
|
||||
open Suave.Xml
|
||||
|
||||
type UserContext = { Id: string option }
|
||||
|
||||
[<AutoOpen>]
|
||||
module Tags =
|
||||
/// Generate a meta tag
|
||||
let meta attr = tag "meta" attr empty
|
||||
|
||||
/// Generate a link to a stylesheet
|
||||
let stylesheet url = linkAttr [ "rel", "stylesheet"; "href", url ]
|
||||
|
||||
let aAttr attr x = tag "a" attr (flatten x)
|
||||
let a = aAttr []
|
||||
let buttonAttr attr x = tag "button" attr (flatten x)
|
||||
let button = buttonAttr []
|
||||
|
||||
let footerAttr attr x = tag "footer" attr (flatten x)
|
||||
let footer = footerAttr []
|
||||
let ulAttr attr x = tag "ul" attr (flatten x)
|
||||
let ul = ulAttr []
|
||||
|
||||
/// Used to prevent a self-closing tag where we need no text
|
||||
let noText = text ""
|
||||
let navLinkAttr attr url linkText = aAttr (("href", url) :: attr) [ text linkText ]
|
||||
|
||||
let navLink = navLinkAttr []
|
||||
|
||||
let jsLink func linkText = navLinkAttr [ "onclick", func ] "javascript:void(0)" linkText
|
||||
|
||||
/// Create a link to a JavaScript file
|
||||
let js src = scriptAttr [ "src", src ] [ noText ]
|
||||
|
||||
[<AutoOpen>]
|
||||
module PageComponents =
|
||||
let prependDoctype document = sprintf "<!DOCTYPE html>\n%s" document
|
||||
let render = xmlToString >> prependDoctype
|
||||
|
||||
let navigation userCtx =
|
||||
[
|
||||
match userCtx.Id with
|
||||
| Some _ ->
|
||||
yield navLink Route.journal "Journal"
|
||||
yield navLink Route.User.logOff "Log Off"
|
||||
| _ -> yield jsLink "mpj.signIn()" "Log On"
|
||||
|
||||
]
|
||||
|> List.map (fun x -> tag "li" [] x)
|
||||
let pageHeader userCtx =
|
||||
divAttr [ "class", "navbar navbar-inverse navbar-fixed-top" ] [
|
||||
divAttr [ "class", "container" ] [
|
||||
divAttr [ "class", "navbar-header" ] [
|
||||
buttonAttr [ "class", "navbar-toggle"; "data-toggle", "collapse"; "data-target", ".navbar-collapse" ] [
|
||||
spanAttr [ "class", "sr-only" ] (text "Toggle navigation")
|
||||
spanAttr [ "class", "icon-bar" ] noText
|
||||
spanAttr [ "class", "icon-bar" ] noText
|
||||
spanAttr [ "class", "icon-bar" ] noText
|
||||
]
|
||||
navLinkAttr [ "class", "navbar-brand" ] "/" "myPrayerJournal"
|
||||
]
|
||||
divAttr [ "class", "navbar-collapse collapse" ] [
|
||||
ulAttr [ "class", "nav navbar-nav navbar-right" ] (navigation userCtx)
|
||||
]
|
||||
]
|
||||
]
|
||||
let pageFooter =
|
||||
footerAttr [ "class", "mpj-footer" ] [
|
||||
pAttr [ "class", "text-right" ] [
|
||||
text "myPrayerJournal v0.8.1"
|
||||
]
|
||||
]
|
||||
let row = divAttr [ "class", "row" ]
|
||||
|
||||
let fullRow xml =
|
||||
row [ divAttr [ "class", "col-xs-12" ] xml ]
|
||||
|
||||
/// Display a page
|
||||
let page userCtx content =
|
||||
html [
|
||||
head [
|
||||
meta [ "charset", "UTF-8" ]
|
||||
meta [ "name", "viewport"; "content", "width=device-width, initial-scale=1" ]
|
||||
title "myPrayerJournal"
|
||||
stylesheet "https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css"
|
||||
stylesheet "/content/styles.css"
|
||||
stylesheet "https://fonts.googleapis.com/icon?family=Material+Icons"
|
||||
]
|
||||
body [
|
||||
pageHeader userCtx
|
||||
divAttr [ "class", "container body-content" ] [
|
||||
content
|
||||
pageFooter
|
||||
]
|
||||
js "https://cdn.auth0.com/js/lock/10.14/lock.min.js"
|
||||
js "/js/mpj.js"
|
||||
]
|
||||
]
|
||||
|> render
|
||||
|
||||
let home =
|
||||
fullRow [
|
||||
p [ text " "]
|
||||
p [ text "myPrayerJournal is a place where individuals can record their prayer requests, record that they prayed for them, update them as God moves in the situation, and record a final answer received on that request. It will also allow individuals to review their answered prayers." ]
|
||||
p [ text "This site is currently in very limited alpha, as it is being developed with a core group of test users. If this is something you are interested in using, check back around mid-February 2017 to check on the development progress." ]
|
||||
]
|
||||
|
||||
let journal (reqs : Request list) =
|
||||
fullRow [
|
||||
p [ text "journal goes here" ]
|
||||
]
|
||||
@@ -1,6 +0,0 @@
|
||||
Auth0.AuthenticationApi
|
||||
jose-jwt
|
||||
Newtonsoft.Json
|
||||
Npgsql.EntityFrameworkCore.PostgreSQL
|
||||
Suave
|
||||
Suave.Experimental
|
||||
Reference in New Issue
Block a user