From: Frederik Vanrenterghem Date: Thu, 28 Dec 2023 13:55:49 +0000 (+0800) Subject: Merge branch 'min-demand' X-Git-Url: http://git.vanrenterghem.biz/www2.vanrenterghem.biz.git/commitdiff_plain/9ca4c5d427319065ff4e884ddb4505343d5a779f?hp=66edb467d6b9fa9d52dc39ba4a375052703895fe Merge branch 'min-demand' --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5a94119 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +# Makefile for www.vanrenterghem.biz + +.PHONY: all publish rebuild + +all: publish rsync + +publish: maak-website.el + @echo "Publishing... only changed files." + emacs --batch --load maak-website.el --funcall org-publish-all + +rebuild: maak-website.el + @echo "Publishing... total rebuild." + emacs --batch --load maak-website.el --eval='(org-publish "website" t)' + +rsync: + @echo "rsync published site to niihau." + rsync --human-readable --archive --verbose target/ --rsh="ssh" frederik@niihau.vanrenterghem.biz:/srv/www2.vanrenterghem.biz/ diff --git a/html/head.mustache b/html/head.mustache index f0c0eac..482ae88 100644 --- a/html/head.mustache +++ b/html/head.mustache @@ -2,5 +2,6 @@ + {{title}} diff --git a/html/post-index.mustache b/html/post-index.mustache index 5622b6d..e581eff 100644 --- a/html/post-index.mustache +++ b/html/post-index.mustache @@ -6,10 +6,23 @@ {{>navbar}} -
- - {{{contents}}} -
+
+
+
+ +
+
+
+ {{{contents}}} +
+
+
+
{{>footer}} diff --git a/html/post.mustache b/html/post.mustache index a5605de..c8f4522 100644 --- a/html/post.mustache +++ b/html/post.mustache @@ -6,29 +6,34 @@ {{>navbar}} - -
-
-

    Tags:

    + +
    +
    + + {{{contents}}} +
    +
    +
    +
    -
    -

    Posted on {{{date}}}

    +
    -
    -

    {{title}}

    - {{{contents}}} -
    -
    +
    +

    Posted on {{{date}}}

    +
    +
