1b3a8b493e
deploy / deploy (push) Failing after 1m21s
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>
72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
using System.Text.Json.Nodes;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
using SoroushAsadi.Services;
|
|
|
|
namespace SoroushAsadi.Pages.Admin.Posts;
|
|
|
|
[Authorize]
|
|
public class PostEditModel(ContentService content) : PageModel
|
|
{
|
|
[BindProperty(SupportsGet = true)]
|
|
public string Slug { get; set; } = "";
|
|
|
|
public string CurrentBody { get; private set; } = "";
|
|
public string Message { get; private set; } = "";
|
|
public bool HasOverride { get; private set; }
|
|
|
|
// Known default bodies live in Blog/Post.cshtml.cs (DefaultBodies)
|
|
private static readonly Dictionary<string, string> _defaults = new()
|
|
{
|
|
["rag-eval-framework"] = SoroushAsadi.Pages.Blog.DefaultBodies.RagEval,
|
|
["agentic-n8n-patterns"] = SoroushAsadi.Pages.Blog.DefaultBodies.N8nPatterns,
|
|
["vertex-cost-control"] = SoroushAsadi.Pages.Blog.DefaultBodies.VertexCost,
|
|
["k8s-llm-inference"] = SoroushAsadi.Pages.Blog.DefaultBodies.K8sInference,
|
|
["flutter-on-device-ai"] = SoroushAsadi.Pages.Blog.DefaultBodies.FlutterAI,
|
|
["enterprise-ai-roadmap"] = SoroushAsadi.Pages.Blog.DefaultBodies.EnterpriseRoadmap,
|
|
};
|
|
|
|
public void OnGet()
|
|
{
|
|
var overrides = content.GetPostOverrides();
|
|
if (overrides.TryGetValue(Slug, out var node) && node["body"]?.GetValue<string>() is { } body)
|
|
{
|
|
CurrentBody = body;
|
|
HasOverride = true;
|
|
}
|
|
else
|
|
{
|
|
CurrentBody = _defaults.GetValueOrDefault(Slug, "");
|
|
}
|
|
}
|
|
|
|
public IActionResult OnPost(string body, string? reset)
|
|
{
|
|
if (reset == "1")
|
|
{
|
|
// Remove override — default body shows through
|
|
var existing = content.GetPostOverrides();
|
|
existing.Remove(Slug);
|
|
// Rebuild the posts JSON without this slug
|
|
var obj = new JsonObject();
|
|
foreach (var kv in existing) obj[kv.Key] = kv.Value.DeepClone();
|
|
content.SaveSection(ContentService.PostsKey, obj.ToJsonString());
|
|
|
|
Message = "Reset to default.";
|
|
HasOverride = false;
|
|
CurrentBody = _defaults.GetValueOrDefault(Slug, "");
|
|
return Page();
|
|
}
|
|
|
|
content.SavePost(Slug, new JsonObject { ["body"] = body });
|
|
HasOverride = true;
|
|
CurrentBody = body;
|
|
Message = "Saved.";
|
|
return Page();
|
|
}
|
|
}
|
|
|
|
// Re-export DefaultBodies from the Blog page so this page can use them
|
|
|