From 6bbd6507411ed4e721a2b93cc685bbc95727728f Mon Sep 17 00:00:00 2001 From: Anas Rashid Date: Sun, 4 Oct 2026 23:32:16 +0200 Subject: [PATCH] Diwan: make env config work, ur-PK locale, own-site links relative - AddEnvironmentVariables() where appsettings.json is read directly - JWT ValidIssuer follows RSecurityBackend:ApplicationName (was hard-coded Ganjoor) - deploy/entrypoint.sh: copy settings RSecurityBackend reads only from appsettings.json - Dockerfile: pin SDK 10.0.302 (newer Razor rejects some upstream views) - lang=ur-PK; ganjoor.net own-site links -> relative; api.ganjoor.net -> APIRoot; search.xml - DIWAN.md: first admin password is Test!123 (upstream doc is wrong) Co-Authored-By: Claude Opus 5.5 --- DIWAN.md | 12 ++++++++---- Dockerfile | 6 ++++-- GanjooRazor/APIRoot.cs | 6 +++--- .../Areas/Admin/Pages/ReviewQuoteds.cshtml | 2 +- GanjooRazor/Areas/User/Pages/Editor.cshtml | 2 +- .../Areas/User/Pages/MySuggestedQuotes.cshtml | 2 +- GanjooRazor/Areas/User/Pages/Section.cshtml | 2 +- GanjooRazor/Areas/User/Pages/VerseAdd.cshtml | 2 +- GanjooRazor/Pages/Auth/Login.cshtml | 2 +- GanjooRazor/Pages/Auth/ResetPassword.cshtml | 2 +- GanjooRazor/Pages/Auth/SignUp.cshtml | 2 +- .../Pages/CommentReports/ReportComment.cshtml | 2 +- GanjooRazor/Pages/Error.cshtml | 4 ++-- GanjooRazor/Pages/ImageRecommendation/Pin.cshtml | 2 +- GanjooRazor/Pages/Map.cshtml | 2 +- GanjooRazor/Pages/Misc/Photos.cshtml | 4 ++-- GanjooRazor/Pages/Misc/t6e.cshtml | 2 +- .../Contribs/_GroupedByDateViewPartial.cshtml | 2 +- GanjooRazor/Pages/Recitations/AudioClip.cshtml | 4 ++-- .../Pages/Recitations/RecitationsOrder.cshtml | 2 +- .../Pages/Recitations/ReportRecitation.cshtml | 2 +- GanjooRazor/Pages/Shared/_AdminLayout.cshtml | 4 ++-- GanjooRazor/Pages/Shared/_Layout.cshtml | 2 +- GanjooRazor/Pages/Shared/_UserPanelLayout.cshtml | 4 ++-- GanjooRazor/Pages/SongRecommendation/Bp.cshtml | 4 ++-- .../Pages/SongRecommendation/Golha.cshtml | 2 +- .../Pages/SongRecommendation/Spotify.cshtml | 4 ++-- GanjooRazor/Pages/errors/404.cshtml | 4 ++-- GanjooRazor/Pages/errors/503.cshtml | 4 ++-- GanjooRazor/Pages/random.cshtml | 2 +- GanjooRazor/wwwroot/js/vaabd.js | 2 +- GanjooRazor/wwwroot/search.xml | 8 ++++---- RMuseum/DbContext/RMuseumDbContext.cs | 2 +- .../GanjoorService-Mundex.cs | 2 +- RMuseum/Startup.cs | 2 +- RMuseum/WebServiceUrl.cs | 2 +- deploy/entrypoint.sh | 16 ++++++++++++++++ 37 files changed, 76 insertions(+), 54 deletions(-) create mode 100755 deploy/entrypoint.sh diff --git a/DIWAN.md b/DIWAN.md index ed2da13b..da75bef5 100644 --- a/DIWAN.md +++ b/DIWAN.md @@ -8,7 +8,10 @@ This is a fork of [GanjoorService](https://github.com/ganjoor/GanjoorService) (G - **Urdu basics:** pages are `lang="ur"`. The home page, footer and century groups (Hijri centuries, e.g. "تیرہویں صدی ہجری") are in Urdu. Deeper pages, such as admin and account pages, are still Persian. - **Fonts:** Noto Nastaliq Urdu by default, with a **نستعلیق / نسخ** switch (Noto Naskh Arabic) at the bottom left. The choice is remembered per browser. - **Footer:** links to Ganjoor-only services (Hafez divination, music index, etc.) are removed. Links to the Wikisource source, the data and the code are added. -- **Linux/Docker:** `Dockerfile` + `docker-compose.yml` (SQL Server 2022, API, site, Caddy for HTTPS). The code itself is unchanged apart from the text above. +- **Linux/Docker:** `Dockerfile` + `docker-compose.yml` (SQL Server 2022, API, site, Caddy for HTTPS). +- **Config fixes so env vars work:** the four places that read `appsettings.json` directly now also read environment variables. The JWT issuer follows `RSecurityBackend:ApplicationName` instead of the hard-coded "Ganjoor". `deploy/entrypoint.sh` copies the settings that RSecurityBackend reads only from `appsettings.json` (connection string, secret, app name, admin email) into the file at container start. +- **Links:** `ganjoor.net` links to the site's own pages are now relative. Links to Ganjoor's other services (blog, audio, etc.) are left as they are. +- **Locale:** `ur-PK`. ## Deploy (Ubuntu/Debian x86-64, e.g. Vultr) @@ -29,7 +32,7 @@ SQL Server needs about 2 GB of RAM. Use a plan with at least 4 GB in total. ### Load the data -1. Open `https://SITE_DOMAIN/login` and sign in with `ADMIN_EMAIL` and any password that meets the password rules. That first login creates the admin account. +1. Open `https://SITE_DOMAIN/login` and sign in with `ADMIN_EMAIL` and the password **`Test!123`**. The first login creates the admin account with that fixed password (RSecurityBackend's default; upstream's guide is wrong about this). **Change it right away** in the user panel. 2. On the import page that opens (or **Admin → مالی و سایت → درون‌ریزی دادهٔ عمومی**), choose **Internet URL** and enter: ``` https://cdn.jsdelivr.net/gh/anas-rashid/diwan-data@main/ @@ -47,8 +50,9 @@ git pull && docker compose up -d --build ## Build locally (macOS/Linux) ```sh -dotnet build RMuseum/RMuseum.csproj -p:EnableWindowsTargeting=true -dotnet build GanjooRazor/GanjooRazor.csproj -p:EnableWindowsTargeting=true +cd RMuseum # its global.json pins SDK 10.0.302; newer SDKs fail on some upstream Razor views +dotnet build RMuseum.csproj -p:EnableWindowsTargeting=true +dotnet build ../GanjooRazor/GanjooRazor.csproj -p:EnableWindowsTargeting=true ``` Running it needs SQL Server, so use the Docker setup above. SQL Server's image is x86-64 only. diff --git a/Dockerfile b/Dockerfile index 6e83f5a7..65946f85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,8 @@ # only use the plain .NET + ASP.NET Core runtimes, so the framework-dependent output runs on Linux. # docker build --build-arg PROJECT=RMuseum . # docker build --build-arg PROJECT=GanjooRazor . -FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +# SDK pinned to RMuseum/global.json: newer Razor compilers (10.0.4xx) reject some upstream views +FROM mcr.microsoft.com/dotnet/sdk:10.0.302 AS build ARG PROJECT WORKDIR /src COPY . . @@ -14,5 +15,6 @@ ARG PROJECT ENV APP_DLL=$PROJECT.dll ASPNETCORE_HTTP_PORTS=8080 WORKDIR /app COPY --from=build /app . +COPY deploy/entrypoint.sh /entrypoint.sh EXPOSE 8080 -ENTRYPOINT ["sh", "-c", "exec dotnet \"$APP_DLL\""] +ENTRYPOINT ["/entrypoint.sh"] diff --git a/GanjooRazor/APIRoot.cs b/GanjooRazor/APIRoot.cs index 845e7c1e..9279ca3b 100644 --- a/GanjooRazor/APIRoot.cs +++ b/GanjooRazor/APIRoot.cs @@ -18,7 +18,7 @@ namespace GanjooRazor if (!string.IsNullOrEmpty(_url)) return _url; IConfigurationRoot configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json") + .SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").AddEnvironmentVariables() // diwan: honour env overrides (Docker) .Build(); _url = configuration["APIRoot"]; return _url; @@ -39,7 +39,7 @@ namespace GanjooRazor if (!string.IsNullOrEmpty(_InternetUrl)) return _InternetUrl; IConfigurationRoot configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json") + .SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").AddEnvironmentVariables() // diwan: honour env overrides (Docker) .Build(); _InternetUrl = configuration["GlobalAPIRoot"]; return _InternetUrl; @@ -64,7 +64,7 @@ namespace GanjooRazor if (!string.IsNullOrEmpty(_semanticSearchUrl)) return _semanticSearchUrl; IConfigurationRoot configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json") + .SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").AddEnvironmentVariables() // diwan: honour env overrides (Docker) .Build(); _semanticSearchUrl = configuration["SemanticSearchAPIRoot"]; return _semanticSearchUrl; diff --git a/GanjooRazor/Areas/Admin/Pages/ReviewQuoteds.cshtml b/GanjooRazor/Areas/Admin/Pages/ReviewQuoteds.cshtml index 9b9c92e7..802fc0af 100644 --- a/GanjooRazor/Areas/Admin/Pages/ReviewQuoteds.cshtml +++ b/GanjooRazor/Areas/Admin/Pages/ReviewQuoteds.cshtml @@ -128,7 +128,7 @@ else
- +
diff --git a/GanjooRazor/Areas/User/Pages/Editor.cshtml b/GanjooRazor/Areas/User/Pages/Editor.cshtml index d111e490..84cf7fe3 100644 --- a/GanjooRazor/Areas/User/Pages/Editor.cshtml +++ b/GanjooRazor/Areas/User/Pages/Editor.cshtml @@ -1983,7 +1983,7 @@ else
-

توجه داشته باشید که کارکرد برچسب‌گذاری اشعار در دیوان یافتن اشعار هم‌وزن است. از این جهت از پیشنهاد صورت‌های سلیقه‌ای و متفاوت یک وزن خودداری کنید تا این قابلیت مختل نشود. این نکته را هم مد نظر داشته باشید.

+

توجه داشته باشید که کارکرد برچسب‌گذاری اشعار در دیوان یافتن اشعار هم‌وزن است. از این جهت از پیشنهاد صورت‌های سلیقه‌ای و متفاوت یک وزن خودداری کنید تا این قابلیت مختل نشود. این نکته را هم مد نظر داشته باشید.

diff --git a/GanjooRazor/Areas/User/Pages/MySuggestedQuotes.cshtml b/GanjooRazor/Areas/User/Pages/MySuggestedQuotes.cshtml index bdb89dc9..9759f3e4 100644 --- a/GanjooRazor/Areas/User/Pages/MySuggestedQuotes.cshtml +++ b/GanjooRazor/Areas/User/Pages/MySuggestedQuotes.cshtml @@ -162,7 +162,7 @@ else - + diff --git a/GanjooRazor/Areas/User/Pages/Section.cshtml b/GanjooRazor/Areas/User/Pages/Section.cshtml index 1dee4e02..88300083 100644 --- a/GanjooRazor/Areas/User/Pages/Section.cshtml +++ b/GanjooRazor/Areas/User/Pages/Section.cshtml @@ -166,7 +166,7 @@ else
-

توجه داشته باشید که کارکرد برچسب‌گذاری اشعار در دیوان یافتن اشعار هم‌وزن است. از این جهت از پیشنهاد صورت‌های سلیقه‌ای و متفاوت یک وزن خودداری کنید تا این قابلیت مختل نشود. این نکته را هم مد نظر داشته باشید.

+

توجه داشته باشید که کارکرد برچسب‌گذاری اشعار در دیوان یافتن اشعار هم‌وزن است. از این جهت از پیشنهاد صورت‌های سلیقه‌ای و متفاوت یک وزن خودداری کنید تا این قابلیت مختل نشود. این نکته را هم مد نظر داشته باشید.

diff --git a/GanjooRazor/Areas/User/Pages/VerseAdd.cshtml b/GanjooRazor/Areas/User/Pages/VerseAdd.cshtml index 338579d6..8102314c 100644 --- a/GanjooRazor/Areas/User/Pages/VerseAdd.cshtml +++ b/GanjooRazor/Areas/User/Pages/VerseAdd.cshtml @@ -7,7 +7,7 @@ } - + diff --git a/GanjooRazor/Pages/Auth/Login.cshtml b/GanjooRazor/Pages/Auth/Login.cshtml index a1a4fd46..135e4717 100644 --- a/GanjooRazor/Pages/Auth/Login.cshtml +++ b/GanjooRazor/Pages/Auth/Login.cshtml @@ -6,7 +6,7 @@ } - + @ViewData["Title"] diff --git a/GanjooRazor/Pages/Auth/ResetPassword.cshtml b/GanjooRazor/Pages/Auth/ResetPassword.cshtml index 9bcb2b90..38ae927d 100644 --- a/GanjooRazor/Pages/Auth/ResetPassword.cshtml +++ b/GanjooRazor/Pages/Auth/ResetPassword.cshtml @@ -4,7 +4,7 @@ Layout = null; } - + @ViewData["Title"] diff --git a/GanjooRazor/Pages/Auth/SignUp.cshtml b/GanjooRazor/Pages/Auth/SignUp.cshtml index c6ac5439..80823604 100644 --- a/GanjooRazor/Pages/Auth/SignUp.cshtml +++ b/GanjooRazor/Pages/Auth/SignUp.cshtml @@ -5,7 +5,7 @@ } - + @ViewData["Title"] diff --git a/GanjooRazor/Pages/CommentReports/ReportComment.cshtml b/GanjooRazor/Pages/CommentReports/ReportComment.cshtml index 0ea53890..616aaba9 100644 --- a/GanjooRazor/Pages/CommentReports/ReportComment.cshtml +++ b/GanjooRazor/Pages/CommentReports/ReportComment.cshtml @@ -4,7 +4,7 @@ Layout = null; } - + diff --git a/GanjooRazor/Pages/Error.cshtml b/GanjooRazor/Pages/Error.cshtml index f5361525..673b7121 100644 --- a/GanjooRazor/Pages/Error.cshtml +++ b/GanjooRazor/Pages/Error.cshtml @@ -6,7 +6,7 @@ } - + @@ -16,7 +16,7 @@ - +