From 68315aa4aae700b111174473c6fd3ed42dd63adb Mon Sep 17 00:00:00 2001
From: Hamid Reza Mohammadi
Date: Sat, 18 Jul 2026 13:51:04 +0330
Subject: [PATCH] refactoring
---
GanjooRazor/Pages/Contribs.cshtml | 61 +-----------
GanjooRazor/Pages/FAQ.cshtml | 26 +----
GanjooRazor/Pages/GanjoorPage.cshtml | 67 ++-----------
GanjooRazor/Pages/Hashieha.cshtml | 61 +-----------
GanjooRazor/Pages/Index.cshtml | 1 -
GanjooRazor/Pages/Quotes.cshtml | 41 +-------
GanjooRazor/Pages/Search.cshtml | 96 +------------------
GanjooRazor/Pages/Shared/_Layout.cshtml | 8 ++
.../Pages/Shared/_SearchHeaderPartial.cshtml | 92 ++++++++++++++++++
.../Shared/_SearchHeaderPartial.cshtml.cs | 47 +++++++++
GanjooRazor/Pages/Simi.cshtml | 61 +-----------
11 files changed, 159 insertions(+), 402 deletions(-)
create mode 100644 GanjooRazor/Pages/Shared/_SearchHeaderPartial.cshtml
create mode 100644 GanjooRazor/Pages/Shared/_SearchHeaderPartial.cshtml.cs
diff --git a/GanjooRazor/Pages/Contribs.cshtml b/GanjooRazor/Pages/Contribs.cshtml
index a09d4451..cd639f22 100644
--- a/GanjooRazor/Pages/Contribs.cshtml
+++ b/GanjooRazor/Pages/Contribs.cshtml
@@ -13,65 +13,7 @@
}
else
{
-
-

-
-
-
-
+
@@ -117,7 +59,6 @@ else
-
@if (ViewData["TrackingScript"] != null && !string.IsNullOrEmpty(ViewData["TrackingScript"].ToString()))
{
diff --git a/GanjooRazor/Pages/FAQ.cshtml b/GanjooRazor/Pages/FAQ.cshtml
index 737f13e7..b5b30f8a 100644
--- a/GanjooRazor/Pages/FAQ.cshtml
+++ b/GanjooRazor/Pages/FAQ.cshtml
@@ -9,30 +9,7 @@
}
else
{
-
-

-
-
-
-
+
@@ -91,7 +68,6 @@ else
-
@if (ViewData["TrackingScript"] != null && !string.IsNullOrEmpty(ViewData["TrackingScript"].ToString()))
{
diff --git a/GanjooRazor/Pages/GanjoorPage.cshtml b/GanjooRazor/Pages/GanjoorPage.cshtml
index fa13b7d8..6f5e270f 100644
--- a/GanjooRazor/Pages/GanjoorPage.cshtml
+++ b/GanjooRazor/Pages/GanjoorPage.cshtml
@@ -113,7 +113,6 @@ else if (Model.ReadOnlyMode)
}
-
@if (Model.IsPoemPage)
{
if (Model.GanjoorPage != null && Model.GanjoorPage.Poem.Recitations.Length > 0)
@@ -201,66 +200,12 @@ else if (Model.ReadOnlyMode)
{
return;
}
-
-

-
-
-
-
+
diff --git a/GanjooRazor/Pages/Hashieha.cshtml b/GanjooRazor/Pages/Hashieha.cshtml
index db18b777..64b64823 100644
--- a/GanjooRazor/Pages/Hashieha.cshtml
+++ b/GanjooRazor/Pages/Hashieha.cshtml
@@ -10,65 +10,7 @@
}
else
{
-
-

-
-
-
-
+
@@ -300,7 +242,6 @@ else
-
@if (ViewData["TrackingScript"] != null && !string.IsNullOrEmpty(ViewData["TrackingScript"].ToString()))
{
diff --git a/GanjooRazor/Pages/Index.cshtml b/GanjooRazor/Pages/Index.cshtml
index 65bf46c2..79f660c4 100644
--- a/GanjooRazor/Pages/Index.cshtml
+++ b/GanjooRazor/Pages/Index.cshtml
@@ -40,7 +40,6 @@ else if (Model.ReadOnlyMode)
}
-
@if (!string.IsNullOrEmpty(Model.LastError))
{
diff --git a/GanjooRazor/Pages/Quotes.cshtml b/GanjooRazor/Pages/Quotes.cshtml
index 97dfc92f..d62c1287 100644
--- a/GanjooRazor/Pages/Quotes.cshtml
+++ b/GanjooRazor/Pages/Quotes.cshtml
@@ -9,45 +9,7 @@
}
else
{
-
-

-
-
-
-
+
@@ -165,7 +127,6 @@ else
-
@if (ViewData["TrackingScript"] != null && !string.IsNullOrEmpty(ViewData["TrackingScript"].ToString()))
{
diff --git a/GanjooRazor/Pages/Search.cshtml b/GanjooRazor/Pages/Search.cshtml
index 912742ba..f67c6396 100644
--- a/GanjooRazor/Pages/Search.cshtml
+++ b/GanjooRazor/Pages/Search.cshtml
@@ -14,100 +14,7 @@
}
else
{
-
-

-
-
-
-
+
@@ -247,7 +154,6 @@ else
-
@if (ViewData["TrackingScript"] != null && !string.IsNullOrEmpty(ViewData["TrackingScript"].ToString()))
{
diff --git a/GanjooRazor/Pages/Shared/_Layout.cshtml b/GanjooRazor/Pages/Shared/_Layout.cshtml
index e289e686..24ec7e74 100644
--- a/GanjooRazor/Pages/Shared/_Layout.cshtml
+++ b/GanjooRazor/Pages/Shared/_Layout.cshtml
@@ -17,6 +17,12 @@
// deliberately (or at least currently) skipped on error pages. A layout can't see each page's
// own LastError state, so centralizing this would make tracking fire on error pages that
// previously suppressed it. Each page keeps rendering its own TrackingScript block as before.
+ //
+ // vaabd.js WAS centralized below (confirmed byte-identical and unconditional across every main
+ // page). One minor, functionally-inert reordering: it used to render right before each page's
+ // own TrackingScript block; now it renders right after @RenderBody() finishes, which is after
+ // TrackingScript on any page that has one. The two scripts are unrelated (word-tooltip widget vs
+ // analytics), so this shouldn't matter, but flagging it since it's a real order change.
}
@@ -41,6 +47,8 @@
@RenderBody()
+
+
@await RenderSectionAsync("Scripts", required: false)
diff --git a/GanjooRazor/Pages/Shared/_SearchHeaderPartial.cshtml b/GanjooRazor/Pages/Shared/_SearchHeaderPartial.cshtml
new file mode 100644
index 00000000..6c6162ee
--- /dev/null
+++ b/GanjooRazor/Pages/Shared/_SearchHeaderPartial.cshtml
@@ -0,0 +1,92 @@
+@model GanjooRazor.Pages._SearchHeaderPartialModel
+
+

+
+
+
+
diff --git a/GanjooRazor/Pages/Shared/_SearchHeaderPartial.cshtml.cs b/GanjooRazor/Pages/Shared/_SearchHeaderPartial.cshtml.cs
new file mode 100644
index 00000000..fbddf787
--- /dev/null
+++ b/GanjooRazor/Pages/Shared/_SearchHeaderPartial.cshtml.cs
@@ -0,0 +1,47 @@
+using RMuseum.Models.Ganjoor.ViewModels;
+using System.Collections.Generic;
+
+namespace GanjooRazor.Pages
+{
+ ///
+ /// Model for the shared #hdr2 search-form + poet/category dropdown header used by GanjoorPage,
+ /// Search, Simi, Quotes, Hashieha, Contribs, and FAQ. Before this, each page carried its own
+ /// copy of this block - identical in 3 cases (Simi/Hashieha/Contribs), and varying in specific,
+ /// explainable ways in the other 4 (see each page's own model-construction code for the mapping).
+ ///
+ public class _SearchHeaderPartialModel
+ {
+ public List Poets { get; set; }
+
+ /// 0 marks the "all poets" option as selected.
+ public int SelectedPoetId { get; set; }
+
+ public string SearchQuery { get; set; } = "";
+
+ ///
+ /// Whether the hidden "es" (exact search) field renders at all. Its value is always "1" when
+ /// shown - only Search.cshtml ties this to a real toggle; every other page always shows it
+ /// unconditionally.
+ ///
+ public bool ShowExactSearchHiddenField { get; set; } = true;
+
+ /// Null (default) hides the category dropdown entirely.
+ public GanjoorCatViewModel CurrentCategory { get; set; }
+
+ ///
+ /// Null means "always mark CurrentCategory as selected" (GanjoorPage/Simi/Hashieha/Contribs
+ /// behavior - these never let you pick a different category than the one you're already
+ /// looking at). A value means "mark whichever ancestor/current/child matches this id instead"
+ /// (Search's behavior, where the category filter is independent of what you're looking at).
+ ///
+ public int? SelectedCategoryId { get; set; }
+
+ ///
+ /// GanjoorPage's category select is missing the inline width style the other 6 pages have -
+ /// preserved here rather than silently unified, since it may be an intentional visual
+ /// difference (or CSS already handles #cat's width and the inline style is redundant on the
+ /// other pages - not something to guess at).
+ ///
+ public bool WideCategorySelect { get; set; } = true;
+ }
+}
diff --git a/GanjooRazor/Pages/Simi.cshtml b/GanjooRazor/Pages/Simi.cshtml
index 5fd7a450..9ef2b11f 100644
--- a/GanjooRazor/Pages/Simi.cshtml
+++ b/GanjooRazor/Pages/Simi.cshtml
@@ -54,65 +54,7 @@
}
else
{
-
-

-
-
-
-
+
@@ -393,7 +335,6 @@
-
@if (ViewData["TrackingScript"] != null && !string.IsNullOrEmpty(ViewData["TrackingScript"].ToString()))
{