+
{{>footer}} diff --git a/maak-website.el b/maak-website.el index f9a7d05..d878c67 100644 --- a/maak-website.el +++ b/maak-website.el @@ -1,6 +1,12 @@ (require 'cl-lib) (require 'org) (require 'ox-publish) +(add-to-list 'load-path "~/.emacs.d/elpa/ox-rss-20230408.231") +(add-to-list 'load-path "~/.emacs.d/elpa/mustache-20230713.514") +(add-to-list 'load-path "~/.emacs.d/elpa/s-20220902.1511") +(add-to-list 'load-path "~/.emacs.d/elpa/dash-20230714.723") +(add-to-list 'load-path "~/.emacs.d/elpa/f-20230823.1159") +(add-to-list 'load-path "~/.emacs.d/elpa/htmlize-20210825.2150") (require 'ox-rss) (load "~/.emacs.d/lisp/mustache-html.el") @@ -9,6 +15,7 @@ (setq org-html-htmlize-output-type 'css) ; default: 'inline-css (setq org-time-stamp-custom-formats '("%A %e %B %Y" . "%A %e %B %Y at %H:%M")) (setq org-display-custom-times t) +(setq org-html-container-element "div") ;; TODO - check (setq my-blog-base-folder "~/websites/stage.vanrenterghem.biz") (setq my-blog-source-folder "~/websites/stage.vanrenterghem.biz/source") (setq my-blog-target-folder "~/websites/stage.vanrenterghem.biz/target") @@ -47,14 +54,19 @@ (defun my-blog-create-tags-files (plist) "Create org files for each tag defined in FILETAGS in posts, storing them in my-blog-tags-folder." - (unless (file-directory-p my-blog-tags-folder) (make-directory my-blog-tags-folder)) - (with-temp-file (file-name-concat my-blog-source-folder "tag-index.org") + (let* ((tagfolder (file-name-concat + (plist-get (cdr (assoc "landing" org-publish-project-alist)) :base-directory))) + (postfolder (file-name-concat + (plist-get (cdr (assoc "posts" org-publish-project-alist)) :base-directory))) + (relpostfolder (file-relative-name postfolder tagfolder))) + (unless (file-directory-p my-blog-tags-folder) (make-directory my-blog-tags-folder)) + (with-temp-file (file-name-concat tagfolder "tag-index.org") (insert (concat "#+mustache-template: " (file-name-concat my-blog-mustache-folder "tags-index.mustache") "\n")) (insert (concat "#+TITLE: Blog - All tags\n")) (insert "#+OPTIONS: ^:nil\n") ; do not use underscores as subscript (insert "\n") (dolist (tag (sort (my-org-get-all-filetags) (lambda (x y) (string-lessp (car x) (car y))) )) - (insert (concat "- [[file:" (file-name-concat my-blog-posts-folder (concat "tag-" (car tag) ".org")) "][" (car tag) "]]\n")))) + (insert (concat "- [[file:" (file-name-concat relpostfolder (concat "tag-" (car tag) ".org")) "][" (car tag) "]]\n"))))) (dolist (tag (my-org-get-all-filetags)) (with-temp-file (file-name-concat my-blog-tags-folder (concat "tag-" (car tag) ".org")) (insert (concat "#+mustache-template: " (file-name-concat my-blog-mustache-folder "tags.mustache") "\n")) @@ -132,29 +144,38 @@ Either the section between #+BEGIN_PREVIEW and +#END_PREVIEW is used, or the fir (let* ((abspath (file-name-concat "/home/frederik/websites/stage.vanrenterghem.biz/source/posts" file)) (relpath (file-relative-name abspath "/home/frederik/websites/stage.vanrenterghem.biz/source/posts/")) (title (org-publish-find-title file project-plist)) - (date (format-time-string (cdr org-time-stamp-formats) (org-publish-find-date file project-plist))) + (date (format-time-string (cdr org-time-stamp-custom-formats) (org-publish-find-date file project-plist))) (preview (my-blog-get-preview abspath)) ) ;; insert a horizontal line before every post, kill the first one ;; before saving - (insert "-----\n") (insert (concat "* [[file:" relpath "][" title "]]\n")) ;; add properties for `ox-rss.el' here (let ((rss-permalink (concat (file-name-sans-extension relpath) ".html")) - (rss-pubdate date)) + (rss-pubdate (format-time-string (cdr org-time-stamp-formats) (org-publish-find-date file project-plist)))) (org-mode) + (org-set-property "HTML_CONTAINER_CLASS" "card mb-2") ;Bootstrap margin border 2 + (org-set-property "HTML_HEADLINE_CLASS" "card-header card-title border-bottom-0 fs-5 fw-bold text-decoration-none") (org-set-property "RSS_PERMALINK" rss-permalink) (org-set-property "PUBDATE" rss-pubdate) (org-set-property "RSS_TITLE" title)) ;; insert the date, preview, & read more link + (insert "#+ATTR_HTML: :class card-header\n") (insert (concat "Published: " date "\n\n")) + (insert "#+BEGIN_export html\n") + (insert "
\n") + (insert "#+END_export\n") (insert preview) ;(insert (concat "#+INCLUDE: \"" relpath "\" :only-contents t :lines \"1-10\"\n")) - (insert "\n") - (insert (concat "[[file:" relpath "][Read More...]]\n")))) + (insert "\n") + (insert (concat "[[file:" relpath "][Read More...]]\n")) + (insert "#+BEGIN_export html\n") + (insert "
\n") + (insert "#+END_export\n") + )) ;; kill the first hrule to make this look OK - (goto-char (point-min)) - (let ((kill-whole-line t)) (kill-line)) + ;(goto-char (point-min)) + ;(let ((kill-whole-line t)) (kill-line)) ;; insert a title and save (insert "#+OPTIONS: title:nil\n") (insert "#+TITLE: Frederik Vanrenterghem's blog\n") @@ -185,9 +206,18 @@ representation for the files to include, as returned by (defun my-blog-cleanup-sitemaps (plist) "Clean up temporary files created in the process of publishing" + ;; Create a body-only version of the tags index. Needs absolute path to posts folder. + (with-temp-file (file-name-concat + (plist-get (cdr (assoc "landing" org-publish-project-alist)) :publishing-directory) + "tag-index-body.html") + (insert-file-contents (file-name-concat + (plist-get (cdr (assoc "landing" org-publish-project-alist)) :base-directory) + "tag-index.org")) + (org-export-to-buffer 'mustache-html (current-buffer) nil nil nil t nil) + (replace-string "href=\"posts" "href=\"/posts")) (delete-file (file-name-concat my-blog-source-folder "sitemap.org")) (delete-file (file-name-concat my-blog-posts-folder "sitemap.org")) - ) + (delete-file (file-name-concat my-blog-posts-folder "sitemap.org~"))) (setq org-publish-project-alist `(("landing" diff --git a/source/assets/styles/org-htmlize.css b/source/assets/styles/org-htmlize.css index e52ecac..2884c65 100644 --- a/source/assets/styles/org-htmlize.css +++ b/source/assets/styles/org-htmlize.css @@ -10,7 +10,7 @@ blockquote { } pre {} -pre {background-color:lightgoldenrodyellow;color:#1f058E;} +pre {background-color:#000000;color:#FFFFFF;} pre span.org-builtin {color:#006FE0;font-weight:bold;} pre span.org-string {color:#008000;} pre span.org-doc {color:#008000;} diff --git a/source/index.org b/source/index.org index 664f8bc..b3d3570 100644 --- a/source/index.org +++ b/source/index.org @@ -39,7 +39,7 @@ was born and raised in Belgium, but except for a year back in 2013 where he live * G'day mate! -Welcome on my little corner of the world wide web! +Welcome to my little corner of the world wide web! I'm Frederik Vanrenterghem, living in Western Australia with my family since 2014. The fact I even maintain a website anymore probably gives away my age - yes, I was born before the 80's! diff --git a/source/posts/Fibonacci_golden_spiral.org b/source/posts/Fibonacci_golden_spiral.org index 90abf9a..14ba5b0 100644 --- a/source/posts/Fibonacci_golden_spiral.org +++ b/source/posts/Fibonacci_golden_spiral.org @@ -10,10 +10,8 @@ #+OPTIONS: toc:nil #+date: <2019-09-16 22:03:03> -* What After having read the first part of a Rcpp tutorial which compared native R vs C++ implementations of a Fibonacci sequence generator, I resorted to drawing the so-called Golden Spiral using R. -* Details Libraries used in this example are the following #+BEGIN_SRC R :session R @@ -338,7 +336,6 @@ df <- data.frame(t(serie)) #+RESULTS: : TRUE -* Result With everything now ready in the right coordinate system, it's now only a matter of setting some options to make the output look acceptable. #+BEGIN_SRC R :session R :results output file graphics :file ../assets/golden_spiral-ggplot-coord-fixed.png :width 800 :height 800 :exports both ggplot(df, aes(x=X1,y=X2)) + @@ -356,5 +353,4 @@ ggplot(df, aes(x=X1,y=X2)) + y = "") #+END_SRC -* Note on how this post was written. -After a long hiatus, I set about using emacs, org-mode and ESS together to create this post. All code is part of an .org file, and gets exported to markdown using the orgmode conversion - C-c C-e m m. +Note on how this post was written: After a long hiatus, I set about using emacs, org-mode and ESS together to create this post. All code is part of an .org file, and gets exported to markdown using the orgmode conversion - C-c C-e m m. diff --git a/source/posts/explore-AU-road-fatalities.org b/source/posts/explore-AU-road-fatalities.org index ce66e5a..6c60f33 100644 --- a/source/posts/explore-AU-road-fatalities.org +++ b/source/posts/explore-AU-road-fatalities.org @@ -2,10 +2,6 @@ #+filetags: :R:analysis: #+title: Explore Australian road fatalities. -** Road fatalities in Australia -:PROPERTIES: -:CUSTOM_ID: road-fatalities-in-australia -:END: Recently inspired to doing a little analysis again, I landed on a dataset from [[https://bitre.gov.au/statistics/safety/fatal_road_crash_database.aspx]], @@ -15,6 +11,7 @@ great example of how governments are moving with the times! ** Trends :PROPERTIES: :CUSTOM_ID: trends +:HTML_CONTAINER_CLASS: card-body :END: I started by looking at the trends - what is the approximate number of road fatalities a year, and how is it evolving over time? Are there any @@ -33,6 +30,7 @@ differences noticeable between states? Or by gender? ** What age group is most at risk in city traffic? :PROPERTIES: :CUSTOM_ID: what-age-group-is-most-at-risk-in-city-traffic +:HTML_CONTAINER_CLASS: card-body :END: Next, I wondered if there were any particular ages that were more at risk in city traffic. I opted to quickly bin the data to produce a @@ -57,6 +55,7 @@ fatalities %>% ** Hypothesis :PROPERTIES: :CUSTOM_ID: hypothesis +:HTML_CONTAINER_CLASS: card-body :END: Based on the above, I wondered - are people above 65 more likely to die in slow traffic areas? To make this a bit easier, I added two variables @@ -130,6 +129,7 @@ prop.test(pensioners,everyone) ** Conclusion :PROPERTIES: :CUSTOM_ID: conclusion +:HTML_CONTAINER_CLASS: card-body :END: It's possible to conclude older people are over-represented in the fatalities in lower speed zones. Further ideas for investigation are