Full rewrite of the portfolio site from Next.js 14 to .NET 10: - ASP.NET Core 10 Razor Pages, no Node.js dependency - EF Core 10 + SQLite (same schema as before — data survives upgrade) - Cookie authentication (same single-password model) - Resend contact form via HttpClient - Bilingual FA/EN via locale cookie + BasePageModel - All UI ported to Razor Pages with Tailwind CDN + custom CSS - Vanilla JS: particles, typewriter, cursor, animations, portfolio modal - Dockerfile: SDK 10.0-alpine → aspnet 10.0-alpine (no npm/Node needed) - CI/CD: dropped NPM_TOKEN, ADMIN_SESSION_SECRET — pure dotnet publish Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
@page "/Admin/Sections/{key}"
|
||||
@model SoroushAsadi.Pages.Admin.Sections.SectionEditModel
|
||||
@{
|
||||
Layout = "_AdminLayout";
|
||||
ViewData["Title"] = "Edit: " + Model.SectionKey;
|
||||
}
|
||||
|
||||
<div class="mb-6 flex items-center gap-4">
|
||||
<a href="/Admin/Sections" class="text-slate-400 hover:text-white transition-colors text-sm">← Sections</a>
|
||||
<h1 class="font-display text-xl font-bold text-white">@Model.SectionKey</h1>
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.Message))
|
||||
{
|
||||
<div class="mb-4 rounded-lg border border-emerald/30 bg-emerald/10 px-4 py-3 text-sm text-emerald">@Model.Message</div>
|
||||
}
|
||||
|
||||
<form method="post" class="space-y-4">
|
||||
<div>
|
||||
<label class="label-mono mb-2 block">JSON ({"fa": {...}, "en": {...}})</label>
|
||||
<textarea name="json" rows="24"
|
||||
class="w-full rounded-xl border border-white/10 bg-white/[.03] px-4 py-3 font-mono text-xs text-slate-200 outline-none focus:border-electric/60 transition-colors resize-y"
|
||||
spellcheck="false">@Model.CurrentJson</textarea>
|
||||
</div>
|
||||
<div class="flex gap-3">
|
||||
<button type="submit" class="btn-primary">Save</button>
|
||||
<a href="/Admin/Sections" class="btn-ghost">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using SoroushAsadi.Services;
|
||||
|
||||
namespace SoroushAsadi.Pages.Admin.Sections;
|
||||
|
||||
[Authorize]
|
||||
public class SectionEditModel(ContentService content) : PageModel
|
||||
{
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string SectionKey { get; set; } = "";
|
||||
|
||||
public string CurrentJson { get; private set; } = "{\n \"fa\": {},\n \"en\": {}\n}";
|
||||
public string Message { get; private set; } = "";
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
var node = content.GetSection(SectionKey);
|
||||
if (node is not null)
|
||||
CurrentJson = node.ToJsonString(new JsonSerializerOptions { WriteIndented = true });
|
||||
}
|
||||
|
||||
public IActionResult OnPost(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Validate JSON
|
||||
JsonDocument.Parse(json);
|
||||
content.SaveSection(SectionKey, json);
|
||||
Message = "Saved.";
|
||||
CurrentJson = json;
|
||||
return Page();
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
Message = $"Invalid JSON: {ex.Message}";
|
||||
CurrentJson = json;
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
@page "/Admin/Sections"
|
||||
@model SoroushAsadi.Pages.Admin.Sections.SectionsIndexModel
|
||||
@{
|
||||
Layout = "_AdminLayout";
|
||||
ViewData["Title"] = "Sections";
|
||||
var all = new[]{ "hero","services","dataflow","stack","expertise","portfolio","blog","contact","footer" };
|
||||
}
|
||||
|
||||
<div class="mb-6 flex items-center justify-between">
|
||||
<h1 class="font-display text-2xl font-bold text-white">Sections</h1>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
@foreach (var key in all)
|
||||
{
|
||||
var hasOverride = Model.OverrideKeys.Contains(key);
|
||||
<div class="glass flex items-center justify-between p-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="font-mono text-sm text-white">@key</span>
|
||||
@if (hasOverride)
|
||||
{
|
||||
<span class="rounded-full bg-electric/10 px-2 py-0.5 font-mono text-[.65rem] text-electric">customized</span>
|
||||
}
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<a href="/Admin/Sections/@key" class="btn-ghost text-xs py-1.5 px-3">Edit</a>
|
||||
@if (hasOverride)
|
||||
{
|
||||
<form method="post" asp-page-handler="Reset" class="inline">
|
||||
<input type="hidden" name="key" value="@key" />
|
||||
<button type="submit" class="rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-1.5 text-xs text-red-400 hover:bg-red-500/20 transition-colors">Reset</button>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,19 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using SoroushAsadi.Services;
|
||||
|
||||
namespace SoroushAsadi.Pages.Admin.Sections;
|
||||
|
||||
[Authorize]
|
||||
public class SectionsIndexModel(ContentService content) : PageModel
|
||||
{
|
||||
public IReadOnlySet<string> OverrideKeys { get; private set; } = new HashSet<string>();
|
||||
public void OnGet() => OverrideKeys = content.GetSectionKeys().ToHashSet();
|
||||
|
||||
public IActionResult OnPostReset(string key)
|
||||
{
|
||||
content.DeleteSection(key);
|
||||
return RedirectToPage();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user