1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-22 23:58:39 +02:00

[DRAFT] Example

This commit is contained in:
sakex 2023-09-18 14:25:22 +02:00
parent 0d566ce042
commit ee44bee477
4 changed files with 13 additions and 79 deletions

View File

@ -41,19 +41,7 @@ jobs:
run: mdbook build -d book
- name: Zip exercise templates
run: cd book/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/
- name: Build all translations
run: |
for po_lang in ${{ env.LANGUAGES }}; do
echo "::group::Building $po_lang translation"
MDBOOK_BOOK__LANGUAGE=$po_lang \
MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$po_lang/ \
mdbook build -d book/$po_lang
(cd book/$po_lang/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/)
mv book/$po_lang/html book/html/$po_lang
echo "::endgroup::"
done
run: cd book && find . -name "exerciser" -type d -exec bash -c 'zip --recurse-paths ./html/$(dirname {})/comprehensive-rust-exercises.zip {}/comprehensive-rust-exercises/' \;
- name: Setup Pages
uses: actions/configure-pages@v2

View File

@ -29,7 +29,7 @@ class = "bob"
[output.html]
curly-quotes = true
additional-js = ["speaker-notes.js"]
additional-css = ["svgbob.css", "speaker-notes.css", "language-picker.css"]
additional-css = ["svgbob.css", "speaker-notes.css"]
site-url = "/comprehensive-rust/"
git-repository-url = "https://github.com/google/comprehensive-rust"
edit-url-template = "https://github.com/google/comprehensive-rust/edit/main/{path}"
@ -82,3 +82,12 @@ line-numbers = true
[output.exerciser]
output-directory = "comprehensive-rust-exercises"
[output.i18n-helpers]
default_language = "en"
[output.i18n-helpers.languages]
"en" = "English"
"es" = "Spanish (Español)"
"ko" = "Korean (한국어)"
"pt-BR" = "Brazilian Portuguese (Português do Brasil)"

View File

@ -1,13 +0,0 @@
#language-list {
left: auto;
right: 10px;
}
[dir=rtl] #language-list {
left: 10px;
right: auto;
}
#language-list a {
color: inherit;
}

View File

@ -165,59 +165,9 @@
</div>
<h1 class="menu-title">{{ book_title }}</h1>
<div class="right-buttons">
<button id="language-toggle" class="icon-button" type="button"
title="Change language" aria-label="Change language"
aria-haspopup="true" aria-expanded="false"
aria-controls="language-list">
<i class="fa fa-globe"></i>
</button>
<ul id="language-list" class="theme-popup" aria-label="Languages" role="menu">
<li role="none"><button role="menuitem" class="theme">
<a id="en">English</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="pt-BR">Brazilian Portuguese (Português do Brasil)</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="ko">Korean (한국어)</a>
</button></li>
<li role="none"><button role="menuitem" class="theme">
<a id="es">Spanish (Español)</a>
</button></li>
</ul>
<script>
let langToggle = document.getElementById("language-toggle");
let langList = document.getElementById("language-list");
langToggle.addEventListener("click", (event) => {
langList.style.display = langList.style.display == "block" ? "none" : "block";
});
let selectedLang = document.getElementById("{{ language }}");
if (selectedLang) {
selectedLang.parentNode.classList.add("theme-selected");
}
// The path to the root, taking the current
// language into account.
{{#if (eq language "en")}}
let full_path_to_root = "{{ path_to_root }}";
{{else}}
let full_path_to_root = "{{ path_to_root }}../";
{{/if}}
// The page path (mdbook only gives us
// access to the path to the Markdown file).
let path = "{{ path }}".replace(/\.md$/, ".html");
for (let lang of langList.querySelectorAll("a")) {
if (lang.id == "en") {
lang.href = `${full_path_to_root}${path}`;
} else {
lang.href = `${full_path_to_root}${lang.id}/${path}`;
}
}
</script>
<LanguagePicker>
</LanguagePicker>
{{#if print_enable}}
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>