'((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")