diff --git a/.vscode/launch.json b/.vscode/launch.json index 1768fa5..47886ae 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,7 +17,7 @@ // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser "serverReadyAction": { "action": "openExternally", - "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + "pattern": "\\bNow listening on:\\s+(http?://\\S+)" }, "env": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index be8ae83..8841348 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -1,4 +1,5 @@ -using BinaryDad.Notes.Services; +using BinaryDad.Notes.Models; +using BinaryDad.Notes.Services; using Microsoft.AspNetCore.Mvc; namespace BinaryDad.Notes.Controllers; @@ -15,8 +16,12 @@ public class HomeController : Controller [Route("{noteName?}")] public IActionResult Index(string? noteName) { - var content = noteService.Get(noteName); + var model = new ContentModel + { + Text = noteService.GetText(noteName), + NoteNames = noteService.GetNoteNames() + }; - return View((object)content); + return View(model); } } diff --git a/Models/ContentModel.cs b/Models/ContentModel.cs new file mode 100644 index 0000000..26f2e64 --- /dev/null +++ b/Models/ContentModel.cs @@ -0,0 +1,7 @@ +namespace BinaryDad.Notes.Models; + +public class ContentModel +{ + public ICollection NoteNames { get; set; } + public string Text { get; set; } +} \ No newline at end of file diff --git a/Models/ErrorViewModel.cs b/Models/ErrorViewModel.cs deleted file mode 100644 index 8e3c889..0000000 --- a/Models/ErrorViewModel.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace BinaryDad.Notes.Models; - -public class ErrorViewModel -{ - public string? RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); -} diff --git a/NoteHub.cs b/NoteHub.cs index 20ad638..52836ef 100644 --- a/NoteHub.cs +++ b/NoteHub.cs @@ -23,7 +23,7 @@ namespace BinaryDad.Notes public async Task SaveNote(string content, string? noteName) { - noteService.Save(content, noteName); + noteService.SaveText(content, noteName); // find all other connections except for the current one var clientConnections = NoteContext.ClientNotes diff --git a/Notes/content b/Notes/content new file mode 100644 index 0000000..521df3e --- /dev/null +++ b/Notes/content @@ -0,0 +1 @@ +default page \ No newline at end of file diff --git a/Notes/homelab-stuff b/Notes/homelab-stuff new file mode 100644 index 0000000..2fe782f --- /dev/null +++ b/Notes/homelab-stuff @@ -0,0 +1 @@ +some homelab stuff \ No newline at end of file diff --git a/Notes/my-notes b/Notes/my-notes new file mode 100644 index 0000000..ff4a3a5 --- /dev/null +++ b/Notes/my-notes @@ -0,0 +1 @@ +sdsada \ No newline at end of file diff --git a/Notes/sdfsfd b/Notes/sdfsfd new file mode 100644 index 0000000..6197c15 --- /dev/null +++ b/Notes/sdfsfd @@ -0,0 +1 @@ +this is on weird page \ No newline at end of file diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index b02486a..67f6526 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -8,29 +8,6 @@ }, "dotnetRunMessages": true, "applicationUrl": "http://localhost:5015" - }, - "https": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "dotnetRunMessages": true, - "applicationUrl": "https://localhost:7042;http://localhost:5015" - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Docker": { - "commandName": "Docker", - "launchBrowser": true, - "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", - "publishAllPorts": true, - "useSSL": true } }, "iisSettings": { diff --git a/Services/FileNoteService.cs b/Services/FileNoteService.cs index 3e6c92e..6d1eed5 100644 --- a/Services/FileNoteService.cs +++ b/Services/FileNoteService.cs @@ -13,7 +13,7 @@ CheckFile(defaultFileName); } - public string Get(string? noteName) + public string GetText(string? noteName) { CheckFile(noteName); @@ -22,10 +22,12 @@ public ICollection GetNoteNames() { - return Directory.GetFiles(filePath); + return Directory.GetFiles(filePath) + .Select(f => Path.GetFileName(f)) + .ToList(); } - public void Save(string content, string? noteName) + public void SaveText(string content, string? noteName) { File.WriteAllText(GetFilePath(noteName), content); } @@ -37,7 +39,7 @@ // ensure initialized if (!File.Exists(filePath)) { - Save("Hi! Feel free to start typing. Everything will be saved soon after you are done typing.", noteName); + SaveText("Hi! Feel free to start typing. Everything will be saved soon after you are done typing.", noteName); } } diff --git a/Services/INoteService.cs b/Services/INoteService.cs index e61dbde..a5467b2 100644 --- a/Services/INoteService.cs +++ b/Services/INoteService.cs @@ -3,7 +3,7 @@ public interface INoteService { ICollection GetNoteNames(); - string Get(string? noteName); - void Save(string content, string? noteName); + string GetText(string? noteName); + void SaveText(string content, string? noteName); } } diff --git a/Views/Home/Index.cshtml b/Views/Home/Index.cshtml index 18616fa..8dee1b3 100644 --- a/Views/Home/Index.cshtml +++ b/Views/Home/Index.cshtml @@ -1,6 +1,13 @@ -@model string +@model ContentModel - + + +
+ @foreach (var note in Model.NoteNames) + { + @note + } +
Saved
Updated
\ No newline at end of file diff --git a/Views/Shared/Error.cshtml b/Views/Shared/Error.cshtml deleted file mode 100644 index a1e0478..0000000 --- a/Views/Shared/Error.cshtml +++ /dev/null @@ -1,25 +0,0 @@ -@model ErrorViewModel -@{ - ViewData["Title"] = "Error"; -} - -

Error.

-

An error occurred while processing your request.

- -@if (Model.ShowRequestId) -{ -

- Request ID: @Model.RequestId -

-} - -

Development Mode

-

- Swapping to Development environment will display more detailed information about the error that occurred. -

-

- The Development environment shouldn't be enabled for deployed applications. - It can result in displaying sensitive information from exceptions to end users. - For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development - and restarting the app. -

diff --git a/wwwroot/css/site.css b/wwwroot/css/site.css index ce64259..40ba5c2 100644 --- a/wwwroot/css/site.css +++ b/wwwroot/css/site.css @@ -20,6 +20,23 @@ body { min-height: 100%; } +div.note-names { + position: fixed; + bottom: 0; + left: 0; + font-size: 11px; +} + +div.note-names a { + color: #666; + padding: 0 5px; + text-decoration: none; +} + +div.note-names a:not(:last-of-type) { + border-right: 1px solid #666; +} + textarea { width: 100%; height: 100%; @@ -52,14 +69,14 @@ textarea { border-radius: 5px 5px 0 0; } - .toast.show { - bottom: 0; - } +.toast.show { + bottom: 0; +} - .toast#saved-indicator { - background-color: green; - } +.toast#saved-indicator { + background-color: green; +} - .toast#update-indicator { - background-color: orangered; - } +.toast#update-indicator { + background-color: orangered; +} \ No newline at end of file