Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

book: make sure that the ads are actually readable #146

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ build:
- curl --location --silent --show-error --fail https://github.com/cargo-bins/cargo-quickinstall/releases/download/mdbook-0.4.40/mdbook-0.4.40-x86_64-unknown-linux-gnu.tar.gz | tar -xzvvf - -C $HOME/bin
# Convert the book to HTML.
- $HOME/bin/mdbook build book --dest-dir $READTHEDOCS_OUTPUT/html
# Make the ads readable.
- cat book/ethicalads-theme.css >> $READTHEDOCS_OUTPUT/html/css/general.css
# We are done!
- cp book/404.html $READTHEDOCS_OUTPUT/html
1 change: 1 addition & 0 deletions book/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
book
.sass-cache
1 change: 1 addition & 0 deletions book/ethicalads-theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions book/ethicalads-theme.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// run: scss --sass --style compressed ethicalads-theme.sass > ethicalads-theme.css
.ethical-sidebar
margin-left: auto
.ea-content
background: var(--bg) !important
color: var(--fg) !important
a:is(:link, :visited)
color: var(--fg) !important
a:is(:hover, :active, :focus)
color: var(--sidebar-active) !important
strong
color: var(--sidebar-active) !important
.ea-callout
a:is(:link, :visited)
color: var(--sidebar-non-existant) !important
a:is(:hover, :active, :focus)
color: var(--sidebar-fg) !important
5 changes: 3 additions & 2 deletions book/update-theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
INDEX_HBS_PORT = 443
INDEX_HBS_PROTO = "GET"
INDEX_HBS_PATH = "/repos/rust-lang/mdBook/contents/src/theme/index.hbs"
INDEX_HBS_DATA = None
INDEX_HBS_HEADERS = {
"user-agent": "Update index.hbs for +https://github.com/rinja-rs/rinja",
}

SIDEBAR_STYLE = 'style="display:flex; flex-direction:column"'
SCROLLBOX_END = r"""
<div id="ethical-ad-placement" data-ea-publisher="readthedocs" data-ea-type="image"></div>
<div id="ethical-ad-placement" class="ethical-sidebar" data-ea-publisher="readthedocs" data-ea-type="image"></div>
<readthedocs-flyout></readthedocs-flyout>
"""
TOC_START = '<div style="flex:1">'
Expand Down Expand Up @@ -53,7 +54,7 @@

def update_theme(target: PathLike) -> None:
with closing(HTTPSConnection(INDEX_HBS_DOMAIN, INDEX_HBS_PORT)) as conn:
conn.request(INDEX_HBS_PROTO, INDEX_HBS_PATH, None, INDEX_HBS_HEADERS)
conn.request(INDEX_HBS_PROTO, INDEX_HBS_PATH, INDEX_HBS_DATA, INDEX_HBS_HEADERS)
res = conn.getresponse()
if res.status != 200:
raise Exception(f"Status={res.status!r}")
Expand Down