Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ param (
[string] $Configuration = "Debug",

[switch] $NoRestore,

[switch] $Clean
)

Expand All @@ -24,24 +24,21 @@ $srcDir = Join-Path -Path $rootDir -ChildPath 'src'
$testDir = Join-Path -Path $rootDir -ChildPath 'test'

switch ($Action) {
"Test" { $projectdir = Join-Path -Path $testDir -ChildPath 'Falco.Markup.Tests' }
"Pack" { $projectDir = Join-Path -Path $srcDir -ChildPath 'Falco.Markup' }
"BuildSite" { $projectDir = Join-Path -Path $rootDir -ChildPath 'site' }
"DevelopSite" { $projectDir = Join-Path -Path $rootDir -ChildPath 'site' }
Default { $projectDir = Join-Path -Path $srcDir -ChildPath 'Falco.Markup' }
"Test" { $projectdir = Join-Path -Path $testDir -ChildPath 'Falco.Tests' }
"Pack" { $projectDir = Join-Path -Path $srcDir -ChildPath 'Falco' }
Default { $projectDir = Join-Path -Path $srcDir -ChildPath 'Falco' }
}

if(!$NoRestore.IsPresent) {
RunCommand "dotnet restore $projectDir --force --force-evaluate --nologo --verbosity quiet"
}

