aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Brannon <chris@the-brannons.com>2021-03-31 16:01:28 -0700
committerChristopher Brannon <chris@the-brannons.com>2021-03-31 16:01:28 -0700
commit709e592251e10b6332debbf988640d002989a32d (patch)
treef5cd51f933384302a77f6349232ee89418e9983b
parent3ab7ff463e60eeef0bfae278cb0772f4f645672e (diff)
downloadnawp-709e592251e10b6332debbf988640d002989a32d.tar
nawp-709e592251e10b6332debbf988640d002989a32d.tar.gz
nawp-709e592251e10b6332debbf988640d002989a32d.tar.bz2
nawp-709e592251e10b6332debbf988640d002989a32d.tar.lz
nawp-709e592251e10b6332debbf988640d002989a32d.tar.xz
nawp-709e592251e10b6332debbf988640d002989a32d.tar.zst
nawp-709e592251e10b6332debbf988640d002989a32d.zip
Split out site-customizable variables into /etc/nawp-site.scm.
-rw-r--r--README.md8
-rw-r--r--nawp-site.scm5
-rwxr-xr-xnawp.scm17
3 files changed, 22 insertions, 8 deletions
diff --git a/README.md b/README.md
index 00389c0..77b97d4 100644
--- a/README.md
+++ b/README.md
@@ -33,8 +33,9 @@ Here is a list of the external Scheme libraries ("eggs" in Chicken Scheme parlan
You'll also need a CGI-capable web server. I use lighttpd with mod_cgi
enabled.
-Edit `nawp.scm` in your text editor of choice, customizing the variables
-`blog-base-uri`, `blog-title`, and `blog-description` to taste.
+Copy `nawp-site.scm` to `/etc/nawp-site.scm`.
+Edit `/etc/nawp-site.scm` in your text editor of choice, customizing the
+variables `blog-base-uri`, `blog-title`, and `blog-description` to taste.
Once the dependencies are installed, run:
```csc nawp.scm```
@@ -111,5 +112,4 @@ Markdown is useful, but it is also poorly specified -- excepting CommonMark -- a
Idle speculation: I wonder how hard it would be to add SXML as an output format to pandoc...
-A comment system would be nice. So would separating out site-specific
-variables into a config file, perhaps `/etc/nawp-site.scm`.
+A comment system would be nice.
diff --git a/nawp-site.scm b/nawp-site.scm
new file mode 100644
index 0000000..08b38b0
--- /dev/null
+++ b/nawp-site.scm
@@ -0,0 +1,5 @@
+;;; Site-customization file for nawp. Copy to /etc/nawp-site.scm and
+;;; customize to taste.
+(define blog-base-uri "https://the-brannons.com/blog/")
+(define blog-title "Brannon's Banal Babblings")
+(define blog-description "Insert clever description.")
diff --git a/nawp.scm b/nawp.scm
index c425ab7..4041d97 100755
--- a/nawp.scm
+++ b/nawp.scm
@@ -20,6 +20,7 @@
(import
anaphora
atom
+ (chicken file)
(chicken format)
(chicken io)
(chicken pathname)
@@ -38,11 +39,19 @@
uri-common)
(define-anaphor avalues values #:cascade)
+(define site-file "/etc/nawp-site.scm")
+
+;;; Customizable variables. Override in /etc/nawp-site.scm.
+(define blog-base-uri (uri-reference "https://example.net/blog/"))
+(define blog-title "Yet Another NAWP Blog")
+(define blog-description "Default description.")
+
+(when (file-exists? site-file)
+ (load site-file)
+ (unless (uri? blog-base-uri)
+ (set! blog-base-uri (uri-reference blog-base-uri))))
-(define blog-title "Brannon's Banal Babblings")
-(define blog-description "Insert clever description.")
(define atom-page-name "feed.atom")
-(define blog-base-uri (uri-reference "https://the-brannons.com/blog/"))
(define posts-base-uri (uri-relative-to (uri-reference "posts/") blog-base-uri))
(define feed-uri (uri-relative-to (uri-reference atom-page-name) blog-base-uri))
(define db-file "/var/lib/nawp/blog.db")
@@ -197,7 +206,7 @@
(apply make-post
(map
(lambda (field) (aand (assoc field row) (cdr it)))
- '(id timestamp slug title author body))))
+ '(ID timestamp slug title author body))))
(define (fetch-latest-posts #!key before)
;; What I really want here is a composable sexp representation of SQL.