Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
Update to F# 5 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljsummers committed Nov 16, 2020
1 parent e3583f9 commit b0d3bd4
Show file tree
Hide file tree
Showing 24 changed files with 103 additions and 118 deletions.
6 changes: 3 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project>
<PropertyGroup>
<AssemblyVersion>7.4.2.0</AssemblyVersion>
<FileVersion>7.4.2.0</FileVersion>
<AssemblyVersion>7.5.0.0</AssemblyVersion>
<FileVersion>7.5.0.0</FileVersion>
<Authors>danieljsummers</Authors>
<Company>Bit Badger Solutions</Company>
<Version>7.4.2</Version>
<Version>7.5.0</Version>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/PrayerTracker.Data/DataAccess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ type AppDbContext with
}
let! grps = q.ToListAsync ()
return grps
|> Seq.map (fun grp -> grp.smallGroupId.ToString "N", sprintf "%s | %s" grp.church.name grp.name)
|> Seq.map (fun grp -> grp.smallGroupId.ToString "N", $"{grp.church.name} | {grp.name}")
|> List.ofSeq
}

Expand Down
6 changes: 1 addition & 5 deletions src/PrayerTracker.Data/PrayerTracker.Data.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -20,8 +20,4 @@
<PackageReference Include="TaskBuilder.fs" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.7.0" />
</ItemGroup>