if ($Clean)
{
if ($Clean) {
RunCommand "dotnet clean $projectDir -c $Configuration --nologo --verbosity quiet"
}

switch ($Action) {
"Test" { RunCommand "dotnet test `"$projectDir`"" }
"Pack" { RunCommand "dotnet pack `"$projectDir`" -c $Configuration --include-symbols --include-source" }
Default { RunCommand "dotnet build `"$projectDir`" -c $Configuration" }
}
"Test" { RunCommand "dotnet test `"$projectDir`"" }
"Pack" { RunCommand "dotnet pack `"$projectDir`" -c $Configuration --include-symbols --include-source" }
Default { RunCommand "dotnet build `"$projectDir`" -c $Configuration" }
}
43 changes: 40 additions & 3 deletions Falco.Markup.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,63 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{25A4B987-E
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Falco.Markup.Tests", "test\Falco.Markup.Tests\Falco.Markup.Tests.fsproj", "{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{5D20AA90-6969-D8BD-9DCD-8634F4692FDA}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "StaticWebsite", "samples\StaticWebsite\StaticWebsite.fsproj", "{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Debug|x64.ActiveCfg = Debug|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Debug|x64.Build.0 = Debug|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Debug|x86.ActiveCfg = Debug|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Debug|x86.Build.0 = Debug|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Release|Any CPU.Build.0 = Release|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Release|x64.ActiveCfg = Release|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Release|x64.Build.0 = Release|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Release|x86.ActiveCfg = Release|Any CPU
{06D04004-6DB3-4522-8EFA-E5239219EF0D}.Release|x86.Build.0 = Release|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Debug|x64.ActiveCfg = Debug|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Debug|x64.Build.0 = Debug|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Debug|x86.ActiveCfg = Debug|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Debug|x86.Build.0 = Debug|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Release|Any CPU.Build.0 = Release|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Release|x64.ActiveCfg = Release|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Release|x64.Build.0 = Release|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Release|x86.ActiveCfg = Release|Any CPU
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA}.Release|x86.Build.0 = Release|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Debug|x64.ActiveCfg = Debug|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Debug|x64.Build.0 = Debug|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Debug|x86.ActiveCfg = Debug|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Debug|x86.Build.0 = Debug|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Release|Any CPU.Build.0 = Release|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Release|x64.ActiveCfg = Release|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Release|x64.Build.0 = Release|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Release|x86.ActiveCfg = Release|Any CPU
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{06D04004-6DB3-4522-8EFA-E5239219EF0D} = {795C5C1E-4386-49BE-8B93-CB0722AC6220}
{A6AADC18-B737-4CB4-8B35-857E9F94C5CA} = {25A4B987-EB43-4351-A7CD-C5451613B590}
{2C6417E9-ACAE-4B44-A4FA-31D53720F09D} = {5D20AA90-6969-D8BD-9DCD-8634F4692FDA}
EndGlobalSection
EndGlobal
42 changes: 0 additions & 42 deletions samples/StaticWebsite.fsx

This file was deleted.

40 changes: 40 additions & 0 deletions samples/StaticWebsite/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
open System
open System.IO
open Falco.Markup

// Components
let divider =
_hr [ _class_ "divider" ]

// Template
let master (title : string) (content : XmlNode list) =
_html [ _lang_ "en" ] [
_head [] [
_title [] [ _text "Sample App" ]
]
_body [] content
]

// Views
let homeView =
master "Homepage" [
_h1' "Homepage"
divider
_p' "Lorem ipsum dolor sit amet."
]

let aboutView =
master "About Us" [
_h1' "About"
divider
_p' "Lorem ipsum dolor sit amet."
]

// Generate website
let writeHtmlToFile (filename : string) (html : XmlNode) =
File.WriteAllText(
Path.Join(__SOURCE_DIRECTORY__, filename),
renderHtml html)

writeHtmlToFile "_homepage.html" homeView
writeHtmlToFile "_about.html" aboutView
16 changes: 16 additions & 0 deletions samples/StaticWebsite/StaticWebsite.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Falco.Markup\Falco.Markup.fsproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions samples/StaticWebsite/_about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head><title>Sample App</title></head><body><h1>About</h1><hr class="divider" /><p>Lorem ipsum dolor sit amet.</p></body></html>
1 change: 1 addition & 0 deletions samples/StaticWebsite/_homepage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head><title>Sample App</title></head><body><h1>Homepage</h1><hr class="divider" /><p>Lorem ipsum dolor sit amet.</p></body></html>
28 changes: 14 additions & 14 deletions src/Falco.Markup/Attr.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Attr =
"class", " "
"style", "; "
"accept", ", " ]

/// Merge two XmlAttribute lists
let merge (attrs1 : XmlAttribute list) (attrs2 : XmlAttribute list) =

Expand Down Expand Up @@ -446,7 +446,7 @@ module Attr =

/// Alias for `enctype=multipart/form-data`
let enctypeMultipart = enctype "multipart/form-data"

// Alias for `method=post`
let methodPost = method "post"

Expand All @@ -470,7 +470,7 @@ module Attr =

/// Alias for `target=_unfencedTop`
let targetUnfencedTop = target "_unfencedTop"

/// Alias for `type=button`
let typeButton = type' "button"

Expand Down Expand Up @@ -545,35 +545,35 @@ module Attr =
value (x.ToString())

/// Alias for `value={str}` by invoking `_.ToString(format)` on input
let inline valueStringf format (x : ^T when ^T : (member ToString : string -> string)) =
let inline valueStringf format (x : ^T when ^T : (member ToString : string -> string)) =
value (x.ToString(format))

/// Alias for `Attr.valueStringf "yyyy-MM-dd" dt`
let valueDate (dt : DateTime) =
valueStringf "yyyy-MM-dd" dt

/// Alias for `Attr.valueStringf "s" dt`
let valueDatetimeLocal (dt : DateTime) =
valueStringf "s" dt
let valueDatetimeLocal (dt : DateTime) =
valueStringf "s" dt

/// Alias for `Attr.valueStringf "yyyy-MM"`
let valueMonth (dt : DateTime) =
valueStringf "yyyy-MM" dt

/// Alias for `Attr.valueStringf "hh\:mm" time`
let valueTime (time : TimeSpan) =
/// Alias for `Attr.valueStringf "hh\:mm" time`
let valueTime (time : TimeSpan) =
valueStringf "hh\:mm" time
let private cal = System.Globalization.GregorianCalendar(GregorianCalendarTypes.USEnglish)

let private cal = GregorianCalendar(GregorianCalendarTypes.USEnglish)

/// Alias for `value={yyyy-W#}` (ex: `value=1986-W50`)
let valueWeek (dt : DateTime) =
let valueWeek (dt : DateTime) =
let wk = cal.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday).ToString("00")
let yr = dt.ToString("yyyy")
value (sprintf "%s-W%s" yr wk)

/// Invoke `fn` if `Some` otherwise return `value=""`
let valueOption fn opt =
let valueOption fn opt =
match opt with Some x -> fn x | None -> valueEmpty

//
Expand Down Expand Up @@ -841,4 +841,4 @@ module Attr =
let onwaiting = create "onwaiting"

/// `wheel={value}` event
let onwheel = create "wheel"
let onwheel = create "wheel"
1 change: 1 addition & 0 deletions src/Falco.Markup/Falco.Markup.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<Compile Include="Attr.fs" />
<Compile Include="Elem.fs" />
<Compile Include="Text.fs" />
<Compile Include="Html.fs" />
<Compile Include="Svg.fs" />
<Compile Include="Templates.fs" />
<Compile Include="TestHelpers.fs" />
Expand Down
Loading