feat: pages_enabled admin controls with subscription-only search#4674
feat: pages_enabled admin controls with subscription-only search#4674NorkzYT wants to merge 39 commits intoiv-org:masterfrom
Conversation
|
Code formatting issues will be fixed soon. |
|
If we are going to allow every specific pages to be disabled, we might as well use an array for that like: |
|
Great suggestion. Do you recommend I implement it in this GitHub Pull Request or in a separate one? |
|
Would prefer in this one but we would need to keep compatibility with existing popular_enabled parameter. |
|
Understood, that works. |
|
@SamantazFox advice on my comment please: #4674 (comment) |
Yes, I second that! However, it will be a breaking change (will go with the next major version release). @NorkzYT Though, why do you want to disable search? For the trending feed, I can understand that you may not want random crap in your home page, but why search? |
|
My plan is to enable Invidious admins to control which features are accessible to users. This is particularly important for families/my family with young children who prefer YouTube over YouTube Kids. I found that existing tools lacked the ability to give admins such granular control over user features, thus I decided to contribute to Invidious by developing these admin control features. For instance, in my case, I want to restrict access for some users that only very young children use to only allow certain YouTube channels that are pre-approved and subscribed to their user account. By disabling features like search, trending, and popular, I can ensure that children only interact with videos from these subscribed channels and playlists, thereby preventing exposure to unsuitable and overage content. Additionally, I propose adding a search bar specifically for subscriptions and playlists. This would allow users to quickly find videos within these predefined categories without the need to navigate through entire channels or playlists, thus saving time and ensuring a safer viewing experience. I know that a tool called TubeArchivist has a search feature for videos that have already been downloaded. However, I am switching from TubeArchivist to Invidious because I no longer want to host 5TB of downloaded YouTube videos, especially as the library keeps growing. |
|
I will start working on this to complete as soon as I can. |
|
Complete. Someone please test as the only issue I know is the Invidious docker container becoming |
The health check is hitting the trending endpoint Which you have disabled, so it is natural for it to appear unhealthy |
|
Ah, thank you for the explanation. Much appreciated. I went right by it and did not notice. |
Co-authored-by: Samantaz Fox <coding@samantaz.fr>
Co-authored-by: Samantaz Fox <coding@samantaz.fr>
|
Thank you for the info. Suggestions have been added and completed. |
|
Hi sorry about the slow response. I had to push a couple extra commits to this branch for a few changes that were a bit hard to explain. This is the first deprecation within the Invidious config in a long-while so I wanted to make it as smooth as possible but tackling on warnings and tests to something very much not designed for it (the deprecated annotation will not cause a message to be printed to the user in this case) involves some less than ideal code imo. Other than that everything looks good and is ready to be merged in the next batch! Pinging @unixfox @Fijxu @SamantazFox for any last-minute objections to the new config and deprecation before merging in the next batch. |
|
Understood, no problem. Thank you for your time and work. |
|
I was wondering since the breakage of trending (#5397). Shouldn't trending be disabled by default in this PR? Or we will come up with a new page for trending? |
c2d5465 to
8c922d0
Compare
|
The following config is not working at the moment. Will continue working on this. |
|
Understood, I appreciate the heads-up. I will hold off on any changes until that PR concludes. |
|
You can keep working on it since #5555 was merged and the Trending page is still available. |
…debug config route - Fix kemal_static_file_handler directory_listing to use Path types (Crystal API compat) - Add missing search_page_disabled translation key to en-US.json - Filter preferences default_home options based on pages_enabled config - Add admin-only /debug_config route for verifying configuration state
6602695 to
bd6dd9c
Compare
…ectly HTML checkboxes send no value when unchecked, so the fallback "|| \"on\"" always re-enabled popular/trending/search on save. Changed default to "off" to match the pattern used by captcha_enabled, login_enabled, and other checkbox toggles in the same handler.
…isabled
- Hide navbar search box when CONFIG.page_enabled?("search") is false
- Keep Invidious logo visible with proper width when search bar is hidden
- Hide search widget on search_homepage when search is disabled
- Block /results, /api/v1/search/suggestions in before_all guard
- Block /hashtag/* and /api/v1/hashtag/* when search is disabled
…sabled
When pages_enabled.search is false, instead of blocking search entirely,
the search bar now searches within the user's subscriptions and saved
playlists only. YouTube's search API is never called.
Changes:
- routes/search.cr: detect search_disabled, force subscription+playlist
search for logged-in users, 403 for anonymous users
- search/processors.cr: new subscriptions_and_playlists() method that
queries both the subscription materialized view and playlist_videos
table, merges and deduplicates results
- before_all.cr: let /search through to the route handler (APIs still
blocked), keep /hashtag/* blocked
- search_box.ecr: dynamic placeholder ("Search subscriptions & playlists")
- search_homepage.ecr: hint text when in subscription-only mode
- search.ecr: hide YouTube filters, show lock icon + notice, custom
empty-results message
- template.ecr: always show search bar (subscription search needs it)
- en-US.json: 6 new locale strings for subscription-only search UX
trending_enabled and search_enabled params addedCheck if the video already exists in the playlist before inserting. Uses the existing select_index() query. Returns 409 via the API and silently redirects back on the web UI. Applied to both the web route (playlist_ajax) and the API v1 route (POST /api/v1/auth/playlists/:plid/videos).
The return from before_all did not stop the route handler from executing. The trending/popular/hashtag routes still ran and overwrote the 403 response. Now set a halted flag and use Kemal halt in the before_all block to prevent route handler execution. Error page now renders with the full Invidious theme (dark mode, navbar, CSS) matching the rest of the UI.
|
GitHub PR Complete. Title and Description updated to explain the changes in this PR. |
|
I think you meant @Fijxu ? |
|
You are correct. |
Summary
Adds
pages_enabledadmin controls for Popular, Trending, and Search. When YouTube search is disabled, users can still search within their subscriptions and saved playlists. Also prevents duplicate videos in playlists.Motivation
Invidious admins who run family instances need control over what users can access. A parent subscribes to approved channels on a child's account, disables search/trending/popular, and the child can only browse and search within those channels. No exposure to the wider YouTube catalog.
Config
Changes
Admin Preferences Fix
"on"because HTML checkboxes send no value when unchecked. Fixed to"off"to match the existing pattern forcaptcha_enabledandlogin_enabled.Route Blocking
/feed/popular,/feed/trending,/hashtag/*return 403 when disabled./api/v1/search,/api/v1/search/suggestions,/api/v1/hashtag/*return 403 JSON when disabled.Subscription-Only Search
pages_enabled.searchisfalseand the user is logged in,/searchqueries the subscription materialized view andplaylist_videostable instead of YouTube.Playlist Duplicate Prevention
/playlist_ajax) and the API route (POST /api/v1/auth/playlists/:plid/videos).UI
Files Changed
src/invidious/routes/preferences.cr— checkbox persistence fixsrc/invidious/routes/before_all.cr— route blocking logicsrc/invidious/routes/search.cr— subscription-only search modesrc/invidious/search/processors.cr—subscriptions_and_playlistssearch methodsrc/invidious/routes/playlists.cr— playlist duplicate check (web)src/invidious/routes/api/v1/authenticated.cr— playlist duplicate check (API)src/invidious/views/template.ecr— navbar search barsrc/invidious/views/search_homepage.ecr— subscription hintsrc/invidious/views/search.ecr— conditional filters and empty statesrc/invidious/views/components/search_box.ecr— dynamic placeholderlocales/en-US.json— 6 new locale stringsScreenshots