Skip to content

Commit abef44d

Browse files
committed
Refactor naming
1 parent e36a293 commit abef44d

File tree

17 files changed

+124
-102
lines changed

17 files changed

+124
-102
lines changed

docs-builder.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.ApiExplorer.Tests",
107107
EndProject
108108
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.Site", "src\Elastic.Documentation.Site\Elastic.Documentation.Site.csproj", "{89B83007-71E6-4B57-BA78-2544BFA476DB}"
109109
EndProject
110-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.LegacyPageLookup", "src\Elastic.Documentation.LegacyPageLookup\Elastic.Documentation.LegacyPageLookup.csproj", "{111E7029-BB29-4039-9B45-04776798A8DD}"
110+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.LegacyDocs", "src\Elastic.Documentation.LegacyDocs\Elastic.Documentation.LegacyDocs.csproj", "{111E7029-BB29-4039-9B45-04776798A8DD}"
111111
EndProject
112-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.LegacyPageLookup.Tests", "tests\Elastic.Documentation.LegacyPageLookup.Tests\Elastic.Documentation.LegacyPageLookup.Tests.csproj", "{164F55EC-9412-4CD4-81AD-3598B57632A6}"
112+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.LegacyDocs.Tests", "tests\Elastic.Documentation.LegacyDocs.Tests\Elastic.Documentation.LegacyDocs.Tests.csproj", "{164F55EC-9412-4CD4-81AD-3598B57632A6}"
113113
EndProject
114114
Global
115115
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<RootNamespace>Elastic.Documentation.LegacyPageLookup</RootNamespace>
78
</PropertyGroup>
89

910
<ItemGroup>

src/Elastic.Documentation.LegacyPageLookup/LegacyPageLookup.cs renamed to src/Elastic.Documentation.LegacyDocs/LegacyPageChecker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace Elastic.Documentation.LegacyPageLookup;
1010
public class LegacyPageLookup(IFileSystem fs)
1111
{
1212
private BloomFilter? _bloomFilter;
13-
private readonly string _bloomFilterBinaryPath = Path.Combine(Paths.WorkingDirectoryRoot.FullName, "src", "Elastic.Documentation.LegacyPageLookup", "legacy-pages.bloom.bin");
13+
private readonly string _bloomFilterBinaryPath = Path.Combine(Paths.WorkingDirectoryRoot.FullName, "src", "Elastic.Documentation.LegacyDocs", "legacy-pages.bloom.bin");
1414

1515

1616
public bool PathExists(string path)

src/Elastic.Documentation.LegacyPageLookup/PagesProvider.cs renamed to src/Elastic.Documentation.LegacyDocs/PagesProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ public interface IPagesProvider
1212
IEnumerable<string> GetPages();
1313
}
1414

15+
/// <summary>
16+
/// Gets pages from a local checked-out elastic/built-docs repository
17+
/// </summary>
18+
/// <param name="gitRepositoryPath"></param>
1519
public class LocalPagesProvider(string gitRepositoryPath) : IPagesProvider
1620
{
1721
public IEnumerable<string> GetPages() =>

src/Elastic.Documentation/Legacy/ILegacyUrlMapper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Elastic.Documentation.Legacy;
66

7-
public record LegacyPageMapping(string Url, string Version)
7+
public record LegacyPageMapping(string RawUrl, string Version, bool Exists)
88
{
9-
public override string ToString() => Url.Replace("/current/", $"/{Version}/");
9+
public override string ToString() => RawUrl.Replace("/current/", $"/{Version}/");
1010
};
1111

1212
public interface ILegacyUrlMapper

src/Elastic.Markdown/Elastic.Markdown.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</ItemGroup>
2929

3030
<ItemGroup>
31-
<ProjectReference Include="..\Elastic.Documentation.LegacyPageLookup\Elastic.Documentation.LegacyPageLookup.csproj" />
31+
<ProjectReference Include="..\Elastic.Documentation.LegacyDocs\Elastic.Documentation.LegacyDocs.csproj" />
3232
<ProjectReference Include="..\Elastic.Documentation.Site\Elastic.Documentation.Site.csproj" />
3333
<ProjectReference Include="..\Elastic.Documentation.LinkIndex\Elastic.Documentation.LinkIndex.csproj" />
3434
<ProjectReference Include="..\Elastic.Documentation\Elastic.Documentation.csproj" />

src/Elastic.Markdown/Slices/HtmlWriter.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ private async Task<string> RenderLayout(MarkdownFile markdown, MarkdownDocument
8686
.Distinct()
8787
.ToHashSet();
8888

89-
var legacyPageLookup = new LegacyPageLookup(new FileSystem());
90-
9189
var slice = Index.Create(new IndexViewModel
9290
{
9391
SiteName = siteName,
@@ -114,8 +112,7 @@ private async Task<string> RenderLayout(MarkdownFile markdown, MarkdownDocument
114112
StaticFileContentHashProvider = StaticFileContentHashProvider,
115113
ReportIssueUrl = reportUrl,
116114
CurrentVersion = legacyPages.Count > 0 ? legacyPages.ElementAt(0).Version : "9.0+",
117-
LegacyPages = legacyPages.Skip(1).Where(
118-
l => Uri.TryCreate(l.ToString(), UriKind.Absolute, out var uri) && legacyPageLookup.PathExists(uri.AbsolutePath)).ToArray(),
115+
LegacyPages = legacyPages.Skip(1).ToArray(),
119116
VersionDropdownItems = VersionDrownDownItemViewModel.FromLegacyPageMappings(legacyPages.Skip(1).ToArray()),
120117
Products = allProducts
121118
});

src/Elastic.Markdown/Slices/Layout/_TableOfContents.cshtml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<li class="block">
3535
<a
3636

37-
class="block py-2 px-4 font-semibold text-grey-60 cursor-default"
37+
class="block py-1 px-4 font-semibold text-grey-60 cursor-default"
3838
@Htmx.GetNavHxAttributes(false, "mouseover")
3939
>
4040
@if (Model.CurrentVersion is not null)
@@ -50,17 +50,28 @@
5050
@foreach (var legacyPage in Model.LegacyPages)
5151
{
5252
<li class="block">
53-
<a
54-
class="block py-1 px-4 text-sm hover:underline hover:text-black hover:bg-grey-10 active:bg-blue-elastic-70 active:text-white font-semibold text-ink rounded-sm"
55-
href="@legacyPage">
56-
@legacyPage.Version
57-
</a>
53+
@if (legacyPage.Exists)
54+
{
55+
<a
56+
class="block py-1 px-4 text-sm hover:underline hover:text-black hover:bg-grey-10 active:bg-blue-elastic-70 active:text-white font-semibold text-ink rounded-sm"
57+
href="@legacyPage">
58+
@legacyPage.Version
59+
</a>
60+
}
61+
else
62+
{
63+
<a
64+
class="block py-1 px-4 font-semibold text-grey-60 cursor-default">
65+
@legacyPage.Version
66+
</a>
67+
}
68+
5869
</li>
5970
}
6071
@if (Model.LegacyPages.Length == 0)
6172
{
6273
<li class="block border-t-1 border-grey-20">
63-
<div class="py-2 px-4 text-sm">
74+
<div class="py-1 px-4 text-sm">
6475
There is no previous version of this page.
6576
</div>
6677
</li>

0 commit comments

Comments
 (0)