From: Eshel Yaron Date: Sun, 2 Apr 2023 05:55:50 +0000 (+0300) Subject: New website design X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f1e7e690f55ad370906ea965a80598d548048bda;p=esy-publish.git New website design --- diff --git a/.gitignore b/.gitignore index e8587e3..4bc6c34 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ /org/index.tex /out/ *~ +/html.bk/ +/org/sitemap.org +/org/theindex.inc +/org/theindex.org diff --git a/Makefile b/Makefile index f7dd4c0..85455b7 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,10 @@ -.PHONY: update local remote new +.PHONY: local remote sweep -new: sweep +remote: local + emacs -Q --batch -l publish.el -f esy/publish-to-remote + +local: sweep emacs -Q --batch -l publish.el -f esy/publish sweep: git submodule update --remote -- sweep - -update: - git submodule update --remote -- dotfiles - git submodule update --remote -- sweep - -local: - emacs -Q --batch -l publish.el --eval '(org-publish "eshelyaron.local" t)' - -remote: update - emacs -Q --batch -l publish.el --eval '(org-publish "eshelyaron.com" t)' diff --git a/assets/style.css b/assets/style.css index 253ee29..ab2cabd 100644 --- a/assets/style.css +++ b/assets/style.css @@ -224,3 +224,7 @@ Generated with `M-x org-html-htmlize-generate-css` after loading the .timestamp { color: #5dc0aa; } + +.subtitle { + font-style: italic; +} diff --git a/org/posts/2023-03-27-foo.org b/org/posts/2023-03-27-foo.org deleted file mode 100644 index 1c0bc06..0000000 --- a/org/posts/2023-03-27-foo.org +++ /dev/null @@ -1,10 +0,0 @@ -#+TITLE: Foo -#+SUBTITLE: Bar -#+DESCRIPTION: Baz -#+KEYWORDS: spam -#+DATE: 2023-03-28 - -* An exercise in recursion courtesy of Jeremy Friesen -#+INDEX: CV - -Foo bar baz. diff --git a/org/posts/2023-03-31-bar.org b/org/posts/2023-03-31-bar.org deleted file mode 100644 index 14f6e64..0000000 --- a/org/posts/2023-03-31-bar.org +++ /dev/null @@ -1,9 +0,0 @@ -#+TITLE: Bar -#+SUBTITLE: Foo -#+DESCRIPTION: Baz -#+KEYWORDS: spam -#+DATE: 2023-03-31 - -* An exercise in recursion courtesy of Jeremy Friesen - -Foo bar baz. diff --git a/org/posts/2023-04-01-a-post-about-nothing.org b/org/posts/2023-04-01-a-post-about-nothing.org deleted file mode 100644 index 2005d4c..0000000 --- a/org/posts/2023-04-01-a-post-about-nothing.org +++ /dev/null @@ -1,14 +0,0 @@ -#+TITLE: A post about nothing -#+SUBTITLE: John von Neumann once said... -#+DESCRIPTION: A post about nothing at all -#+KEYWORDS: personal -#+DATE: 2023-04-01 - -* What's this post all about? - -#+begin_quote -There is no point in being precise if you do not even know what you -are talking about. -#+end_quote - -I don't know. diff --git a/org/posts/index.org b/org/posts/index.org index 1002c95..9677968 100644 --- a/org/posts/index.org +++ b/org/posts/index.org @@ -1,4 +1,4 @@ -#+TITLE: Posts +#+TITLE: All Posts #+DESCRIPTION: Eshel Yaron's blog posts #+KEYWORDS: eshel language emacs programming prolog diff --git a/org/sitemap.org b/org/sitemap.org deleted file mode 100644 index fd69e04..0000000 --- a/org/sitemap.org +++ /dev/null @@ -1,12 +0,0 @@ -#+TITLE: Sitemap for project org - -- [[file:index.org][Eshel Yaron]] -- [[file:theindex.org][Index]] -- [[file:pub.org][Public PGP Key]] -- [[file:sweep.org][Sweep: SWI-Prolog Embedded in Emacs]] -- posts - - [[file:posts/2023-04-01-a-post-about-nothing.org][A post about nothing]] - - [[file:posts/2023-03-31-bar.org][Bar]] - - [[file:posts/2023-03-27-foo.org][Foo]] - - [[file:posts/index.org][Posts]] - - [[file:posts/2023-04-01-take-on-recursion.org][Take on Recursion]] \ No newline at end of file diff --git a/org/theindex.inc b/org/theindex.inc deleted file mode 100644 index 6453c73..0000000 --- a/org/theindex.inc +++ /dev/null @@ -1,2 +0,0 @@ -* C - - [[file:posts/2023-03-27-foo.org::*An exercise in recursion courtesy of Jeremy Friesen][CV]] diff --git a/org/theindex.org b/org/theindex.org deleted file mode 100644 index 9ac19f8..0000000 --- a/org/theindex.org +++ /dev/null @@ -1,4 +0,0 @@ -#+TITLE: Index - -#+INCLUDE: "theindex.inc" - diff --git a/publish.el b/publish.el index 51172c5..63d6267 100644 --- a/publish.el +++ b/publish.el @@ -23,15 +23,49 @@ '((emacs-lisp . t) (shell . t))) -(setq org-confirm-babel-evaluate nil) +(setq org-confirm-babel-evaluate nil + make-backup-files nil) (defun esy/dom-to-string (&rest doms) (with-temp-buffer (mapc #'dom-print doms) (buffer-string))) +(defvar esy/publish-remote-directory + "/ssh:root@direct.eshelyaron.com:/var/www/html") + +(defvar esy/publish-root-directory + (file-name-directory load-file-name)) + +(defvar esy/publish-org-directory + (file-name-as-directory (expand-file-name + "org" + esy/publish-root-directory))) + +(defvar esy/publish-org-posts-directory + (file-name-as-directory (expand-file-name + "posts" + esy/publish-org-directory))) + +(defvar esy/publish-out-directory + (file-name-as-directory (expand-file-name + "html" + esy/publish-root-directory))) + +(defvar esy/publish-out-posts-directory + (file-name-as-directory (expand-file-name + "posts" + esy/publish-out-directory))) + +(defvar esy/publish-assets-directory + (file-name-as-directory (expand-file-name + "assets" + esy/publish-root-directory))) + (defun esy/publish-post-to-dom (file) - (with-current-buffer (find-file-noselect (expand-file-name file "/Users/eshelyaron/checkouts/eshelyaron.com/out/posts")) + (with-current-buffer (find-file-noselect + (expand-file-name + file esy/publish-out-posts-directory)) (let ((dom (libxml-parse-html-region (point-min) (point-max)))) `(item nil (title nil ,(string-join (dom-strings (car (dom-by-tag dom 'title))))) @@ -42,8 +76,25 @@ (pubDate nil ,(substring file 0 10)) (description nil ,(format "" (esy/dom-to-string (car (dom-by-id dom "content"))))))))) -(defun esy/publish-posts (&rest _) - (let ((posts (reverse (directory-files "/Users/eshelyaron/checkouts/eshelyaron.com/out/posts" nil (rx bos digit (+ any) ".html" eos))))) +(defun esy/publish-sitemap (plist) + (let ((locs (mapcar (lambda (file) + (concat "https://eshelyaron.com/" + (file-relative-name file esy/publish-out-directory))) + (directory-files-recursively esy/publish-out-directory + (rx ".html" eos))))) + (with-temp-buffer + (insert "\n") + (dom-print `(urlset ((xlmns . "http://www.sitemaps.org/schemas/sitemap/0.9")) + ,@(mapcar (lambda (loc) + `(url nil (loc nil ,loc))) + locs)) + t t) + (write-file (expand-file-name "sitemap.xml" (plist-get plist :publishing-directory)))))) + +(defun esy/publish-posts (plist) + (let ((posts (reverse (directory-files esy/publish-out-posts-directory + nil + (rx bos digit (+ any) ".html" eos))))) (with-temp-buffer (insert "\n") (dom-print `(rss ((version . "2.0")) @@ -55,13 +106,13 @@ (pubDate nil ,(format-time-string "%F")) ,@(mapcar #'esy/publish-post-to-dom posts))) t t) - (write-file "/Users/eshelyaron/checkouts/eshelyaron.com/out/rss.xml")))) + (write-file (expand-file-name "rss.xml" (plist-get plist :publishing-directory)))))) (defun esy/org-dblock-insert-posts (limit) (interactive (list (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) (org-create-dblock (list :name "posts" - :dir "/Users/eshelyaron/checkouts/eshelyaron.com/org/posts" + :dir esy/publish-org-posts-directory :limit limit)) (org-update-dblock)) @@ -81,30 +132,49 @@ (delete-blank-lines))) (defun esy/publish-posts-prepare-index (&rest _) - (dolist (file '("/Users/eshelyaron/checkouts/eshelyaron.com/org/posts/index.org" - "/Users/eshelyaron/checkouts/eshelyaron.com/org/index.org")) - (with-current-buffer (find-file-noselect file) + (dolist (dir (list esy/publish-org-posts-directory esy/publish-org-directory)) + (with-current-buffer (find-file-noselect (expand-file-name "index.org" dir)) (org-update-all-dblocks)))) +(defun esy/publish-completion-function (plist) + (esy/publish-posts plist) + (esy/publish-sitemap plist)) + +(defun esy/publish-to-remote () + (delete-directory esy/publish-remote-directory t) + (copy-directory esy/publish-out-directory esy/publish-remote-directory nil t t) + ;; (let ((files (directory-files-recursively esy/publish-out-directory + ;; (rx (or ".html" + ;; ".ico" + ;; ".svg" + ;; ".xml" + ;; ".css") + ;; eos)))) + ;; (dolist-with-progress-reporter (file files) "Copying files" + ;; (copy-file file + ;; (expand-file-name (file-relative-name file + ;; esy/publish-out-directory) + ;; esy/publish-remote-directory) + ;; t))) + ) + (defun esy/publish (&optional modified-only) (interactive "P") - (let* ((publishing-directory "/Users/eshelyaron/checkouts/eshelyaron.com/out") + (let* ((publishing-directory esy/publish-out-directory) (org-export-with-sub-superscripts '{}) (org-export-with-section-numbers nil) (org-export-with-toc nil) (org-html-htmlize-output-type 'css) (org-publish-project-alist - (list '("all" :components ("org" "assets")) + (list '("all" :components ("assets" "org")) (list "assets" - :base-directory "/Users/eshelyaron/checkouts/eshelyaron.com/assets" + :base-directory esy/publish-assets-directory :publishing-directory publishing-directory - :preparation-function #'ignore - :completion-function #'ignore :base-extension "svg\\|ico\\|css" :publishing-function #'org-publish-attachment) (list "org" - :completion-function #'esy/publish-posts - :base-directory "/Users/eshelyaron/checkouts/eshelyaron.com/org" + :completion-function #'esy/publish-completion-function + :base-directory esy/publish-org-directory :publishing-directory publishing-directory :preparation-function #'esy/publish-posts-prepare-index :completion-function #'ignore @@ -116,6 +186,7 @@ :html-doctype "html5" :html-html5-fancy t :auto-sitemap t + :sitemap-title "Sitemap for eshelyaron.com" :makeindex t :with-date t :html-head-include-default-style nil @@ -149,7 +220,8 @@ (width . "30") (alt . "Mail")))) " " - (a ((href . "https://emacs.ch/@eshel")) + (a ((href . "https://emacs.ch/@eshel") + (rel . "me")) (img ((src . "/mastodon.svg") (height . "28") (width . "28")