Skip to content

Commit

Permalink
v0.1.5: auto acknowledge Google Analytics
Browse files Browse the repository at this point in the history
Resolve #10

Signed-off-by: Hollow Man <[email protected]>
  • Loading branch information
HollowMan6 committed Feb 9, 2023
1 parent 0234b3c commit 5db206a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`!
Expand All @@ -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`.

Expand All @@ -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
Expand Down
10 changes: 7 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -83,7 +83,7 @@ title = "An Example"

本程序支持最新的基于Chromium的浏览器,不支持Safari和Firefox。如果你需要指定,请指定完整的路径,比如说`/usr/bin/foo`。如果指定了错误的可执行文件,则很可能会出现超时错误或者直接报错。

- static_site_url
- static-site-url

接受输入一个字符串,默认为空`''`。其指定书的静态网站托管URL,从而修复书之外的相对链接,将其转换为绝对路径。

Expand All @@ -99,6 +99,10 @@ title = "An Example"

接受输入一个布尔值,默认为`false`。其指定是否在PDF中显示背景图片,`true`为显示,`false`为不显示。

- theme

接受输入一个字符串。其指定用于打印书的主题。

- scale

接受输入一个数字,默认为`1`。其指定缩放因子,例如指定值为`1.25`,则将页面缩放125%。
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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())) {
Expand Down

0 comments on commit 5db206a

Please sign in to comment.