</Project>
6 changes: 1 addition & 5 deletions src/PrayerTracker.Tests/PrayerTracker.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -26,8 +26,4 @@
<ProjectReference Include="..\PrayerTracker\PrayerTracker.fsproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.7.0" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/PrayerTracker.UI/Church.fs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ let maintain (churches : Church list) (stats : Map<string, ChurchStats>) ctx vi
churches
|> List.map (fun ch ->
let chId = flatGuid ch.churchId
let delAction = sprintf "/web/church/%s/delete" chId
let delAction = $"/web/church/{chId}/delete"
let delPrompt = s.["Are you sure you want to delete this {0}? This action cannot be undone.",
sprintf "%s (%s)" (s.["Church"].Value.ToLower ()) ch.name]
$"""{s.["Church"].Value.ToLower ()} ({ch.name})"""]
tr [] [
td [] [
a [ _href (sprintf "/web/church/%s/edit" chId); _title s.["Edit This Church"].Value ] [ icon "edit" ]
a [ _href $"/web/church/{chId}/edit"; _title s.["Edit This Church"].Value ] [ icon "edit" ]
a [ _href delAction
_title s.["Delete This Church"].Value
_onclick (sprintf "return PT.confirmDelete('%s','%A')" delAction delPrompt) ]
_onclick $"return PT.confirmDelete('{delAction}','{delPrompt}')" ]
[ icon "delete_forever" ]
]
td [] [ str ch.name ]
Expand All @@ -96,7 +96,7 @@ let maintain (churches : Church list) (stats : Map<string, ChurchStats>) ctx vi
]
[ div [ _class "pt-center-text" ] [
br []
a [ _href (sprintf "/web/church/%s/edit" emptyGuid); _title s.["Add a New Church"].Value ]
a [ _href $"/web/church/{emptyGuid}/edit"; _title s.["Add a New Church"].Value ]
[ icon "add_circle"; rawText " &nbsp;"; locStr s.["Add a New Church"] ]
br []
br []
Expand Down
8 changes: 4 additions & 4 deletions src/PrayerTracker.UI/CommonFunctions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let space = rawText " "
let icon name = i [ _class "material-icons" ] [ rawText name ]

/// Generate a Material Design icon, specifying the point size (must be defined in CSS)
let iconSized size name = i [ _class (sprintf "material-icons md-%i" size) ] [ rawText name ]
let iconSized size name = i [ _class $"material-icons md-{size}" ] [ rawText name ]

/// Generate a CSRF prevention token
let csrfToken (ctx : HttpContext) =
Expand Down Expand Up @@ -72,7 +72,7 @@ let namedColorList name selected attrs (s : IStringLocalizer) =
|> Seq.map (fun color ->
let (colorName, dispText, txtColor) = color
option [ yield _value colorName
yield _style (sprintf "background-color:%s;color:%s;" colorName txtColor)
yield _style $"background-color:{colorName};color:{txtColor};"
match colorName = selected with true -> yield _selected | false -> () ] [
encodedText (dispText.Value.ToLower ())
])
Expand All @@ -97,7 +97,7 @@ let selectList name selected attrs items =
|> select (List.concat [ [ _name name; _id name ]; attrs ])

/// Generate the text for a default entry at the top of a select list
let selectDefault text = sprintf "%s" text
let selectDefault text = $"{text}"

/// Generate a standard submit button with icon and text
let submit attrs ico text = button (_type "submit" :: attrs) [ icon ico; rawText " &nbsp;"; locStr text ]
Expand All @@ -115,7 +115,7 @@ let blockquote = tag "blockquote"
/// role attribute
let _role = attr "role"
/// aria-* attribute
let _aria typ = attr (sprintf "aria-%s" typ)
let _aria typ = attr $"aria-{typ}"
/// onclick attribute
let _onclick = attr "onclick"
/// onsubmit attribute
Expand Down
6 changes: 3 additions & 3 deletions src/PrayerTracker.UI/Home.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ let error code vi =
br []
hr []
div [ _style "font-size:70%;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif" ] [
img [ _src (sprintf "/img/%A.png" s.["footer_en"])
_alt (sprintf "%A %A" s.["PrayerTracker"] s.["from Bit Badger Solutions"])
_title (sprintf "%A %A" s.["PrayerTracker"] s.["from Bit Badger Solutions"])
img [ _src $"""/img/%A{s.["footer_en"]}.png"""
_alt $"""%A{s.["PrayerTracker"]} %A{s.["from Bit Badger Solutions"]}"""
_title $"""%A{s.["PrayerTracker"]} %A{s.["from Bit Badger Solutions"]}"""
_style "vertical-align:text-bottom;" ]
str vi.version
]
Expand Down
2 changes: 1 addition & 1 deletion src/PrayerTracker.UI/I18N.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ let localizer = lazy (stringLocFactory.Create ("Common", resAsmName))

/// Get a view localizer
let forView (view : string) =
htmlLocFactory.Create (sprintf "Views.%s" (view.Replace ('/', '.')), resAsmName)
htmlLocFactory.Create ($"""Views.{view.Replace ('/', '.')}""", resAsmName)
12 changes: 6 additions & 6 deletions src/PrayerTracker.UI/Layout.fs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module Navigation =
[ icon "list"; space; locStr s.["View Request List"] ]
]
li [] [
a [ _href (sprintf "https://docs.prayer.bitbadger.solutions/%s" <| langCode ())
a [ _href $"https://docs.prayer.bitbadger.solutions/{langCode ()}"
_aria "label" s.["Help"].Value;
_title s.["View Help"].Value
_target "_blank"
Expand Down Expand Up @@ -183,9 +183,9 @@ let private htmlHead m pageTitle =
title [] [ locStr pageTitle; titleSep; locStr s.["PrayerTracker"] ]
yield! commonHead
for cssFile in m.style do
link [ _rel "stylesheet"; _href (sprintf "/css/%s.css" cssFile); _type "text/css" ]
link [ _rel "stylesheet"; _href $"/css/{cssFile}.css"; _type "text/css" ]
for jsFile in m.script do
script [ _src (sprintf "/js/%s.js" jsFile) ] []
script [ _src $"/js/{jsFile}.js" ] []
]

/// Render a link to the help page for the current page
Expand All @@ -194,7 +194,7 @@ let private helpLink link =
sup [] [
a [ _href link
_title s.["Click for Help on This Page"].Value
_onclick (sprintf "return PT.showHelp('%s')" link) ] [
_onclick $"return PT.showHelp('{link}')" ] [
icon "help_outline"
]
]
Expand All @@ -211,7 +211,7 @@ let private messages m =
let s = I18N.localizer.Force ()
m.messages
|> List.map (fun msg ->
table [ _class (sprintf "pt-msg %s" (msg.level.ToLower ())) ] [
table [ _class $"pt-msg {msg.level.ToLower ()}" ] [
tr [] [
td [] [
match msg.level with
Expand Down Expand Up @@ -249,7 +249,7 @@ let private htmlFooter m =
]
div [ _id "pt-footer" ] [
a [ _href "/web/"; _style "line-height:28px;" ] [
img [ _src (sprintf "/img/%O.png" s.["footer_en"]); _alt imgText; _title imgText ]
img [ _src $"""/img/%O{s.["footer_en"]}.png"""; _alt imgText; _title imgText ]
]
str m.version
space
Expand Down
46 changes: 23 additions & 23 deletions src/PrayerTracker.UI/PrayerRequest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let edit (m : EditRequest) today ctx vi =
label [] [ locStr s.["Expiration"] ]
ReferenceList.expirationList s ((m.isNew >> not) ())
|> List.map (fun exp ->
let radioId = sprintf "expiration_%s" (fst exp)
let radioId = $"expiration_{fst exp}"
span [ _class "text-nowrap" ] [
radio "expiration" radioId (fst exp) m.expiration
label [ _for radioId ] [ locStr (snd exp) ]
Expand All @@ -80,13 +80,13 @@ let edit (m : EditRequest) today ctx vi =
/// View for the request e-mail results page
let email m vi =
let s = I18N.localizer.Force ()
let pageTitle = sprintf "%s%s" s.["Prayer Requests"].Value m.listGroup.name
let pageTitle = $"""{s.["Prayer Requests"].Value} • {m.listGroup.name}"""
let prefs = m.listGroup.preferences
let addresses =
m.recipients
|> List.fold (fun (acc : StringBuilder) mbr -> acc.AppendFormat(", {0} <{1}>", mbr.memberName, mbr.email))
(StringBuilder ())
[ p [ _style (sprintf "font-family:%s;font-size:%ipt;" prefs.listFonts prefs.textFontSize) ] [
[ p [ _style $"font-family:{prefs.listFonts};font-size:%i{prefs.textFontSize}pt;" ] [
locStr s.["The request list was sent to the following people, via individual e-mails"]
rawText ":"
br []
Expand Down Expand Up @@ -143,9 +143,9 @@ let lists (grps : SmallGroup list) vi =
tr [] [
match grp.preferences.isPublic with
| true ->
a [ _href (sprintf "/web/prayer-requests/%s/list" grpId); _title s.["View"].Value ] [ icon "list" ]
a [ _href $"/web/prayer-requests/{grpId}/list"; _title s.["View"].Value ] [ icon "list" ]
| false ->
a [ _href (sprintf "/web/small-group/log-on/%s" grpId); _title s.["Log On"].Value ]
a [ _href $"/web/small-group/log-on/{grpId}"; _title s.["Log On"].Value ]
[ icon "verified_user" ]
|> List.singleton
|> td []
Expand Down Expand Up @@ -179,8 +179,8 @@ let maintain m (ctx : HttpContext) vi =
m.requests
|> Seq.map (fun req ->
let reqId = flatGuid req.prayerRequestId
let reqText = Utils.htmlToPlainText req.text
let delAction = sprintf "/web/prayer-request/%s/delete" reqId
let reqText = htmlToPlainText req.text
let delAction = $"/web/prayer-request/{reqId}/delete"
let delPrompt =
[ s.["Are you sure you want to delete this {0}? This action cannot be undone.",
s.["Prayer Request"].Value.ToLower() ]
Expand All @@ -192,36 +192,36 @@ let maintain m (ctx : HttpContext) vi =
|> String.concat ""
tr [] [
td [] [
a [ _href (sprintf "/web/prayer-request/%s/edit" reqId); _title l.["Edit This Prayer Request"].Value ]
a [ _href $"/web/prayer-request/{reqId}/edit"; _title l.["Edit This Prayer Request"].Value ]
[ icon "edit" ]
match req.isExpired now m.smallGroup.preferences.daysToExpire with
| true ->
a [ _href (sprintf "/web/prayer-request/%s/restore" reqId)
a [ _href $"/web/prayer-request/{reqId}/restore"
_title l.["Restore This Inactive Request"].Value ]
[ icon "visibility" ]
| false ->
a [ _href (sprintf "/web/prayer-request/%s/expire" reqId)
a [ _href $"/web/prayer-request/{reqId}/expire"
_title l.["Expire This Request Immediately"].Value ]
[ icon "visibility_off" ]
a [ _href delAction; _title l.["Delete This Request"].Value;
_onclick (sprintf "return PT.confirmDelete('%s','%s')" delAction delPrompt) ]
_onclick $"return PT.confirmDelete('{delAction}','{delPrompt}')" ]
[ icon "delete_forever" ]
]
td [ updReq req ] [
str (req.updatedDate.ToString(s.["MMMM d, yyyy"].Value, System.Globalization.CultureInfo.CurrentUICulture))
str (req.updatedDate.ToString(s.["MMMM d, yyyy"].Value, Globalization.CultureInfo.CurrentUICulture))
]
td [] [ locStr typs.[req.requestType] ]
td [ reqExp req ] [ str (match req.requestor with Some r -> r | None -> " ") ]
td [] [
match reqText.Length with
| len when len < 60 -> rawText reqText
| _ -> rawText (sprintf "%s&hellip;" reqText.[0..59])
| _ -> rawText $"{reqText.[0..59]}&hellip;"
]
])
|> List.ofSeq
[ div [ _class "pt-center-text" ] [
br []
a [ _href (sprintf "/web/prayer-request/%s/edit" emptyGuid); _title s.["Add a New Request"].Value ]
a [ _href $"/web/prayer-request/{emptyGuid}/edit"; _title s.["Add a New Request"].Value ]
[ icon "add_circle"; rawText " &nbsp;"; locStr s.["Add a New Request"] ]
rawText " &nbsp; &nbsp; &nbsp; "
a [ _href "/web/prayer-requests/view"; _title s.["View Prayer Request List"].Value ]
Expand Down Expand Up @@ -302,14 +302,14 @@ let maintain m (ctx : HttpContext) vi =
/// View for the printable prayer request list
let print m version =
let s = I18N.localizer.Force ()
let pageTitle = sprintf "%s%s" s.["Prayer Requests"].Value m.listGroup.name
let imgAlt = sprintf "%s %s" s.["PrayerTracker"].Value s.["from Bit Badger Solutions"].Value
let pageTitle = $"""{s.["Prayer Requests"].Value} • {m.listGroup.name}"""
let imgAlt = $"""{s.["PrayerTracker"].Value} {s.["from Bit Badger Solutions"].Value}"""
article [] [
rawText (m.asHtml s)
br []
hr []
div [ _style "font-size:70%;font-family:@Model.ListGroup.preferences.listFonts;" ] [
img [ _src (sprintf "/img/%s.png" s.["footer_en"].Value)
div [ _style $"font-size:70%%;font-family:{m.listGroup.preferences.listFonts};" ] [
img [ _src $"""/img/{s.["footer_en"].Value}.png"""
_style "vertical-align:text-bottom;"
_alt imgAlt
_title imgAlt ]
Expand All @@ -323,13 +323,13 @@ let print m version =
/// View for the prayer request list
let view m vi =
let s = I18N.localizer.Force ()
let pageTitle = sprintf "%s%s" s.["Prayer Requests"].Value m.listGroup.name
let pageTitle = $"""{s.["Prayer Requests"].Value} • {m.listGroup.name}"""
let spacer = rawText " &nbsp; &nbsp; &nbsp; "
let dtString = m.date.ToString "yyyy-MM-dd"
[ div [ _class "pt-center-text" ] [
br []
a [ _class "pt-icon-link"
_href (sprintf "/web/prayer-requests/print/%s" dtString)
_href $"/web/prayer-requests/print/{dtString}"
_title s.["View Printable"].Value ] [
icon "print"; rawText " &nbsp;"; locStr s.["View Printable"]
]
Expand All @@ -345,16 +345,16 @@ let view m vi =
| false -> findSunday (date.AddDays 1.)
let sunday = findSunday m.date
a [ _class "pt-icon-link"
_href (sprintf "/web/prayer-requests/view/%s" (sunday.ToString "yyyy-MM-dd"))
_href $"""/web/prayer-requests/view/{sunday.ToString "yyyy-MM-dd"}"""
_title s.["List for Next Sunday"].Value ] [
icon "update"; rawText " &nbsp;"; locStr s.["List for Next Sunday"]
]
spacer
let emailPrompt = s.["This will e-mail the current list to every member of your group, without further prompting. Are you sure this is what you are ready to do?"].Value
a [ _class "pt-icon-link"
_href (sprintf "/web/prayer-requests/email/%s" dtString)
_href $"/web/prayer-requests/email/{dtString}"
_title s.["Send via E-mail"].Value
_onclick (sprintf "return PT.requests.view.promptBeforeEmail('%s')" emailPrompt) ] [
_onclick $"return PT.requests.view.promptBeforeEmail('{emailPrompt}')" ] [
icon "mail_outline"; rawText " &nbsp;"; locStr s.["Send via E-mail"]
]
spacer
Expand Down
6 changes: 1 addition & 5 deletions src/PrayerTracker.UI/PrayerTracker.UI.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -61,8 +61,4 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.7.0" />
</ItemGroup>

</Project>
Loading

0 comments on commit b0d3bd4

Please sign in to comment.