mirror of
https://github.com/thegeneralist01/archivr
synced 2026-07-22 03:05:32 +02:00
feat: Reader mode via Mozilla Readability.js
Adds an opt-in 'Reader mode' advanced option to the capture dialog. When enabled, Readability.js is injected as a browser script during SingleFile capture; it fires on single-file-on-before-capture-start, replaces the page body with the distilled article content, injects a clean typographic stylesheet, and adds a header with title/byline/site. Falls back silently if Readability fails (e.g. non-article pages). - vendor/readability/Readability.js Apache 2.0, Mozilla, v0.6.0 - singlefile.rs: embed READABILITY_JS + READER_MODE_WRAPPER_JS via include_str!; write both to temp dir when reader_mode is true; base_single_file_cmd now accepts &[&Path] for multiple --browser-script - capture.rs: CaptureConfig.reader_mode: bool - routes.rs: CaptureBody.reader_mode: Option<bool> (defaults false) - api.js: submitCapture passes reader_mode in payload - CaptureDialog.jsx: Reader mode toggle in Advanced options (off by default)
This commit is contained in:
parent
28c62ddc5a
commit
596a6d1c89
9 changed files with 2967 additions and 74 deletions
|
|
@ -78,10 +78,9 @@ impl PlatformMetadata {
|
|||
pub struct CaptureConfig {
|
||||
pub cookie_rules: Vec<database::CookieRule>,
|
||||
/// Override for uBlock Origin Lite during WebPage captures.
|
||||
/// `None` = derive from `ARCHIVR_UBLOCK` env var (existing behaviour).
|
||||
/// `Some(false)` = disabled by admin/user choice for this capture.
|
||||
/// `Some(true)` = explicitly enabled (still needs `ARCHIVR_UBLOCK_EXT` to be valid).
|
||||
pub ublock_enabled: Option<bool>,
|
||||
/// Apply Mozilla Readability to distil the page to article content before archiving.
|
||||
pub reader_mode: bool,
|
||||
}
|
||||
|
||||
/// Resolves which cookies apply to `url` by evaluating all rules in ordinal order.
|
||||
|
|
@ -1015,7 +1014,7 @@ pub fn perform_capture(
|
|||
|
||||
// Source: web page — archive as a self-contained HTML snapshot via single-file-cli
|
||||
if source == Source::WebPage {
|
||||
match downloader::singlefile::save(locator, store_path, ×tamp, &cookies, config.ublock_enabled) {
|
||||
match downloader::singlefile::save(locator, store_path, ×tamp, &cookies, config.ublock_enabled, config.reader_mode) {
|
||||
Ok(result) => {
|
||||
let file_extension = ".html".to_string();
|
||||
let temp_html = store_path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue