mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 17:25:32 +00:00
Small Stuff
This commit is contained in:
@@ -23,7 +23,7 @@ Note that nodejs is used only as a build tool for css (and possibly in the futur
|
||||
|
||||
## Development tools
|
||||
|
||||
Run
|
||||
Set the `DOTNET_ENVIRONMENT` variable to `Development`. Run
|
||||
|
||||
`dotnet watch run` and
|
||||
|
||||
@@ -47,6 +47,16 @@ For a Linux server run:
|
||||
|
||||
`dotnet publish --runtime linux-x64 -c Release`
|
||||
|
||||
In the appropriate settings (set the `DOTNET_ENVIRONMENT` variable on the server to `Staging` (development.hamann-ausgabe.de) or `Production` (hamann-ausgabe.de)) set the variables for
|
||||
|
||||
- HamannFileStoreLinux
|
||||
- WorkingTreePathLinux
|
||||
- BareRepositoryPathLinux
|
||||
- RepositoryBranch
|
||||
- RepositoryURL
|
||||
|
||||
Absolute paths, sadly, are reqired. Create Folders if neccessary. Reading rights are required for `HamannFileStoreLinux` (to save the state). The `BareRepositoryPath` usually is the `.git` Folder inside the Repo, where the Server gets the latest commit information from `refs/heads/<Branch-Name>`. To sync either you set up a git server and set the server as remote of the repository to push. Or use git webhooks to pull on pushes.
|
||||
|
||||
## Redesign der Hamann-Vebseite, drittes Update
|
||||
Veränderungenen in der Funktionalität für den Benutzer
|
||||
- Behutsames Redesign der Webseite:
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
|
||||
@* Global Scripts -- These are not inside .cshtml to not loose deferred execution posibility *@
|
||||
<feature name="Notifications">
|
||||
<script defer src="/js/websocket.js" asp-append-version="true"></script>
|
||||
</feature>
|
||||
<script defer src="/js/marginals.js" asp-append-version="true"></script>
|
||||
<script defer src="/js/theme.js" asp-append-version="true"></script>
|
||||
<script defer src="/js/active.js" asp-append-version="true"></script>
|
||||
|
||||
@@ -7,3 +7,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer src="/js/websocket.js" asp-append-version="true"></script>
|
||||
@@ -5,6 +5,7 @@ using HaWeb;
|
||||
using HaWeb.FileHelpers;
|
||||
using HaWeb.Models;
|
||||
using HaWeb.XMLParser;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
using Microsoft.FeatureManagement;
|
||||
|
||||
public class WebSocketMiddleware : IMiddleware {
|
||||
@@ -70,16 +71,24 @@ public class WebSocketMiddleware : IMiddleware {
|
||||
WebSocketReceiveResult result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||
while (!result.CloseStatus.HasValue) {
|
||||
var msg = Encoding.UTF8.GetString(buffer,0,result.Count);
|
||||
if (msg.ToLower() == "hello") {
|
||||
var state = _xmlProvider.GetGitState();
|
||||
await webSocket.SendAsync(_SerializeToBytes(state), WebSocketMessageType.Text, true, CancellationToken.None);
|
||||
await webSocket.SendAsync(_SerializeToBytes(new FileState(_xmlService.GetState())), WebSocketMessageType.Text, true, CancellationToken.None);
|
||||
} else if (msg.ToLower() == "ping" ) {
|
||||
await webSocket.SendAsync(_SerializeToBytes(new { Ping = true}), WebSocketMessageType.Text, true, CancellationToken.None);
|
||||
try {
|
||||
if (msg.ToLower() == "hello") {
|
||||
var state = _xmlProvider.GetGitState();
|
||||
await webSocket.SendAsync(_SerializeToBytes(state), WebSocketMessageType.Text, true, CancellationToken.None);
|
||||
await webSocket.SendAsync(_SerializeToBytes(new FileState(_xmlService.GetState())), WebSocketMessageType.Text, true, CancellationToken.None);
|
||||
} else if (msg.ToLower() == "ping" ) {
|
||||
await webSocket.SendAsync(_SerializeToBytes(new { Ping = true}), WebSocketMessageType.Text, true, CancellationToken.None);
|
||||
}
|
||||
result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||
} catch (ConnectionAbortedException ex) {
|
||||
_openSockets!.Remove(webSocket);
|
||||
}
|
||||
result = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||
}
|
||||
await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
|
||||
try {
|
||||
await webSocket.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
|
||||
} catch (ConnectionAbortedException ex) {
|
||||
_openSockets.Remove(webSocket);
|
||||
}
|
||||
_openSockets!.Remove(webSocket);
|
||||
}
|
||||
|
||||
@@ -116,7 +125,11 @@ public class WebSocketMiddleware : IMiddleware {
|
||||
private async Task _SendToAll<T>(T msg) {
|
||||
if (_openSockets == null) return;
|
||||
foreach (var socket in _openSockets) {
|
||||
await socket.SendAsync(_SerializeToBytes(msg), WebSocketMessageType.Text, true, CancellationToken.None);
|
||||
try {
|
||||
await socket.SendAsync(_SerializeToBytes(msg), WebSocketMessageType.Text, true, CancellationToken.None);
|
||||
} catch (ConnectionAbortedException ex) {
|
||||
_openSockets.Remove(socket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ socket.onopen = function (event) {
|
||||
socket.send("Hello");
|
||||
wsPingInterval = setInterval(() => {
|
||||
socket.send("Ping");
|
||||
}, 4500);
|
||||
}, 30000);
|
||||
updateMessage();
|
||||
};
|
||||
socket.onclose = function (event) {
|
||||
|
||||
Reference in New Issue
Block a user