]> git.eshelyaron.com Git - esy-publish.git/commitdiff
New website design
authorEshel Yaron <me@eshelyaron.com>
Sun, 2 Apr 2023 05:55:50 +0000 (08:55 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sun, 2 Apr 2023 05:55:50 +0000 (08:55 +0300)
.gitignore
Makefile
assets/style.css
org/posts/2023-03-27-foo.org [deleted file]
org/posts/2023-03-31-bar.org [deleted file]
org/posts/2023-04-01-a-post-about-nothing.org [deleted file]
org/posts/index.org
org/sitemap.org [deleted file]
org/theindex.inc [deleted file]
org/theindex.org [deleted file]
publish.el

index e8587e3edaff6fec19003bbe6b143cb538f8dfc6..4bc6c346433b582343ddfba68ae451032d03d4b2 100644 (file)
@@ -4,3 +4,7 @@
 /org/index.tex
 /out/
 *~
+/html.bk/
+/org/sitemap.org
+/org/theindex.inc
+/org/theindex.org
index f7dd4c0a6456d154946d6ef65273d27fee603eae..85455b78059c56e6c188055d43030a09a09815ff 100644 (file)
--- 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)'
index 253ee296337c61ce492123b3461dfdc3ce1b0ca1..ab2cabd2d45059dde4a5b451fc98d19eb6862a5c 100644 (file)
@@ -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 (file)
index 1c0bc06..0000000
+++ /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 (file)
index 14f6e64..0000000
+++ /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 (file)
index 2005d4c..0000000
+++ /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.
index 1002c95ca4baf17cfcfda8dce7a665aadf082e74..96779681ef5dc9d399abfb377f7352fbb551d67d 100644 (file)
@@ -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 (file)
index fd69e04..0000000
+++ /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 (file)
index 6453c73..0000000
+++ /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 (file)
index 9ac19f8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#+TITLE: Index
-
-#+INCLUDE: "theindex.inc"
-
index 51172c5021fd4d2c20c66d561bbe859b30b625e6..63d6267aadec2f2ffbdeba646081d950f098c683 100644 (file)
  '((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)))))
              (pubDate nil ,(substring file 0 10))
              (description nil ,(format "<![CDATA[%s]]>" (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 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\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 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n")
       (dom-print `(rss ((version . "2.0"))
                                 (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))
 
     (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
                       :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
                                              (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")