From 10db06b4694ae9bc9ec6e095d5d47827c2d6357f Mon Sep 17 00:00:00 2001 From: haraldh Date: Tue, 1 Sep 2020 20:00:17 +0000 Subject: [PATCH] deploy: a78b9a22f7c3c86320562eaf15a2050a967532bd --- 404.html | 218 + ayu-highlight.css | 4 +- book.js | 181 +- css/chrome.css | 35 +- css/general.css | 17 +- end.html | 85 +- favicon.svg | 22 + fonts/OPEN-SANS-LICENSE.txt | 202 + fonts/SOURCE-CODE-PRO-LICENSE.txt | 93 + fonts/fonts.css | 101 + fonts/open-sans-v17-all-charsets-300.woff2 | Bin 0 -> 44352 bytes ...open-sans-v17-all-charsets-300italic.woff2 | Bin 0 -> 40656 bytes fonts/open-sans-v17-all-charsets-600.woff2 | Bin 0 -> 44936 bytes ...open-sans-v17-all-charsets-600italic.woff2 | Bin 0 -> 42120 bytes fonts/open-sans-v17-all-charsets-700.woff2 | Bin 0 -> 44988 bytes ...open-sans-v17-all-charsets-700italic.woff2 | Bin 0 -> 40800 bytes fonts/open-sans-v17-all-charsets-800.woff2 | Bin 0 -> 44536 bytes ...open-sans-v17-all-charsets-800italic.woff2 | Bin 0 -> 40812 bytes fonts/open-sans-v17-all-charsets-italic.woff2 | Bin 0 -> 41076 bytes .../open-sans-v17-all-charsets-regular.woff2 | Bin 0 -> 43236 bytes ...source-code-pro-v11-all-charsets-500.woff2 | Bin 0 -> 59140 bytes highlight.js | 8 +- index.html | 297 +- print.html | 8818 ++++++----------- searcher.js | 2 +- searchindex.js | 2 +- searchindex.json | 2 +- tutorial1.html | 91 +- tutorial10.html | 797 +- tutorial11.html | 797 +- tutorial12.html | 795 +- tutorial13.html | 795 +- tutorial14.html | 103 +- tutorial2.html | 806 +- tutorial3.html | 792 +- tutorial4.html | 801 +- tutorial5.html | 790 +- tutorial6.html | 790 +- tutorial7.html | 790 +- tutorial8.html | 798 +- tutorial9.html | 798 +- 41 files changed, 7770 insertions(+), 12060 deletions(-) create mode 100644 404.html create mode 100644 favicon.svg create mode 100644 fonts/OPEN-SANS-LICENSE.txt create mode 100644 fonts/SOURCE-CODE-PRO-LICENSE.txt create mode 100644 fonts/fonts.css create mode 100644 fonts/open-sans-v17-all-charsets-300.woff2 create mode 100644 fonts/open-sans-v17-all-charsets-300italic.woff2 create mode 100644 fonts/open-sans-v17-all-charsets-600.woff2 create mode 100644 fonts/open-sans-v17-all-charsets-600italic.woff2 create mode 100644 fonts/open-sans-v17-all-charsets-700.woff2 create mode 100644 fonts/open-sans-v17-all-charsets-700italic.woff2 create mode 100644 fonts/open-sans-v17-all-charsets-800.woff2 create mode 100644 fonts/open-sans-v17-all-charsets-800italic.woff2 create mode 100644 fonts/open-sans-v17-all-charsets-italic.woff2 create mode 100644 fonts/open-sans-v17-all-charsets-regular.woff2 create mode 100644 fonts/source-code-pro-v11-all-charsets-500.woff2 diff --git a/404.html b/404.html new file mode 100644 index 0000000..5d16ed5 --- /dev/null +++ b/404.html @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + +
+
+

Document not found (404)

+

This URL is invalid, sorry. Please use the navigation bar or search to continue.

