aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Laprade <jesselaprade@gmail.com>2021-04-18 16:09:09 -0400
committerJesse Laprade <jesselaprade@gmail.com>2021-04-18 16:09:09 -0400
commit41721ab0f3f56027d1481330d1adf0815b44e363 (patch)
tree07d991da2b5f609206215957915a764a0aaea063
parent6ee316fa234e76507db6cb696367c2fe72bd8bf7 (diff)
downloadsprout-41721ab0f3f56027d1481330d1adf0815b44e363.tar.gz
sprout-41721ab0f3f56027d1481330d1adf0815b44e363.tar.bz2
sprout-41721ab0f3f56027d1481330d1adf0815b44e363.zip
Removed repetitive code!
Turns out variable/constant definitions evaluate, so having a (file->yaml ...) as a variable value broke things, so what I did was put it in a function, and it worked, because I /think/ the evaluation of function definitions are delayed until they are called??? who knows! this knowledge helped clean a lot of stuff up at least!
-rw-r--r--sprout.rkt16
1 files changed, 8 insertions, 8 deletions
diff --git a/sprout.rkt b/sprout.rkt
index 2caa2ea..3cb145f 100644
--- a/sprout.rkt
+++ b/sprout.rkt
@@ -120,6 +120,9 @@ string-block
env-visual
(get-editor-fallback))))
+(define (yaml-ref key)
+ (hash-ref (file->yaml yaml-file-location) key))
+
(define (string-cleanup str)
((compose
(lambda (x) (string-replace x #px"\t+" " "))
@@ -192,8 +195,7 @@ string-block
(define (publish)
(let* ([posts (directory-list dir-posts)]
- [config (file->yaml yaml-file-location)]
- [remote-location (string-append (hash-ref config "output-path") rss-file)])
+ [remote-location (string-append (yaml-ref "output-path") rss-file)])
(if (> (length posts) 0)
(begin (clear-screen)
(system-format "rsync -av --delete ~a ~a" rss-file-build remote-location)
@@ -208,13 +210,11 @@ string-block
(let* ([posts-as-strings (map path->string posts)]
[posts-full-paths (map (lambda (x) (string-append dir-posts x))
posts-as-strings)]
- [config (file->yaml yaml-file-location)]
- [config-ref (lambda (arg) (hash-ref config arg))]
[header (format rss-header
- (config-ref "title")
- (config-ref "url-base")
- (config-ref "description")
- (string-append (config-ref "url-base") rss-file))])
+ (yaml-ref "title")
+ (yaml-ref "url-base")
+ (yaml-ref "description")
+ (string-append (yaml-ref "url-base") rss-file))])
;; write header to file
(display-to-file header rss-file-build #:exists 'truncate)
;; write items to file