aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2024-02-07 13:22:44 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2024-02-08 09:02:42 +0200
commit0e2a0090da2e00167847d16f89db452872704b05 (patch)
tree8a00f5eb907753175f09e619b3137e0d45e51c30
parent4e322c636bbc3e8064342931fe604bc6ddbe5f4e (diff)
Improvements
-rw-r--r--.gitignore5
-rw-r--r--app.scm50
-rw-r--r--article.md42
-rw-r--r--index.html6
-rw-r--r--todo.txt4
5 files changed, 60 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d9df752
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+dist
+dist/
+pages
+pages/
+
diff --git a/app.scm b/app.scm
index 7b22dbf..683dc5f 100644
--- a/app.scm
+++ b/app.scm
@@ -15,7 +15,8 @@
shell
srfi-13
intarweb
- html-parser)
+ html-parser
+ (chicken process))
(define (pipe x . fns)
(match fns
@@ -25,8 +26,13 @@
;; Convenience macro (@ expr ...) that expands to (lambda (x) (expr ... x))
(define-syntax @
(syntax-rules ()
- ((_ fn-body expr ...)
- (lambda (x) (fn-body expr ... x)))))
+ ((_ expr ...)
+ (lambda (x) (expr ... x)))))
+
+(define-syntax thunk
+ (syntax-rules ()
+ ((_ expr ...)
+ (lambda () (expr ...)))))
(define (replace from to str)
(irregex-replace/all from str to))
@@ -89,12 +95,48 @@
(send-response body: html-text
headers: '((content-type #(text/html ((charset . utf-8)))))))
+(define (compile-file filepath return)
+ (if (not (irregex-search "\\.md$" filepath))
+ (begin
+ (print (format "Copying non-md file: ~A" filepath))
+ (copy-file filepath
+ (replace "pages\\/" "dist/" filepath))
+ (return (void))))
+
+ (print (format "Compiling: ~A" filepath))
+ (define out-path (pipe filepath
+ (@ replace "\\.md" ".html")
+ (@ replace "pages\\/" "dist/")))
+
+ (define out-content (pipe filepath
+ (@ convert-md-to-html)
+ (@ highlight-code-blocks)
+ (@ insert-to-page-tmpl "index.html")))
+
+ (with-output-to-file out-path
+ (thunk display out-content)))
+
+(define (recompile)
+ (create-directory "dist" #t)
+ (for-each (@ delete-file) (glob "dist/*"))
+ (find-files "pages"
+ action: (lambda (filepath prev-result) (call/cc (lambda (k) (compile-file filepath k))))))
+
+(thread-start!
+ (lambda ()
+ (receive (input _ _) (process "fswatch -o pages")
+ (let loop ()
+ (print (format "Monitored directory has changed (# of changes: ~A)" (read-line input)))
+ (recompile)
+ (loop)))))
+
(thread-start!
(lambda ()
(print "starting nrepl on port 1234")
(nrepl-prompt (lambda () (display "#;0> ")))
(nrepl 1234)))
-(vhost-map `((".*" . ,(lambda (c) (app c)))))
+(recompile)
+(vhost-map `((".*" . ,(lambda (c) (app c)))))
(start-server)
diff --git a/article.md b/article.md
deleted file mode 100644
index bc0d9db..0000000
--- a/article.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# Article title
-
-Some text
-
-[Link text](http://example.com)
-
-Paragraph with inline _Python code_: `%lang py% import foo`, wonder what this looks like.
-
-## Subtitle
-
- %lang c%
- int main() {
- return 0;
- }
-
-### Let's try a Lisp
-
- %lang scm%
- (define foo (+ 1 2 3 4))
-
-### And Rust
-
- %lang rs%
- const STARTING_MISSILES: i32 = 8;
- const READY_AMOUNT: i32 = 2;
-
- fn main() {
- let mut missiles: i32 = STARTING_MISSILES;
- let ready: i32 = READY_AMOUNT;
- println!("Firing {} of my {} missiles...", ready, missiles);
- missiles = missiles - ready;
- println!("{} missiles left", missiles);
- }
-
-## client side jäsä (juuso commission)
-
- %lang js%
- alert("beenis");
-
-> This is a quote
->
-> > Alas poor Yorick
diff --git a/index.html b/index.html
index b1e4892..ce0fb2e 100644
--- a/index.html
+++ b/index.html
@@ -1,7 +1,7 @@
<!doctype html>
<html lang="en">
<head>
- <title>Test</title>
+ <title>jan.systems</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@@ -63,6 +63,10 @@
color: #0090a0;
}
+ img {
+ max-width: 100%;
+ }
+
blockquote {
display: block;
background-color: #0090a020;
diff --git a/todo.txt b/todo.txt
new file mode 100644
index 0000000..0e26bbe
--- /dev/null
+++ b/todo.txt
@@ -0,0 +1,4 @@
+2024-02-07 feat: Remove webserver stuff
+2024-02-07 feat: Make pages and dist folders configurable via env
+2024-02-07 feat: Add sxml transform step that parses ![[url]] image links
+2024-02-07 feat: self-host font instead of Google dependency