summary refs log tree commit diff
path: root/config.org
diff options
context:
space:
mode:
Diffstat (limited to 'config.org')
-rw-r--r--config.org222
1 files changed, 80 insertions, 142 deletions
diff --git a/config.org b/config.org
index 7c1ed14..b02f4b6 100644
--- a/config.org
+++ b/config.org
@@ -684,148 +684,6 @@ This doesn't respect my timestamp custom format configured above.
   (setopt valign-max-table-size 0)
 #+end_src
 
-** Website generation
-
-#+begin_src elisp
-(defun read-file-as-string (filename)
-  "Read file contents from FILENAME."
-  (with-temp-buffer
-    (insert-file-contents filename)
-    (buffer-string)))
-#+end_src
-
-#+begin_src elisp
-(setq noa/website-header (read-file-as-string "/home/noa/projects/org-website/templates/header.html"))
-(setq noa/website-footer (read-file-as-string "/home/noa/projects/org-website/templates/footer.html"))
-#+end_src
-
-The index page generation functions were taken from Dennis Ogbe.  Thank you!
-
-#+begin_src elisp
-(defun my-blog-parse-sitemap-list (l)
-  "Convert the sitemap list in to a list of filenames."
-  ;; LIST looks like:
-  ;; (unordered ("[[file:uses.org][Things i use]]") ("[[file:media.org][Media Diary]]") ("[[file:tanklobsters.org][Tank lobsters]]"))
-  (mapcar #'(lambda (i)
-              (let ((link (with-temp-buffer
-                            (let ((org-inhibit-startup nil))
-                              (insert (car i))
-                              (org-mode)
-                              (goto-char (point-min))
-                              (org-element-link-parser)))))
-                (when link
-                  (plist-get (cadr link) :path))))
-          (cdr l)))
-#+end_src
-
-#+begin_src elisp
-  (defun my-blog-sort-article-list (l p)
-    "sort the article list anti-chronologically."
-    (sort l #'(lambda (a b)
-                (let ((date-a (org-publish-find-date a p))
-                      (date-b (org-publish-find-date b p)))
-                  (not (time-less-p date-a date-b))))))
-#+end_src
-
-#+begin_src elisp
-(defun noa/naive-org-first-paragraph (file)
-  "Naively returns the first paragraph of FILE.
-
-	The way that the first paragraph is determined is to assume that there will be an org metadata block beforehand, so look for the first two consecutive newlines and mark the following paragraph."
-  (with-temp-buffer
-    (insert-file-contents file)
-    (goto-char (point-min))
-    (re-search-forward "\n\n")
-    (mark-paragraph)
-    (let ((beg (mark))
-          (end (point)))
-      (buffer-substring beg end))))
-#+end_src
-
-#+begin_src elisp
-  (defun noa/website-sitemap (title list)
-    "Generate the index page for my website."
-    ;; LIST looks like:
-    ;; (unordered ("[[file:uses.org][Things i use]]") ("[[file:media.org][Media Diary]]") ("[[file:tanklobsters.org][Tank lobsters]]"))
-    (with-temp-buffer
-      ;; mangle the parsed list given to us into a plain lisp list of files
-      (let* ((filenames (my-blog-parse-sitemap-list list))
-	     (project-plist (assoc "website-pages" org-publish-project-alist))
-	     (articles (my-blog-sort-article-list filenames project-plist)))
-	(message (concat "PLIST: " (plist-get project-plist :base-directory)))
-      
-	(insert "Several parts of this website are broken as i wrangle with the monstrosity that is programming in emacs lisp.  The content should still be fine, but for further cosmetics please hold <3\n\n")
-	(dolist (file filenames)
-	  (let* ((abspath (file-name-concat "/home/noa/data/share" file))
-		 ;; (abspath (file-name-concat (plist-get project-plist :base-directory) file))
-		 (relpath (file-relative-name abspath "/home/noa/data/share"))
-		 (title (org-publish-find-title file project-plist))
-		 (date (format-time-string (car org-time-stamp-custom-formats) (org-publish-find-date file project-plist)))
-		 (preview (noa/naive-org-first-paragraph abspath)))
-	    (insert (concat "* [[file:" relpath "][" title "]]\n"))
-	    (insert (concat
-		     "*" date ":*"
-		     preview))
-	    (insert "\n")))
-	;; insert a title and save
-	(insert "#+TITLE: noa.pub\n")
-	(buffer-string))))
-      #+end_src
-
-#+begin_src elisp
-  (defun noa/org-publish-sitemap-entry (entry style project)
-    "Default format for site map ENTRY, as a string.
-  ENTRY is a file name.  STYLE is the style of the sitemap.
-  PROJECT is the current project."
-    (cond ((not (directory-name-p entry))
-	   (format "%s: [[file:%s][%s]]"
-		   (format-time-string (car org-time-stamp-custom-formats) (org-publish-find-date entry project))
-		   entry
-		   (org-publish-find-title entry project)))
-	  ((eq style 'tree)
-	   ;; Return only last subdir.
-	   (file-name-nondirectory (directory-file-name entry)))
-	  (t entry)))
-
-  (setq org-publish-project-alist
-	`(("website"
-	   :components ("website-pages" "website-assets"))
-	  ("website-pages"
-	   :publishing-function org-html-publish-to-html
-	   :base-directory "/home/noa/data/share"
-	   :publishing-directory "/home/noa/projects/org-website"
-	   :base-extension "org"
-	   :with-drawers t
-	   :html-link-home "/"
-	   :html-head-include-default-style nil
-	   :html-head-include-scripts nil
-	   :html-doctype "html5"
-	   ;; :html-validation-link nil
-	   :html-preamble ""
-	   :html-postamble ,noa/website-footer
-	   :html-home/up-format ""
-	   :html-link-up ""
-	   :html-html5-fancy t
-	   :html-indent nil
-	   :html-head "<link rel=\"icon\" href=\"data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>𰻝</text></svg>\">\n<link rel=\"stylesheet\" type=\"text/css\" href=\"love.css\" />
-  <meta name=\"color-scheme\" content=\"light dark\">"
-	   :auto-sitemap t
-	   :sitemap-filename "/home/noa/projects/org-website/index.org"
-	   :sitemap-title "noa.pub"
-	   :sitemap-style list
-	   :sitemap-format-entry noa/org-publish-sitemap-entry
-	   ;; :sitemap-function noa/website-sitemap
-	   :sitemap-sort-folders ignore
-	   :sitemap-sort-files anti-chronologically
-	   :sitemap-ignore-case t)
-	  ("website-assets"
-	   :publishing-function org-publish-attachment
-	   :base-directory "/home/noa/data/share"
-	   :publishing-directory "/home/noa/projects/org-website"
-	   :base-extension "css\\|js\\|png|\\jpg"
-	   :recursive t)))
-#+end_src
-
 ** Markdown
 
 #+begin_src elisp
@@ -882,6 +740,86 @@ Almost everywhere else, the ~highlight~ face is used for interactive text on mou
 
 I mentioned that i thought this wasn't the best default behaviour [[https://github.com/minad/jinx/discussions/184][in the jinx repository]], but Daniel seems happy with it.  I appreciate that he's made it so easy to change the behaviour to something i prefer.
 
+* My website
+I generate my website using org mode.  I use the built in ox-publish subsystem for convenience.  However, it isn't all that convenient, as it doesn't actually work very well at the moment.
+
+#+begin_src elisp
+(defun read-file-as-string (filename)
+  "Read file contents from FILENAME."
+  (with-temp-buffer
+    (insert-file-contents filename)
+    (buffer-string)))
+#+end_src
+
+#+begin_src elisp
+  (setq noa/website-header (read-file-as-string "/home/noa/projects/org-website/templates/header.html"))
+  (setq noa/website-footer "<strong><a href=\"/\">noa.pub</a></strong> ·
+  <a href=\"https://creativecommons.org/licenses/by-sa/4.0/\">cc by-sa</a> ·
+  <a href=\"/index.xml\">feed</a> ·
+  <a href=\"/archive.html\">archive</a>
+  <br/>
+  <a href=\"./urls.html\">urls</a> ·
+  <a href=\"./uses.html\">uses</a> ·
+  <a href=\"/now.html\">now</a> ·
+  <a href=\"/media.html\">media</a> ·
+  <!--<a href=\"/\">go travelling</a>-->
+  ")
+#+end_src
+
+#+begin_src elisp
+  (setq org-publish-project-alist
+        `(("website"
+  	 :components ("website-pages" "website-assets" "website-feed"))
+  	("website-pages"
+  	 :publishing-function org-html-publish-to-html
+  	 :base-directory "/home/noa/data/share"
+  	 :publishing-directory "/home/noa/projects/org-website"
+  	 :base-extension "org"
+  	 :with-drawers t
+  	 :html-link-home "/"
+  	 :html-head-include-default-style nil
+  	 :html-head-include-scripts nil
+  	 :html-doctype "html5"
+  	 ;; :html-validation-link nil
+  	 :html-preamble ""
+  	 :html-postamble ,noa/website-footer
+  	 :html-home/up-format ""
+  	 :html-link-up ""
+  	 :html-html5-fancy t
+  	 :html-indent nil ;; breaks <pre> tag
+  	 :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"love.css\" />
+  <meta name=\"color-scheme\" content=\"light dark\">"
+  	 :auto-sitemap t
+  	 :sitemap-filename "/home/noa/data/share/archive.org"
+  	 :sitemap-title "Archive"
+  	 :sitemap-style list
+  	 :sitemap-sort-folders ignore
+  	 :sitemap-ignore-case t
+           )
+  	("website-assets"
+  	 :publishing-function org-publish-attachment
+  	 :base-directory "/home/noa/data/share"
+  	 :publishing-directory "/home/noa/projects/org-website"
+  	 :base-extension "css\\|js\\|png|\\jpg|\\ico"
+  	 :recursive t)
+          ("website-feed"
+  	 :base-directory "/home/noa/data/share"
+  	 :base-extension "org"
+  	 :publishing-directory "~/projects/org-website/"
+  	 :publishing-function (org-rss-publish-to-rss)
+  	 :html-link-home "https://noa.pub/"
+  	 :html-link-use-abs-url t
+           :exclude ".*"
+           :include ("index.org")))
+        ))
+#+end_src
+
+We also need to install a newer version of htmlize so that we can properly convert syntax highlighted code into html.  I wish there was a way to turn this off, but i couldn't easily find it, so we're stuck with it for now.
+
+#+begin_src elisp
+  (package-ensure 'htmlize)
+#+end_src
+
 * Completing-read everywhere with consult
 Consult is a package to provide navigation commands that take advantage of completing-read.  I set up a nice completing-read environment earlier with vertico.  There are a lot of commands built in to consult, and it's possible to define more.  But i use it very simply.