From 6f97cb888178686b642d25038781079b6c1d73a8 Mon Sep 17 00:00:00 2001 From: Mathieu Guindon Date: Tue, 29 Oct 2024 22:19:30 -0400 Subject: [PATCH 01/11] ignore appsettings.json --- .gitignore | 3 ++- rubberduckvba.Server/appsettings.json | 29 --------------------------- 2 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 rubberduckvba.Server/appsettings.json diff --git a/.gitignore b/.gitignore index 1a4c036..933f381 100644 --- a/.gitignore +++ b/.gitignore @@ -361,4 +361,5 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd +/rubberduckvba.Server/appsettings.json diff --git a/rubberduckvba.Server/appsettings.json b/rubberduckvba.Server/appsettings.json deleted file mode 100644 index 0a58fec..0000000 --- a/rubberduckvba.Server/appsettings.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "ConnectionStrings": { - "RubberduckDb": "Data Source=(localdb)\\MSSQLLocalDB;Integrated Security=True;Trust Server Certificate=True;", - "HangfireDb": "Data Source=(localdb)\\MSSQLLocalDB;Integrated Security=True;Trust Server Certificate=True;" - }, - "GitHub": { - "CodeInspectionDefaultSettingsUri": "/Rubberduck.CodeAnalysis/Properties/CodeInspectionDefaults.settings", - "CodeInspectionInfoResxUri": "https://github.com/rubberduck-vba/Rubberduck/blob/next/Rubberduck.Resources/Inspections/InspectionInfo.resx" - }, - "Hangfire": { - "QueuePollIntervalSeconds": 30, - "AutoRetryAttempts": 2, - "AutoRetryDelaySeconds": [ 2, 5, 10, 30, 60 ], - "HeartbeatIntervalMinutes": 1, - "CancellationCheckIntervalSeconds": 300, - "ConfigureHangfireServerOnStartup": true, - "CreateUpdateInstallerDownloadsJob": true, - "CreateUpdateXmldocContentJob": true, - "UpdateInstallerDownloadsSchedule": "0 0 * * *", // daily - "UpdateXmldocContentSchedule": "0 0 31 2 *" // never - }, - "AllowedHosts": "*" -} From 60bb31ac27dcdb09d1174be9797e733308e7102f Mon Sep 17 00:00:00 2001 From: Mathieu Guindon Date: Tue, 29 Oct 2024 22:19:56 -0400 Subject: [PATCH 02/11] layout tweaks; fix markdown formatting --- .../SyntaxHighlighterService.cs | 3 +- .../Api/Admin/AdminController.cs | 1 - .../Api/Features/FeaturesController.cs | 18 ++-- .../XmlDoc/XmlDocInspection.cs | 4 +- rubberduckvba.Server/Program.cs | 3 +- .../InstallerDownloadStatsOrchestrator.cs | 4 +- .../Services/MarkdownFormattingService.cs | 4 +- rubberduckvba.client/src/app/app.module.ts | 2 + .../example-box/example-box.component.html | 7 +- .../feature-box/feature-box.component.html | 101 ++++++++---------- .../feature-info/feature-info.component.html | 11 +- .../feature-item-box.component.html | 4 +- .../loading-content.component.html | 8 ++ .../loading-content.component.ts | 17 +++ .../src/app/model/tags.model.ts | 4 +- .../routes/features/features.component.html | 21 ++-- .../src/app/routes/home/home.component.ts | 2 +- .../src/assets/__autocompletion.gif | Bin 0 -> 50137 bytes .../src/assets/autocompletion.gif | Bin 50137 -> 11496 bytes 19 files changed, 111 insertions(+), 103 deletions(-) create mode 100644 rubberduckvba.client/src/app/components/loading-content/loading-content.component.html create mode 100644 rubberduckvba.client/src/app/components/loading-content/loading-content.component.ts create mode 100644 rubberduckvba.client/src/assets/__autocompletion.gif diff --git a/RubberduckServices/SyntaxHighlighterService.cs b/RubberduckServices/SyntaxHighlighterService.cs index 7f6a9e8..03ed507 100644 --- a/RubberduckServices/SyntaxHighlighterService.cs +++ b/RubberduckServices/SyntaxHighlighterService.cs @@ -99,7 +99,8 @@ public async Task FormatAsync(string code) let trimmed = line.Substring(indent) select FormatIndents(trimmed); - return await Task.FromResult(string.Join("
", formattedLines)); + var reconstructed = string.Join("
", formattedLines); + return await Task.FromResult(reconstructed); } private void FormatTokens(StringBuilder builder, ITokenStream tokens, IntervalListener[] listeners) diff --git a/rubberduckvba.Server/Api/Admin/AdminController.cs b/rubberduckvba.Server/Api/Admin/AdminController.cs index 9e768f2..16406db 100644 --- a/rubberduckvba.Server/Api/Admin/AdminController.cs +++ b/rubberduckvba.Server/Api/Admin/AdminController.cs @@ -42,7 +42,6 @@ public async ValueTask UpdateTagMetadata() return await ValueTask.FromResult(Ok(jobId)); } - [Authorize("github")] [HttpGet("admin/config/current")] public async ValueTask Config() { diff --git a/rubberduckvba.Server/Api/Features/FeaturesController.cs b/rubberduckvba.Server/Api/Features/FeaturesController.cs index de60313..0a39ef9 100644 --- a/rubberduckvba.Server/Api/Features/FeaturesController.cs +++ b/rubberduckvba.Server/Api/Features/FeaturesController.cs @@ -48,6 +48,9 @@ public async Task>> Index() return Ok(model); } + private static readonly IDictionary _moduleTypeNames = typeof(ExampleModuleType).GetMembers().Where(e => e.GetCustomAttribute() != null) + .ToDictionary(member => member.Name, member => member.GetCustomAttribute()?.Description ?? member.Name); + [HttpGet("features/{name}")] [AllowAnonymous] public async Task> Info([FromRoute] string name) @@ -63,12 +66,10 @@ public async Task> Info([FromRoute] string name) return NotFound(); } - var moduleTypeNames = typeof(ExampleModuleType).GetMembers().Where(e => e.GetCustomAttribute() != null).ToDictionary(member => member.Name, member => member.GetCustomAttribute()?.Description ?? member.Name); - var model = new FeatureViewModel(feature with { Description = await md.FormatMarkdownDocument(feature.Description, true), - ShortDescription = feature.ShortDescription, + ShortDescription = await md.FormatMarkdownDocument(feature.ShortDescription), ParentId = feature.Id, ParentName = feature.Name, @@ -76,8 +77,8 @@ public async Task> Info([FromRoute] string name) Features = feature.Features.Select(subFeature => subFeature with { - Description = subFeature.Description, - ShortDescription = subFeature.ShortDescription + Description = md.FormatMarkdownDocument(subFeature.Description).ConfigureAwait(false).GetAwaiter().GetResult(), + ShortDescription = md.FormatMarkdownDocument(subFeature.ShortDescription).ConfigureAwait(false).GetAwaiter().GetResult() }).ToArray(), Inspections = feature.Items.Select(item => @@ -108,11 +109,14 @@ public async Task> Info([FromRoute] string name) DefaultSeverity = info.DefaultSeverity, QuickFixes = info.QuickFixes, Serialized = item.Serialized, - Examples = info.Examples ?? [] + Examples = info.Examples.Select(e => e with + { + Modules = e.Modules.Select(module => module with { ModuleTypeName = _moduleTypeNames[module.ModuleType.ToString()] }).ToList() + }).ToList() ?? [] }; }).ToArray(), - Items = feature.Items + //Items = feature.Items }); //cache.Write(HttpContext.Request.Path, model); diff --git a/rubberduckvba.Server/ContentSynchronization/XmlDoc/XmlDocInspection.cs b/rubberduckvba.Server/ContentSynchronization/XmlDoc/XmlDocInspection.cs index 7da610b..7ca4812 100644 --- a/rubberduckvba.Server/ContentSynchronization/XmlDoc/XmlDocInspection.cs +++ b/rubberduckvba.Server/ContentSynchronization/XmlDoc/XmlDocInspection.cs @@ -163,13 +163,13 @@ private IEnumerable ParseExamples(XElement node) { HtmlContent = await _markdownService.FormatMarkdownDocument("" + m.Nodes().OfType().Single().Value.Trim().Replace(" ", " ") + "", withSyntaxHighlighting: true), ModuleName = m.Attribute(XmlDocSchema.Inspection.Example.Module.ModuleNameAttribute)?.Value ?? string.Empty, - ModuleType = ModuleTypes.TryGetValue(m.Attribute(XmlDocSchema.Inspection.Example.Module.ModuleTypeAttribute)?.Value ?? string.Empty, out var type) ? type : ExampleModuleType.Any, + ModuleType = ModuleTypes.TryGetValue(m.Attribute(XmlDocSchema.Inspection.Example.Module.ModuleTypeAttribute)?.Value.Trim() ?? string.Empty, out var type) ? type : ExampleModuleType.Any, }) .Select(t => t.GetAwaiter().GetResult()) .Concat(e.Nodes().OfType().Select(async x => new ExampleModule { - HtmlContent = await _markdownService.FormatMarkdownDocument(x.Value, withSyntaxHighlighting: true), + HtmlContent = await _markdownService.FormatMarkdownDocument("" + x.Value.Trim().Replace(" ", " ") + "", withSyntaxHighlighting: true), ModuleName = "Module1", ModuleType = ExampleModuleType.Any }) diff --git a/rubberduckvba.Server/Program.cs b/rubberduckvba.Server/Program.cs index 9b3e7f7..f379a97 100644 --- a/rubberduckvba.Server/Program.cs +++ b/rubberduckvba.Server/Program.cs @@ -16,13 +16,14 @@ using rubberduckvba.com.Server.ContentSynchronization.XmlDoc.Abstract; using rubberduckvba.com.Server.Hangfire; using rubberduckvba.com.Server.Services; +using System.Diagnostics; using System.Reflection; namespace rubberduckvba.com.Server; public class HangfireAuthenticationFilter : IDashboardAuthorizationFilter { - public bool Authorize([NotNull] DashboardContext context) => context.Request.RemoteIpAddress == "20.220.30.154"; + public bool Authorize([NotNull] DashboardContext context) => Debugger.IsAttached || context.Request.RemoteIpAddress == "20.220.30.154"; } public class Program diff --git a/rubberduckvba.Server/Services/InstallerDownloadStatsOrchestrator.cs b/rubberduckvba.Server/Services/InstallerDownloadStatsOrchestrator.cs index a68264c..e2b1f45 100644 --- a/rubberduckvba.Server/Services/InstallerDownloadStatsOrchestrator.cs +++ b/rubberduckvba.Server/Services/InstallerDownloadStatsOrchestrator.cs @@ -13,14 +13,14 @@ public async Task UpdateContentAsync(TagSyncRequestParameters request, Cancellat { await pipeline.ExecuteAsync(request, tokenSource); } - catch (TaskCanceledException) + catch (TaskCanceledException e) { var exceptions = pipeline.Exceptions.ToList(); if (exceptions.Count > 0) { if (exceptions.Count == 1) { - throw exceptions[0]; + throw new OperationCanceledException(e.Message, exceptions[0]); } else { diff --git a/rubberduckvba.Server/Services/MarkdownFormattingService.cs b/rubberduckvba.Server/Services/MarkdownFormattingService.cs index 248c387..8a014bd 100644 --- a/rubberduckvba.Server/Services/MarkdownFormattingService.cs +++ b/rubberduckvba.Server/Services/MarkdownFormattingService.cs @@ -18,7 +18,7 @@ public async Task FormatMarkdownDocument(string content, bool withSyntax return string.Empty; } - var markdown = content.Replace("\n","\r\n"); + var markdown = content.Replace("\n", "\r\n"); if (withSyntaxHighlighting) { markdown = await PreProcessMarkdownString(markdown); @@ -63,7 +63,7 @@ private async Task PreProcessMarkdownString(string content) node.AppendChild(codeAreaDiv); } - return document.DocumentNode.FirstChild.InnerHtml; + return document.DocumentNode.InnerHtml; } private async Task PostProcessHtml(string html) diff --git a/rubberduckvba.client/src/app/app.module.ts b/rubberduckvba.client/src/app/app.module.ts index 8c9cb30..ab024be 100644 --- a/rubberduckvba.client/src/app/app.module.ts +++ b/rubberduckvba.client/src/app/app.module.ts @@ -21,6 +21,7 @@ import { FeatureItemExampleComponent } from './components/quickfix-example.modal import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { BrowserModule } from '@angular/platform-browser'; import { RouterModule } from '@angular/router'; +import { LoadingContentComponent } from './components/loading-content/loading-content.component'; //import { httpInterceptorProviders } from './services/HttpRequestInterceptor'; @@ -38,6 +39,7 @@ import { RouterModule } from '@angular/router'; FeatureItemBoxComponent, ExampleBoxComponent, FeatureItemExampleComponent, + LoadingContentComponent ], bootstrap: [AppComponent], imports: [ diff --git a/rubberduckvba.client/src/app/components/example-box/example-box.component.html b/rubberduckvba.client/src/app/components/example-box/example-box.component.html index 5665c2d..44a5952 100644 --- a/rubberduckvba.client/src/app/components/example-box/example-box.component.html +++ b/rubberduckvba.client/src/app/components/example-box/example-box.component.html @@ -1,9 +1,6 @@
-
-

Loading...

-