Add "Go to Hadith Number" input to collection navigation#164
Open
mahmoodhamdi wants to merge 1 commit into
Open
Add "Go to Hadith Number" input to collection navigation#164mahmoodhamdi wants to merge 1 commit into
mahmoodhamdi wants to merge 1 commit into
Conversation
Adds a numeric input plus "Go" button that lets users jump directly to a hadith by its number within the current collection. The widget is rendered on the collection landing page and on the book/single-hadith pages (collection/index.php and collection/dispbook.php). Input is restricted to numeric values via input attributes and a client-side regex check; the URL is built in JavaScript using the existing `<collectionName>:<hadithNumber>` route, so no new server-side handling is needed. Styling uses the same CSS variables as the search box widget, so the field picks up the existing light/dark themes. Fixes sunnah-com#153
Contributor
|
@fsid could you please review? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a "Go to Hadith Number" input to the collection navigation flow so users
can jump directly to a specific hadith instead of scrolling through a book or
using the browser's in-page find.
A new view widget (
collection/_go_to_hadith.php) renders a numeric input anda "Go" button. JavaScript validates the input and builds the
/<collectionName>:<hadithNumber>URL, which the existingactionHadithByNumberroute already handles (including the 301 redirect thatstrips leading zeros).
The widget is included in:
collection/index.php— the collection landing page (e.g./bukhari)collection/dispbook.php— the book page and single-hadith page(e.g.
/bukhari/1,/bukhari:1)Implementation notes
type="number",pattern="[0-9]*",inputmode="numeric", and a client-side regex. No server-side validationis needed since the existing route already handles bad inputs.
$collectionNameis passed into JavaScript viajson_encodeto preventXSS.
uniqid()so the widget can appearmore than once on the same page without ID collisions.
box widget (
--chip-selected-bg,--border-color,--primary-text-color,--secondary-text-color), so the field picks up the existing light/darkthemes.
layout tidy.
No new server-side endpoints, no new dependencies, no DB changes.
Fixes #153
Test plan
/<collection>:<number>prevents navigation if bypassed
01→1) stripped client-side; the existingserver-side 301 redirect remains as a fallback
php -lclean on all changed files