Skip to content

Commit

Permalink
Merge commit 'bfd31d5ab71108772a27d55d161d127fd15c0766'
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Jul 26, 2024
2 parents cbe3bfb + bfd31d5 commit 33b5f54
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/Tool/MVPBlog/MVPBlog.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVP博客统计", "MVP博客统计.csproj", "{A56CAE00-C21F-4B30-9D19-7E0493C05A5B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A56CAE00-C21F-4B30-9D19-7E0493C05A5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A56CAE00-C21F-4B30-9D19-7E0493C05A5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A56CAE00-C21F-4B30-9D19-7E0493C05A5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A56CAE00-C21F-4B30-9D19-7E0493C05A5B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions app/Tool/MVPBlog/MVP博客统计.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>

</Project>
44 changes: 44 additions & 0 deletions app/Tool/MVPBlog/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// See https://aka.ms/new-console-template for more information

using System.Text;
using System.Text.RegularExpressions;

var blogFolder = @"C:\lindexi\Blog\";
var output = "Result.csv";

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

foreach (var blogFile in Directory.EnumerateFiles(blogFolder, "*.md"))
{
var fileName = Path.GetFileNameWithoutExtension(blogFile);

var dateText = ReadDateFromFile(blogFile);

if (!string.IsNullOrEmpty(dateText))
{
File.AppendAllText(output, $"\"{fileName}\",{dateText}\r\n", Encoding.GetEncoding("GBK"));
Console.WriteLine($"{fileName} {dateText}");
}
}

string? ReadDateFromFile(string blogFile)
{
using var fileStream = File.OpenRead(blogFile);
using var streamReader = new StreamReader(fileStream);
while (true)
{
var line = streamReader.ReadLine();
if (line is null)
{
break;
}

var match = Regex.Match(line, @"<\!\-\- CreateTime\:([\S\s]*) \-\->");
if (match.Success)
{
return match.Groups[1].Value;
}
}

return null;
}

0 comments on commit 33b5f54

Please sign in to comment.