From 6d8a7df95f53ef33691f70759489bd7e961a9973 Mon Sep 17 00:00:00 2001 From: jamie Date: Wed, 15 Oct 2025 08:52:08 +0100 Subject: refactor: some "small" changes --- assets/css/default.scss | 273 ++++++++++++++++++++++ assets/css/fonts.scss | 0 assets/css/syntax.scss | 243 +++++++++++++++++++ assets/fonts/AtkinsonHyperlegibleMono-Regular.ttf | Bin 0 -> 34320 bytes assets/fonts/AtkinsonHyperlegibleNext-Regular.ttf | Bin 0 -> 48064 bytes assets/images/favicon.ico | Bin 0 -> 14098 bytes assets/images/noise.png | Bin 0 -> 26039 bytes assets/images/nonbinary-flag.svg | 21 ++ css/default.scss | 240 ------------------- css/fonts.scss | 0 css/syntax.scss | 243 ------------------- images/favicon.ico | Bin 14098 -> 0 bytes images/noise.png | Bin 26039 -> 0 bytes images/nonbinary-flag.svg | 21 -- posts/2025-06-20-vr-plus-nixos-plus-nvidia.md | 15 +- site.hs | 95 ++++---- templates/default.html | 8 +- 17 files changed, 599 insertions(+), 560 deletions(-) create mode 100644 assets/css/default.scss create mode 100644 assets/css/fonts.scss create mode 100644 assets/css/syntax.scss create mode 100644 assets/fonts/AtkinsonHyperlegibleMono-Regular.ttf create mode 100644 assets/fonts/AtkinsonHyperlegibleNext-Regular.ttf create mode 100644 assets/images/favicon.ico create mode 100644 assets/images/noise.png create mode 100644 assets/images/nonbinary-flag.svg delete mode 100644 css/default.scss delete mode 100644 css/fonts.scss delete mode 100644 css/syntax.scss delete mode 100644 images/favicon.ico delete mode 100644 images/noise.png delete mode 100644 images/nonbinary-flag.svg diff --git a/assets/css/default.scss b/assets/css/default.scss new file mode 100644 index 0000000..c3d6044 --- /dev/null +++ b/assets/css/default.scss @@ -0,0 +1,273 @@ +$background-color: oklch(22.49% 0.008 297.21); +$foreground-color: oklch(98.51% 0 0); +$primary-color: oklch(82.67% 0.096 307.5); +$secondary-color: oklch(from $primary-color l c 240); + +@import "syntax"; + +@mixin for-phone-only { + @media (max-width: 499px) { + @content; + } +} + +:root { + font-size: 16px; // acts as a sort of scale because everything uses rem. +} + +* { + box-sizing: border-box; + transition: 0.1s ease-in-out; + /* outline: 1px solid rgba(255, 1, 0, 0.2); */ + padding: 0; + margin: 0; +} + +body { + display: flex; + flex-direction: column; + align-items: center; + $opacity: 25%; + background-color: black; + // prettier-ignore + background-image: + url("/images/noise.png"), + radial-gradient(circle at center center, oklch(22.49% 0.008 297.21), transparent), + radial-gradient(circle at bottom left, #27577D, transparent), + radial-gradient(circle at top right, #952EA4 0%, transparent), + radial-gradient(circle at center right, #6949A5 0%, transparent), + radial-gradient(circle at top center, #336BA0 0%, transparent); + background-attachment: fixed; + color: white; + color: $foreground-color; + $gaps: 1rem; + padding: $gaps; + padding-top: 5rem; + gap: $gaps; + + overflow-x: hidden; + + &>* { + display: flex; + flex-direction: column; + gap: 1rem; + background-color: $background-color; + width: 100%; + max-width: 50rem; + padding: 1.5rem 2.5rem; + outline: 0.2rem solid $background-color; + outline-offset: 0.2rem; + } +} + +// --- NAVIGATION BAR --- +nav { + display: flex; + width: unset; + padding: 1rem; + position: fixed; + flex-direction: column; + align-items: center; + gap: 1rem; + height: fit-content; + transform: translateX(28rem); + + svg { + fill: $foreground-color; + $size: 2rem; + width: $size; + height: $size; + } + + a { + display: flex; + writing-mode: vertical-rl; + text-orientation: sideways; + text-decoration: none; + justify-content: center; + color: $foreground-color; + } + + hr { + width: 100%; + } +} + +@include for-phone-only { + position: inherit; + flex-direction: row; + + hr { + display: none; + } +} + +// --- STANDARD ELEMENTS --- +a { + color: mediumpurple; + color: $primary-color; + + &:hover { + filter: brightness(0.75); + } +} + +@mixin std-style { + display: block; + margin: 0; +} + +p { + @include std-style; +} + +ul { + display: flex; + flex-direction: column; + gap: 0.5rem; + list-style-type: none; + margin: 0; + padding: 0; + + &>li:before { + content: "~"; + color: oklch(82.67% 0.087 180); + padding-left: 0.5rem; + padding-right: 0.25rem; + } +} + +@for $i from 1 through 6 { + h#{$i} { + @include std-style; + padding-top: 0.5rem; + + &:before { + $hashes: ""; + + @for $_ from 1 through $i { + $hashes: $hashes + "#"; + } + + content: "#{$hashes} "; + color: oklch(82.67% 0.087 #{280 + ($i - 1) * 40}); + } + } +} + +@for $i from 1 through 15 { + ul>li:nth-child(n+#{$i}):before { + color: oklch(82.67% 0.087 #{100 + ($i - 1) * 80}); + } +} + +img { + user-select: none; + + &:hover { + animation: spin 0.5s ease-in-out; + } +} + +@keyframes spin { + from { + transform: rotate(0deg); + } + + to { + transform: rotate(360deg); + } +} + +hr { + $color: oklch(from $foreground-color 0.45 c h); + // Not a single platform can decide which way to set the color of a `hr`. + background-color: $color; + color: $color; + border-color: $color; +} + +.playlist { + display: flex; + flex-direction: row; + align-items: center; + gap: 15px; +} + +// FONTS!!!!!!!!!!!!!!!!! TODO: split up +@font-face { + font-family: "Atkinson Hyperlegible Next"; + src: url("/assets/fonts/AtkinsonHyperlegibleNext-Regular.ttf") +} + + +@font-face { + font-family: "Atkinson Hyperlegible Mono"; + src: url("/assets/fonts/AtkinsonHyperlegibleMono-Regular.ttf") +} + +* { + font-family: "Atkinson Hyperlegible Next", sans-serif; + font-optical-sizing: auto; + text-transform: lowercase; +} + + +p, +ul, +span { + text-align: justify; + font-size: 1.25rem; +} + +code {} + +h1, +h2, +h3, +h4, +h5, +h6 { + font-size: 1.75rem; +} + +address { + opacity: 0.5; + text-align: right; + width: auto; + margin-top: -2.1lh; // TODO: i can fix this when it becomes a problem :) + margin-bottom: 0.5rem; // SO HACKY +} + +footer { + gap: 0; +} + +footer>* { + text-align: center; + font-size: 1rem; + opacity: 0.5; +} + +// SYNTAX!!!!!!! +div.sourceCode { + // prettier-ignore + background-image: + url("/images/noise.png"), + radial-gradient(circle at center center, oklch(22.49% 0.008 297.21), transparent), + radial-gradient(circle at bottom left, #27577D, transparent), + radial-gradient(circle at top right, #952EA4 0%, transparent), + radial-gradient(circle at center right, #6949A5 0%, transparent), + radial-gradient(circle at top center, #336BA0 0%, transparent); + background-attachment: scroll; + padding: 0.2rem; + overflow: hidden; + font-family: "Atkinson Hyperlegible Mono", monospace; + + &>* { + background-color: $background-color; + background-attachment: fixed; + padding: 1.2rem; + overflow: scroll; + } +} \ No newline at end of file diff --git a/assets/css/fonts.scss b/assets/css/fonts.scss new file mode 100644 index 0000000..e69de29 diff --git a/assets/css/syntax.scss b/assets/css/syntax.scss new file mode 100644 index 0000000..42be310 --- /dev/null +++ b/assets/css/syntax.scss @@ -0,0 +1,243 @@ +a.sourceLine { + display: inline-block; + line-height: 1.25; +} + +a.sourceLine { + pointer-events: none; + color: inherit; + text-decoration: inherit; +} + +a.sourceLine:empty { + height: 1.2em; +} + +.sourceCode { + overflow: visible; +} + +code.sourceCode { + white-space: pre; + position: relative; +} + +div.sourceCode { + margin: 1em 0; +} + +pre.sourceCode { + margin: 0; +} + +@media screen { + div.sourceCode { + overflow: auto; + } +} + +@media print { + code.sourceCode { + white-space: pre-wrap; + } + + a.sourceLine { + text-indent: -1em; + padding-left: 1em; + } +} + +pre.numberSource a.sourceLine { + position: relative; + left: -4em; +} + +pre.numberSource a.sourceLine::before { + content: attr(title); + position: relative; + left: -1em; + text-align: right; + vertical-align: baseline; + border: none; + pointer-events: all; + display: inline-block; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + padding: 0 4px; + width: 4em; + color: #aaaaaa; +} + +pre.numberSource { + margin-left: 3em; + border-left: 1px solid #aaaaaa; + padding-left: 4px; +} + +div.sourceCode { +} + +@media screen { + a.sourceLine::before { + text-decoration: underline; + } +} + +code span.al { + color: #f85858; + font-weight: bold; +} + +/* Alert */ +code span.an { + color: #3dddd8; + font-weight: bold; + font-style: italic; +} + +/* Annotation */ +code span.at { + color: #2ac68e; +} + +/* Attribute */ +code span.bn { + color: #2ac68e; +} + +/* BaseN */ +code span.bu { +} + +/* BuiltIn */ +code span.cf { + color: #2ac68e; + font-weight: bold; +} + +/* ControlFlow */ +code span.ch { + color: #008ce3; +} + +/* Char */ +code span.cn { + color: #f85858; +} + +/* Constant */ +code span.co { + color: #3dddd8; + font-style: italic; +} + +/* Comment */ +code span.cv { + color: #3dddd8; + font-weight: bold; + font-style: italic; +} + +/* CommentVar */ +code span.do { + color: #f85858; + font-style: italic; +} + +/* Documentation */ +code span.dt { + color: #f85858; +} + +/* DataType */ +code span.dv { + color: #2ac68e; +} + +/* DecVal */ +code span.er { + color: #f85858; + font-weight: bold; +} + +/* Error */ +code span.ex { +} + +/* Extension */ +code span.fl { + color: #40a070; +} + +/* Float */ +code span.fu { + color: #008ce3; +} + +/* Function */ +code span.im { +} + +/* Import */ +code span.in { + color: #3dddd8; + font-weight: bold; + font-style: italic; +} + +/* Information */ +code span.kw { + color: #2ac68e; + font-weight: bold; +} + +/* Keyword */ +code span.op { + color: #aaaaaa; +} + +/* Operator */ +code span.ot { + color: #2ac68e; +} + +/* Other */ +code span.pp { + color: #ff8a00; +} + +/* Preprocessor */ +code span.sc { + color: #4070a0; +} + +/* SpecialChar */ +code span.ss { + color: #008ce3; +} + +/* SpecialString */ +code span.st { + color: #008ce3; +} + +/* String */ +code span.va { + color: #008ce3; +} + +/* Variable */ +code span.vs { + color: #008ce3; +} + +/* VerbatimString */ +code span.wa { + color: #3dddd8; + font-weight: bold; + font-style: italic; +} diff --git a/assets/fonts/AtkinsonHyperlegibleMono-Regular.ttf b/assets/fonts/AtkinsonHyperlegibleMono-Regular.ttf new file mode 100644 index 0000000..157d62e Binary files /dev/null and b/assets/fonts/AtkinsonHyperlegibleMono-Regular.ttf differ diff --git a/assets/fonts/AtkinsonHyperlegibleNext-Regular.ttf b/assets/fonts/AtkinsonHyperlegibleNext-Regular.ttf new file mode 100644 index 0000000..3fa771f Binary files /dev/null and b/assets/fonts/AtkinsonHyperlegibleNext-Regular.ttf differ diff --git a/assets/images/favicon.ico b/assets/images/favicon.ico new file mode 100644 index 0000000..5000bb7 Binary files /dev/null and b/assets/images/favicon.ico differ diff --git a/assets/images/noise.png b/assets/images/noise.png new file mode 100644 index 0000000..93c1ad7 Binary files /dev/null and b/assets/images/noise.png differ diff --git a/assets/images/nonbinary-flag.svg b/assets/images/nonbinary-flag.svg new file mode 100644 index 0000000..5252870 --- /dev/null +++ b/assets/images/nonbinary-flag.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + diff --git a/css/default.scss b/css/default.scss deleted file mode 100644 index 5fd653f..0000000 --- a/css/default.scss +++ /dev/null @@ -1,240 +0,0 @@ -$background-color: oklch(22.49% 0.008 297.21); -$foreground-color: oklch(98.51% 0 0); -$primary-color: oklch(82.67% 0.096 307.5); -$secondary-color: oklch(from $primary-color l c 240); - -@import "syntax"; - -:root { - font-size: 16px; // acts as a sort of scale because everything uses rem. -} - -* { - box-sizing: border-box; - transition: 0.1s ease-in-out; - /* outline: 1px solid rgba(255, 1, 0, 0.2); */ - padding: 0; - margin: 0; -} - -body { - display: flex; - flex-direction: column; - align-items: center; - $opacity: 25%; - background-color: black; - // prettier-ignore - background-image: - url("/images/noise.png"), - radial-gradient(circle at center center, oklch(22.49% 0.008 297.21), transparent), - radial-gradient(circle at bottom left, #27577D, transparent), - radial-gradient(circle at top right, #952EA4 0%, transparent), - radial-gradient(circle at center right, #6949A5 0%, transparent), - radial-gradient(circle at top center, #336BA0 0%, transparent); - background-attachment: fixed; - color: white; - color: $foreground-color; - $gaps: 1rem; - padding: $gaps; - padding-top: 5rem; - gap: $gaps; - - overflow-x: hidden; - - &>* { - display: flex; - flex-direction: column; - gap: 1rem; - background-color: $background-color; - width: 100%; - max-width: 50rem; - padding: 1.5rem 2.5rem; - outline: 0.2rem solid $background-color; - outline-offset: 0.2rem; - } -} - -// --- NAVIGATION BAR --- -// This whole navbar section needs refactoring, because I'm already confused by it -nav { - display: flex; - width: unset; - padding: 1rem; - position: fixed; - top: 1rem; // TODO: actually have this floating next to the side like the old site - right: 1rem; - flex-direction: column; - align-items: center; - gap: 1rem; - height: fit-content; - - svg { - fill: $foreground-color; - $size: 2rem; - width: $size; - height: $size; - } - - a { - display: flex; - writing-mode: vertical-rl; - text-orientation: sideways; - text-decoration: none; - justify-content: center; - color: $foreground-color; - } - - hr { - width: 100%; - } -} - -// --- STANDARD ELEMENTS --- -a { - color: mediumpurple; - color: $primary-color; - - &:hover { - filter: brightness(0.75); - } -} - -@mixin std-style { - display: block; - margin: 0; -} - -p { - @include std-style; -} - -ul { - display: flex; - flex-direction: column; - gap: 0.5rem; - list-style-type: none; - margin: 0; - padding: 0; - - &>li:before { - content: "~"; - color: oklch(82.67% 0.087 180); - padding-left: 0.5rem; - padding-right: 0.25rem; - } -} - -@for $i from 1 through 6 { - h#{$i} { - @include std-style; - padding-top: 0.5rem; - - &:before { - $hashes: ""; - - @for $_ from 1 through $i { - $hashes: $hashes + "#"; - } - - content: "#{$hashes} "; - color: oklch(82.67% 0.087 #{280 + ($i - 1) * 40}); - } - } -} - -@for $i from 1 through 15 { - ul>li:nth-child(n+#{$i}):before { - color: oklch(82.67% 0.087 #{100 + ($i - 1) * 80}); - } -} - -img { - user-select: none; - pointer-events: none; -} - -hr { - $color: oklch(from $foreground-color 0.45 c h); - // Not a single platform can decide which way to set the color of a `hr`. - background-color: $color; - color: $color; - border-color: $color; -} - -.playlist { - display: flex; - flex-direction: row; - align-items: center; - gap: 15px; -} - -// FONTS!!!!!!!!!!!!!!!!! TODO: split up -@import url("https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible+Next:ital,wght@0,200..800;1,200..800&display=swap"); -@import url("https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible+Mono:ital,wght@0,200..800;1,200..800&display=swap"); - -* { - font-family: "Atkinson Hyperlegible Next", sans-serif; - font-optical-sizing: auto; - text-transform: lowercase; -} - - -p, -ul, -span { - text-align: justify; - font-size: 1.25rem; -} - -code { - font-family: "Atkinson Hyperlegible Mono", monospace; -} - -h1, -h2, -h3, -h4, -h5, -h6 { - font-size: 1.75rem; -} - -address { - opacity: 0.5; - text-align: right; - width: auto; - margin-top: -2.1lh; // TODO: i can fix this when it becomes a problem :) - margin-bottom: 0.5rem; // SO HACKY -} - -footer { - gap: 0; -} - -footer>* { - text-align: center; - font-size: 1rem; - opacity: 0.5; -} - -// SYNTAX!!!!!!! -div.sourceCode { - // prettier-ignore - background-image: - url("/images/noise.png"), - radial-gradient(circle at center center, oklch(22.49% 0.008 297.21), transparent), - radial-gradient(circle at bottom left, #27577D, transparent), - radial-gradient(circle at top right, #952EA4 0%, transparent), - radial-gradient(circle at center right, #6949A5 0%, transparent), - radial-gradient(circle at top center, #336BA0 0%, transparent); - background-attachment: fixed; - padding: 0.2rem; - overflow: hidden; - - &>* { - background-color: $background-color; - background-attachment: fixed; - padding: 1.2rem; - overflow: scroll; - } -} \ No newline at end of file diff --git a/css/fonts.scss b/css/fonts.scss deleted file mode 100644 index e69de29..0000000 diff --git a/css/syntax.scss b/css/syntax.scss deleted file mode 100644 index 42be310..0000000 --- a/css/syntax.scss +++ /dev/null @@ -1,243 +0,0 @@ -a.sourceLine { - display: inline-block; - line-height: 1.25; -} - -a.sourceLine { - pointer-events: none; - color: inherit; - text-decoration: inherit; -} - -a.sourceLine:empty { - height: 1.2em; -} - -.sourceCode { - overflow: visible; -} - -code.sourceCode { - white-space: pre; - position: relative; -} - -div.sourceCode { - margin: 1em 0; -} - -pre.sourceCode { - margin: 0; -} - -@media screen { - div.sourceCode { - overflow: auto; - } -} - -@media print { - code.sourceCode { - white-space: pre-wrap; - } - - a.sourceLine { - text-indent: -1em; - padding-left: 1em; - } -} - -pre.numberSource a.sourceLine { - position: relative; - left: -4em; -} - -pre.numberSource a.sourceLine::before { - content: attr(title); - position: relative; - left: -1em; - text-align: right; - vertical-align: baseline; - border: none; - pointer-events: all; - display: inline-block; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - padding: 0 4px; - width: 4em; - color: #aaaaaa; -} - -pre.numberSource { - margin-left: 3em; - border-left: 1px solid #aaaaaa; - padding-left: 4px; -} - -div.sourceCode { -} - -@media screen { - a.sourceLine::before { - text-decoration: underline; - } -} - -code span.al { - color: #f85858; - font-weight: bold; -} - -/* Alert */ -code span.an { - color: #3dddd8; - font-weight: bold; - font-style: italic; -} - -/* Annotation */ -code span.at { - color: #2ac68e; -} - -/* Attribute */ -code span.bn { - color: #2ac68e; -} - -/* BaseN */ -code span.bu { -} - -/* BuiltIn */ -code span.cf { - color: #2ac68e; - font-weight: bold; -} - -/* ControlFlow */ -code span.ch { - color: #008ce3; -} - -/* Char */ -code span.cn { - color: #f85858; -} - -/* Constant */ -code span.co { - color: #3dddd8; - font-style: italic; -} - -/* Comment */ -code span.cv { - color: #3dddd8; - font-weight: bold; - font-style: italic; -} - -/* CommentVar */ -code span.do { - color: #f85858; - font-style: italic; -} - -/* Documentation */ -code span.dt { - color: #f85858; -} - -/* DataType */ -code span.dv { - color: #2ac68e; -} - -/* DecVal */ -code span.er { - color: #f85858; - font-weight: bold; -} - -/* Error */ -code span.ex { -} - -/* Extension */ -code span.fl { - color: #40a070; -} - -/* Float */ -code span.fu { - color: #008ce3; -} - -/* Function */ -code span.im { -} - -/* Import */ -code span.in { - color: #3dddd8; - font-weight: bold; - font-style: italic; -} - -/* Information */ -code span.kw { - color: #2ac68e; - font-weight: bold; -} - -/* Keyword */ -code span.op { - color: #aaaaaa; -} - -/* Operator */ -code span.ot { - color: #2ac68e; -} - -/* Other */ -code span.pp { - color: #ff8a00; -} - -/* Preprocessor */ -code span.sc { - color: #4070a0; -} - -/* SpecialChar */ -code span.ss { - color: #008ce3; -} - -/* SpecialString */ -code span.st { - color: #008ce3; -} - -/* String */ -code span.va { - color: #008ce3; -} - -/* Variable */ -code span.vs { - color: #008ce3; -} - -/* VerbatimString */ -code span.wa { - color: #3dddd8; - font-weight: bold; - font-style: italic; -} diff --git a/images/favicon.ico b/images/favicon.ico deleted file mode 100644 index 5000bb7..0000000 Binary files a/images/favicon.ico and /dev/null differ diff --git a/images/noise.png b/images/noise.png deleted file mode 100644 index 93c1ad7..0000000 Binary files a/images/noise.png and /dev/null differ diff --git a/images/nonbinary-flag.svg b/images/nonbinary-flag.svg deleted file mode 100644 index 5252870..0000000 --- a/images/nonbinary-flag.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - diff --git a/posts/2025-06-20-vr-plus-nixos-plus-nvidia.md b/posts/2025-06-20-vr-plus-nixos-plus-nvidia.md index 3c6b90e..88fd45c 100644 --- a/posts/2025-06-20-vr-plus-nixos-plus-nvidia.md +++ b/posts/2025-06-20-vr-plus-nixos-plus-nvidia.md @@ -2,6 +2,15 @@ title: VR + NixOS + Nvidia --- +## ⚠️ Note + +This post is quite outdated now. +The 'prerequisites' section is still quite accurate, as you still need the proprietary drivers, however setting WiVRn +up is significantly easier. I recommend looking at the [Linux VR Adventures Wiki](https://lvra.gitlab.io/docs/distros/nixos/) +for a much better guide. + +## Introduction + For the longest time, getting VR working nicely with Linux (and especially NixOS) was a monumental task. Nowadays however, it is easier than ever: only requiring a handful of lines of Nix! @@ -91,7 +100,11 @@ We are using `osConfig` in this case, as to use the same package we use when ena Going back to our main configuration, we now need to tell the game to actually use these settings. -We can do this by setting our game launch options to `PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/wivrn/comp_ipc %command%`, however that isn't very "Nix", is it? +We can do this by setting our game launch options to... +```sh +PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/wivrn/comp_ipc %command% +``` +...however, that isn't very "Nix", is it? To do this for _every_ game, we can override our steam package to include this environment variable. ```nix diff --git a/site.hs b/site.hs index 832409e..7c9980b 100644 --- a/site.hs +++ b/site.hs @@ -1,37 +1,36 @@ -------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} -import Control.Exception (SomeException, catch) -import Data.List (isInfixOf, sortBy) -import Data.Monoid (mappend) -import Hakyll -import Hakyll.Web.Sass (sassCompiler) -import System.Environment -import System.FilePath.Posix (splitFileName, takeBaseName, - takeDirectory, ()) -import System.Process +import Control.Exception +import Data.List +import Data.Monoid +import Hakyll +import Hakyll.Web.Sass +import System.Environment +import System.FilePath.Posix +import System.Process -------------------------------------------------------------------------------- main :: IO () main = hakyll $ do - match "images/*" $ do - route idRoute - compile copyFileCompiler + match "templates/*" $ compile templateBodyCompiler - match "css/*.css" $ do + match ("assets/images/*" .||. "assets/fonts/*") $ do route idRoute - compile compressCssCompiler + compile copyFileCompiler - match "css/*.scss" $ do + match "assets/css/*" $ do route $ setExtension "css" let compressCssItem = fmap compressCss compile (compressCssItem <$> sassCompiler) - match "404.html" $ do - route idRoute + match "posts/*" $ do + route prettyRoute compile $ pandocCompiler - >>= loadAndApplyTemplate "templates/default.html" defaultCtx + >>= loadAndApplyTemplate "templates/post.html" postCtx + >>= saveSnapshot "content" + >>= loadAndApplyTemplate "templates/default.html" postCtx >>= relativizeUrls >>= removeIndexHtml @@ -43,13 +42,11 @@ main = hakyll $ do >>= relativizeUrls >>= removeIndexHtml - match "posts/*" $ do - route prettyRoute + match "404.html" $ do + route idRoute compile $ pandocCompiler - >>= loadAndApplyTemplate "templates/post.html" postCtx - >>= saveSnapshot "content" - >>= loadAndApplyTemplate "templates/default.html" postCtx + >>= loadAndApplyTemplate "templates/default.html" defaultCtx >>= relativizeUrls >>= removeIndexHtml @@ -59,8 +56,8 @@ main = hakyll $ do posts <- recentFirst =<< loadAll "posts/*" let archiveCtx = listField "posts" postCtx (return posts) - `mappend` constField "title" "Archives" - `mappend` defaultCtx + <> constField "title" "Archives" + <> defaultCtx makeItem "" >>= loadAndApplyTemplate "templates/archive.html" archiveCtx @@ -68,10 +65,24 @@ main = hakyll $ do >>= relativizeUrls >>= removeIndexHtml + match "index.html" $ do + route idRoute + compile $ do + posts <- recentFirst =<< loadAll "posts/*" + let indexCtx = + listField "posts" postCtx (return posts) + <> defaultCtx + + getResourceBody + >>= applyAsTemplate indexCtx + >>= loadAndApplyTemplate "templates/default.html" indexCtx + >>= relativizeUrls + >>= removeIndexHtml + create ["atom.xml"] $ do route idRoute compile $ do - let feedCtx = postCtx `mappend` bodyField "description" + let feedCtx = postCtx <> bodyField "description" posts <- fmap (take 10) . recentFirst =<< loadAllSnapshots "posts/*" "content" @@ -80,28 +91,12 @@ main = hakyll $ do create ["rss.xml"] $ do route idRoute compile $ do - let feedCtx = postCtx `mappend` bodyField "description" + let feedCtx = postCtx <> bodyField "description" posts <- fmap (take 10) . recentFirst =<< loadAllSnapshots "posts/*" "content" renderRss feedConfiguration feedCtx posts - match "index.html" $ do - route idRoute - compile $ do - posts <- recentFirst =<< loadAll "posts/*" - let indexCtx = - listField "posts" postCtx (return posts) - `mappend` defaultCtx - - getResourceBody - >>= applyAsTemplate indexCtx - >>= loadAndApplyTemplate "templates/default.html" indexCtx - >>= relativizeUrls - >>= removeIndexHtml - - match "templates/*" $ compile templateBodyCompiler - -------------------------------------------------------------------------------- feedConfiguration :: FeedConfiguration feedConfiguration = @@ -129,9 +124,9 @@ removeIndexHtml item = return $ fmap (withUrls removeIndexStr) item removeIndexStr :: String -> String removeIndexStr url = case splitFileName url of (dir, "index.html") | isLocal dir -> dir - _ -> url + _ -> url where - isLocal uri = not (isInfixOf "://" uri) + isLocal uri = not ("://" `isInfixOf` uri) -------------------------------------------------------------------------------- @@ -150,17 +145,11 @@ cDateCtx = dateField "cdate" "%Y-%m-%d" gitRevisionField :: String -> Context String gitRevisionField = flip field (const gitRevision) --- Compiler which attempts to find the current git revision. This is done by --- first checking the "REVISION" environment variable and, if this fails, --- running the command "git rev-parse HEAD". gitRevision :: Compiler String -gitRevision = do - rev <- unsafeCompiler (getEnv "REVISION" `catch` (\e -> return (e :: SomeException) >> return "")) - if rev == "" - then unixFilter "git" ["rev-parse", "--short=7", "HEAD"] "" - else return rev +gitRevision = unixFilter "git" ["rev-parse", "--short=7", "HEAD"] "" gitRevisionCtx :: Context String gitRevisionCtx = gitRevisionField "revision" -------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- diff --git a/templates/default.html b/templates/default.html index bd94760..f50fae5 100644 --- a/templates/default.html +++ b/templates/default.html @@ -5,7 +5,7 @@ $title$ ~ Skiletro - + @@ -75,7 +75,11 @@ Archive Playlists
- +
$body$