Merge branch 'master' into dev/multiple-notes

This commit is contained in:
Ryan Peters 2023-07-10 13:24:31 -04:00
commit d73e065805
7 changed files with 39 additions and 28 deletions

3
.vscode/launch.json vendored
View File

@ -24,7 +24,8 @@
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
"checkForDevCert": false
},
{
"name": ".NET Core Attach",

View File

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using BinaryDad.Notes.Services;
namespace BinaryDad.Notes.Controllers
{
public class ApiController : ControllerBase
{
private readonly INoteService noteService;
public ApiController(INoteService noteService)
{
this.noteService = noteService;
}
public string Note() => noteService.Get();
}
}

View File

@ -1,22 +1,13 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish "BinaryDad.Notes.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
COPY --from=build /app/publish .
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["BinaryDad.Notes.csproj", "."]
RUN dotnet restore "./BinaryDad.Notes.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "BinaryDad.Notes.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "BinaryDad.Notes.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BinaryDad.Notes.dll"]

View File

@ -9,14 +9,11 @@ builder.Services.AddControllersWithViews();
builder.Services.AddSignalR();
builder.Services.AddSingleton<INoteService, FileNoteService>();
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(30);
});
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(o =>
{
o.LoginPath = "/login";
o.Cookie.Name = "NotesUser";
o.Cookie.MaxAge = TimeSpan.FromDays(3);
});
var app = builder.Build();

View File

@ -1,8 +1,4 @@
@{
ViewBag.Title = "Login";
}
@Html.ValidationSummary()
@Html.ValidationSummary()
<form method="post">
<input type="password" name="passphrase" placeholder="Passphrase" />

View File

@ -57,7 +57,7 @@ textarea {
border-width: 0;
}
.dark textarea {
body.dark, body.dark input, body.dark textarea {
background-color: #222;
color: #ddd;
}

View File

@ -55,6 +55,15 @@ $(function () {
showToast('#update-indicator');
});
// update content after reconnected
connection.onreconnected(function() {
$.get('api/note', function(content) {
$textarea.val(content);
showToast('#update-indicator');
console.log('Refreshed after disconnect');
});
});
// set dark mode
if (window.location.hash == '#dark') {
$('body').addClass('dark');