From e1b7e1f50709c89b7b6448bd86999a5a562f0e1b Mon Sep 17 00:00:00 2001 From: Duncan Wilkie Date: Mon, 26 Jun 2023 10:15:27 -0500 Subject: Start over cleanly --- dnw/static-pages.scm | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++ dnw/tags.scm | 65 +++++++++++++++++++ dnw/theme.scm | 127 ++++++++++++++++++++++++++++++++++++ dnw/utils.scm | 37 +++++++++++ 4 files changed, 407 insertions(+) create mode 100644 dnw/static-pages.scm create mode 100644 dnw/tags.scm create mode 100644 dnw/theme.scm create mode 100644 dnw/utils.scm (limited to 'dnw') diff --git a/dnw/static-pages.scm b/dnw/static-pages.scm new file mode 100644 index 0000000..578e009 --- /dev/null +++ b/dnw/static-pages.scm @@ -0,0 +1,178 @@ + + +(define-module (dnw static-pages) + #:use-module (ice-9 match) + #:use-module (ice-9 rdelim) + #:use-module (ice-9 popen) + #:use-module (dnw utils) + #:use-module (dnw theme) + #:use-module (dnw tags) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-19) + #:use-module (sxml simple) + #:use-module (haunt page) + #:use-module (haunt utils) + #:use-module (haunt post) + #:use-module (haunt html) + #:export (index-page + me-page + friends-page + influences-page)) + +;; TODO: tags-template +;; building index-page +(define about + `(section (@ (id "about")) + (div + (p "My name is Duncan. I live below the Mason-Dixon.") + (p "I write down thoughts I think are interesting here.")))) + +(define (recents site posts) + `(section (@ (id "recent")) + (div + (h1 "Recent Posts" + ,(hyperlink "/feed.xml" (image "rss.png" "RSS Feed Icon" "rss-icon"))) + (div (@ (class "post-listing")) + ,(map (lambda (post) + (post-header site post)) + (take-up-to 10 (posts/reverse-chronological posts)))) + ,(hyperlink "/posts" "All Posts")))) + +(define (index-content site posts) + `(,about ,(recents site posts))) + +(define (index-page site posts) + (make-page "/index.html" + (base-template site (index-content site posts) #:title "Home ") + sxml->html)) + +(define me + `((section (@ (id "addressbook")) + (ul (p "GPG: " ,(hyperlink "/assets/pubkey.txt" "A63B DBA0 B4FB 6EAB 1D1A 6665 029C EF3B A922 2674"))) + (ul (p "Email: (rot13 \"qaj@shapgbevny.klm\")") + (p "Matrix: (rot13 \"synzvajnyehf@zngevk.bet\")") + (p "IRC: (rot13 \"SynzvaJnyehf@yvoren.pung\")")) + (ul (p "Nostr: npub1a706jyq9hljs08fsr7ejzr3g4l33fpwnadxp63hmjp6tshfvlcqs6z3w29")) + (ul (p "Github: " ,(hyperlink "https://github.com/Antigravityd" "Antigravityd")))) ;; TODO: consider moving to Sourcehut. + (section (@ (id "prose")) + (h1 "About Me") + (p "My name is Duncan. I am 20, and have lived most of my life in rural Arkansas. I graduated in 2023 from LSU, cum laude, " + "with dual degrees in math and physics, and have at various times been employed as a dishwasher, maintainence guy, tutor, " + "data science intern, embedded developer, and research scientist. I am currently unemployed.") + (p "Had I my druthers, I would like to be able to make a career out of decentralized science, " + "doing physics research and teaching not dependent on the state or the university system and their insidious pollution" + "of the discipline. " + "In the interim, I'm in no way above contributing to society more directly. Hire me; I'll learn anything. I have a " + ,(hyperlink "/assets/cv.pdf" "terrible CV") " you can read.") + (h1 "Academic Interests") + (h2 "Physical Science") + (p "I've planned on studying physics since I was 5. I enjoy studing almost anything that's natural and dead, " + "and all my other interests are largely subsidiary to this. " + "I like the areas where physics intersects with math, particularly when it does so in mathematically-exciting ways. " + "I also " (emph "loved") " my classes about emergent phenomena: thermodynamic, statistical, and condensed-matter physics. " + "I spent the latter half of my time working under Jeff Chancellor's Space Radiation Transport and Applied Nuclear Physics " + "(SpaRTAN physics) research group, doing embedded design of radiation detectors and writing improvements for transport code.") + (h2 "Mathematics") + (p "I view math primarily as a tool for physical science and philosophy in general. " + "Accordingly, I want to get to the frontier of the discipline as fast as possible: I probably will need to make new tools. " + "The only domain that seems not to have borne much practical fruit, except as a " (emph "target") " for developing " + "\"real\" tools, is number theory. " + "However, I particularly like topology/geometry and algebra, and would prefer if analysis and discrete math borrowed " + "as many of its tools and methods as possible.") + (h2 "Computation") + (p "Fundamentally, computer science is a branch of mathematics, in my view. " + "I am interested in ways to compute as abstractly, efficiently, securely, and correctly as possible. " + "As such, I enjoy functional and logic programming languages, which succeed by representing computation in maximally " + "mathematical form, using the abstractions that have been most useful in a general context. " + "I like writing things in Haskell and Lisp. I have written many things in Python, C, and Fortran. " + "I didn't enjoy it (although Fortran was much better than expected—prefered to C). " + "I would like to learn Rust to replace the latter two, and also Lean for formal verification of mathematics and programs. " + "Julia as a scripting language is also intriguing, for projects consumed by people allergic to parentheses. " + "Software that is not " ,(hyperlink "https://gnu.org/philosophy" "Free") " might as well not be software at all. " + "I use GNU Emacs for almost everything.") + (h2 "Engineering") + (p "For all of the above, you have to build real, material things. " + "Physical science requires the construction of detectors, accelerators, and whatnot; " + "mathematics needs blackboards, chalk, printing presses, and a society to ignore; " + "and computation needs computers and network technology. " + "This is predominantly electrical work—designing silicon, circuits, wire protocols, radios, and so on. " + "I've done a fair bit of this. " + "However, that electrical work is predicated on things like power generation, structures to protect the electronics, etc. " + "So, I aspire to learn \"real\" CAD at some point, and understand these things too. ") + (h2 "Praxeology") + (p "There simply is not enough time in a person's life for autarkic, first-principles generation of every part of every thing " + "one's primary interests depend on. " + "It is critically important to understand and verify those steps, but it is necessary to outsource their production. " + "In order to understand the principles under which this outsourcing occurs, why it's even possible at all, " + "and how it need not be vicious, one must study the category of action. " + "Austrian economics, and more generally praxeology, does so correctly. " + "The critical error of conventional economics, as with many social- and life-science disciplines, " + "is thoughtless application of the methods of physical science, without careful consideration of whether the philosophical " + "conditions the correctness of those methods depend are present. " + "These fail spectacularly in analysis of action: the wants and desires of humans are not immutable, comparable quantities. " + "However, Austrian economists tend to thoughtlessly reject methodological precision due to superficial association " + "with these historical fallacies. " + "A mathematical, in the truest sense, grounding for the reasoning of Mises, Rothbard, and Hoppe " + "is a longstanding pet project of mine. ") + (h2 "Foundations: Philosophy and Theology") + (p "All of this again rests on some foundational definitions and propositions about the nature of reality, truth, reason, mind, " + "beauty, and morality. " + "Very recently, I've become acutely interested in these foundations, particularly the philosophy of mathematics and science. " + "I am metaphysically an ardent platonist, and believe that analysis of the problem of perception in a platonist context " + "contains parts identifiable with mathematics and science. " + "This analysis, however, carries little further: I am attracted to methodological anarchy, which holds " + "that there is no essential distinction between practice, philosophy, teaching, and history of science (and mathematics)." + "Anything and everything there is fair game—and many scientific revolutions are the result of such foundational assaults.") + (p "That the philosophical tradition which created the modern world emerged almost exclusively out of Abrahamic religion, " + "and that its sustaining manifestation is almost exclusively owed to Protestant Christians, carries tremedous weight with me." + " I see no essential difference between these theological premises and philosophy, save methodology—" + "the former implemented in story, and the latter rhetoric—and accordingly extend foundational interest to Christiandom.") + (h2 "Blind Spots") + (p "I don't know much about linguistics and aesthetics/art (save the mere verneer to which all men are exposed). " + "These are similarly foundational, as philosophy can only be communicated through language, and must be bootstrapped " + "by the beautiful (usually stories). " + "I would like to learn these things, but am not taking active measures in any capacity to do so at the moment.") + (h1 "Anti-Interests") + (p "I dislike: OOP, Javascript, the Intel Management Engine, almost all TV and movies, number theory, measure theory, " + "drugs, the War on Drugs, appeals to authority, the Federal Reserve System, occupational licensure, and collectivism.") + (h1 "Touching Grass") + (p "I listen to (.*)core, rock and metal from the 60s–80s, microtonal and avant-garde jazz and classical, and old standards. " + "I all-too-seldom go outside: when I remember I enjoy it, I resistance train, hike, (spin|fly) fish, (snow|water) ski, " + "climb, and mountaineer. " + "I read high fantasy and sci-fi obsessively for about 10 years, and occasionally go back through " + "the Tolkein, Jordan, and Sanderson novels I love. " + "I watch a lot of football and baseball; my Tigers picked up a ring in each while I was there.")))) + + +(define (me-page site posts) + (make-page "/pages/me.html" + (base-template site me #:title "Me") + sxml->html)) + +(define friends + `((h1 "Friends") + (p "Blogs/websites of people and corporations I know firsthand, as friends, colleagues, or employers. ") + (table + (tbody + (tr (td ,(hyperlink "https://atlantis-industries.com" "Atlantis Industries")) (td "Worked on retainer with them for a year.")) + (tr (td ,(hyperlink "https://spartanphysics.com/" "SpaRTAN Physics")) (td "Lab I spent half my undergrad in.")) + (tr (td ,(hyperlink "https://www.lsu.edu/physics/people/faculty/chancellor.php" "Jeff Chancellor")) + (td "My undergrad advisor, founder and CTO of Atlantis and director of SpaRTAN Physics.")))))) + +(define (friends-page site posts) + (make-page "/pages/friends.html" + (base-template site friends #:title "Friends") + sxml->html)) + +(define influences + `((h1 "Influences") + (p "Anything and everything I can think of that's affected how I think. ") + (h2 "Blogs") + (h2 "Books and Monographs") + (h2 "Scholarly Articles") + (h2 "Videos and Talks"))) + +(define (influences-page site posts) + (make-page "/pages/influences.html" + (base-template site influences #:title "Influences") + sxml->html)) diff --git a/dnw/tags.scm b/dnw/tags.scm new file mode 100644 index 0000000..0c00354 --- /dev/null +++ b/dnw/tags.scm @@ -0,0 +1,65 @@ + +(define-module (dnw tags) + #:use-module (dnw theme) + #:use-module (haunt post) + #:use-module (srfi srfi-1) + #:use-module (haunt html) + #:use-module (haunt post) + #:use-module (haunt page) + #:use-module (haunt utils) + #:use-module (ice-9 match) + #:export (group-by-tag + count-tags + tag-uri + tags->page + tag-description + desc-alist)) + +(define (group-by-tag posts) + "Given a lisp of haunt posts generate a list grouping tags with the +posts associated with it." + (let ((table (make-hash-table))) + (for-each (lambda (post) + (let ((tags (post-ref post 'tags))) + (for-each (lambda (tag) + (let ((current (hash-ref table tag))) + (if current + (hash-set! table tag (cons post current)) + (hash-set! table tag (list post))))) + tags))) + posts) + (hash-fold alist-cons '() table))) + + +(define (count-tags posts) + "Return a list of tags associated with their count in descending +order." + (sort (map (lambda (tag) + (list (car tag) (length (cdr tag)))) + (group-by-tag posts)) + (lambda (a b) (> (cadr a) (cadr b))))) + + +(define (tag-uri tag) + "Given a TAG return the page that contains only posts associated +with that TAG." + (string-append "/posts/tag/" tag ".html")) + + +(define (tags->page site posts) + (flat-map (match-lambda + ((tag . posts) + (make-page (tag-uri tag) + (base-template site (tags-template site posts #:title tag) + #:title tag) + sxml->html))) + (group-by-tag posts))) + +(define (tag-description tag descalist) + (let ((desc (assoc tag descalist))) + (if desc + `(p ,(cdr desc)) + '(p "No description.")))) + +(define desc-alist + '(("Test" . "This is a test of the tag description feature."))) diff --git a/dnw/theme.scm b/dnw/theme.scm new file mode 100644 index 0000000..69688bc --- /dev/null +++ b/dnw/theme.scm @@ -0,0 +1,127 @@ + + +(define-module (dnw theme) + #:use-module (ice-9 match) + #:use-module (srfi srfi-19) + #:use-module (haunt site) + #:use-module (haunt post) + #:use-module (haunt utils) + #:use-module (dnw utils) + #:use-module (dnw tags) + #:use-module (haunt builder blog) + #:export (dnw-haunt-theme + base-template + post-header + tags-template)) + +(define stylesheets '("style.css")) + +(define nav-bar-tabs '(("Me" "/pages/me.html") + ("Friends" "/pages/friends.html") + ("Influences" "/pages/influences.html") + ("Projects" "/posts/tag/Project.html"))) + +(define dnw-title "Through the Heart of Every Man") + +(define header + `(header + ,(hyperlink "/" (image "combgeo.png" "home")) + (h1 ,dnw-title) + (nav (ul + ,@(map (lambda (tuple) + `(li ,(apply hyperlink (reverse tuple)))) + nav-bar-tabs))))) + +(define footer + `(footer + (div + (p "© 2023 Duncan Wilkie") + ,(image "by-sa.svg" + "Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) Logo")) + (p "Unless otherwise specified, the text and images on this site are free culture works available under the " + ,(hyperlink "https://creativecommons.org/licenses/by-sa/4.0/" + "Creative Commons Attribution Share-Alike 4.0 International") + " license.") + (p "This website is built with " + ,(hyperlink "http://haunt.dthompson.us/" "Haunt") + ", a static site generator written in " + ,(hyperlink "https://gnu.org/software/guile" "Guile Scheme") + ". The source code is available " + ,(hyperlink "https://github.com/Antigravityd/functorial.xyz" "here") + "."))) + +(define* (base-template site body #:key title) + `((doctype html) + (html (@ (lang "en"))) + (head + ,(if (null? title) + `(title title) + `(title ,(string-join (list title dnw-title) " — "))) + (meta (@ (charset "utf-8"))) + (meta (@ (name "viewport") + (content "width=device-width, initial_scale=1"))) + ,@(map (lambda (file-name) (stylesheet file-name)) stylesheets) + (meta (@ (name "HandheldFriendly") (content "True"))) + (meta (@ (name "author") (content "Duncan Wilkie"))) + (meta (@ (name "subject") (content "Ravings of a Madman"))) + (meta (@ (name "medium") (content "blog"))) + (meta (@ (name "og:title") (content ,title)))) + (body (@ (class "")) + ,header + ,body + ,footer))) + +(define (post-meta post) + `(p ,(let ((tgs (post-ref post 'tags)) + (datestr (date->string (post-date post) "~e ~B ~Y"))) + (if tgs + `(,(string-append datestr " | ") + (span (@ (class "tags")) + ,(map (lambda (tag) + `(span + ,(hyperlink (tag-uri tag) tag) + " ")) + tgs))) + datestr)))) + +(define (post-header site post) + `(div (@ (id "post")) + (div (@ (class "title")) + (h2 ,(hyperlink (post-uri site post) + (post-ref post 'title)))) + (div (@ (class "subtitle")) + ,(post-meta post)))) + +(define (post-template post) + `((h1 ,(post-ref post 'title)) + ,(post-meta post) + ,(post-sxml post))) + +(define* (tags-template site posts #:key title) + `((section (@ (id "posts")) + (div (@ (class "container")) + (h1 "Tagged #" ,title) + ,(tag-description title desc-alist) + (div (@ (class "post-listing")) + ,(map (lambda (post) + (post-header site post)) + (posts/reverse-chronological posts))))))) + +(define (collection-template site title posts prefix) + `((section (@ (id "posts")) + (div (@ (class "container")) + (h1 "All Posts" + ,(hyperlink "/feed.xml" (image "rss.png" "RSS Feed Icon" "rss-icon"))) + (div (@ (class "post-listing")) + ,(map (lambda (post) (post-header site post)) + (posts/reverse-chronological posts))))))) + +(define dnw-haunt-theme + (theme #:name "Through the Heart of Every Man" + #:layout + (lambda (site title body) + (base-template + site body + #:title dnw-title)) + #:post-template post-template + #:collection-template collection-template)) diff --git a/dnw/utils.scm b/dnw/utils.scm new file mode 100644 index 0000000..e25ed97 --- /dev/null +++ b/dnw/utils.scm @@ -0,0 +1,37 @@ + +;; Shameless "borrowing" of SXML conveniences from jakob.space and bendersteed.tech. +;; A few modifications and a few additions. + +(define-module (dnw utils) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (haunt site) + #:export + (hyperlink + image + stylesheet + script + post-uri)) + +(define (hyperlink target text) + `(a (@ (href ,target)) ,text)) + +(define* (image file-name #:optional description class) + (let ((src (string-append "/assets/image/" file-name))) + (if description + (if class + `(img (@ (src ,src) (alt ,description) (title ,description) (class ,class))) + `(img (@ (src ,src) (alt ,description) (title ,description)))) + (if class + `(img (@ (src ,src) (class ,class))) + `(img (@ (src ,src))))))) + +(define (stylesheet file-name) + `(link (@ (rel "stylesheet") (href ,(format #f "/assets/css/~a" file-name))))) + +(define (script file-name) + (let ((src (string-append "/assets/js/" file-name))) + `(script (@ (src ,src))))) + +(define (post-uri site post) + (string-append "/posts/" (site-post-slug site post) ".html")) -- cgit v1.2.3