From 257acd1087116af4b1265653c1b13cb6eeaaf1e4 Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Mon, 27 Nov 2023 13:13:47 -0500 Subject: [PATCH 01/11] gitignore .vs files --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3f3309f0..a85e28a8 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ packages/ SnowSite/Snow/Images/original-images/ SnowSite/Snow/_ignore/ *.log -src/Barbato/Snow/ \ No newline at end of file +src/Barbato/Snow/ +.vs \ No newline at end of file From b4a1291fd880ed568bd6b3ea7683990df3f9aa85 Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Thu, 16 Nov 2023 21:40:54 -0500 Subject: [PATCH 02/11] update to .net 4.8 --- debug.ps1 | 1 + src/Barbato.Tests/Barbato.Tests.csproj | 12 ++-- src/Barbato.Tests/packages.config | 2 +- src/Barbato/Barbato.csproj | 41 +++++++++---- src/Barbato/Web.config | 41 +++++++------ src/Barbato/packages.config | 8 +-- src/Snow.Tests/Snow.Tests.csproj | 23 +++---- src/Snow.Tests/app.config | 21 ++++--- src/Snow.Tests/packages.config | 4 +- src/Snow/FodyWeavers.xml | 5 -- src/Snow/Snow.csproj | 85 ++++++-------------------- src/Snow/app.config | 21 ++++--- src/Snow/packages.config | 34 +++++------ 13 files changed, 134 insertions(+), 164 deletions(-) create mode 100644 debug.ps1 delete mode 100644 src/Snow/FodyWeavers.xml diff --git a/debug.ps1 b/debug.ps1 new file mode 100644 index 00000000..42543b8e --- /dev/null +++ b/debug.ps1 @@ -0,0 +1 @@ +& src\Snow\bin\Debug\Snow config=.\SnowSite\Snow\Snow.config debug=true server=true \ No newline at end of file diff --git a/src/Barbato.Tests/Barbato.Tests.csproj b/src/Barbato.Tests/Barbato.Tests.csproj index 8d200179..f66d7f61 100644 --- a/src/Barbato.Tests/Barbato.Tests.csproj +++ b/src/Barbato.Tests/Barbato.Tests.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,10 +9,11 @@ Properties Barbato.Tests Barbato.Tests - v4.0 + v4.8 512 ..\ true + true @@ -22,6 +23,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -30,15 +32,15 @@ TRACE prompt 4 + false False ..\packages\FakeItEasy.1.22.0\lib\net40\FakeItEasy.dll - - False - ..\packages\Nancy.0.23.2\lib\net40\Nancy.dll + + ..\packages\Nancy.1.4.5\lib\net40\Nancy.dll diff --git a/src/Barbato.Tests/packages.config b/src/Barbato.Tests/packages.config index ec8fdd08..3d4d46f3 100644 --- a/src/Barbato.Tests/packages.config +++ b/src/Barbato.Tests/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/Barbato/Barbato.csproj b/src/Barbato/Barbato.csproj index 9d7fd854..5de636e8 100644 --- a/src/Barbato/Barbato.csproj +++ b/src/Barbato/Barbato.csproj @@ -1,5 +1,5 @@  - + Debug @@ -13,7 +13,7 @@ Properties Barbato Barbato - v4.0 + v4.8 true @@ -21,6 +21,11 @@ ..\ true + + + + + true @@ -30,6 +35,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -38,15 +44,15 @@ TRACE prompt 4 + false ..\packages\ftplib.1.0.1.2\lib\net35\ftplib.dll - - False - ..\packages\Nancy.0.23.2\lib\net40\Nancy.dll + + ..\packages\Nancy.1.4.5\lib\net40\Nancy.dll False @@ -60,9 +66,8 @@ False ..\packages\Nancy.Validation.DataAnnotations.0.23.2\lib\net40\Nancy.Validation.DataAnnotations.dll - - False - ..\packages\Nancy.Viewengines.Razor.0.23.2\lib\net40\Nancy.ViewEngines.Razor.dll + + ..\packages\Nancy.Viewengines.Razor.1.4.3\lib\net40\Nancy.ViewEngines.Razor.dll False @@ -74,12 +79,18 @@ - + + + + + True + ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll + False ..\packages\WorldDomination.Web.Authentication.0.19.2\lib\net40\WorldDomination.Web.Authentication.dll @@ -200,12 +211,16 @@ -if $(ConfigurationName) == Debug ( -xcopy /s /y /R "$(SolutionDir)packages\Nancy.Viewengines.Razor.0.23.2\BuildProviders\Nancy.ViewEngines.Razor.BuildProviders.dll" "$(ProjectDir)bin\" -xcopy /s /y /R "$(SolutionDir)packages\Nancy.Viewengines.Razor.0.23.2\lib\Net40\Nancy.ViewEngines.Razor.dll" "$(ProjectDir)bin\" -) + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + - - + + - - + - - + + + + + + + + + + - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/src/Barbato/packages.config b/src/Barbato/packages.config index a13505db..f7b2ce24 100644 --- a/src/Barbato/packages.config +++ b/src/Barbato/packages.config @@ -4,13 +4,13 @@ - - + + - - + + diff --git a/src/Snow.Tests/Snow.Tests.csproj b/src/Snow.Tests/Snow.Tests.csproj index e0fcf3df..96153fae 100644 --- a/src/Snow.Tests/Snow.Tests.csproj +++ b/src/Snow.Tests/Snow.Tests.csproj @@ -1,5 +1,5 @@  - + @@ -10,11 +10,13 @@ Properties Snow.Tests Snow.Tests - v4.5 + v4.8 512 ..\ true - 834b1f1b + + + true @@ -37,11 +39,11 @@ ..\packages\FakeItEasy.1.25.2\lib\net40\FakeItEasy.dll - - ..\packages\Nancy.1.1\lib\net40\Nancy.dll + + ..\packages\Nancy.1.4.5\lib\net40\Nancy.dll - - ..\packages\Nancy.Viewengines.Razor.1.1\lib\net40\Nancy.ViewEngines.Razor.dll + + ..\packages\Nancy.Viewengines.Razor.1.4.3\lib\net40\Nancy.ViewEngines.Razor.dll @@ -117,17 +119,16 @@ -if $(ConfigurationName) == Debug ( -xcopy /s /y /R "$(SolutionDir)packages\Nancy.Viewengines.Razor.1.1\BuildProviders\Nancy.ViewEngines.Razor.BuildProviders.dll" "$(ProjectDir)bin\" -xcopy /s /y /R "$(SolutionDir)packages\Nancy.Viewengines.Razor.1.1\lib\Net40\Nancy.ViewEngines.Razor.dll" "$(ProjectDir)bin\" -) + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + - \ No newline at end of file diff --git a/src/Snow/Snow.csproj b/src/Snow/Snow.csproj index f039d7ae..8b7f5f93 100644 --- a/src/Snow/Snow.csproj +++ b/src/Snow/Snow.csproj @@ -1,5 +1,5 @@  - + @@ -10,7 +10,7 @@ Properties Snow Snow - v4.5 + v4.8 512 false ..\ @@ -29,7 +29,9 @@ 1.0.0.%2a false true - 6ab6bd74 + + + config=../../../../SnowSite/Snow/ debug=true server=true @@ -75,21 +77,20 @@ ..\packages\Microsoft.Owin.StaticFiles.3.0.1\lib\net45\Microsoft.Owin.StaticFiles.dll - - ..\packages\Nancy.1.1\lib\net40\Nancy.dll + + ..\packages\Nancy.1.4.5\lib\net40\Nancy.dll - - ..\packages\Nancy.Testing.1.1\lib\net40\Nancy.Testing.dll + + ..\packages\Nancy.Testing.1.4.1\lib\net40\Nancy.Testing.dll - - ..\packages\Nancy.Viewengines.Markdown.1.1\lib\net40\Nancy.ViewEngines.Markdown.dll + + ..\packages\Nancy.Viewengines.Markdown.1.4.1\lib\net40\Nancy.ViewEngines.Markdown.dll - - ..\packages\Nancy.Viewengines.Razor.1.1\lib\net40\Nancy.ViewEngines.Razor.dll + + ..\packages\Nancy.Viewengines.Razor.1.4.3\lib\net40\Nancy.ViewEngines.Razor.dll - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll ..\packages\Nowin.0.15.1.0\lib\net45\Nowin.dll @@ -191,67 +192,22 @@ false - - - Designer - - xcopy /s /y /R "$(ProjectDir)bin\$(ConfigurationName)\Snow.exe" "$(SolutionDir)Barbato\Snow\" xcopy /s /y /R "$(ProjectDir)bin\$(ConfigurationName)\Nancy.dll" "$(SolutionDir)Barbato\Snow\" xcopy /s /y /R "$(ProjectDir)bin\$(ConfigurationName)\Nancy.ViewEngines.Razor.dll" "$(SolutionDir)Barbato\Snow\" -xcopy /s /y /R "$(ProjectDir)bin\$(ConfigurationName)\Nancy.Testing.dll" "$(SolutionDir)Barbato\Snow\" -if $(ConfigurationName) == Debug ( -xcopy /s /y /R "$(SolutionDir)packages\Nancy.Viewengines.Razor.1.1\BuildProviders\Nancy.ViewEngines.Razor.BuildProviders.dll" "$(ProjectDir)bin\" -xcopy /s /y /R "$(SolutionDir)packages\Nancy.Viewengines.Razor.1.1\lib\Net40\Nancy.ViewEngines.Razor.dll" "$(ProjectDir)bin\" -) +xcopy /s /y /R "$(ProjectDir)bin\$(ConfigurationName)\Nancy.Testing.dll" "$(SolutionDir)Barbato\Snow\" - - - - - - - - - - - - (); -var attribute = config.Attribute("ExcludeAssemblies"); -if (attribute != null) - foreach (var item in attribute.Value.Split('|').Select(x => x.Trim()).Where(x => x != string.Empty)) - excludedAssemblies.Add(item); -var element = config.Element("ExcludeAssemblies"); -if (element != null) - foreach (var item in element.Value.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Where(x => x != string.Empty)) - excludedAssemblies.Add(item); - -var filesToCleanup = Files.Select(f => f.ItemSpec).Where(f => !excludedAssemblies.Contains(Path.GetFileNameWithoutExtension(f), StringComparer.InvariantCultureIgnoreCase)); - -foreach (var item in filesToCleanup) - File.Delete(item); -]]> - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + - \ No newline at end of file diff --git a/src/Snow/app.config b/src/Snow/app.config index 5e226a46..d7404687 100644 --- a/src/Snow/app.config +++ b/src/Snow/app.config @@ -9,15 +9,8 @@ - - - - - - - - - + + @@ -30,4 +23,12 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Snow/packages.config b/src/Snow/packages.config index c58580c8..098abc82 100644 --- a/src/Snow/packages.config +++ b/src/Snow/packages.config @@ -1,21 +1,19 @@  - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file From 0382b721ce59d91cd4e7072cfc668b91e766abc0 Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Fri, 17 Nov 2023 14:39:52 -0500 Subject: [PATCH 03/11] add .gitkeep to _pages --- SnowSite/Snow/_pages/.gitkeep | Bin 0 -> 6 bytes src/Snow/Program.cs | 1 + 2 files changed, 1 insertion(+) create mode 100644 SnowSite/Snow/_pages/.gitkeep diff --git a/SnowSite/Snow/_pages/.gitkeep b/SnowSite/Snow/_pages/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..49cc8ef0e116cef009fe0bd72473a964bbd07f9b GIT binary patch literal 6 NcmezWkC%aq0RRg=0u=xN literal 0 HcmV?d00001 diff --git a/src/Snow/Program.cs b/src/Snow/Program.cs index d9dcf27b..0ac2c064 100644 --- a/src/Snow/Program.cs +++ b/src/Snow/Program.cs @@ -72,6 +72,7 @@ private static void Main(string[] args) if (!string.IsNullOrWhiteSpace(settings.Pages)) { pages = new DirectoryInfo(settings.Pages).EnumerateFiles("*", SearchOption.AllDirectories) + .Where(x => extensions.Contains(x.Extension)) .Select(x => PagesParser.GetFileData(x, settings)) .OrderByDescending(x => x.Date) .Where(x => x.Published != Published.Private && !(x is Post.MissingPost)) From eb4d4812aa7bfbd7e9e4c8752ab798e5a79008dc Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Fri, 17 Nov 2023 15:08:09 -0500 Subject: [PATCH 04/11] add path of output-dir to logging --- src/Snow/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Snow/Program.cs b/src/Snow/Program.cs index 0ac2c064..4a77caa0 100644 --- a/src/Snow/Program.cs +++ b/src/Snow/Program.cs @@ -174,7 +174,7 @@ private static void Main(string[] args) File.Copy(source, destination, true); } - Console.WriteLine("Sandra.Snow : " + DateTime.Now.ToString("HH:mm:ss") + " : Finish processing"); + Console.WriteLine($"Sandra.Snow : { DateTime.Now.ToString("HH:mm:ss") } : Finish processing (output dir: { Path.GetFullPath(settings.PostsOutput) })"); if (commands.ContainsKey("server")) { From 6516fdc3c76452db4e7fd4662bc7f1e818a0da43 Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Mon, 27 Nov 2023 17:38:43 -0500 Subject: [PATCH 05/11] fix default snow.config to match settings object --- SnowSite/Snow/snow.config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SnowSite/Snow/snow.config b/SnowSite/Snow/snow.config index d193502a..1df8045d 100644 --- a/SnowSite/Snow/snow.config +++ b/SnowSite/Snow/snow.config @@ -7,7 +7,8 @@ "pages": "_pages", "layouts": "_layouts", "theme": "default", - "output": "../Website", + "postsOutput": "../Website", + "pagesOutput": "../Website", "urlFormat": "yyyy/MM/slug", "copyDirectories": [ "images", From 247184930cf8e31085f20c36f40516ecd11187fd Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Mon, 27 Nov 2023 17:39:08 -0500 Subject: [PATCH 06/11] remove redundant wait-for-continue --- src/Snow/Program.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Snow/Program.cs b/src/Snow/Program.cs index 4a77caa0..c5d2af2f 100644 --- a/src/Snow/Program.cs +++ b/src/Snow/Program.cs @@ -181,7 +181,9 @@ private static void Main(string[] args) SnowServer.Start(settings); } - if (commands.ContainsKey("debug")) + if (commands.ContainsKey("debug") + && !commands.ContainsKey("server") //server already has press-any-key-to-stop so waitforcontinue is redundant. + ) { DebugHelperExtensions.WaitForContinue(); } From 96638dd9df072da4b69485ad0d84f77acfe34586 Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Mon, 27 Nov 2023 17:42:49 -0500 Subject: [PATCH 07/11] simple publish script --- publish.ps1 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 publish.ps1 diff --git a/publish.ps1 b/publish.ps1 new file mode 100644 index 00000000..8c241593 --- /dev/null +++ b/publish.ps1 @@ -0,0 +1,50 @@ +#.SYNOPSIS +# Simple 1-step publish script, but has many assumptions. See description. + +#.DESCRIPTION +# This publish is a simple local convenience measure for publishing SnowSite +# from localhost to your gitrepo, assuming you've customized SnowSite to become +# your site. +# +# It also assumes you've already compiled Sandra.snow in "debug" mode. +# +# It also assumes that your "config" is set to output directly into your target +# static site repo. +# +# If any of these assumptions are false, you may need to use a different publish +# script, or customize this one. + +param ( + # git commit message for both Sandra.Snow repo and output repo. + [Parameter(mandatory)] + [string] $commitMessage, + + # path to the config file. Must be in the site directory. Defaults to SnowSite\Snow\Snow.config + [Parameter()] + [IO.FileInfo] $configPath = $null +) + +Push-Location $PSScriptRoot + +# defaulting. +if (-not $configPath) { + $configPath = [IO.FileInfo](Resolve-Path ".\SnowSite\Snow\Snow.config").Path +} +$configDirPath = Split-Path $configPath -Parent +$outputPath = Resolve-Path (Join-Path $configDirPath $config.postsOutput) + +& src\Snow\bin\Debug\Snow config=$configPath + +#region commits +git add . +git commit -m $message +git push + +Push-Location $outputPath + git add . + git commit -m $message + git push +Pop-Location +#endregion commits + +Pop-Location \ No newline at end of file From 75db630218063c5e731cdcbe2e336ba4b1447422 Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Tue, 28 Nov 2023 00:22:45 -0500 Subject: [PATCH 08/11] github actions --- .github/workflows/build-snow.yml | 33 ++++++++++ .github/workflows/publish-website.yml | 94 +++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 .github/workflows/build-snow.yml create mode 100644 .github/workflows/publish-website.yml diff --git a/.github/workflows/build-snow.yml b/.github/workflows/build-snow.yml new file mode 100644 index 00000000..4bca4e49 --- /dev/null +++ b/.github/workflows/build-snow.yml @@ -0,0 +1,33 @@ +name: Build Snow +# compile Sandra.Snow binary in release mode and publish as artifact "Snow" + +on: + push: + branches: [ "master" ] + paths: + - 'src/**' + - '.github/workflows/build-snow.yml' + workflow_dispatch: + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup NuGet + uses: NuGet/setup-nuget@v1.0.5 + - name: setup-msbuild + uses: microsoft/setup-msbuild@v1.1 + - name: Restore Packages + run: nuget restore src/Sandra.Snow.sln + - name: Build solution + run: msbuild src/Sandra.Snow.sln -t:rebuild -property:Configuration=Release + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.3 + with: + # Artifact name + name: Snow + # A file, directory or wildcard pattern that describes what to upload + path: src/Snow/bin/Release diff --git a/.github/workflows/publish-website.yml b/.github/workflows/publish-website.yml new file mode 100644 index 00000000..fbeb3c63 --- /dev/null +++ b/.github/workflows/publish-website.yml @@ -0,0 +1,94 @@ +name: Publish Website +# publish SnowSite to the repo set in vars.WEBSITE_REPO, using the pat defined in secrets.WEBSITE_PAT +# note that this action overrides the output paths set in the snow config file + +on: + push: + paths: + - 'SnowSite/**' + - '.github/workflows/publish-website.yml' + workflow_dispatch: + workflow_run: + workflows: ["Build Snow"] + types: + - completed + +env: + YAML_PATH: .github/workflows/publish-website.yml + IS_WEBSITE_REPO_SET: ${{ vars.WEBSITE_REPO != null }} + IS_WEBSITE_PAT_SET: ${{ secrets.WEBSITE_PAT != null }} + +jobs: + publish: + runs-on: windows-latest + steps: + - name: Check WEBSITE_REPO var + if: ${{ env.IS_WEBSITE_REPO_SET == 'false' }} + shell: pwsh + run: | + "::warning file=$env:YAML_PATH::Mandatory repo variable WEBSITE_REPO is not set." + + - name: Check WEBSITE_PAT secret + if: ${{ env.IS_WEBSITE_REPO_SET == 'true' && env.IS_WEBSITE_PAT_SET == 'false' }} + shell: pwsh + run: | + "::error file=$env:YAML_PATH::Mandatory repo secret WEBSITE_PAT is not set." + + - name: Checkout SnowSite + if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }} + uses: actions/checkout@v3 + with: + sparse-checkout: SnowSite + path: doc + + - name: Checkout Website + if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }} + uses: actions/checkout@v3 + with: + repository: ${{ vars.WEBSITE_REPO }} + path: website + token: ${{ secrets.WEBSITE_PAT }} + + - name: Download Snow artifact + if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }} + uses: dawidd6/action-download-artifact@v2 + with: + workflow: build-snow.yml + + - name: run Snow + if: ${{ env.IS_WEBSITE_REPO_SET == 'true' }} + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + $blogDir = (mkdir ".\website" -force).FullName + $docDir = ".\doc\SnowSite" + + "Configuring git..." + + pushd $docDir + $lastMessage = git log -1 --pretty=%B | Select-Object -First 1 + $lastUserName = git log -1 --pretty=format:'%an' | Select-Object -First 1 + $lastUserEamil = git log -1 --pretty=format:'%ae' | Select-Object -First 1 + + git config --global user.name "github actions bot (on behalf of $lastUserName)" + git config --global user.email $lastUserEamil + git config --global core.autocrlf false + popd + + "Overriding output dirs to $blogDir" + $configPath = "$docDir\Snow\Snow.config.json" + $config = Get-Content $configPath | ConvertFrom-Json + $config.postsOutput = $blogDir + $config.pagesOutput = $blogDir + $config | ConvertTo-Json | Out-File $configPath + + "Running Snow..." + & Snow\Snow.exe "config=$configPath" + + Write-Output "Updating $blogdir..." + cd $blogdir + Get-Location #DEBUG + + git add . + git commit -m "Publish: $lastMessage" + git push \ No newline at end of file From 403df709e4bede5b361e7adbd9d681c401cc908d Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Mon, 20 Nov 2023 10:39:16 -0500 Subject: [PATCH 09/11] rename "Snow.config" to "snow.config.json" optionally --- SnowSite/Snow/{snow.config => snow.config.json} | 0 debug.ps1 | 2 +- publish.ps1 | 2 +- src/Sandra.Snow.sln | 9 ++++++--- src/Snow/Extensions/IoExtensions.cs | 2 +- src/Snow/Program.cs | 12 ++++++++++-- 6 files changed, 19 insertions(+), 8 deletions(-) rename SnowSite/Snow/{snow.config => snow.config.json} (100%) diff --git a/SnowSite/Snow/snow.config b/SnowSite/Snow/snow.config.json similarity index 100% rename from SnowSite/Snow/snow.config rename to SnowSite/Snow/snow.config.json diff --git a/debug.ps1 b/debug.ps1 index 42543b8e..a1a20665 100644 --- a/debug.ps1 +++ b/debug.ps1 @@ -1 +1 @@ -& src\Snow\bin\Debug\Snow config=.\SnowSite\Snow\Snow.config debug=true server=true \ No newline at end of file +& src\Snow\bin\Debug\Snow config=.\SnowSite\Snow\Snow.config.json debug=true server=true \ No newline at end of file diff --git a/publish.ps1 b/publish.ps1 index 8c241593..658f96ff 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -28,7 +28,7 @@ Push-Location $PSScriptRoot # defaulting. if (-not $configPath) { - $configPath = [IO.FileInfo](Resolve-Path ".\SnowSite\Snow\Snow.config").Path + $configPath = [IO.FileInfo](Resolve-Path ".\SnowSite\Snow\Snow.config.json").Path } $configDirPath = Split-Path $configPath -Parent $outputPath = Resolve-Path (Join-Path $configDirPath $config.postsOutput) diff --git a/src/Sandra.Snow.sln b/src/Sandra.Snow.sln index d7eba3a5..34abba31 100644 --- a/src/Sandra.Snow.sln +++ b/src/Sandra.Snow.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30501.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34309.116 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Snow", "Snow\Snow.csproj", "{1143B7F0-4D45-4681-ACF8-EC24E4F4DBCC}" EndProject @@ -19,7 +19,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionStuffs", "SolutionStuffs", "{400CA74D-3B1D-4D07-8170-5A5304710D9A}" ProjectSection(SolutionItems) = preProject ..\README.md = ..\README.md - ..\SnowSite\Snow\snow.config = ..\SnowSite\Snow\snow.config + ..\SnowSite\Snow\snow.config.json = ..\SnowSite\Snow\snow.config.json EndProjectSection EndProject Global @@ -48,4 +48,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3D43A1FD-2E25-4078-AF52-D821E9FBC042} + EndGlobalSection EndGlobal diff --git a/src/Snow/Extensions/IoExtensions.cs b/src/Snow/Extensions/IoExtensions.cs index cd6299da..ccfe4d08 100644 --- a/src/Snow/Extensions/IoExtensions.cs +++ b/src/Snow/Extensions/IoExtensions.cs @@ -12,7 +12,7 @@ private static bool IsIn(this string name, IEnumerable names) return names.Contains(name.ToLower(), StringComparer.OrdinalIgnoreCase); } - private static readonly string[] IgnoredFiles = { "cname", "compile.snow.bat", "compile.snow.ps1", "snow.config", ".nojekyll", ".gitignore", ".deployment" }; + private static readonly string[] IgnoredFiles = { "cname", "compile.snow.bat", "compile.snow.ps1", "snow.config", "snow.config.json", ".nojekyll", ".gitignore", ".deployment" }; private static readonly string[] IgnoredDirectories = { ".git", "svn", ".svn", "snow", ".nojekyll", ".gitignore" }; public static void Empty(this DirectoryInfo directory) diff --git a/src/Snow/Program.cs b/src/Snow/Program.cs index c5d2af2f..cb98dea1 100644 --- a/src/Snow/Program.cs +++ b/src/Snow/Program.cs @@ -75,7 +75,7 @@ private static void Main(string[] args) .Where(x => extensions.Contains(x.Extension)) .Select(x => PagesParser.GetFileData(x, settings)) .OrderByDescending(x => x.Date) - .Where(x => x.Published != Published.Private && !(x is Post.MissingPost)) + .Where(x => x.Published != Published.Private) //unlike posts do not check for "MissingPage" functionality because it does not exist. .ToList(); pages.SetPostUrl(settings); @@ -248,10 +248,18 @@ private static SnowSettings CreateSettings(string currentDir) { var settings = SnowSettings.Default(currentDir); var configFile = Path.Combine(currentDir, "snow.config"); + var alternateConfigFile = Path.Combine(currentDir, "snow.config.json"); if (!File.Exists(configFile)) { - throw new FileNotFoundException("Snow config file not found at " + configFile); + if (File.Exists(alternateConfigFile)) + { + configFile = alternateConfigFile; + } + else + { + throw new FileNotFoundException($"Snow config file not found at '{configFile}' or '{alternateConfigFile}'"); + } } var fileData = File.ReadAllText(configFile); From a599eaacf0b4948b8497453e26ac08edd9d31498 Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Mon, 20 Nov 2023 10:39:36 -0500 Subject: [PATCH 10/11] update nuget packages --- src/Barbato.Tests/Barbato.Tests.csproj | 1 + src/Barbato.Tests/app.config | 11 +++++++++++ src/Barbato/Barbato.csproj | 11 +++++------ src/Barbato/Web.config | 11 ++++++++++- src/Barbato/packages.config | 4 ++-- 5 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 src/Barbato.Tests/app.config diff --git a/src/Barbato.Tests/Barbato.Tests.csproj b/src/Barbato.Tests/Barbato.Tests.csproj index f66d7f61..99562e32 100644 --- a/src/Barbato.Tests/Barbato.Tests.csproj +++ b/src/Barbato.Tests/Barbato.Tests.csproj @@ -59,6 +59,7 @@ + diff --git a/src/Barbato.Tests/app.config b/src/Barbato.Tests/app.config new file mode 100644 index 00000000..5c7a24c1 --- /dev/null +++ b/src/Barbato.Tests/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Barbato/Barbato.csproj b/src/Barbato/Barbato.csproj index 5de636e8..ce42a931 100644 --- a/src/Barbato/Barbato.csproj +++ b/src/Barbato/Barbato.csproj @@ -69,9 +69,8 @@ ..\packages\Nancy.Viewengines.Razor.1.4.3\lib\net40\Nancy.ViewEngines.Razor.dll - - False - ..\packages\NLog.3.1.0.0\lib\net40\NLog.dll + + ..\packages\NLog.5.2.6\lib\net46\NLog.dll False @@ -80,13 +79,13 @@ + - - True - ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll + + ..\packages\Microsoft.AspNet.Razor.3.3.0\lib\net45\System.Web.Razor.dll diff --git a/src/Barbato/Web.config b/src/Barbato/Web.config index efb16e0a..34545270 100644 --- a/src/Barbato/Web.config +++ b/src/Barbato/Web.config @@ -66,4 +66,13 @@ - \ No newline at end of file + + + + + + + + + + \ No newline at end of file diff --git a/src/Barbato/packages.config b/src/Barbato/packages.config index f7b2ce24..3fa88424 100644 --- a/src/Barbato/packages.config +++ b/src/Barbato/packages.config @@ -4,13 +4,13 @@ - + - + From 228b689fbc241e14bbd7ee7ed37d3370cda1dd6f Mon Sep 17 00:00:00 2001 From: Martin Zarate Date: Tue, 21 Nov 2023 03:17:15 -0500 Subject: [PATCH 11/11] add title-tag support --- SnowSite/Snow/snow.config.json | 3 ++- SnowSite/Snow/themes/default/_layouts/default.cshtml | 3 ++- src/Snow/StaticFile.cs | 4 ++++ src/Snow/StaticFileProcessors/BaseProcessor.cs | 4 ++++ src/Snow/StaticFileProcessors/CategoriesProcessor.cs | 1 + src/Snow/StaticFileProcessors/DraftsProcessor.cs | 3 ++- src/Snow/TestModule.cs | 5 +++++ src/Snow/ViewModels/BaseViewModel.cs | 5 +++++ 8 files changed, 25 insertions(+), 3 deletions(-) diff --git a/SnowSite/Snow/snow.config.json b/SnowSite/Snow/snow.config.json index 1df8045d..729fdb7d 100644 --- a/SnowSite/Snow/snow.config.json +++ b/SnowSite/Snow/snow.config.json @@ -25,7 +25,8 @@ },{ "file": "categories.cshtml => category" },{ - "file": "archive.cshtml" + "file": "archive.cshtml", + "title": "Archive" },{ "file": "about.cshtml" },{ diff --git a/SnowSite/Snow/themes/default/_layouts/default.cshtml b/SnowSite/Snow/themes/default/_layouts/default.cshtml index f5a758f2..330804a6 100644 --- a/SnowSite/Snow/themes/default/_layouts/default.cshtml +++ b/SnowSite/Snow/themes/default/_layouts/default.cshtml @@ -2,6 +2,7 @@ @using System.Collections.Generic @{ var keywords = String.Join(",", Model.Keywords); + var title = String.Join(" • ", Model.HeaderTitleChain); } @@ -10,7 +11,7 @@ - philliphaydon.com + @title @Html.CanonicalUrl() diff --git a/src/Snow/StaticFile.cs b/src/Snow/StaticFile.cs index 234dbe43..58ef8a54 100644 --- a/src/Snow/StaticFile.cs +++ b/src/Snow/StaticFile.cs @@ -4,5 +4,9 @@ public class StaticFile { public string File { get; set; } public string Loop { get; set; } + /// + /// File title to use in header title if it's HTML. May be overridden by loop. + /// + public string Title { get; set; } } } \ No newline at end of file diff --git a/src/Snow/StaticFileProcessors/BaseProcessor.cs b/src/Snow/StaticFileProcessors/BaseProcessor.cs index 842d1449..b8e4b793 100644 --- a/src/Snow/StaticFileProcessors/BaseProcessor.cs +++ b/src/Snow/StaticFileProcessors/BaseProcessor.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; using System.IO; + using System.Linq; using Enums; public abstract class BaseProcessor @@ -20,6 +21,9 @@ public void Process(SnowyData snowyData, SnowSettings settings) ParseDirectories(snowyData); TestModule.StaticFile = SourceFile; TestModule.Published = Published.True; + TestModule.HeaderTitleChain = new string[] { snowyData.File.Title, TestModule.Settings.BlogTitle } + .Where(t => !string.IsNullOrWhiteSpace(t)) + .ToList(); Impl(snowyData, settings); } diff --git a/src/Snow/StaticFileProcessors/CategoriesProcessor.cs b/src/Snow/StaticFileProcessors/CategoriesProcessor.cs index bd6a2644..0f2d22ee 100644 --- a/src/Snow/StaticFileProcessors/CategoriesProcessor.cs +++ b/src/Snow/StaticFileProcessors/CategoriesProcessor.cs @@ -23,6 +23,7 @@ protected override void Impl(SnowyData snowyData, SnowSettings settings) var posts = GetPosts(snowyData.Files, category); TestModule.Category = category; + TestModule.HeaderTitleChain = new[] { category.Name, "Categories", TestModule.Settings.BlogTitle }; TestModule.GeneratedUrl = settings.SiteUrl + "/category/" + category.Url + "/"; TestModule.PostsInCategory = posts.ToList(); diff --git a/src/Snow/StaticFileProcessors/DraftsProcessor.cs b/src/Snow/StaticFileProcessors/DraftsProcessor.cs index b6c5162d..46df5d1d 100644 --- a/src/Snow/StaticFileProcessors/DraftsProcessor.cs +++ b/src/Snow/StaticFileProcessors/DraftsProcessor.cs @@ -1,6 +1,7 @@ namespace Snow.StaticFileProcessors { using Enums; + using Snow.Models; public class DraftsProcessor : StaticFileProcessor { @@ -12,7 +13,7 @@ public override string ProcessorName protected override void Impl(SnowyData snowyData, SnowSettings settings) { TestModule.Published = Published.Draft; - + TestModule.HeaderTitleChain = new[] { "Drafts", TestModule.Settings.BlogTitle }; base.Impl(snowyData, settings); } } diff --git a/src/Snow/TestModule.cs b/src/Snow/TestModule.cs index 670d31d4..53ce81a9 100644 --- a/src/Snow/TestModule.cs +++ b/src/Snow/TestModule.cs @@ -19,6 +19,9 @@ public static string GeneratedDate get { return Date; } } + //Title to pass to viewmodel, changes on iterations. + public static IEnumerable HeaderTitleChain { get; set; } + //Data changes on iterations public static Post Data { get; set; } public static string StaticFile { get; set; } @@ -66,6 +69,7 @@ public TestModule() NextPage = PageNumber + 1, PreviousPage = PageNumber - 1, MonthYearList = MonthYear, + HeaderTitleChain = HeaderTitleChain, GeneratedDate = GeneratedDate, Category = Category, Drafts = Drafts, @@ -89,6 +93,7 @@ public TestModule() PostDate = Data.Date, Layout = Data.Layout, Title = Data.Title, + HeaderTitleChain = new string[] { Data.Title, Settings.BlogTitle }, GeneratedDate = GeneratedDate, Url = Data.Url, AllCategories = Categories, diff --git a/src/Snow/ViewModels/BaseViewModel.cs b/src/Snow/ViewModels/BaseViewModel.cs index 9db62679..6fe4be65 100644 --- a/src/Snow/ViewModels/BaseViewModel.cs +++ b/src/Snow/ViewModels/BaseViewModel.cs @@ -6,6 +6,11 @@ namespace Snow.ViewModels public abstract class BaseViewModel : DynamicDictionary { + /// + /// Title of current view. Will generally be in order from most to least + /// specific, with final value always being site name. + /// + public IEnumerable HeaderTitleChain { get; set; } /// /// All posts ///