From 92c97ca2cfe5a0454a92d1a86b77f36f92426893 Mon Sep 17 00:00:00 2001 From: Kenneth Gitere Date: Thu, 24 Jun 2021 08:26:40 +0300 Subject: [PATCH] fix: add .epub extension as fallback chore: update dependencies and update README chore: bump version --- Cargo.lock | 50 ++++++++++++++++++++++++++++++-------------------- Cargo.toml | 6 +++--- README.md | 18 ++++++++++++++++-- src/cli.rs | 8 +++++++- src/logs.rs | 13 +++++++------ 5 files changed, 63 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1c29ad..8489e38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -410,9 +410,9 @@ dependencies = [ [[package]] name = "comfy-table" -version = "2.1.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b99e9022e080d384b58d8eaf5976b42a311ff7a9669f8200eb2453c0b2b81a" +checksum = "c93d79ba722818d1a6aedfbe2cf4889330c856d0c6772951efbbf3dd283c070a" dependencies = [ "crossterm", "strum", @@ -504,25 +504,25 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c36c10130df424b2f3552fcc2ddcd9b28a27b1e54b358b45874f88d1ca6888c" +checksum = "c0ebde6a9dd5e331cd6c6f48253254d117642c31653baa475e394657c59c1f7d" dependencies = [ "bitflags", "crossterm_winapi", - "lazy_static", "libc", "mio", "parking_lot", "signal-hook", + "signal-hook-mio", "winapi", ] [[package]] name = "crossterm_winapi" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da8964ace4d3e4a044fd027919b2237000b24315a37c916f61809f1ff2140b9" +checksum = "3a6966607622438301997d3dac0d2f6e9a90c68bb6bc1785ea98456ab93c0507" dependencies = [ "winapi", ] @@ -835,9 +835,9 @@ dependencies = [ [[package]] name = "flexi_logger" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab94b6ac8eb69f1496a6993f26f785b5fd6d99b7416023eb2a6175c0b242b1" +checksum = "8ba2265890613939b533fa11c3728651531419ac549ccf527896201581f23991" dependencies = [ "atty", "chrono", @@ -1551,7 +1551,7 @@ dependencies = [ [[package]] name = "paperoni" -version = "0.4.1-alpha1" +version = "0.5.0-alpha1" dependencies = [ "async-std", "chrono", @@ -2102,20 +2102,30 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.1.17" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" +checksum = "470c5a6397076fae0094aaf06a08e6ba6f37acb77d3b1b91ea92b4d6c8650c39" dependencies = [ "libc", - "mio", "signal-hook-registry", ] [[package]] -name = "signal-hook-registry" -version = "1.3.0" +name = "signal-hook-mio" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +checksum = "29fd5867f1c4f2c5be079aee7a2adf1152ebb04a4bc4d341f504b7dece607ed4" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" dependencies = [ "libc", ] @@ -2271,15 +2281,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7318c509b5ba57f18533982607f24070a55d353e90d4cae30c467cdb2ad5ac5c" +checksum = "aaf86bbcfd1fa9670b7a129f64fc0c9fcbbfe4f1bc4210e9e98fe71ffc12cde2" [[package]] name = "strum_macros" -version = "0.20.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149" +checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index d8305fa..3594149 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ description = "A web article downloader" homepage = "https://github.com/hipstermojo/paperoni" repository = "https://github.com/hipstermojo/paperoni" name = "paperoni" -version = "0.4.1-alpha1" +version = "0.5.0-alpha1" authors = ["Kenneth Gitere "] edition = "2018" license = "MIT" @@ -17,11 +17,11 @@ async-std = "1.9.0" chrono = "0.4.19" clap = "2.33.3" colored = "2.0.0" -comfy-table = "2.1.0" +comfy-table = "3.0.0" derive_builder = "0.10.2" directories = "3.0.2" epub-builder = "0.4.8" -flexi_logger = "0.17.1" +flexi_logger = "0.18.0" futures = "0.3.15" html5ever = "0.25.1" indicatif = "0.16.2" diff --git a/README.md b/README.md index f38c741..5c547b0 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ -Paperoni is a CLI tool made in Rust for downloading web articles as EPUBs. +Paperoni is a CLI tool made in Rust for downloading web articles as EPUBs. There is provisional\* support for exporting to PDF as well. > This project is in an alpha release so it might crash when you use it. Please open an [issue on Github](https://github.com/hipstermojo/paperoni/issues/new) if it does crash. @@ -23,7 +23,7 @@ Check the [releases](https://github.com/hipstermojo/paperoni/releases) page for Paperoni is published on [crates.io](https://crates.io). If you have [cargo](https://github.com/rust-lang/cargo) installed, then run: ```sh -cargo install paperoni --version 0.4.1-alpha1 +cargo install paperoni --version 0.5.0-alpha1 ``` _Paperoni is still in alpha so the `version` flag has to be passed._ @@ -54,6 +54,9 @@ OPTIONS: -h, --help Prints help information + --inline-toc + Add an inlined Table of Contents page at the start of the merged article. + --log-to-file Enables logging of events to a file located in .paperoni/logs with a default log level of debug. Use -v to specify the logging level @@ -147,3 +150,14 @@ This program is still in alpha so a number of things won't work: - Code snippets on Medium articles that are lazy loaded will not appear in the EPUB. There are also web pages it won't work on in general such as Twitter and Reddit threads. + +## PDF exports + +As of version 0.5-alpha1, you can now export to PDF using a third party tool. This requires that you install [Calibre](https://calibre-ebook.com/) which comes with a ebook conversion. You can convert the epub to a pdf through the terminal with `ebook-convert`: + +```sh +# Assuming the downloaded epub was called foo.epub +ebook-convert foo.epub foo.pdf +``` + +Alternatively, you can use the Calibre GUI to do the file conversion. diff --git a/src/cli.rs b/src/cli.rs index 3ffd4f7..62937e7 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -159,7 +159,13 @@ impl<'a> TryFrom> for AppConfig { Some(max_conn) => max_conn.parse::()?.get(), None => DEFAULT_MAX_CONN, }) - .merged(arg_matches.value_of("output_name").map(ToOwned::to_owned)) + .merged(arg_matches.value_of("output_name").map(|name| { + if name.ends_with(".epub") { + name.to_owned() + } else { + name.to_string() + ".epub" + } + })) .can_disable_progress_bar( arg_matches.is_present("verbosity") && !arg_matches.is_present("log-to-file"), ) diff --git a/src/logs.rs b/src/logs.rs index 722c131..a0f51d8 100644 --- a/src/logs.rs +++ b/src/logs.rs @@ -4,7 +4,7 @@ use chrono::{DateTime, Local}; use colored::*; use comfy_table::presets::UTF8_HORIZONTAL_BORDERS_ONLY; use comfy_table::{Cell, CellAlignment, ContentArrangement, Table}; -use flexi_logger::LevelFilter; +use flexi_logger::{FileSpec, LevelFilter}; use log::error; use crate::errors::PaperoniError; @@ -169,11 +169,12 @@ pub fn init_logger( if !paperoni_dir.is_dir() || !log_dir.is_dir() { fs::create_dir_all(&log_dir)?; } - logger = logger - .directory(log_dir) - .discriminant(formatted_timestamp.to_string()) - .suppress_timestamp() - .log_to_file(); + logger = logger.log_to_file( + FileSpec::default() + .directory(log_dir) + .discriminant(formatted_timestamp.to_string()) + .suppress_timestamp(), + ); } logger.start()?; Ok(())