diff --git a/README.md b/README.md index ae6822a..a6003ee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[](https://app.wercker.com/project/bykey/389477226e537a45143ea91336dca281) +[](https://app.wercker.com/project/byKey/8d96ab89960da21d87a545a25acae54c) This repo contains the sources for the Nim by Example book. diff --git a/Rules b/Rules index e2b5ac4..b0d6960 100644 --- a/Rules +++ b/Rules @@ -13,35 +13,59 @@ # item, use the pattern “/about/*/”; “/about/*” will also select the parent, # because “*” matches zero or more characters. -compile '*' do - if item.identifier == '/toc/' +compile '/assets/css/*' do + filter :erb + filter :rainpress if File.basename(item[:content_filename], ".*") == 'all' +end + +compile '/assets/js/*' do + filter :erb + :uglify_js if File.basename(item[:content_filename], ".*") == 'all' +end + +compile '/content/*' do + if item.identifier.to_s == '/content/toc/' filter :kramdown layout 'blank' + elsif item.identifier.to_s == '/content/footer/' + layout 'blank' elsif item[:extension] == 'md' filter :kramdown, {:input => 'GFM'} filter :colorize_syntax, :default_colorizer => :pygmentize filter :relativize_paths, :type => :html layout 'default' - elsif item[:extension] == 'css' - # don’t filter stylesheets - elsif item.binary? - # don’t filter binary items else filter :erb layout 'default' end end -route '*' do - if item[:extension] == 'css' - # Write item with identifier /foo/ to /foo.css - item.identifier.chop + '.css' - elsif item.binary? +route '/assets/css/*' do + # if not debug mode, only let all.css through + unless @config[:debug] + item.identifier.to_s.chop + '.css' if File.basename(item[:content_filename], ".*") == 'all' + else + item.identifier.to_s.chop + '.css' + end +end + +route '/assets/js/*' do + # if not debug mode, only let all.js through + unless @config[:debug] + item.identifier.to_s.chop + '.js' if File.basename(item[:content_filename], ".*") == 'all' + else + item.identifier.to_s.chop + '.js' + end +end + + +route '/content/*' do + if item.binary? # Write item with identifier /foo/ to /foo.ext - item.identifier.chop + '.' + item[:extension] + item.identifier.to_s.sub("/content", "").chop + '.' + item[:extension] else # Write item with identifier /foo/ to /foo/index.html - item.identifier + 'index.html' + item.identifier.to_s.sub("/content", "") + 'index.html' end end diff --git a/content/assets/css/all.css b/content/assets/css/all.css new file mode 100644 index 0000000..f385aa0 --- /dev/null +++ b/content/assets/css/all.css @@ -0,0 +1 @@ +<%= all_css @config[:stylesheets] %> diff --git a/content/assets/css/colorful.css b/content/assets/css/colorful.css new file mode 100644 index 0000000..d29370e --- /dev/null +++ b/content/assets/css/colorful.css @@ -0,0 +1,72 @@ +/* pygments-css colorful */ +code[class^='language-'] .gp { + color: #c65d09; + font-weight: bold; + /* NOTE: Hacks to allow copy-paste */ + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} /* Generic.Prompt */ +body:not(.darkmode) code[class^='language-'] .hll { background-color: #ffffcc } +body:not(.darkmode) code[class^='language-'] .c { color: #808080 } /* Comment */ +body:not(.darkmode) code[class^='language-'] .err { color: #F00000; background-color: #F0A0A0 } /* Error */ +body:not(.darkmode) code[class^='language-'] .k { color: #008000; font-weight: bold } /* Keyword */ +body:not(.darkmode) code[class^='language-'] .o { color: #303030 } /* Operator */ +body:not(.darkmode) code[class^='language-'] .cm { color: #808080 } /* Comment.Multiline */ +body:not(.darkmode) code[class^='language-'] .cp { color: #507090 } /* Comment.Preproc */ +body:not(.darkmode) code[class^='language-'] .c1 { color: #808080 } /* Comment.Single */ +body:not(.darkmode) code[class^='language-'] .cs { color: #cc0000; font-weight: bold } /* Comment.Special */ +body:not(.darkmode) code[class^='language-'] .gd { color: #A00000 } /* Generic.Deleted */ +body:not(.darkmode) code[class^='language-'] .ge { font-style: italic } /* Generic.Emph */ +body:not(.darkmode) code[class^='language-'] .gr { color: #FF0000 } /* Generic.Error */ +body:not(.darkmode) code[class^='language-'] .gh { color: #000080; font-weight: bold } /* Generic.Heading */ +body:not(.darkmode) code[class^='language-'] .gi { color: #00A000 } /* Generic.Inserted */ +body:not(.darkmode) code[class^='language-'] .go { color: #808080 } /* Generic.Output */ +body:not(.darkmode) code[class^='language-'] .gs { font-weight: bold } /* Generic.Strong */ +body:not(.darkmode) code[class^='language-'] .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +body:not(.darkmode) code[class^='language-'] .gt { color: #0040D0 } /* Generic.Traceback */ +body:not(.darkmode) code[class^='language-'] .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +body:not(.darkmode) code[class^='language-'] .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +body:not(.darkmode) code[class^='language-'] .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +body:not(.darkmode) code[class^='language-'] .kp { color: #003080; font-weight: bold } /* Keyword.Pseudo */ +body:not(.darkmode) code[class^='language-'] .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +body:not(.darkmode) code[class^='language-'] .kt { color: #303090; font-weight: bold } /* Keyword.Type */ +body:not(.darkmode) code[class^='language-'] .m { color: #6000E0; font-weight: bold } /* Literal.Number */ +body:not(.darkmode) code[class^='language-'] .s { background-color: #fff0f0 } /* Literal.String */ +body:not(.darkmode) code[class^='language-'] .na { color: #0000C0 } /* Name.Attribute */ +body:not(.darkmode) code[class^='language-'] .nb { color: #007020 } /* Name.Builtin */ +body:not(.darkmode) code[class^='language-'] .nc { color: #B00060; font-weight: bold } /* Name.Class */ +body:not(.darkmode) code[class^='language-'] .no { color: #003060; font-weight: bold } /* Name.Constant */ +body:not(.darkmode) code[class^='language-'] .nd { color: #505050; font-weight: bold } /* Name.Decorator */ +body:not(.darkmode) code[class^='language-'] .ni { color: #800000; font-weight: bold } /* Name.Entity */ +body:not(.darkmode) code[class^='language-'] .ne { color: #F00000; font-weight: bold } /* Name.Exception */ +body:not(.darkmode) code[class^='language-'] .nf { color: #0060B0; font-weight: bold } /* Name.Function */ +body:not(.darkmode) code[class^='language-'] .nl { color: #907000; font-weight: bold } /* Name.Label */ +body:not(.darkmode) code[class^='language-'] .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ +body:not(.darkmode) code[class^='language-'] .nt { color: #007000 } /* Name.Tag */ +body:not(.darkmode) code[class^='language-'] .nv { color: #906030 } /* Name.Variable */ +body:not(.darkmode) code[class^='language-'] .ow { color: #000000; font-weight: bold } /* Operator.Word */ +body:not(.darkmode) code[class^='language-'] .w { color: #bbbbbb } /* Text.Whitespace */ +body:not(.darkmode) code[class^='language-'] .mf { color: #6000E0; font-weight: bold } /* Literal.Number.Float */ +body:not(.darkmode) code[class^='language-'] .mh { color: #005080; font-weight: bold } /* Literal.Number.Hex */ +body:not(.darkmode) code[class^='language-'] .mi { color: #0000D0; font-weight: bold } /* Literal.Number.Integer */ +body:not(.darkmode) code[class^='language-'] .mo { color: #4000E0; font-weight: bold } /* Literal.Number.Oct */ +body:not(.darkmode) code[class^='language-'] .sb { background-color: #fff0f0 } /* Literal.String.Backtick */ +body:not(.darkmode) code[class^='language-'] .sc { color: #0040D0 } /* Literal.String.Char */ +body:not(.darkmode) code[class^='language-'] .sd { color: #D04020 } /* Literal.String.Doc */ +body:not(.darkmode) code[class^='language-'] .s2 { background-color: #fff0f0 } /* Literal.String.Double */ +body:not(.darkmode) code[class^='language-'] .se { color: #606060; font-weight: bold; background-color: #fff0f0 } /* Literal.String.Escape */ +body:not(.darkmode) code[class^='language-'] .sh { background-color: #fff0f0 } /* Literal.String.Heredoc */ +body:not(.darkmode) code[class^='language-'] .si { background-color: #e0e0e0 } /* Literal.String.Interpol */ +body:not(.darkmode) code[class^='language-'] .sx { color: #D02000; background-color: #fff0f0 } /* Literal.String.Other */ +body:not(.darkmode) code[class^='language-'] .sr { color: #000000; background-color: #fff0ff } /* Literal.String.Regex */ +body:not(.darkmode) code[class^='language-'] .s1 { background-color: #fff0f0 } /* Literal.String.Single */ +body:not(.darkmode) code[class^='language-'] .ss { color: #A06000 } /* Literal.String.Symbol */ +body:not(.darkmode) code[class^='language-'] .bp { color: #007020 } /* Name.Builtin.Pseudo */ +body:not(.darkmode) code[class^='language-'] .vc { color: #306090 } /* Name.Variable.Class */ +body:not(.darkmode) code[class^='language-'] .vg { color: #d07000; font-weight: bold } /* Name.Variable.Global */ +body:not(.darkmode) code[class^='language-'] .vi { color: #3030B0 } /* Name.Variable.Instance */ +body:not(.darkmode) code[class^='language-'] .il { color: #0000D0; font-weight: bold } /* Literal.Number.Integer.Long */ diff --git a/content/assets/css/cotton_candy.css b/content/assets/css/cotton_candy.css new file mode 100644 index 0000000..ef6d896 --- /dev/null +++ b/content/assets/css/cotton_candy.css @@ -0,0 +1,8 @@ +#main code, code * { color: #675D69; } +code[class^='language-'] .k { color: #143A77; } +code[class^='language-'] .kp { color: #8C5DC7; } +code[class^='language-'] .kd { color: #8C5DC7; } +code[class^='language-'] .mi { color: #8C5DC7; } +code[class^='language-'] .s { color: #0060B0; } +code[class^='language-'] .c { color: #91B9A3; } +code[class^='language-'] .o { color: #009DE7; } diff --git a/content/assets/css/main.css b/content/assets/css/main.css new file mode 100644 index 0000000..8d14e3e --- /dev/null +++ b/content/assets/css/main.css @@ -0,0 +1,133 @@ +body { + background: #F5F7F6; + color: #000000; + margin: 0; padding: 0; + max-width: 720px; + + text-rendering: optimizelegibility; + + font-family: Palatino, serif; + line-height: 20px; +} + +#sidebar { + margin: 15px; + float: left; + width: 205px; + padding: 10px 0; + + background-color: #FFF; + box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.5); + + transition: margin-left 1s; +} + +#sidebar.collapsed { margin-left: -180px; } + +#sidebar ul { padding: 0 1em; margin: 0; list-style-type: none; } +#sidebar li:before { content: '⁃'; padding-right: 0.5em; color: black; } +#sidebar li.visited:before { content: '✔'; padding-right: 0.2em; color: green; } + + +.abs-hamburger { + position: relative; + width: 0; height: 0; +} +.nav-toggle { + position: absolute; + left: 175px; + width: 25px; height: 25px; + cursor: pointer; + margin-right: 5px; + margin-bottom: 5px; +} +.nav-toggle span, +.nav-toggle span:before, +.nav-toggle span:after { + border-radius: 1px; + height: 5px; + width: 25px; + background: white; + position: absolute; + display: block; + content: ''; + box-shadow: inset 0px 0px 2px 0px #000; +} +.nav-toggle span:before { top: -8px; } +.nav-toggle span:after { bottom: -8px; } +.nav-toggle span { margin-top: 9.5px; } + + +#nextprev { + overflow: hidden; + padding: .5em 1em; +} + +.text-icon { font-size: 5em; } +#arrow-prev { float: left; } +#arrow-next { float: right; } + + +article { + margin: 15px; + + transition: max-width 1s; +} +article.expanded { max-width: 680px; } + + +a { text-decoration: none; } +a:link, a:visited { color: #B45D47; } +a:hover { color: #FE3B3B; } + +a.disabled, a:link.disabled, a:visited.disabled { color: #999; pointer-events: none; } +a:hover.disabled { color: #888; } + + +pre, code { font-family: Monaco, Menlo, Consolas, "Courier New", monospace; } +code { + border-radius: 1px; + background-color: #FFF; + padding: 0.2em; +} +pre code { + display: block; + padding: 1em; + white-space: pre-wrap; +} + + +h1, h2, h3, h4, h5, h6 { line-height: 125%; } + + +footer { + margin-top: 50px; + clear: both; + + text-align: center; + color: #777; +} +footer ul { list-style: none; margin: 0; padding: 0; } +footer li { display: inline; } +footer li+li:before { content: '|'; } +footer a:link, footer a:visited { color: #777; } +footer a:hover { color: #999; } + +.notransition { + -webkit-transition: none !important; + -moz-transition: none !important; + -o-transition: none !important; + -ms-transition: none !important; + transition: none !important; +} + + +@media screen and (min-width: 925px) { + body { margin: 0 auto; } + body #sidebar.collapsed, body #sidebar { margin-left: -205px; } + body article.expanded, body article { max-width: none; width: none; min-width: none; } +} + +@media screen and (max-width: 1200px) { + body { margin-right: 0; } +} diff --git a/content/assets/css/monokai.css b/content/assets/css/monokai.css new file mode 100644 index 0000000..3dcebc7 --- /dev/null +++ b/content/assets/css/monokai.css @@ -0,0 +1,64 @@ +body.darkmode code[class^='language-'] { background-color: #333; color: #f8f8f2} +body.darkmode code[class^='language-'] .hll { background-color: #49483e } +body.darkmode code[class^='language-'] .c { color: #75715e } /* Comment */ +body.darkmode code[class^='language-'] .err { color: #960050; background-color: #1e0010 } /* Error */ +body.darkmode code[class^='language-'] .k { color: #66d9ef } /* Keyword */ +body.darkmode code[class^='language-'] .l { color: #ae81ff } /* Literal */ +body.darkmode code[class^='language-'] .n { color: #f8f8f2 } /* Name */ +body.darkmode code[class^='language-'] .o { color: #f92672 } /* Operator */ +body.darkmode code[class^='language-'] .p { color: #f8f8f2 } /* Punctuation */ +body.darkmode code[class^='language-'] .cm { color: #75715e } /* Comment.Multiline */ +body.darkmode code[class^='language-'] .cp { color: #75715e } /* Comment.Preproc */ +body.darkmode code[class^='language-'] .c1 { color: #75715e } /* Comment.Single */ +body.darkmode code[class^='language-'] .cs { color: #75715e } /* Comment.Special */ +body.darkmode code[class^='language-'] .ge { font-style: italic } /* Generic.Emph */ +body.darkmode code[class^='language-'] .gs { font-weight: bold } /* Generic.Strong */ +body.darkmode code[class^='language-'] .kc { color: #66d9ef } /* Keyword.Constant */ +body.darkmode code[class^='language-'] .kd { color: #66d9ef } /* Keyword.Declaration */ +body.darkmode code[class^='language-'] .kn { color: #f92672 } /* Keyword.Namespace */ +body.darkmode code[class^='language-'] .kp { color: #66d9ef } /* Keyword.Pseudo */ +body.darkmode code[class^='language-'] .kr { color: #66d9ef } /* Keyword.Reserved */ +body.darkmode code[class^='language-'] .kt { color: #66d9ef } /* Keyword.Type */ +body.darkmode code[class^='language-'] .ld { color: #e6db74 } /* Literal.Date */ +body.darkmode code[class^='language-'] .m { color: #ae81ff } /* Literal.Number */ +body.darkmode code[class^='language-'] .s { color: #e6db74 } /* Literal.String */ +body.darkmode code[class^='language-'] .na { color: #a6e22e } /* Name.Attribute */ +body.darkmode code[class^='language-'] .nb { color: #f8f8f2 } /* Name.Builtin */ +body.darkmode code[class^='language-'] .nc { color: #a6e22e } /* Name.Class */ +body.darkmode code[class^='language-'] .no { color: #66d9ef } /* Name.Constant */ +body.darkmode code[class^='language-'] .nd { color: #a6e22e } /* Name.Decorator */ +body.darkmode code[class^='language-'] .ni { color: #f8f8f2 } /* Name.Entity */ +body.darkmode code[class^='language-'] .ne { color: #a6e22e } /* Name.Exception */ +body.darkmode code[class^='language-'] .nf { color: #a6e22e } /* Name.Function */ +body.darkmode code[class^='language-'] .nl { color: #f8f8f2 } /* Name.Label */ +body.darkmode code[class^='language-'] .nn { color: #f8f8f2 } /* Name.Namespace */ +body.darkmode code[class^='language-'] .nx { color: #a6e22e } /* Name.Other */ +body.darkmode code[class^='language-'] .py { color: #f8f8f2 } /* Name.Property */ +body.darkmode code[class^='language-'] .nt { color: #f92672 } /* Name.Tag */ +body.darkmode code[class^='language-'] .nv { color: #f8f8f2 } /* Name.Variable */ +body.darkmode code[class^='language-'] .ow { color: #f92672 } /* Operator.Word */ +body.darkmode code[class^='language-'] .w { color: #f8f8f2 } /* Text.Whitespace */ +body.darkmode code[class^='language-'] .mf { color: #ae81ff } /* Literal.Number.Float */ +body.darkmode code[class^='language-'] .mh { color: #ae81ff } /* Literal.Number.Hex */ +body.darkmode code[class^='language-'] .mi { color: #ae81ff } /* Literal.Number.Integer */ +body.darkmode code[class^='language-'] .mo { color: #ae81ff } /* Literal.Number.Oct */ +body.darkmode code[class^='language-'] .sb { color: #e6db74 } /* Literal.String.Backtick */ +body.darkmode code[class^='language-'] .sc { color: #e6db74 } /* Literal.String.Char */ +body.darkmode code[class^='language-'] .sd { color: #e6db74 } /* Literal.String.Doc */ +body.darkmode code[class^='language-'] .s2 { color: #e6db74 } /* Literal.String.Double */ +body.darkmode code[class^='language-'] .se { color: #ae81ff } /* Literal.String.Escape */ +body.darkmode code[class^='language-'] .sh { color: #e6db74 } /* Literal.String.Heredoc */ +body.darkmode code[class^='language-'] .si { color: #e6db74 } /* Literal.String.Interpol */ +body.darkmode code[class^='language-'] .sx { color: #e6db74 } /* Literal.String.Other */ +body.darkmode code[class^='language-'] .sr { color: #e6db74 } /* Literal.String.Regex */ +body.darkmode code[class^='language-'] .s1 { color: #e6db74 } /* Literal.String.Single */ +body.darkmode code[class^='language-'] .ss { color: #e6db74 } /* Literal.String.Symbol */ +body.darkmode code[class^='language-'] .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ +body.darkmode code[class^='language-'] .vc { color: #f8f8f2 } /* Name.Variable.Class */ +body.darkmode code[class^='language-'] .vg { color: #f8f8f2 } /* Name.Variable.Global */ +body.darkmode code[class^='language-'] .vi { color: #f8f8f2 } /* Name.Variable.Instance */ +body.darkmode code[class^='language-'] .il { color: #ae81ff } /* Literal.Number.Integer.Long */ +body.darkmode code[class^='language-'] .gh { } /* Generic Heading & Diff Header */ +body.darkmode code[class^='language-'] .gu { color: #75715e; } /* Generic.Subheading & Diff Unified/Comment? */ +body.darkmode code[class^='language-'] .gd { color: #f92672; } /* Generic.Deleted & Diff Deleted */ +body.darkmode code[class^='language-'] .gi { color: #a6e22e; } /* Generic.Inserted & Diff Inserted */ diff --git a/content/assets/css/normalize.css b/content/assets/css/normalize.css new file mode 100644 index 0000000..b6a2510 --- /dev/null +++ b/content/assets/css/normalize.css @@ -0,0 +1 @@ +/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0} diff --git a/content/assets/js/all.js b/content/assets/js/all.js new file mode 100644 index 0000000..30b2c4c --- /dev/null +++ b/content/assets/js/all.js @@ -0,0 +1 @@ +<%= all_js @config[:scripts] %> diff --git a/content/assets/js/main.js b/content/assets/js/main.js new file mode 100644 index 0000000..32f8de1 --- /dev/null +++ b/content/assets/js/main.js @@ -0,0 +1,87 @@ +function setVisibleTags(){ + var tocLinks = document.querySelectorAll("#sidebar a:link, a:visited"); + for(var i = 0; i < tocLinks.length; i++){ + if(localStorage.getItem(tocLinks[i].getAttribute("href")) != null){ + tocLinks[i].parentNode.classList.add("visited"); + } + } +} + +function updateSidebar(notransition) { + if (notransition) { + document.querySelectorAll("#sidebar")[0].classList.add("notransition"); + document.querySelectorAll("article")[0].classList.add("notransition"); + } + localStorage.setItem("openside", window.sidebarExpanded); + if (!window.sidebarExpanded) { + document.querySelectorAll("#sidebar")[0].classList.add("collapsed"); + document.querySelectorAll("article")[0].classList.add("expanded"); + } else { + document.querySelectorAll("#sidebar")[0].classList.remove("collapsed"); + document.querySelectorAll("article")[0].classList.remove("expanded"); + } + if (notransition) { + setTimeout(function(){ + document.querySelectorAll("#sidebar")[0].classList.remove("notransition"); + document.querySelectorAll("article")[0].classList.remove("notransition"); + }, 100); + } +} + +function sidebarClick() { + window.sidebarExpanded = !window.sidebarExpanded; + updateSidebar(false); +} + +function getNextPrev() { + // thanks iznogoodd from #nim @ freenode.net + var links = document.querySelectorAll('#sidebar a[href]'); + + var nav = {prev: null, next: null}; + for(var i = 0; i < links.length; i++){ + var item = links.item(i); + if(item && item.getAttribute('href') === window.location.pathname){ + nav.prev = links.item(i - 1) && links.item(i - 1).getAttribute('href'); + nav.next = links.item(i + 1) && links.item(i + 1).getAttribute('href'); + return nav; + } + } +} + +function updateNextPrevButtons() { + var nav = getNextPrev(); + + var prev = document.getElementById("arrow-prev"); + var next = document.getElementById("arrow-next"); + + if (nav.prev != null) { prev.classList.remove("disabled"); prev.href = nav.prev; } + if (nav.next != null) { next.classList.remove("disabled"); next.href = nav.next; } +} + +var darkmodeOn = (localStorage.getItem("darkmode") === "true"); +function toggleDarkMode() { + darkmodeOn = !darkmodeOn; + document.getElementsByTagName("body")[0].classList.toggle("darkmode"); + localStorage.setItem("darkmode", darkmodeOn); +} + +function initDarkMode() { + if (darkmodeOn) + document.getElementsByTagName("body")[0].classList.add("darkmode"); +} + + +var isMobile = window.screen.width < 720; +if (localStorage.getItem("openside") === null) { + window.sidebarExpanded = !isMobile; +} else { + window.sidebarExpanded = (localStorage.getItem("openside") === "true"); +} + +localStorage.setItem(window.location.pathname, true); +window.onload = function(){ + updateSidebar(true); + initDarkMode(); + setVisibleTags(); + updateNextPrevButtons(); +} diff --git a/content/arrays.md b/content/content/arrays.md similarity index 96% rename from content/arrays.md rename to content/content/arrays.md index c77329f..1411ba5 100644 --- a/content/arrays.md +++ b/content/content/arrays.md @@ -4,7 +4,7 @@ title: Arrays # Arrays -The arrays in Nim are like classic C arrays, their size is specified at compile-time and cannot given or changed at runtime. +The arrays in Nim are like classic C arrays, their size is specified at compile-time and cannot be given or changed at runtime. ``` nimrod type diff --git a/content/bitsets.md b/content/content/bitsets.md similarity index 100% rename from content/bitsets.md rename to content/content/bitsets.md diff --git a/content/block.md b/content/content/block.md similarity index 90% rename from content/block.md rename to content/content/block.md index 05e591b..b445981 100644 --- a/content/block.md +++ b/content/content/block.md @@ -6,11 +6,11 @@ title: Blocks Blocks can be introduced in two different ways: by indenting statements or with `()`s. -The first way ist to use indenting, e.g. using `if-elif-else`, `while`, `for` statements, or the `block` statement. +The first way is to use indenting, e.g. using `if-elif-else`, `while`, `for` statements, or the `block` statement. ``` nimrod if true: - echo "Nimrod is great!" + echo "Nim is great!" while false: echo "This line is never output!" diff --git a/content/case.md b/content/content/case.md similarity index 98% rename from content/case.md rename to content/content/case.md index fc64a76..765fb0c 100644 --- a/content/case.md +++ b/content/content/case.md @@ -54,7 +54,7 @@ Another feature of case statements is that the possible values are narrowed, mea ``` nimrod let x = 2 -case (x and 3) + 7: +case (x and 0b11) + 7: of 7: echo "A" of 8: echo "B" of 9: echo "C" diff --git a/content/exceptions.md b/content/content/exceptions.md similarity index 100% rename from content/exceptions.md rename to content/content/exceptions.md diff --git a/content/content/footer.md b/content/content/footer.md new file mode 100644 index 0000000..0686e2a --- /dev/null +++ b/content/content/footer.md @@ -0,0 +1,2 @@ +