From 5db206a90b79c4777fa4af59564f4f4b47345f8c Mon Sep 17 00:00:00 2001 From: Hollow Man Date: Thu, 9 Feb 2023 19:38:47 +0200 Subject: [PATCH] v0.1.5: auto acknowledge Google Analytics Resolve #10 Signed-off-by: Hollow Man --- .github/workflows/test.yml | 24 ++++++++++++++++++++++++ Cargo.toml | 2 +- README.md | 6 +++--- README_CN.md | 10 +++++++--- src/main.rs | 10 ++++++++++ 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 773e09f..b15bb87 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -157,6 +157,20 @@ jobs: name: "Rust_Nomicon" backend-depends: "" static-url: "https://doc.rust-lang.org/nomicon/" + - os: "macos-latest" + repo: "https://github.com/google/comprehensive-rust" + dir: "comprehensive-rust" + name: "Comprehensive_Rust" + backend-depends: "helloworld" + # backend-depends: "mdbook-svgbob" + static-url: "https://google.github.io/comprehensive-rust/" + - os: "ubuntu-latest" + repo: "https://github.com/google/comprehensive-rust" + dir: "comprehensive-rust" + name: "Comprehensive_Rust" + backend-depends: "helloworld" + # backend-depends: "mdbook-svgbob" + static-url: "https://google.github.io/comprehensive-rust/" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -171,6 +185,8 @@ jobs: if: matrix.backend-depends != '' run: | cargo install ${{ matrix.backend-depends }} + ## TODO: Remove when issue gets fixed + cargo install --git https://github.com/HollowMan6/mdbook-svgbob - name: Build and install mdbook executable run: | git clone https://github.com/HollowMan6/mdbook mdbook_exec @@ -269,6 +285,12 @@ jobs: name: "Rust_Nomicon" backend-depends: "" static-url: "https://doc.rust-lang.org/nomicon/" + - repo: "https://github.com/google/comprehensive-rust" + dir: "comprehensive-rust" + name: "Comprehensive_Rust" + backend-depends: "helloworld" + # backend-depends: "mdbook-svgbob" + static-url: "https://google.github.io/comprehensive-rust/" runs-on: "windows-latest" steps: - uses: actions/checkout@v3 @@ -283,6 +305,8 @@ jobs: if: matrix.backend-depends != '' run: | cargo install ${{ matrix.backend-depends }} + ## TODO: Remove when issue gets fixed + cargo install --git https://github.com/HollowMan6/mdbook-svgbob - name: Build and install mdbook executable run: | git clone https://github.com/HollowMan6/mdbook mdbook_exec diff --git a/Cargo.toml b/Cargo.toml index fb30d0b..dcb4c6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0" name = "mdbook-pdf" readme = "README.md" repository = "https://github.com/HollowMan6/mdbook-pdf" -version = "0.1.4" +version = "0.1.5" include = [ "**/*.rs", "Cargo.toml", diff --git a/README.md b/README.md index f5ae25f..eafab41 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Finally you can build your book and get the PDF file with `mdbook build` command ## Configuration Support customize PDF paper orientation, scale of the webpage rendering, paper width and height, page margins, generated PDF page ranges, whether to display header and footer as well as customize their formats, and more. -Check [book.toml](test_doc/book.toml#L10-L35) and comments for details for the available configurations of `[output.pdf]`. +Check [book.toml](test_doc/book.toml#L10-L36) and comments for details for the available configurations of `[output.pdf]`. ## Common Issues 1. Support for Firefox in `mdbook-pdf`! @@ -85,7 +85,7 @@ If you have relative links that link outside the book, please provide the [stati This should be realized by Chromium, and an issue has already been filed for this [here](https://bugs.chromium.org/p/chromium/issues/detail?id=781797). -Initial support for the bookmark/outline of the PDF file has already been available ([mdbook-pdf-outline](https://pypi.org/project/mdbook-pdf-outline/)). It is written in Python and is another backend for `mdbook` and should be used with `mdbook-pdf` and the [mdbook version](https://github.com/rust-lang/mdBook/pull/1738) mentioned in Common Issues 2 for fixing the broken links in `print.html`. +Initial support for the bookmark/outline of the PDF file has already been available ([mdbook-pdf-outline](https://pypi.org/project/mdbook-pdf-outline/)). It is written in Python and is another backend for `mdbook` and should be used with `mdbook-pdf` and ***the [mdbook version](https://github.com/rust-lang/mdBook/pull/1738) mentioned in Common Issues 2 for fixing the broken links in `print.html`***. You can install this backend by `pip install mdbook-pdf-outline`. @@ -108,7 +108,7 @@ Finally, you can find the outlined version at `book/pdf-outline/output.pdf`. 4. Failed to render my book for PDF in `mdbook-pdf`! -Will appreciate if you can report it to the [issue tracker](https://github.com/HollowMan6/mdbook-pdf/issues/new) providing all the traces for `mdbook-pdf` rendering. +Will appreciate if you can report it to the [issue tracker](https://github.com/HollowMan6/mdbook-pdf/issues/new) providing all the traces for `mdbook-pdf` rendering as well as your `book.toml`. You can also provide the link to your book's repository if it's open source. ```bash RUST_BACKTRACE=full RUST_LOG=trace mdbook build diff --git a/README_CN.md b/README_CN.md index 71e940e..eb28755 100644 --- a/README_CN.md +++ b/README_CN.md @@ -70,7 +70,7 @@ title = "An Example" ## 配置 支持自定义PDF纸张方向、页面缩放比例、纸张宽度和高度、页面边距、生成的PDF页面范围、是否显示页眉和页脚以及自定义其格式等。 -查看 [book.toml](test_doc/book.toml#L10-L35) 以了解 `[output.pdf]` 可用配置的详细信息。 +查看 [book.toml](test_doc/book.toml#L10-L36) 以了解 `[output.pdf]` 可用配置的详细信息。 ### 具体参数详解 - trying-times @@ -83,7 +83,7 @@ title = "An Example" 本程序支持最新的基于Chromium的浏览器,不支持Safari和Firefox。如果你需要指定,请指定完整的路径,比如说`/usr/bin/foo`。如果指定了错误的可执行文件,则很可能会出现超时错误或者直接报错。 -- static_site_url +- static-site-url 接受输入一个字符串,默认为空`''`。其指定书的静态网站托管URL,从而修复书之外的相对链接,将其转换为绝对路径。 @@ -99,6 +99,10 @@ title = "An Example" 接受输入一个布尔值,默认为`false`。其指定是否在PDF中显示背景图片,`true`为显示,`false`为不显示。 +- theme + +接受输入一个字符串。其指定用于打印书的主题。 + - scale 接受输入一个数字,默认为`1`。其指定缩放因子,例如指定值为`1.25`,则将页面缩放125%。 @@ -193,7 +197,7 @@ like-wkhtmltopdf = true 4. 无法在 `mdbook-pdf` 中将我的书呈现为 PDF! -如果您能将它报告给[问题跟踪器](https://github.com/HollowMan6/mdbook-pdf/issues/new),并提供`mdbook-pdf`渲染时产生的所有跟踪,将不胜感激。 +如果您能将它报告给[问题跟踪器](https://github.com/HollowMan6/mdbook-pdf/issues/new),并提供`mdbook-pdf`渲染时产生的所有跟踪,以及`book.toml`配置文件,和书的仓库地址(如果有的话),将不胜感激。 ```bash RUST_BACKTRACE=full RUST_LOG=trace mdbook build diff --git a/src/main.rs b/src/main.rs index 4bf63ea..e3f2f5a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -178,6 +178,16 @@ fn main() -> Result<(), Box> { let page = tab.navigate_to(&url)?.wait_until_navigated()?; page.wait_for_element("#content-has-all-loaded-for-mdbook-pdf-generation")?; + // Accept the Google Analytics cookie. + match page.find_element("a.cookieBarConsentButton") { + Ok(_) => { + page.evaluate("document.querySelector('a.cookieBarConsentButton').click()", false)?; + println!("The book you built uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic."); + println!("Learn more at: https://policies.google.com/technologies/cookies"); + } + Err(_) => (), + }; + // Find the theme and click it to change the theme. if !cloned_cfg.theme.is_empty() { match tab.find_element(&format!("button.theme#{}", cloned_cfg.theme.to_lowercase())) {