Skip to content

Custom sites: manage from the UI and reload without restart - #2275

Open
moToroTor wants to merge 3 commits into
xbapps:masterfrom
moToroTor:feature/custom-sites-edit
Open

moToroTor wants to merge 3 commits into
xbapps:masterfrom
moToroTor:feature/custom-sites-edit

Conversation

@moToroTor

Copy link
Copy Markdown

The Custom Sites form under Settings > Advanced could only create sites blind: no list of what exists, no way to fix a forgotten Main Site binding without hand-editing scrapers.json, no feedback, and unsupported domains were silently dropped. And every change needed a restart.

This adds, in two commits:

List, edit and delete from the UI

  • New GET /api/options/custom-sites returns the flat custom-site list; new DELETE /api/options/custom-sites removes an entry by URL.
  • PUT /api/options/custom-sites/create still upserts (so re-submitting the same URL edits), but now returns the updated list and 400s with a clear error on unsupported domains instead of silently dropping them.
  • The Advanced tab shows existing custom sites (source, name, URL, Main Site) with Edit (prefills the form including the Main Site dropdown) and Delete with confirmation.

Reload without restart

  • New POST /api/options/custom-sites/reload re-reads scrapers.json: new IDs register, existing IDs re-register in place with a fresh scrape closure (so rebinds and renames apply to future scrapes), then Site rows sync via InitSites. Returns added/updated counts.
  • The six addXxxScraper helpers now use reregister wrappers, identical at startup (empty registry) and enabling live replacement.
  • Entries deleted from the file stay registered until restart (noted in the UI).

Verification

  • New tests in pkg/api, pkg/scrape, pkg/models; existing TestScraperIDsAreUnique and TestOfficialScraperListIsFullyRegistered (79 entries) still pass.
  • Verified live in Docker: new site activated by reload with no restart; rebind applied to the Site row with zero restarts.

The Advanced tab form could only create custom sites blind: no list of
what exists, no way to fix a missing Main Site binding without
hand-editing scrapers.json, no feedback, and unsupported domains were
silently dropped.

- GET /api/options/custom-sites returns the flat custom-site list
- DELETE /api/options/custom-sites removes an entry by URL
- PUT /api/options/custom-sites/create now upserts as before but
  returns the updated list and 400s on unsupported domains
- Advanced tab shows existing custom sites with Edit/Delete; editing
  prefills the form including the Main Site binding
- restart is still required (custom scrapers register at startup and
  InitSites applies the binding on boot)
Re-reads scrapers.json on demand: new custom sites register and
edited entries (rebinds, renames) re-register in place with a fresh
scrape closure, then Site rows are synced via InitSites. Entries
deleted from the file stay registered until restart.

- models.ReregisterScraper: replace-by-ID or append; GetScraperByID
- scrape.ReloadCustomScrapers + POST /api/options/custom-sites/reload
- the six addXxxScraper helpers use the reregister wrappers, which is
  identical at startup (empty registry) and enables live replacement
- Advanced tab Reload button with added/updated counts in the toast
POST /api/options/custom-sites/reload was sent bodyless, but the
options WebService Consumes(application/json), so go-restful rejected
it with 415 before the handler ran. Send {} from the UI and accept */*
on the route (same pattern as inconsistencies fixAll).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant