Skip to content

Commit 9c0bc2e

Browse files
committed
Merge branch 'nix'
2 parents b9fa4bf + 47e9a74 commit 9c0bc2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+255
-61
lines changed

README.org

+1-13

deploy

-7
This file was deleted.

deploy.bat

-8
This file was deleted.

CNAME dist/CNAME

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/index.html dist/index.html

File renamed without changes.
File renamed without changes.

docs/lessons/02-values-types-variables.html dist/lessons/02-values-types-variables.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ <h2 id="example-repl-session">Example REPL session</h2>
167167
<span id="cb2-44"><a href="#cb2-44" aria-hidden="true" tabindex="-1"></a><span class="op">&gt;</span></span>
168168
<span id="cb2-45"><a href="#cb2-45" aria-hidden="true" tabindex="-1"></a></span>
169169
<span id="cb2-46"><a href="#cb2-46" aria-hidden="true" tabindex="-1"></a><span class="ex">C:\Users\Tim</span><span class="op">&gt;</span></span></code></pre></div>
170-
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
170+
<section class="footnotes" role="doc-endnotes">
171171
<hr />
172172
<ol>
173173
<li id="fn1" role="doc-endnote"><p>This list of types differs from the technical list of types in JavaScript. The types listed here are the intuitive types, meaning it’s closer to what goes on in our heads when programming with JavaScript. For the technical types in JavaScript, see <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures">MDN</a>.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>

docs/lessons/03-operators.html dist/lessons/03-operators.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ <h2 id="using-operators">Using operators</h2>
227227
<p>Try changing the values and adding more code. Get creative!</p>
228228
<h2 id="a-word-about-errors">A word about errors</h2>
229229
<p>Sometimes when you run your code, you may see node produce an error instead of the expected result. That’s not a bad thing! Node is trying to help make sure your code is unambiguous and doesn’t contain any silly mistakes that may cause unexpected problems. Think of errors as a gentle way of pointing out that something needs to be fixed in your code. Understanding the errors that node produces can take a lot of practice. Every error will have a message to let you know why there is an error in the first place and approximately where the problem is in your code (by telling you a line number). Because of the complexity of the code interpretation process, the error message and line number may not actually point you in the right direction! That being said, you should first assume that the error message <em>is</em> helpful and use its guidance, but be aware that it’s not a guarantee and you might need to look elsewhere. You will get to know the common errors with practice.</p>
230-
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
230+
<section class="footnotes" role="doc-endnotes">
231231
<hr />
232232
<ol>
233233
<li id="fn1" role="doc-endnote"><p>There is also a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality">less strict equality operator</a> (<code>==</code>), but it works unintuitively so it is advised not to use it.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
File renamed without changes.

docs/lessons/05-functions.html dist/lessons/05-functions.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ <h2 id="exercises">Exercises</h2>
234234
<li><a href="../exercises/05-functions-solutions.js" download type="application/octet-stream">Download solutions</a></li>
235235
</ul>
236236

237-
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
237+
<section class="footnotes" role="doc-endnotes">
238238
<hr />
239239
<ol>
240240
<li id="fn1" role="doc-endnote"><p>For more information on functional programming, read the <a href="../#preface">preface</a>, <a href="https://en.wikipedia.org/wiki/Functional_programming">wikipedia</a>, or <a href="https://en.wikibooks.org/wiki/Computer_Programming/Functional_programming">wikibooks</a>.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>

docs/lessons/06-strings.html dist/lessons/06-strings.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ <h2 id="exercises">Exercises</h2>
110110
<li><a href="../exercises/06-strings-solutions.js" download type="application/octet-stream">Download solutions</a></li>
111111
</ul>
112112

113-
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
113+
<section class="footnotes" role="doc-endnotes">
114114
<hr />
115115
<ol>
116116
<li id="fn1" role="doc-endnote"><p>See all the string methods on <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">MDN</a>.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>

docs/lessons/07-arrays.html dist/lessons/07-arrays.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ <h2 id="exercises">Exercises</h2>
242242
<li><a href="../exercises/07-arrays-solutions.js" download type="application/octet-stream">Download solutions</a></li>
243243
</ul>
244244

245-
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
245+
<section class="footnotes" role="doc-endnotes">
246246
<hr />
247247
<ol>
248248
<li id="fn1" role="doc-endnote"><p>See all the array methods on <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">MDN</a>.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>

docs/lessons/08-more-arrays.html dist/lessons/08-more-arrays.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ <h2 id="exercises">Exercises</h2>
287287
<li><a href="../exercises/08-more-arrays-solutions.js" download type="application/octet-stream">Download solutions</a></li>
288288
</ul>
289289

290-
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
290+
<section class="footnotes" role="doc-endnotes">
291291
<hr />
292292
<ol>
293293
<li id="fn1" role="doc-endnote"><p>See all the array methods on <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">MDN</a>.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>

docs/lessons/09-objects.html dist/lessons/09-objects.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ <h2 id="exercises">Exercises</h2>
260260
<li><a href="../exercises/09-objects-solutions.js" download type="application/octet-stream">Download solutions</a></li>
261261
</ul>
262262

263-
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
263+
<section class="footnotes" role="doc-endnotes">
264264
<hr />
265265
<ol>
266266
<li id="fn1" role="doc-endnote"><p>Technically, object properties can be <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol">Symbols</a>, but this is uncommon.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
File renamed without changes.
File renamed without changes.

docs/lessons/12-async.html dist/lessons/12-async.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ <h3 id="with-asyncawait">With async/await</h3>
388388
<span id="cb24-23"><a href="#cb24-23" aria-hidden="true" tabindex="-1"></a>}<span class="op">;</span></span>
389389
<span id="cb24-24"><a href="#cb24-24" aria-hidden="true" tabindex="-1"></a></span>
390390
<span id="cb24-25"><a href="#cb24-25" aria-hidden="true" tabindex="-1"></a><span class="fu">go</span>()<span class="op">;</span></span></code></pre></div>
391-
<section class="footnotes footnotes-end-of-document" role="doc-endnotes">
391+
<section class="footnotes" role="doc-endnotes">
392392
<hr />
393393
<ol>
394394
<li id="fn1" role="doc-endnote"><p>Technically, <code>readFile()</code>’s arguments are more flexible than described here but we can ignore the optional arguments for our purposes.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>

dist/robots.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Disallow:

flake.lock

+42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
description = "hakyll-nix-template";
3+
4+
nixConfig.bash-prompt = "[nix]λ ";
5+
6+
inputs = {
7+
nixpkgs.url = "nixpkgs/nixos-21.05";
8+
9+
flake-utils = {
10+
url = "github:numtide/flake-utils";
11+
inputs.nixpkgs.follows = "nixpkgs";
12+
};
13+
};
14+
15+
outputs = { flake-utils, nixpkgs, self }:
16+
flake-utils.lib.eachDefaultSystem (system:
17+
let
18+
config = {};
19+
overlays = [ (import ./haskell-overlay.nix) ];
20+
pkgs = import nixpkgs { inherit config overlays system; };
21+
in rec {
22+
defaultPackage = packages.website;
23+
defaultApp = apps.hakyll-site;
24+
25+
packages = with pkgs.myHaskellPackages; { inherit ssg website; };
26+
27+
apps.hakyll-site = flake-utils.lib.mkApp {
28+
drv = packages.ssg;
29+
exePath = "/bin/hakyll-site";
30+
};
31+
32+
devShell = pkgs.myHaskellPackages.shellFor {
33+
packages = p: [ p.ssg ];
34+
35+
buildInputs = with pkgs.myHaskellPackages; [
36+
ssg
37+
38+
# Helpful tools for `nix develop` shells
39+
#
40+
#ghcid # https://github.com/ndmitchell/ghcid
41+
#haskell-language-server # https://github.com/haskell/haskell-language-server
42+
#hlint # https://github.com/ndmitchell/hlint
43+
#ormolu # https://github.com/tweag/ormolu
44+
];
45+
46+
withHoogle = true;
47+
};
48+
}
49+
);
50+
}

hakyll.patch

Whitespace-only changes.

haskell-overlay.nix

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
final: prev:
2+
let
3+
inherit (prev.stdenv) mkDerivation;
4+
inherit (prev.lib.trivial) flip pipe;
5+
inherit (prev.haskell.lib)
6+
appendPatch
7+
appendConfigureFlags
8+
dontCheck
9+
doJailbreak;
10+
11+
withPatch = flip appendPatch;
12+
withFlags = flip appendConfigureFlags;
13+
14+
haskellCompiler = "ghc884";
15+
in {
16+
myHaskellPackages = prev.haskell.packages.${haskellCompiler}.override {
17+
overrides = hpFinal: hpPrev:
18+
let
19+
hakyll-src = hpPrev.callHackage "hakyll" "4.14.0.0" {};
20+
pandoc-src = hpPrev.callHackage "pandoc" "2.11.4" {}; # version specified by hayll 4.14.0.0
21+
slugger-src = hpPrev.callHackageDirect {
22+
pkg = "slugger";
23+
ver = "0.1.0.1";
24+
sha256 = "sha256-ggeo5TcbI4UlK/CtG4878USX9Cm7Faz16phdjlDOGaI=";
25+
} {}; # not available yet because it's so new
26+
in rec {
27+
hakyll = pipe hakyll-src [
28+
doJailbreak
29+
dontCheck
30+
(withPatch ./hakyll.patch)
31+
(withFlags [ "-f" "watchServer" "-f" "previewServer" ])
32+
];
33+
34+
pandoc = pipe pandoc-src [
35+
doJailbreak
36+
dontCheck
37+
];
38+
39+
slugger = slugger-src;
40+
41+
ssg = hpPrev.callCabal2nix "ssg" ./ssg {};
42+
43+
website = prev.stdenv.mkDerivation {
44+
#__contentAddressed = true; # uncomment if using cas: https://www.tweag.io/blog/2020-09-10-nix-cas/
45+
name = "website";
46+
buildInputs = [ ssg ];
47+
src = prev.nix-gitignore.gitignoreSourcePure [
48+
./.gitignore
49+
".git"
50+
".github"
51+
] ./.;
52+
53+
# LANG and LOCALE_ARCHIVE are fixes pulled from the community:
54+
# https://github.com/jaspervdj/hakyll/issues/614#issuecomment-411520691
55+
# https://github.com/NixOS/nix/issues/318#issuecomment-52986702
56+
# https://github.com/MaxDaten/brutal-recipes/blob/source/default.nix#L24
57+
LANG = "en_US.UTF-8";
58+
LOCALE_ARCHIVE = prev.lib.optionalString
59+
(prev.buildPlatform.libc == "glibc")
60+
"${prev.glibcLocales}/lib/locale/locale-archive";
61+
62+
buildPhase = ''
63+
hakyll-site build --verbose
64+
'';
65+
66+
installPhase = ''
67+
mkdir -p "$out/dist"
68+
cp -r dist/* "$out/dist"
69+
'';
70+
};
71+
};
72+
};
73+
}

result

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/nix/store/zs2qsbf21dm0m5i39h0kn62grbh59vgv-website

rundev

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
nix run . clean && nix run . watch

docs/CNAME src/CNAME

File renamed without changes.

src/_config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: []
File renamed without changes.

css/reset.css src/css/reset.css

File renamed without changes.

css/vs2015.css src/css/vs2015.css

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/exercises/06-strings-solutions.js src/exercises/06-strings-solutions.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,10 @@ For example, 'p4ssw0rd!' gets 9 + 5 + 10 = 24 points.
314314

315315
// Helper function to calculate the points of a password
316316
const calcPoints = password => {
317-
let points = password.length;
318-
if (hasDigit(password)) {
319-
points += 5;
320-
}
321-
if (hasPunctuation(password)) {
322-
points += 10;
323-
}
324-
return points;
317+
const lengthPoints = password.length;
318+
const digitPoints = hasDigit(password) ? 5 : 0;
319+
const puncPoints = hasPunctuation(password) ? 10 : 0;
320+
return lengthPoints + digitPoints + puncPoints;
325321
};
326322

327323
const betterPassword = (pass1, pass2) => {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

index.html src/index.html

File renamed without changes.

preface.org src/preface.org

src/robots.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Disallow:
File renamed without changes.
File renamed without changes.

ssg/LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2020, Robert Pearce
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

site.hs ssg/src/Main.hs

+22-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
--------------------------------------------------------------------------------
22
{-# LANGUAGE OverloadedStrings #-}
3-
import Data.Monoid ((<>))
4-
import Hakyll
3+
import Control.Monad (forM_)
4+
import Data.Monoid ((<>))
5+
import Hakyll
56
import qualified Text.Pandoc as Pandoc
67
import qualified GHC.IO.Encoding as E
78
import Control.Applicative (empty)
@@ -14,22 +15,24 @@ main :: IO ()
1415
main = do
1516
E.setLocaleEncoding E.utf8
1617
hakyllWith config $ do
17-
match "images/*" $ do
18-
route idRoute
19-
compile copyFileCompiler
20-
21-
match "exercises/*" $ do
22-
route idRoute
23-
compile copyFileCompiler
18+
forM_
19+
[ "CNAME"
20+
, "favicon.ico"
21+
, "robots.txt"
22+
, "_config.yml"
23+
, "images/*"
24+
, "js/*"
25+
, "fonts/*"
26+
, "exercises/*"
27+
]
28+
$ \f -> match f $ do
29+
route idRoute
30+
compile copyFileCompiler
2431

2532
match "css/*" $ do
2633
route idRoute
2734
compile compressCssCompiler
2835

29-
match (fromList ["CNAME"]) $ do
30-
route idRoute
31-
compile copyFileCompiler
32-
3336
match (fromList ["preface.org"]) $ do
3437
route $ (gsubRoute "preface.org" (const "index")) `composeRoutes` (setExtension "html")
3538
compile $ do
@@ -68,7 +71,12 @@ main = do
6871
--------------------------------------------------------------------------------
6972
config :: Configuration
7073
config = defaultConfiguration
71-
{ destinationDirectory = "docs"
74+
{ destinationDirectory = "dist"
75+
, previewHost = "127.0.0.1"
76+
, previewPort = 8000
77+
, providerDirectory = "src"
78+
, storeDirectory = "ssg/_cache"
79+
, tmpDirectory = "ssg/_tmp"
7280
}
7381

7482
withTOC :: Pandoc.WriterOptions

0 commit comments

Comments
 (0)