From 76c934d13a0a0dda31c3b8541c39ed2c343d56f6 Mon Sep 17 00:00:00 2001 From: Athene Allen Date: Thu, 30 Jan 2025 13:38:43 +0000 Subject: [PATCH 1/1] fixed --- .gitignore | 19 ++--------- RSSGen/Program.cs | 76 ++++++++++++++++++++++++++++++++++++++++++++ RSSGen/RSSGen.csproj | 14 ++++++++ RSSGen/RSSGen.sln | 22 +++++++++++++ 4 files changed, 114 insertions(+), 17 deletions(-) create mode 100644 RSSGen/Program.cs create mode 100644 RSSGen/RSSGen.csproj create mode 100644 RSSGen/RSSGen.sln diff --git a/.gitignore b/.gitignore index b621bfc..d6ab001 100644 --- a/.gitignore +++ b/.gitignore @@ -20,20 +20,5 @@ Gemfile.lock RSSGen/.vs/ProjectEvaluation/rssgen.metadata.v9.bin RSSGen/.vs/ProjectEvaluation/rssgen.projects.v9.bin RSSGen/.vs/ProjectEvaluation/rssgen.strings.v9.bin -RSSGen/bin/Debug/net8.0/RSSGen.dll -RSSGen/bin/Debug/net8.0/RSSGen.exe -RSSGen/bin/Debug/net8.0/RSSGen.pdb -RSSGen/obj/project.nuget.cache -RSSGen/obj/RSSGen.csproj.nuget.dgspec.json -RSSGen/obj/RSSGen.csproj.nuget.g.props -RSSGen/obj/Debug/net8.0/apphost.exe -RSSGen/obj/Debug/net8.0/RSSGen.AssemblyInfo.cs -RSSGen/obj/Debug/net8.0/RSSGen.AssemblyInfoInputs.cache -RSSGen/obj/Debug/net8.0/RSSGen.assets.cache -RSSGen/obj/Debug/net8.0/RSSGen.dll -RSSGen/obj/Debug/net8.0/RSSGen.GeneratedMSBuildEditorConfig.editorconfig -RSSGen/obj/Debug/net8.0/RSSGen.genruntimeconfig.cache -RSSGen/obj/Debug/net8.0/RSSGen.pdb -RSSGen/obj/Debug/net8.0/RSSGen.sourcelink.json -RSSGen/obj/Debug/net8.0/ref/RSSGen.dll -RSSGen/obj/Debug/net8.0/refint/RSSGen.dll +RSSGen/bin/ +RSSGen/obj/ diff --git a/RSSGen/Program.cs b/RSSGen/Program.cs new file mode 100644 index 0000000..1af488a --- /dev/null +++ b/RSSGen/Program.cs @@ -0,0 +1,76 @@ +using RssFeedGenerator; +using System; +using System.Collections.Generic; +using System.IO; + +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Scanning entries folder for latest files"); + +var filePaths = Directory.EnumerateFiles(Path.Combine(Directory.GetCurrentDirectory(), "../../../../entries")); +var fileInfos = new List(); + +if (filePaths.Any()) +{ + foreach (var path in filePaths) + { + if (Path.GetFileNameWithoutExtension(path).Equals("template", StringComparison.InvariantCultureIgnoreCase)) + continue; + var fInfo = new FileInfo(path); + fileInfos.Add(fInfo); + } +} + +Console.WriteLine("Scanning projects folder for latest files"); + +filePaths = Directory.EnumerateFiles(Path.Combine(Directory.GetCurrentDirectory(), "../../../../projects")); + +if (filePaths.Any()) +{ + foreach (var path in filePaths) + { + var fInfo = new FileInfo(path); + fileInfos.Add(fInfo); + } +} + +fileInfos = fileInfos.OrderByDescending(f => f.CreationTimeUtc).Take(10).ToList(); + +var myRSS = new rss(); + +myRSS.version = 2.0m; + +myRSS.channel = new rssChannel +{ + title = "athene.gay entries", + description = "blog entries for athene.gay", + language = "en-GB", + link = "https://athene.gay", + item = new List() +}; + +foreach (var file in fileInfos) +{ + var item = new rssChannelItem() + { + title = Path.GetFileNameWithoutExtension(file.Name), + pubDate = file.CreationTimeUtc.ToString(), + }; + if (file.FullName.Contains("entries")) + { + item.link = "https://athene.gay/entries/" + Path.GetFileName(file.Name); + } else if (file.FullName.Contains("projects")) + { + item.link = "https://athene.gay/projects/" + Path.GetFileName(file.Name); + } + myRSS.channel.item.Add(item); +} + +var output = Generator.SerializeRSS(myRSS); + +var rssPath = Path.Combine(Directory.GetCurrentDirectory(), "../../../../feed.rss"); + +if (File.Exists(rssPath)) { + File.Delete(rssPath); +} + +File.WriteAllText(rssPath, output); \ No newline at end of file diff --git a/RSSGen/RSSGen.csproj b/RSSGen/RSSGen.csproj new file mode 100644 index 0000000..278f221 --- /dev/null +++ b/RSSGen/RSSGen.csproj @@ -0,0 +1,14 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + diff --git a/RSSGen/RSSGen.sln b/RSSGen/RSSGen.sln new file mode 100644 index 0000000..a16b414 --- /dev/null +++ b/RSSGen/RSSGen.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RSSGen", "RSSGen.csproj", "{5B1B1ED0-6FEF-45A8-A5F1-60EB2EFE5B8A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5B1B1ED0-6FEF-45A8-A5F1-60EB2EFE5B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5B1B1ED0-6FEF-45A8-A5F1-60EB2EFE5B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5B1B1ED0-6FEF-45A8-A5F1-60EB2EFE5B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5B1B1ED0-6FEF-45A8-A5F1-60EB2EFE5B8A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal -- 2.47.3