mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-01 04:16:24 -05:00
Archives can be compressed (SingleFileZ self-extracting HTML) (#477)
* Archives can be compressed (SingleFileZ self-extracting HTML). A new compress_singlefile download setting runs single-file with --compress-content, creating a self-extracting HTML file which is also a valid ZIP. Only the singlefile .html is compressed; readability files are always written uncompressed. Readability, screenshots, titles, and URLs are extracted from the index.html inside the ZIP. A Compress checkbox in the Archive and RSS download forms remembers the user's choice in local storage. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
bfbfa0710b
commit
0a776d030f
11 changed files with 409 additions and 41 deletions
|
|
@ -504,6 +504,22 @@ function AdvancedVideoSettings({form, isVideoLevel = false, isConfigLoaded = tru
|
|||
</Accordion>
|
||||
}
|
||||
|
||||
export function CompressSinglefileToggle({form}) {
|
||||
return <>
|
||||
<InfoHeader
|
||||
headerSize='h4'
|
||||
headerContent='Compress'
|
||||
popupContent='Create a compressed, self-extracting (SingleFileZ) archive. The HTML file is smaller, but not
|
||||
human-readable. Readability files are never compressed.'
|
||||
/>
|
||||
<ToggleForm
|
||||
form={form}
|
||||
name='compress_singlefile'
|
||||
path='settings.compress_singlefile'
|
||||
/>
|
||||
</>
|
||||
}
|
||||
|
||||
function AdvancedDownloadSettings({form}) {
|
||||
const [active, setActive] = React.useState(false);
|
||||
|
||||
|
|
@ -1096,6 +1112,9 @@ export function ArchiveDownloadForm({
|
|||
}) {
|
||||
const [showMessage, setShowMessage] = React.useState(false);
|
||||
|
||||
// Remember the user's compression choice between downloads.
|
||||
const [defaultCompressSinglefile, setDefaultCompressSinglefile] = useLocalStorage('compress_singlefile', false);
|
||||
|
||||
const submitter = propSubmitter || (async (formData) => {
|
||||
const downloadData = {
|
||||
downloader: formData.downloader,
|
||||
|
|
@ -1112,6 +1131,7 @@ export function ArchiveDownloadForm({
|
|||
tag_names: [],
|
||||
settings: {
|
||||
skip_already_downloaded: false,
|
||||
compress_singlefile: defaultCompressSinglefile,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -1130,6 +1150,14 @@ export function ArchiveDownloadForm({
|
|||
onSuccess,
|
||||
});
|
||||
|
||||
// Persist the user's compression choice in local storage.
|
||||
React.useEffect(() => {
|
||||
const {compress_singlefile} = form.formData.settings;
|
||||
if (compress_singlefile !== undefined && compress_singlefile !== defaultCompressSinglefile) {
|
||||
setDefaultCompressSinglefile(compress_singlefile);
|
||||
}
|
||||
}, [form.formData, defaultCompressSinglefile]);
|
||||
|
||||
const localOnCancel = (e) => {
|
||||
if (e) e.preventDefault();
|
||||
if (onCancel) {
|
||||
|
|
@ -1156,6 +1184,11 @@ export function ArchiveDownloadForm({
|
|||
<DownloadTagsSelector form={form}/>
|
||||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
<Grid.Row>
|
||||
<Grid.Column>
|
||||
<CompressSinglefileToggle form={form}/>
|
||||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
<Grid.Row>
|
||||
<Grid.Column>
|
||||
<AdvancedDownloadSettings form={form}/>
|
||||
|
|
@ -1179,6 +1212,8 @@ export function RSSDownloadForm({download, submitter, onDelete, onCancel, action
|
|||
const [userChangedResolutions, setUserChangedResolutions] = React.useState(false);
|
||||
|
||||
const [defaultVideoFormat, setDefaultVideoFormat] = useLocalStorage('video_format', defaultVideoFormatOption);
|
||||
// Remember the user's compression choice between downloads.
|
||||
const [defaultCompressSinglefile, setDefaultCompressSinglefile] = useLocalStorage('compress_singlefile', false);
|
||||
|
||||
submitter = submitter || (async (formData) => {
|
||||
const downloadData = {
|
||||
|
|
@ -1202,6 +1237,7 @@ export function RSSDownloadForm({download, submitter, onDelete, onCancel, action
|
|||
frequency: weeklyOption.value,
|
||||
sub_downloader: null,
|
||||
settings: {
|
||||
compress_singlefile: defaultCompressSinglefile,
|
||||
excluded_urls: null,
|
||||
title_exclude: null,
|
||||
title_include: null,
|
||||
|
|
@ -1272,6 +1308,14 @@ export function RSSDownloadForm({download, submitter, onDelete, onCancel, action
|
|||
}
|
||||
}, [form.formData]);
|
||||
|
||||
// Persist the user's compression choice in local storage.
|
||||
React.useEffect(() => {
|
||||
const {compress_singlefile} = form.formData.settings;
|
||||
if (compress_singlefile !== undefined && compress_singlefile !== defaultCompressSinglefile) {
|
||||
setDefaultCompressSinglefile(compress_singlefile);
|
||||
}
|
||||
}, [form.formData, defaultCompressSinglefile]);
|
||||
|
||||
// Default to "new" download buttons.
|
||||
actions = actions || DownloadFormButtons;
|
||||
const actionsElm = actions({onDelete, onCancel, form});
|
||||
|
|
@ -1333,11 +1377,18 @@ export function RSSDownloadForm({download, submitter, onDelete, onCancel, action
|
|||
</Grid.Row>
|
||||
</>;
|
||||
} else if (form.formData.sub_downloader === Downloaders.Archive) {
|
||||
downloaderRows = <Grid.Row>
|
||||
<Grid.Column>
|
||||
<ExcludedUrls form={form}/>
|
||||
</Grid.Column>
|
||||
</Grid.Row>;
|
||||
downloaderRows = <>
|
||||
<Grid.Row>
|
||||
<Grid.Column>
|
||||
<ExcludedUrls form={form}/>
|
||||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
<Grid.Row>
|
||||
<Grid.Column>
|
||||
<CompressSinglefileToggle form={form}/>
|
||||
</Grid.Column>
|
||||
</Grid.Row>
|
||||
</>;
|
||||
}
|
||||
|
||||
return <Form>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue