@Article.Title
- @Article.PublishDate.ToString("d")
+
+ @Article.PublishDate.ToString("d")
+ @if (Article.Status is not ArticleStatus.Published) {
+ @Article.Status.Humanize()
+ }
+
@Article.BodyPlain[..Math.Min(1000, Article.BodyPlain.Length)]
- @if (Article.Categories.Count > 0) {
+ @if (Action is not null) {
+
+ @Action(Article)
+
+ } else if (Article.Categories.Count > 0) {
@foreach (var category in Article.Categories.OrderBy(c => c.Color)) {
@@ -27,4 +37,6 @@
@code {
[Parameter]
public required Article Article { get; set; }
+ [Parameter]
+ public RenderFragment
? Action { get; set; }
}
diff --git a/Wave/Components/ArticleCardList.razor b/Wave/Components/ArticleCardList.razor
index 69afc00..69133d7 100644
--- a/Wave/Components/ArticleCardList.razor
+++ b/Wave/Components/ArticleCardList.razor
@@ -5,7 +5,7 @@
} else {
@foreach (var article in Articles.OrderByDescending(a => a.PublishDate)) {
-
+
}
}
@@ -13,4 +13,6 @@
@code {
[Parameter]
public required IList Articles { get; set; } = [];
+ [Parameter]
+ public RenderFragment? Action { get; set; }
}
diff --git a/Wave/Components/Layout/NavMenu.razor b/Wave/Components/Layout/NavMenu.razor
index 0c00b79..3b08cbe 100644
--- a/Wave/Components/Layout/NavMenu.razor
+++ b/Wave/Components/Layout/NavMenu.razor
@@ -24,6 +24,7 @@
@Localizer["Future_Label"]
+ @Localizer["Deleted_Label"]
diff --git a/Wave/Components/Pages/ArticleDeleteConfirm.razor b/Wave/Components/Pages/ArticleDeleteConfirm.razor
new file mode 100644
index 0000000..c2b9f25
--- /dev/null
+++ b/Wave/Components/Pages/ArticleDeleteConfirm.razor
@@ -0,0 +1,62 @@
+@page "/article/{id:guid}/delete"
+@using Microsoft.EntityFrameworkCore
+@using Wave.Data
+
+@attribute [Authorize(Policy = "ArticleDeletePermissions")]
+
+@inject IDbContextFactory ContextFactory
+@inject NavigationManager Navigation
+@inject ILogger Logger
+@inject IStringLocalizer Localizer
+
+@(TitlePrefix + (Article is not null ? Localizer["Delete_Title"] : Localizer["NotFound_Title"]))
+
+@if (Article is not null) {
+
+
+
+ @Localizer["Delete_Warning"]
+
+ @Article.Title
+
+
+
+} else {
+ @Localizer["NotFound_Title"]
+ @Localizer["NotFound_Description"]
+ @Localizer["NotFound_BackToHome_Label"]
+}
+
+
+@code {
+ [CascadingParameter(Name = "TitlePrefix")]
+ private string TitlePrefix { get; set; } = default!;
+
+ [Parameter]
+ public Guid Id { get; set; }
+
+ private Article? Article { get; set; }
+
+ protected override async Task OnInitializedAsync() {
+ await using var context = await ContextFactory.CreateDbContextAsync();
+
+ Article = await context.Set().IgnoreQueryFilters()
+ .Where(a => !a.IsDeleted).FirstOrDefaultAsync(a => a.Id == Id);
+ }
+
+ private async Task Delete() {
+ if (Article is null) return;
+
+ var context = await ContextFactory.CreateDbContextAsync();
+ Article.IsDeleted = true;
+ context.Entry(Article).State = EntityState.Modified;
+ await context.SaveChangesAsync();
+
+ Navigation.NavigateTo("/");
+ }
+}
diff --git a/Wave/Components/Pages/ArticleView.razor b/Wave/Components/Pages/ArticleView.razor
index f6818c4..b8ce439 100644
--- a/Wave/Components/Pages/ArticleView.razor
+++ b/Wave/Components/Pages/ArticleView.razor
@@ -78,6 +78,11 @@
}
}
+
+
+ @Localizer["Delete_Submit"]
+
+
diff --git a/Wave/Components/Pages/Deleted.razor b/Wave/Components/Pages/Deleted.razor
new file mode 100644
index 0000000..9a65975
--- /dev/null
+++ b/Wave/Components/Pages/Deleted.razor
@@ -0,0 +1,58 @@
+@page "/deleted"
+@using Microsoft.EntityFrameworkCore
+@using Wave.Data
+
+@attribute [Authorize(Policy = "ArticleDeletePermissions")]
+
+@inject ILogger Logger
+@inject IDbContextFactory ContextFactory
+@inject IStringLocalizer Localizer
+
+@(TitlePrefix + Localizer["Title"])
+
+@Localizer["Title"]
+
+
+
+
+
+
+
+@code {
+ [CascadingParameter(Name = "TitlePrefix")]
+ private string TitlePrefix { get; set; } = default!;
+
+ private List Articles { get; } = [];
+
+ [SupplyParameterFromForm(Name = "id")]
+ private Guid Id { get; set; }
+
+ protected override async Task OnInitializedAsync() {
+ await using var context = await ContextFactory.CreateDbContextAsync();
+
+ Articles.AddRange(await context.Set()
+ .IgnoreQueryFilters().IgnoreAutoIncludes()
+ .Include(a => a.Author)
+ .Where(a => a.IsDeleted)
+ .OrderByDescending(a => a.PublishDate).ThenBy(a => a.Id)
+ .ToListAsync());
+ }
+
+ private async Task Restore() {
+ await using var context = await ContextFactory.CreateDbContextAsync();
+ var article = await context.Set()
+ .IgnoreQueryFilters().IgnoreAutoIncludes()
+ .FirstOrDefaultAsync(a => a.Id == Id);
+
+ if (article is null) throw new ApplicationException("Error restoring Article, not found.");
+
+ article.IsDeleted = false;
+ await context.SaveChangesAsync();
+ Articles.RemoveAt(Articles.FindIndex(a => a.Id == article.Id));
+ }
+
+}
\ No newline at end of file
diff --git a/Wave/Resources/Components/Layout/NavMenu.de-DE.resx b/Wave/Resources/Components/Layout/NavMenu.de-DE.resx
index 0d9c352..447346b 100644
--- a/Wave/Resources/Components/Layout/NavMenu.de-DE.resx
+++ b/Wave/Resources/Components/Layout/NavMenu.de-DE.resx
@@ -131,4 +131,7 @@
API Verwalten
+
+ Gelöscht
+
\ No newline at end of file
diff --git a/Wave/Resources/Components/Layout/NavMenu.resx b/Wave/Resources/Components/Layout/NavMenu.resx
index 8262245..1871de4 100644
--- a/Wave/Resources/Components/Layout/NavMenu.resx
+++ b/Wave/Resources/Components/Layout/NavMenu.resx
@@ -134,4 +134,7 @@
Manage API
+
+ Deleted
+
\ No newline at end of file
diff --git a/Wave/Resources/Components/Pages/ArticleView.de-DE.resx b/Wave/Resources/Components/Pages/ArticleView.de-DE.resx
index 267b839..bdfd5a9 100644
--- a/Wave/Resources/Components/Pages/ArticleView.de-DE.resx
+++ b/Wave/Resources/Components/Pages/ArticleView.de-DE.resx
@@ -137,4 +137,16 @@
Ohne E-Mail Veröffentlichen
+
+ Artikel löschen
+
+
+ Löschen Bestätigen
+
+
+ Ja, Artikel Löschen
+
+
+ Ihr Artikel wird runtergenommen. Bitte beachten Sie das Suchmaschinen eventuell noch links zu diesem Artikel haben, welche dann eine Fehlernachricht produzieren. Der Artikel ist womöglich noch in manchen Caches für die nächsten paar Stunden auffindbar.
+
\ No newline at end of file
diff --git a/Wave/Resources/Components/Pages/ArticleView.resx b/Wave/Resources/Components/Pages/ArticleView.resx
index d34586b..d7f1443 100644
--- a/Wave/Resources/Components/Pages/ArticleView.resx
+++ b/Wave/Resources/Components/Pages/ArticleView.resx
@@ -137,4 +137,16 @@
Publish without Email
+
+ Delete Article
+
+
+ Confirm Delete
+
+
+ Yes, Delete Article
+
+
+ This will take down your Article. Please keep in mind that search engines may still have links to this article, which will produce error messages. The Article may still be accessable in some caches the next couple of hours.
+
\ No newline at end of file
diff --git a/Wave/Resources/Components/Pages/Deleted.de-DE.resx b/Wave/Resources/Components/Pages/Deleted.de-DE.resx
new file mode 100644
index 0000000..e45146a
--- /dev/null
+++ b/Wave/Resources/Components/Pages/Deleted.de-DE.resx
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Gelöschte Artikel
+
+
+ Artikel Wiederherstellen
+
+
\ No newline at end of file
diff --git a/Wave/Resources/Components/Pages/Deleted.en-GB.resx b/Wave/Resources/Components/Pages/Deleted.en-GB.resx
new file mode 100644
index 0000000..4fdb1b6
--- /dev/null
+++ b/Wave/Resources/Components/Pages/Deleted.en-GB.resx
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Wave/Resources/Components/Pages/Deleted.resx b/Wave/Resources/Components/Pages/Deleted.resx
new file mode 100644
index 0000000..8e6aa87
--- /dev/null
+++ b/Wave/Resources/Components/Pages/Deleted.resx
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Deleted Articles
+
+
+ Restore Article
+
+
\ No newline at end of file