+ +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ayu-highlight.css b/ayu-highlight.css index 128e016..0c45c6f 100644 --- a/ayu-highlight.css +++ b/ayu-highlight.css @@ -12,8 +12,7 @@ Original by Dempfi (https://github.com/dempfi/ayu) } .hljs-comment, -.hljs-quote, -.hljs-meta { +.hljs-quote { color: #5c6773; font-style: italic; } @@ -30,6 +29,7 @@ Original by Dempfi (https://github.com/dempfi/ayu) } .hljs-number, +.hljs-meta, .hljs-builtin-name, .hljs-literal, .hljs-type, diff --git a/book.js b/book.js index 186f9ae..5e38636 100644 --- a/book.js +++ b/book.js @@ -4,8 +4,8 @@ window.onunload = function () { }; // Global variable, shared between modules -function playpen_text(playpen) { - let code_block = playpen.querySelector("code"); +function playground_text(playground) { + let code_block = playground.querySelector("code"); if (window.ace && code_block.classList.contains("editable")) { let editor = window.ace.edit(code_block); @@ -23,8 +23,8 @@ function playpen_text(playpen) { ]); } - var playpens = Array.from(document.querySelectorAll(".playpen")); - if (playpens.length > 0) { + var playgrounds = Array.from(document.querySelectorAll(".playground")); + if (playgrounds.length > 0) { fetch_with_timeout("https://play.rust-lang.org/meta/crates", { headers: { 'Content-Type': "application/json", @@ -36,21 +36,21 @@ function playpen_text(playpen) { .then(response => { // get list of crates available in the rust playground let playground_crates = response.crates.map(item => item["id"]); - playpens.forEach(block => handle_crate_list_update(block, playground_crates)); + playgrounds.forEach(block => handle_crate_list_update(block, playground_crates)); }); } - function handle_crate_list_update(playpen_block, playground_crates) { + function handle_crate_list_update(playground_block, playground_crates) { // update the play buttons after receiving the response - update_play_button(playpen_block, playground_crates); + update_play_button(playground_block, playground_crates); // and install on change listener to dynamically update ACE editors if (window.ace) { - let code_block = playpen_block.querySelector("code"); + let code_block = playground_block.querySelector("code"); if (code_block.classList.contains("editable")) { let editor = window.ace.edit(code_block); editor.addEventListener("change", function (e) { - update_play_button(playpen_block, playground_crates); + update_play_button(playground_block, playground_crates); }); // add Ctrl-Enter command to execute rust code editor.commands.addCommand({ @@ -59,7 +59,7 @@ function playpen_text(playpen) { win: "Ctrl-Enter", mac: "Ctrl-Enter" }, - exec: _editor => run_rust_code(playpen_block) + exec: _editor => run_rust_code(playground_block) }); } } @@ -77,7 +77,7 @@ function playpen_text(playpen) { } // get list of `extern crate`'s from snippet - var txt = playpen_text(pre_block); + var txt = playground_text(pre_block); var re = /extern\s+crate\s+([a-zA-Z_0-9]+)\s*;/g; var snippet_crates = []; var item; @@ -106,7 +106,7 @@ function playpen_text(playpen) { code_block.append(result_block); } - let text = playpen_text(code_block); + let text = playground_text(code_block); let classes = code_block.querySelector('code').classList; let has_2018 = classes.contains("edition2018"); let edition = has_2018 ? "2018" : "2015"; @@ -143,6 +143,11 @@ function playpen_text(playpen) { languages: [], // Languages used for auto-detection }); + let code_nodes = Array + .from(document.querySelectorAll('code')) + // Don't highlight `inline code` blocks in headers. + .filter(function (node) {return !node.parentElement.classList.contains("header"); }); + if (window.ace) { // language-rust class needs to be removed for editable // blocks or highlightjs will capture events @@ -154,16 +159,12 @@ function playpen_text(playpen) { .from(document.querySelectorAll('code:not(.editable)')) .forEach(function (block) { hljs.highlightBlock(block); }); } else { - Array - .from(document.querySelectorAll('code')) - .forEach(function (block) { hljs.highlightBlock(block); }); + code_nodes.forEach(function (block) { hljs.highlightBlock(block); }); } // Adding the hljs class gives code blocks the color css // even if highlighting doesn't apply - Array - .from(document.querySelectorAll('code')) - .forEach(function (block) { block.classList.add('hljs'); }); + code_nodes.forEach(function (block) { block.classList.add('hljs'); }); Array.from(document.querySelectorAll("code.language-rust")).forEach(function (block) { @@ -174,23 +175,23 @@ function playpen_text(playpen) { var buttons = document.createElement('div'); buttons.className = 'buttons'; - buttons.innerHTML = ""; + buttons.innerHTML = ""; // add expand button var pre_block = block.parentNode; pre_block.insertBefore(buttons, pre_block.firstChild); pre_block.querySelector('.buttons').addEventListener('click', function (e) { - if (e.target.classList.contains('fa-expand')) { - e.target.classList.remove('fa-expand'); - e.target.classList.add('fa-compress'); + if (e.target.classList.contains('fa-eye')) { + e.target.classList.remove('fa-eye'); + e.target.classList.add('fa-eye-slash'); e.target.title = 'Hide lines'; e.target.setAttribute('aria-label', e.target.title); block.classList.remove('hide-boring'); - } else if (e.target.classList.contains('fa-compress')) { - e.target.classList.remove('fa-compress'); - e.target.classList.add('fa-expand'); + } else if (e.target.classList.contains('fa-eye-slash')) { + e.target.classList.remove('fa-eye-slash'); + e.target.classList.add('fa-eye'); e.target.title = 'Show hidden lines'; e.target.setAttribute('aria-label', e.target.title); @@ -199,10 +200,10 @@ function playpen_text(playpen) { }); }); - if (window.playpen_copyable) { + if (window.playground_copyable) { Array.from(document.querySelectorAll('pre code')).forEach(function (block) { var pre_block = block.parentNode; - if (!pre_block.classList.contains('playpen')) { + if (!pre_block.classList.contains('playground')) { var buttons = pre_block.querySelector(".buttons"); if (!buttons) { buttons = document.createElement('div'); @@ -221,8 +222,8 @@ function playpen_text(playpen) { }); } - // Process playpen code blocks - Array.from(document.querySelectorAll(".playpen")).forEach(function (pre_block) { + // Process playground code blocks + Array.from(document.querySelectorAll(".playground")).forEach(function (pre_block) { // Add play button var buttons = pre_block.querySelector(".buttons"); if (!buttons) { @@ -242,7 +243,7 @@ function playpen_text(playpen) { run_rust_code(pre_block); }); - if (window.playpen_copyable) { + if (window.playground_copyable) { var copyCodeClipboardButton = document.createElement('button'); copyCodeClipboardButton.className = 'fa fa-copy clip-button'; copyCodeClipboardButton.innerHTML = ''; @@ -284,7 +285,7 @@ function playpen_text(playpen) { function showThemes() { themePopup.style.display = 'block'; themeToggleButton.setAttribute('aria-expanded', true); - themePopup.querySelector("button#" + document.body.className).focus(); + themePopup.querySelector("button#" + get_theme()).focus(); } function hideThemes() { @@ -293,6 +294,16 @@ function playpen_text(playpen) { themeToggleButton.focus(); } + function get_theme() { + var theme; + try { theme = localStorage.getItem('mdbook-theme'); } catch (e) { } + if (theme === null || theme === undefined) { + return default_theme; + } else { + return theme; + } + } + function set_theme(theme, store = true) { let ace_theme; @@ -324,9 +335,7 @@ function playpen_text(playpen) { }); } - var previousTheme; - try { previousTheme = localStorage.getItem('mdbook-theme'); } catch (e) { } - if (previousTheme === null || previousTheme === undefined) { previousTheme = default_theme; } + var previousTheme = get_theme(); if (store) { try { localStorage.setItem('mdbook-theme', theme); } catch (e) { } @@ -337,9 +346,7 @@ function playpen_text(playpen) { } // Set theme - var theme; - try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } - if (theme === null || theme === undefined) { theme = default_theme; } + var theme = get_theme(); set_theme(theme, false); @@ -408,7 +415,6 @@ function playpen_text(playpen) { (function sidebar() { var html = document.querySelector("html"); var sidebar = document.getElementById("sidebar"); - var sidebarScrollBox = document.getElementById("sidebar-scrollbox"); var sidebarLinks = document.querySelectorAll('#sidebar a'); var sidebarToggleButton = document.getElementById("sidebar-toggle"); var sidebarResizeHandle = document.getElementById("sidebar-resize-handle"); @@ -450,6 +456,11 @@ function playpen_text(playpen) { // Toggle sidebar sidebarToggleButton.addEventListener('click', function sidebarToggle() { if (html.classList.contains("sidebar-hidden")) { + var current_width = parseInt( + document.documentElement.style.getPropertyValue('--sidebar-width'), 10); + if (current_width < 150) { + document.documentElement.style.setProperty('--sidebar-width', '150px'); + } showSidebar(); } else if (html.classList.contains("sidebar-visible")) { hideSidebar(); @@ -470,7 +481,16 @@ function playpen_text(playpen) { html.classList.add('sidebar-resizing'); } function resize(e) { - document.documentElement.style.setProperty('--sidebar-width', (e.clientX - sidebar.offsetLeft) + 'px'); + var pos = (e.clientX - sidebar.offsetLeft); + if (pos < 20) { + hideSidebar(); + } else { + if (html.classList.contains("sidebar-hidden")) { + showSidebar(); + } + pos = Math.min(pos, window.innerWidth - 100); + document.documentElement.style.setProperty('--sidebar-width', pos + 'px'); + } } //on mouseup remove windows functions mousemove & mouseup function stopResize(e) { @@ -505,9 +525,10 @@ function playpen_text(playpen) { }, { passive: true }); // Scroll sidebar to current active section - var activeSection = sidebar.querySelector(".active"); + var activeSection = document.getElementById("sidebar").querySelector(".active"); if (activeSection) { - sidebarScrollBox.scrollTop = activeSection.offsetTop; + // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView + activeSection.scrollIntoView({ block: 'center' }); } })(); @@ -551,8 +572,8 @@ function playpen_text(playpen) { var clipboardSnippets = new ClipboardJS('.clip-button', { text: function (trigger) { hideTooltip(trigger); - let playpen = trigger.closest("pre"); - return playpen_text(playpen); + let playground = trigger.closest("pre"); + return playground_text(playground); } }); @@ -580,26 +601,60 @@ function playpen_text(playpen) { }); })(); -(function autoHideMenu() { +(function controllMenu() { var menu = document.getElementById('menu-bar'); - var previousScrollTop = document.scrollingElement.scrollTop; - - document.addEventListener('scroll', function () { - if (menu.classList.contains('folded') && document.scrollingElement.scrollTop < previousScrollTop) { - menu.classList.remove('folded'); - } else if (!menu.classList.contains('folded') && document.scrollingElement.scrollTop > previousScrollTop) { - menu.classList.add('folded'); - } - - if (!menu.classList.contains('bordered') && document.scrollingElement.scrollTop > 0) { - menu.classList.add('bordered'); - } - - if (menu.classList.contains('bordered') && document.scrollingElement.scrollTop === 0) { - menu.classList.remove('bordered'); - } - - previousScrollTop = Math.max(document.scrollingElement.scrollTop, 0); - }, { passive: true }); + (function controllPosition() { + var scrollTop = document.scrollingElement.scrollTop; + var prevScrollTop = scrollTop; + var minMenuY = -menu.clientHeight - 50; + // When the script loads, the page can be at any scroll (e.g. if you reforesh it). + menu.style.top = scrollTop + 'px'; + // Same as parseInt(menu.style.top.slice(0, -2), but faster + var topCache = menu.style.top.slice(0, -2); + menu.classList.remove('sticky'); + var stickyCache = false; // Same as menu.classList.contains('sticky'), but faster + document.addEventListener('scroll', function () { + scrollTop = Math.max(document.scrollingElement.scrollTop, 0); + // `null` means that it doesn't need to be updated + var nextSticky = null; + var nextTop = null; + var scrollDown = scrollTop > prevScrollTop; + var menuPosAbsoluteY = topCache - scrollTop; + if (scrollDown) { + nextSticky = false; + if (menuPosAbsoluteY > 0) { + nextTop = prevScrollTop; + } + } else { + if (menuPosAbsoluteY > 0) { + nextSticky = true; + } else if (menuPosAbsoluteY < minMenuY) { + nextTop = prevScrollTop + minMenuY; + } + } + if (nextSticky === true && stickyCache === false) { + menu.classList.add('sticky'); + stickyCache = true; + } else if (nextSticky === false && stickyCache === true) { + menu.classList.remove('sticky'); + stickyCache = false; + } + if (nextTop !== null) { + menu.style.top = nextTop + 'px'; + topCache = nextTop; + } + prevScrollTop = scrollTop; + }, { passive: true }); + })(); + (function controllBorder() { + menu.classList.remove('bordered'); + document.addEventListener('scroll', function () { + if (menu.offsetTop === 0) { + menu.classList.remove('bordered'); + } else { + menu.classList.add('bordered'); + } + }, { passive: true }); + })(); })(); diff --git a/css/chrome.css b/css/chrome.css index 3ff5992..9ca8633 100644 --- a/css/chrome.css +++ b/css/chrome.css @@ -20,14 +20,13 @@ a > .hljs { /* Menu Bar */ -#menu-bar { - position: -webkit-sticky; - position: sticky; - top: 0; +#menu-bar, +#menu-bar-hover-placeholder { z-index: 101; margin: auto calc(0px - var(--page-padding)); } -#menu-bar > #menu-bar-sticky-container { +#menu-bar { + position: relative; display: flex; flex-wrap: wrap; background-color: var(--bg); @@ -35,10 +34,21 @@ a > .hljs { border-bottom-width: 1px; border-bottom-style: solid; } -.js #menu-bar > #menu-bar-sticky-container { - transition: transform 0.3s; +#menu-bar.sticky, +.js #menu-bar-hover-placeholder:hover + #menu-bar, +.js #menu-bar:hover, +.js.sidebar-visible #menu-bar { + position: -webkit-sticky; + position: sticky; + top: 0 !important; } -#menu-bar.bordered > #menu-bar-sticky-container { +#menu-bar-hover-placeholder { + position: sticky; + position: -webkit-sticky; + top: 0; + height: var(--menu-bar-height); +} +#menu-bar.bordered { border-bottom-color: var(--table-border-color); } #menu-bar i, #menu-bar .icon-button { @@ -72,10 +82,6 @@ a > .hljs { text-decoration: none; } -html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-container { - transform: translateY(calc(-10px - var(--menu-bar-height))); -} - .left-buttons { display: flex; margin: 0 5px; @@ -417,6 +423,11 @@ ul#searchresults span.teaser em { display: none; } +.chapter li.chapter-item { + line-height: 1.5em; + margin-top: 0.6em; +} + .chapter li.expanded > a.toggle div { transform: rotate(90deg); } diff --git a/css/general.css b/css/general.css index e0bb851..815dae1 100644 --- a/css/general.css +++ b/css/general.css @@ -25,11 +25,16 @@ code { font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */ } +/* Don't change font size in headers. */ +h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { + font-size: unset; +} + .left { float: left; } .right { float: right; } .boring { opacity: 0.6; } .hide-boring .boring { display: none; } -.hidden { display: none; } +.hidden { display: none !important; } h2, h3 { margin-top: 2.5em; } h4, h5 { margin-top: 2em; } @@ -60,6 +65,7 @@ h4 a.header:target { .page { outline: 0; padding: 0 var(--page-padding); + margin-top: calc(0px - var(--menu-bar-height)); /* Compensate for the #menu-bar-hover-placeholder */ } .page-wrapper { box-sizing: border-box; @@ -78,6 +84,9 @@ h4 a.header:target { margin-right: auto; max-width: var(--content-max-width); } +.content p { line-height: 1.45em; } +.content ol { line-height: 1.45em; } +.content ul { line-height: 1.45em; } .content a { text-decoration: none; } .content a:hover { text-decoration: underline; } .content img { max-width: 100%; } @@ -157,3 +166,9 @@ blockquote { .tooltipped .tooltiptext { visibility: visible; } + +.chapter li.part-title { + color: var(--sidebar-fg); + margin: 5px 0px; + font-weight: bold; +} diff --git a/end.html b/end.html index 11fbd8f..b4bf2fb 100644 --- a/end.html +++ b/end.html @@ -5,13 +5,24 @@ The End - chainerror + + + + + + + + + + + @@ -19,8 +30,9 @@ - - + + + @@ -36,7 +48,7 @@ @@ -80,8 +92,8 @@ @@ -90,37 +102,36 @@
-