diff --git a/Cargo.toml b/Cargo.toml index e9f4894..debbcc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,18 @@ [package] name = "monolith" -version = "2.0.5" +version = "2.0.9" authors = [ "Sunshine ", "Mahdi Robatipoor ", ] -description = "CLI tool to save webpages as a single HTML file" +description = "CLI tool for saving web pages as a single HTML file" [dependencies] base64 = "0.10.1" clap = "2.33.0" html5ever = "0.24.0" indicatif = "0.11.0" -mime-sniffer = "0.1.2" +lazy_static = "1.3.0" regex = "1.2.1" reqwest = "0.9.20" url = "2.1.0" -lazy_static = "1.3.0" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..8daf922 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,34 @@ +name: monolith +base: core18 +version: git +summary: Monolith - Save HTML pages with ease +description: | + A data hoarder's dream come true: bundle any web page into a single + HTML file. You can finally replace that gazillion of open tabs with + a gazillion of .html files stored somewhere on your precious little + drive. + Unlike conventional "Save page as…", monolith not only saves the + target document, it embeds CSS, image, and JavaScript assets all + at once, producing a single HTML5 document that is a joy to store + and share. + If compared to saving websites with wget -mpk, monolith embeds + all assets as data URLs and therefore displays the saved page + exactly the same, being completely separated from the Internet. + +confinement: strict + +parts: + monolith: + plugin: rust + source: . + build-packages: + - libssl-dev + - pkg-config + +apps: + monolith: + command: monolith + plugs: + - home + - network + - removable-media diff --git a/src/html.rs b/src/html.rs index 63c1d7d..22052e3 100644 --- a/src/html.rs +++ b/src/html.rs @@ -1,6 +1,7 @@ use http::{is_valid_url, resolve_url, retrieve_asset}; use std::default::Default; use std::io; +use utils::data_to_dataurl; use html5ever::parse_document; use html5ever::rcdom::{Handle, NodeData, RcDom}; @@ -14,10 +15,12 @@ enum NodeMatch { Anchor, Script, Form, + IFrame, Other, } -const PNG_PIXEL: &str = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; +const TRANSPARENT_PIXEL: &str = "data:image/png;base64,\ +iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="; const JS_DOM_EVENT_ATTRS: [&str; 21] = [ // Input @@ -74,7 +77,8 @@ pub fn walk_and_embed_assets( NodeData::Comment { .. } => { // Note: in case of opt_no_js being set to true, there's no need to worry about // getting rid of comments that may contain scripts, e.g.