working with links
This commit is contained in:
parent
77e6ed78fd
commit
16f4dc9a76
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -17,7 +17,7 @@
|
|||||||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
|
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
|
||||||
"serverReadyAction": {
|
"serverReadyAction": {
|
||||||
"action": "openExternally",
|
"action": "openExternally",
|
||||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
|
"pattern": "\\bNow listening on:\\s+(http?://\\S+)"
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using BinaryDad.Notes.Services;
|
using BinaryDad.Notes.Models;
|
||||||
|
using BinaryDad.Notes.Services;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace BinaryDad.Notes.Controllers;
|
namespace BinaryDad.Notes.Controllers;
|
||||||
@ -15,8 +16,12 @@ public class HomeController : Controller
|
|||||||
[Route("{noteName?}")]
|
[Route("{noteName?}")]
|
||||||
public IActionResult Index(string? 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
Models/ContentModel.cs
Normal file
7
Models/ContentModel.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace BinaryDad.Notes.Models;
|
||||||
|
|
||||||
|
public class ContentModel
|
||||||
|
{
|
||||||
|
public ICollection<string> NoteNames { get; set; }
|
||||||
|
public string Text { get; set; }
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
namespace BinaryDad.Notes.Models;
|
|
||||||
|
|
||||||
public class ErrorViewModel
|
|
||||||
{
|
|
||||||
public string? RequestId { get; set; }
|
|
||||||
|
|
||||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
|
||||||
}
|
|
@ -23,7 +23,7 @@ namespace BinaryDad.Notes
|
|||||||
|
|
||||||
public async Task SaveNote(string content, string? noteName)
|
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
|
// find all other connections except for the current one
|
||||||
var clientConnections = NoteContext.ClientNotes
|
var clientConnections = NoteContext.ClientNotes
|
||||||
|
1
Notes/content
Normal file
1
Notes/content
Normal file
@ -0,0 +1 @@
|
|||||||
|
default page
|
1
Notes/homelab-stuff
Normal file
1
Notes/homelab-stuff
Normal file
@ -0,0 +1 @@
|
|||||||
|
some homelab stuff
|
1
Notes/my-notes
Normal file
1
Notes/my-notes
Normal file
@ -0,0 +1 @@
|
|||||||
|
sdsada
|
1
Notes/sdfsfd
Normal file
1
Notes/sdfsfd
Normal file
@ -0,0 +1 @@
|
|||||||
|
this is on weird page
|
@ -8,29 +8,6 @@
|
|||||||
},
|
},
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"applicationUrl": "http://localhost:5015"
|
"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": {
|
"iisSettings": {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
CheckFile(defaultFileName);
|
CheckFile(defaultFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Get(string? noteName)
|
public string GetText(string? noteName)
|
||||||
{
|
{
|
||||||
CheckFile(noteName);
|
CheckFile(noteName);
|
||||||
|
|
||||||
@ -22,10 +22,12 @@
|
|||||||
|
|
||||||
public ICollection<string> GetNoteNames()
|
public ICollection<string> 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);
|
File.WriteAllText(GetFilePath(noteName), content);
|
||||||
}
|
}
|
||||||
@ -37,7 +39,7 @@
|
|||||||
// ensure initialized
|
// ensure initialized
|
||||||
if (!File.Exists(filePath))
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
public interface INoteService
|
public interface INoteService
|
||||||
{
|
{
|
||||||
ICollection<string> GetNoteNames();
|
ICollection<string> GetNoteNames();
|
||||||
string Get(string? noteName);
|
string GetText(string? noteName);
|
||||||
void Save(string content, string? noteName);
|
void SaveText(string content, string? noteName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
@model string
|
@model ContentModel
|
||||||
|
|
||||||
<textarea id="content" name="content" spellcheck="false">@Model</textarea>
|
<textarea id="content" name="content" spellcheck="false">@Model.Text</textarea>
|
||||||
|
|
||||||
|
<div class="note-names">
|
||||||
|
@foreach (var note in Model.NoteNames)
|
||||||
|
{
|
||||||
|
<a href="@note">@note</a>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="toast" id="saved-indicator">Saved</div>
|
<div class="toast" id="saved-indicator">Saved</div>
|
||||||
<div class="toast" id="update-indicator">Updated</div>
|
<div class="toast" id="update-indicator">Updated</div>
|
@ -1,25 +0,0 @@
|
|||||||
@model ErrorViewModel
|
|
||||||
@{
|
|
||||||
ViewData["Title"] = "Error";
|
|
||||||
}
|
|
||||||
|
|
||||||
<h1 class="text-danger">Error.</h1>
|
|
||||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
|
||||||
|
|
||||||
@if (Model.ShowRequestId)
|
|
||||||
{
|
|
||||||
<p>
|
|
||||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
|
||||||
</p>
|
|
||||||
}
|
|
||||||
|
|
||||||
<h3>Development Mode</h3>
|
|
||||||
<p>
|
|
||||||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
|
||||||
It can result in displaying sensitive information from exceptions to end users.
|
|
||||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
|
||||||
and restarting the app.
|
|
||||||
</p>
|
|
@ -20,6 +20,23 @@ body {
|
|||||||
min-height: 100%;
|
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 {
|
textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -52,14 +69,14 @@ textarea {
|
|||||||
border-radius: 5px 5px 0 0;
|
border-radius: 5px 5px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toast.show {
|
.toast.show {
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toast#saved-indicator {
|
.toast#saved-indicator {
|
||||||
background-color: green;
|
background-color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toast#update-indicator {
|
.toast#update-indicator {
|
||||||
background-color: orangered;
|
background-color: orangered;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user