From 5ad0ee4b3005056561b4f473f7592987ec548e61 Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Thu, 2 May 2019 19:35:44 -0400 Subject: Include Org sources --- haunt/about.scm | 1 + haunt/css/fonts.css | 59 +++++++++ haunt/css/highlight.css | 50 +++++++ haunt/css/jakob.css | 239 ++++++++++++++++++++++++++++++++++ haunt/custom/alias.scm | 44 +++++++ haunt/custom/tag.scm | 39 ++++++ haunt/custom/theme.scm | 141 ++++++++++++++++++++ haunt/fonts/Cantarell-Bold.otf | Bin 0 -> 69196 bytes haunt/fonts/Cantarell-BoldOblique.otf | Bin 0 -> 75888 bytes haunt/fonts/Cantarell-Oblique.otf | Bin 0 -> 74892 bytes haunt/fonts/Cantarell-Regular.otf | Bin 0 -> 68340 bytes haunt/fonts/Hack-Bold.ttf | Bin 0 -> 317628 bytes haunt/fonts/Hack-BoldItalic.ttf | Bin 0 -> 322288 bytes haunt/fonts/Hack-Italic.ttf | Bin 0 -> 316156 bytes haunt/fonts/Hack-Regular.ttf | Bin 0 -> 309408 bytes haunt/haunt.scm | 92 +++++++++++++ haunt/images/favicon.png | Bin 0 -> 8266 bytes haunt/projects.scm | 1 + 18 files changed, 666 insertions(+) create mode 100644 haunt/about.scm create mode 100644 haunt/css/fonts.css create mode 100644 haunt/css/highlight.css create mode 100644 haunt/css/jakob.css create mode 100644 haunt/custom/alias.scm create mode 100644 haunt/custom/tag.scm create mode 100644 haunt/custom/theme.scm create mode 100644 haunt/fonts/Cantarell-Bold.otf create mode 100644 haunt/fonts/Cantarell-BoldOblique.otf create mode 100644 haunt/fonts/Cantarell-Oblique.otf create mode 100644 haunt/fonts/Cantarell-Regular.otf create mode 100644 haunt/fonts/Hack-Bold.ttf create mode 100644 haunt/fonts/Hack-BoldItalic.ttf create mode 100644 haunt/fonts/Hack-Italic.ttf create mode 100644 haunt/fonts/Hack-Regular.ttf create mode 100644 haunt/haunt.scm create mode 100644 haunt/images/favicon.png create mode 100644 haunt/projects.scm (limited to 'haunt') diff --git a/haunt/about.scm b/haunt/about.scm new file mode 100644 index 0000000..c54f0bb --- /dev/null +++ b/haunt/about.scm @@ -0,0 +1 @@ +`((h2 "Hi.")) diff --git a/haunt/css/fonts.css b/haunt/css/fonts.css new file mode 100644 index 0000000..b17b8fd --- /dev/null +++ b/haunt/css/fonts.css @@ -0,0 +1,59 @@ +/* Cantarell */ + +@font-face { + font-family: 'Cantarell'; + src: url('/fonts/Cantarell-Bold.otf') format('opentype'); + font-weight: bold; + font-style: normal; +} + +@font-face { + font-family: 'Cantarell'; + src: url('/fonts/Cantarell-BoldOblique.otf') format('opentype'); + font-weight: bold; + font-style: italic; +} + +@font-face { + font-family: 'Cantarell'; + src: url('/fonts/Cantarell-Oblique.otf') format('opentype'); + font-weight: normal; + font-style: italic; +} + +@font-face { + font-family: 'Cantarell'; + src: url('/fonts/Cantarell-Regular.otf') format('opentype'); + font-weight: normal; + font-style: normal; +} + +/* Hack */ + +@font-face { + font-family: 'Hack'; + src: url('/fonts/Hack-Bold.ttf'); + font-weight: bold; + font-style: normal; +} + +@font-face { + font-family: 'Hack'; + src: url('/fonts/Hack-BoldItalic.ttf'); + font-weight: bold; + font-style: italic; +} + +@font-face { + font-family: 'Hack'; + src: url('/fonts/Hack-Italic.ttf'); + font-weight: normal; + font-style: italic; +} + +@font-face { + font-family: 'Hack'; + src: url('/fonts/Hack-Regular.ttf'); + font-weight: normal; + font-style: normal; +} diff --git a/haunt/css/highlight.css b/haunt/css/highlight.css new file mode 100644 index 0000000..c69bbb7 --- /dev/null +++ b/haunt/css/highlight.css @@ -0,0 +1,50 @@ +.org-preprocessor, +.org-builtin { + color: #afd7d7; +} + +.org-comment { + color: #ff8700; +} + +.org-constant { + color: #87ffd7; +} + +.org-function-name { + color: #afd7ff; +} + +.org-keyword { + color: #1fb6d3; +} + +.org-negation-char { + color: #ff4b4b; +} + +.org-regexp-grouping-backslash { + color: #ffd787; +} + +.org-regexp-grouping-construct { + color: #d18aff; +} + +.org-doc, +.org-doc-string, +.org-string { + color: #ffaf87; +} + +.org-type { + color: #87ff87; +} + +.org-variable-name { + color: #ffd787; +} + +.org-warning { + color: #dd0000; +} diff --git a/haunt/css/jakob.css b/haunt/css/jakob.css new file mode 100644 index 0000000..d2e7cc2 --- /dev/null +++ b/haunt/css/jakob.css @@ -0,0 +1,239 @@ +/* Use smaller fonts and line-height on smaller screens. */ +@media (max-width: 54rem) { + body { + font-size: 14px; + line-height: 160%; + } +} + +@media (max-width: 26rem) { + body { + font-size: 12px; + line-height: 150%; + } +} + +body { + color: #4D4D4D; + background-color: #eee; + font-family: 'Cantarell', serif; + line-height: 140%; + text-rendering: optimizeLegibility; +} + +h1, h2, h3 { + font-family: 'Cantarell', sans; +} + +h1 { + font-size: 150%; + line-height: 110%; +} + +h2 { + font-size: 115%; +} + +h3 { + font-size: 100%; +} + +a { + color: #159957; + text-decoration: none; +} + +pre { + font-family: "Hack", monospace; + font-size: 90%; + line-height: 110%; + min-width: 100%; + background-color: #303539; + padding: 1rem; + color: #f0e9dc; + border-radius: 4px; + display: inline-block; +} + +code { + font-family: "Hack", monospace; +} + +blockquote { + padding-left: 2rem; + border-left: 5px solid #eee; + font-style: italic; +} + +/* Footer */ + +footer { + border-top: 1px solid #ccc; + font-size: 80%; +} + +.copyright { + text-align: center; +} + +.cc-button { + margin-left: 1rem; +} + +/* Navigation */ + +nav { + font-family: "Cantarell", sans; + padding-top: 1rem; + padding-bottom: 1rem; + border-bottom: 1px solid #eee; +} + +nav ul { + list-style-type: none; + margin: 0; + padding: 0; +} + +nav a { + display: inline-block; + color: #000; +} + +nav a:hover { + color: #000; +} + +nav a:visited { + color: #000; +} + +@media (min-width: 800px) { + nav { + margin-bottom: 3rem; + } + + nav ul { + display: inline-block; + } + + nav li { + display: inline; + padding: 1rem; + } + + nav li:first-child { + padding-left: 0; + } +} + +@media (max-width: 800px) { + nav ul { + list-style-type: none; + margin: 0; + padding: 0; + } +} + +/* Container */ + +@media (min-width: 1140px) { + .container { + margin-left: 14rem; + margin-right: 4rem; + max-width: 52rem; + } +} + +@media (min-width: 800px) and (max-width: 1140px) { + .container { + margin-left: 6rem; + margin-right: 4rem; + max-width: 52rem; + } +} + +@media (max-width: 800px) { + .container { + margin: 1rem; + } +} + +.fade-text { + color: #ddd; +} + +/* Summaries */ + +.summary { + margin-bottom: 3rem; +} + +.summary .date { + margin-bottom: 0rem; +} + +.summary p { + margin-top: 1rem; + margin-bottom: 1rem; +} + +/* Posts */ + +.date { + margin-top: -1rem; + margin-bottom: 2rem; + color: #666; +} + +.tags { + margin-top: -2rem; + color: #666; +} + +.tags ul { + display: inline; + list-style: none; + padding-left: 0; +} + +.tags li { + display: inline; + padding-right: 0.5rem; +} + +.post img, .centered-image { + display: block; + max-width: 100%; + height: auto; + margin: 0 auto; + padding: 0px; + border-radius: 4px; +} + +.post video { + display: block; + margin: 0 auto; + padding: 0px; + max-width: 100%; +} + +figcaption { + margin: 1rem 1rem 0 1rem; + color: #717171; + font-style: italic; + font-size: 90%; +} + +.footpara { + display: inline; +} + +.mastodon { + width: 70%; + margin: auto; +} + +.mastodon iframe { + width: 100%; +} diff --git a/haunt/custom/alias.scm b/haunt/custom/alias.scm new file mode 100644 index 0000000..6bc5062 --- /dev/null +++ b/haunt/custom/alias.scm @@ -0,0 +1,44 @@ +;;; Copyright © 2019 Jakob L. Kreuze +;;; +;;; This program is free software; you can redistribute it and/or +;;; modify it under the terms of the GNU General Public License as +;;; published by the Free Software Foundation; either version 3 of the +;;; License, or (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see +;;; . + +(define-module (custom alias) + #:use-module (haunt html) + #:use-module (haunt page) + #:export (article-aliases)) + +(define (article-alias alias target) + "Create a page named ALIAS that redirects to TARGET." + (make-page (string-append alias "/index.html") + `((doctype "html") + (html + (head + (title ,target) + (link (@ (rel "canonical") (href ,target))) + (meta (@ (name "robots") (content "noindex"))) + (meta (@ (charset "utf-8"))) + (meta (@ (http-equiv "refresh") + (content ,(string-append "0; " target))))))) + sxml->html)) + +(define (article-aliases aliases) + "Return a procedure that transforms a list of article ALIASES into pages +redirecting from one arbitrary file to another." + (lambda (site posts) + (map (lambda (alist) + (let ((alias (car alist)) + (target (cdr alist))) + (article-alias alias target))) + aliases))) diff --git a/haunt/custom/tag.scm b/haunt/custom/tag.scm new file mode 100644 index 0000000..a36197a --- /dev/null +++ b/haunt/custom/tag.scm @@ -0,0 +1,39 @@ +;;; Copyright © 2019 Jakob L. Kreuze +;;; +;;; This program is free software; you can redistribute it and/or +;;; modify it under the terms of the GNU General Public License as +;;; published by the Free Software Foundation; either version 3 of the +;;; License, or (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see +;;; . + +(define-module (custom tag) + #:use-module (custom theme) + #:use-module (haunt builder blog) + #:use-module (haunt html) + #:use-module (haunt page) + #:use-module (haunt post) + #:export (sort-by-tag)) + +(define (sort-by-tag) + "Return a procedure that transforms a list of posts into pages containing only +the posts that have a certain tag." + (lambda (site posts) + (map (lambda (alist) + (let* ((tag-name (car alist)) + (posts (cdr alist)) + (title (format #f "Posts tagged as \"~a\"" tag-name)) + (file-name (format #f "tag-~a.html" tag-name)) + (body `(h1 ,(format #f "Tagged as \"~a\"" tag-name)))) + (make-page + file-name + (render-collection jakob-theme site title posts #f) + sxml->html))) + (posts/group-by-tag posts)))) diff --git a/haunt/custom/theme.scm b/haunt/custom/theme.scm new file mode 100644 index 0000000..ac6f2ac --- /dev/null +++ b/haunt/custom/theme.scm @@ -0,0 +1,141 @@ +;;; Copyright © 2019 Jakob L. Kreuze +;;; +;;; This program is free software; you can redistribute it and/or +;;; modify it under the terms of the GNU General Public License as +;;; published by the Free Software Foundation; either version 3 of the +;;; License, or (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see +;;; . + +(define-module (custom theme) + #:use-module (haunt builder blog) + #:use-module (haunt post) + #:use-module (haunt site) + #:use-module (ice-9 match) + #:use-module (srfi srfi-19) + #:export (jakob-theme)) + +(define (stylesheet name) + `(link (@ (rel "stylesheet") + (href ,(string-append "/css/" name ".css"))))) + +(define* (anchor content #:optional (uri content)) + `(a (@ (href ,uri)) ,content)) + +(define %cc-by-sa-link + '(a (@ (href "https://creativecommons.org/licenses/by-sa/4.0/")) + "Creative Commons Attribution Share-Alike 4.0 International")) + +(define %cc-by-sa-button + '(a (@ (class "cc-button") + (href "https://creativecommons.org/licenses/by-sa/4.0/")) + (img (@ (src "https://licensebuttons.net/l/by-sa/4.0/80x15.png"))))) + +(define (link name uri) + `(a (@ (href ,uri)) ,name)) + +(define* (centered-image url #:optional alt) + `(img (@ (class "centered-image") + (src ,url) + ,@(if alt + `((alt ,alt)) + '())))) + +(define (first-paragraph post) + (let loop ((sxml (post-sxml post)) + (result '())) + (match sxml + (() (reverse result)) + ((or (('p ...) _ ...) (paragraph _ ...)) + (reverse (cons paragraph result))) + ((head . tail) + (loop tail (cons head result)))))) + +(define jakob-theme + (theme #:name "jakob" + #:layout + (lambda (site title body) + `((doctype "html") + (html + (head + (meta (@ (charset "utf-8"))) + (meta (@ (name "viewport") + (content "width=device-width, initial-scale=1.0"))) + (link (@ (rel "alternate") + (type "application/atom+xml") + (href "http://jakob.space/index.xml"))) + (link (@ (rel "me") + (href "https://mastodon.sdf.org/@jakob"))) + (link (@ (rel "icon") + (type "image/png") + (href "http://jakob.space/favicon.png"))) + (title ,(string-append title " — " (site-title site))) + ,(stylesheet "fonts") + ,(stylesheet "highlight") + ,(stylesheet "jakob")) + (body + (div (@ (class "container")) + (nav + (ul (li ,(link "Jakob L. Kreuze" "/")) + (li (@ (class "fade-text")) " ") + (li ,(link "About" "/about.html")) + (li ,(link "Blog" "/index.html")) + (li ,(link "Feed" "/feed.xml")) + (li ,(link "Projects" "/projects.html")))) + ,body + (footer (@ (class "text-center")) + (p (@ (class "copyright")) + "© 2019 Jakob L. Kreuze" + ,%cc-by-sa-button) + (p "Unless otherwise specified, the text and images +on this site are free culture works available under the " ,%cc-by-sa-link " +license.") + (p "This website is built with " + (a (@ (href "http://haunt.dthompson.us")) + "Haunt") + ", a static site generator written in " + (a (@ (href "https://gnu.org/software/guile")) + "Guile Scheme") + "."))))))) + #:post-template + (lambda (post) + `((h1 (@ (class "title")),(post-ref post 'title)) + (div (@ (class "date")) + ,(date->string (post-date post) + "~B ~d, ~Y")) + (div (@ (class "tags")) + (ul + (li "Tagged as" + ,@(map (lambda (tag) + `(li ,(link tag (format #f "/tag-~a.html" tag)))) + (post-ref post 'tags))))) + (div (@ (class "post")) + ,(post-sxml post)))) + #:collection-template + (lambda (site title posts prefix) + (define (post-uri post) + (string-append "/" (or prefix "") + (site-post-slug site post) ".html")) + + `((h1 ,title) + ,(map (lambda (post) + (let ((uri (string-append "/" + (site-post-slug site post) + ".html"))) + `(div (@ (class "summary")) + (h2 (a (@ (href ,uri)) + ,(post-ref post 'title))) + (div (@ (class "date")) + ,(date->string (post-date post) + "~B ~d, ~Y")) + (div (@ (class "post")) + ,(first-paragraph post)) + (a (@ (href ,uri)) "read more ➔")))) + posts))))) diff --git a/haunt/fonts/Cantarell-Bold.otf b/haunt/fonts/Cantarell-Bold.otf new file mode 100644 index 0000000..a5b620b Binary files /dev/null and b/haunt/fonts/Cantarell-Bold.otf differ diff --git a/haunt/fonts/Cantarell-BoldOblique.otf b/haunt/fonts/Cantarell-BoldOblique.otf new file mode 100644 index 0000000..5f49d64 Binary files /dev/null and b/haunt/fonts/Cantarell-BoldOblique.otf differ diff --git a/haunt/fonts/Cantarell-Oblique.otf b/haunt/fonts/Cantarell-Oblique.otf new file mode 100644 index 0000000..70539ed Binary files /dev/null and b/haunt/fonts/Cantarell-Oblique.otf differ diff --git a/haunt/fonts/Cantarell-Regular.otf b/haunt/fonts/Cantarell-Regular.otf new file mode 100644 index 0000000..fca6759 Binary files /dev/null and b/haunt/fonts/Cantarell-Regular.otf differ diff --git a/haunt/fonts/Hack-Bold.ttf b/haunt/fonts/Hack-Bold.ttf new file mode 100644 index 0000000..7ff4975 Binary files /dev/null and b/haunt/fonts/Hack-Bold.ttf differ diff --git a/haunt/fonts/Hack-BoldItalic.ttf b/haunt/fonts/Hack-BoldItalic.ttf new file mode 100644 index 0000000..3b137d9 Binary files /dev/null and b/haunt/fonts/Hack-BoldItalic.ttf differ diff --git a/haunt/fonts/Hack-Italic.ttf b/haunt/fonts/Hack-Italic.ttf new file mode 100644 index 0000000..d26198a Binary files /dev/null and b/haunt/fonts/Hack-Italic.ttf differ diff --git a/haunt/fonts/Hack-Regular.ttf b/haunt/fonts/Hack-Regular.ttf new file mode 100644 index 0000000..92a90cb Binary files /dev/null and b/haunt/fonts/Hack-Regular.ttf differ diff --git a/haunt/haunt.scm b/haunt/haunt.scm new file mode 100644 index 0000000..7fd9355 --- /dev/null +++ b/haunt/haunt.scm @@ -0,0 +1,92 @@ +;;; Copyright © 2019 Jakob L. Kreuze +;;; +;;; This program is free software; you can redistribute it and/or +;;; modify it under the terms of the GNU General Public License as +;;; published by the Free Software Foundation; either version 3 of the +;;; License, or (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see +;;; . + +(use-modules (custom alias) + (custom tag) + (custom theme) + (haunt builder atom) + (haunt builder assets) + (haunt builder blog) + (haunt html) + (haunt page) + (haunt post) + (haunt reader) + (haunt site) + (sxml simple) + (srfi srfi-19) + (srfi srfi-26) + (ice-9 match)) + +;; Use a temporary reader until my patch makes it into an upstream release. +(define (read-html-post-prime port) + (values (read-metadata-headers port) + (let loop ((ret '())) + (catch 'parser-error + (lambda () + (match (xml->sxml port) + (('*TOP* sxml) (loop (cons sxml ret))))) + (lambda (key . parameters) + (reverse ret)))))) + +(define html-reader-prime + (make-reader (make-file-extension-matcher "html") + (cut call-with-input-file <> read-html-post-prime))) + +;; Replace Haunt's default 'string->date* function with one that recognizes the +;; date format that Org uses. +(define (org-string->date str) + "Convert STR, a string in Org format, into a SRFI-19 date object." + (string->date str "<~Y-~m-~d ~a>")) + +(register-metadata-parser! 'date org-string->date) + +(define (static-page title slug) + (lambda (site posts) + (let ((file-name (format #f "~a.html" slug)) + (body (load (format #f "~a.scm" slug)))) + (make-page file-name + (with-layout jakob-theme site title body) + sxml->html)))) + +(define %collections + `(("Recent Posts" "index.html" ,posts/reverse-chronological))) + +(define %aliases + '(("blog/post/Bad BEHAVIOR" . "/reverse-engineering-babbys-first-archive-format.html"))) + +(site #:title "Jakob's Personal Webpage" + #:domain "jakob.space" + #:default-metadata + '((author . "Jakob L. Kreuze") + (email . "zerodaysfordays@sdf.lonestar.org")) + #:make-slug (lambda (post) + (let* ((file-name (post-file-name post)) + (splice-start (+ (string-rindex file-name + (cut char=? <> #\/)) + 1)) + (splice-end (string-rindex file-name + (cut char=? <> #\.)))) + (substring file-name splice-start splice-end))) + #:readers (list html-reader-prime) + #:builders (list (blog #:theme jakob-theme #:collections %collections) + (article-aliases %aliases) + (atom-feed) + (sort-by-tag) + (static-page "About Me" "about") + (static-page "Projects" "projects") + (static-directory "css") + (static-directory "fonts") + (static-directory "images"))) diff --git a/haunt/images/favicon.png b/haunt/images/favicon.png new file mode 100644 index 0000000..d5b97ed Binary files /dev/null and b/haunt/images/favicon.png differ diff --git a/haunt/projects.scm b/haunt/projects.scm new file mode 100644 index 0000000..c45a135 --- /dev/null +++ b/haunt/projects.scm @@ -0,0 +1 @@ +`((h1 "Projects")) -- cgit v1.3