]> git.eshelyaron.com Git - esy-publish.git/commitdiff
Add Makefile
authorEshel Yaron <eshel@dazz.io>
Fri, 10 Jun 2022 20:11:07 +0000 (23:11 +0300)
committerEshel Yaron <eshel@dazz.io>
Fri, 10 Jun 2022 20:11:07 +0000 (23:11 +0300)
Makefile [new file with mode: 0644]
dotfiles
publish.el

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..f30ff62
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,10 @@
+.PHONY: update local remote
+
+update:
+       git submodule update --remote -- dotfiles
+
+local:
+       emacs -Q --batch -l publish.el --eval '(org-publish "eshelyaron.local")'
+
+remote:
+       emacs -Q --batch -l publish.el --eval '(org-publish "eshelyaron.com")'
index 06881d41f87421a4a61c500e9db39aad0beb199f..b54475ab0aa68270c541fcbb17b0630e3e49bcf4 160000 (submodule)
--- a/dotfiles
+++ b/dotfiles
@@ -1 +1 @@
-Subproject commit 06881d41f87421a4a61c500e9db39aad0beb199f
+Subproject commit b54475ab0aa68270c541fcbb17b0630e3e49bcf4
index 2d21d4bb28ecf4740b2edec4c6daab0554c96812..dd35146a9cafba35363a19fc8dd835b38c00f9bb 100644 (file)
 
 ;;; Code:
 
+(require 'package)
+(setq package-selected-packages '(htmlize))
+(package-install-selected-packages)
+(package-initialize)
 (require 'ox-publish)
 (require 'ox-html)
 (require 'htmlize)
 (require 'f)
+(require 'tramp)
 
-(setq org-export-with-section-numbers nil
-      org-export-with-toc             nil)
-
-(setq org-html-html5-fancy t
-      org-html-doctype     "html5")
-
-(setq org-html-head-include-default-style nil
-      org-html-head-include-scripts       nil)
-
-(setq org-html-htmlize-output-type 'css)
-
-(setq org-publish-project-alist
-      `(("index"
-         :base-directory "~/checkouts/eshelyaron.com/org"
-         :base-extension "org"
-         :exclude ".*"
-         :include ("index.org")
-         :publishing-directory "/ssh:root@eshelyaron.com:/var/www/html"
-         :publishing-function org-html-publish-to-html
-         :html-head     "<link rel=\"stylesheet\" href=\"/style.css\" type=\"text/css\"/>"
-         :html-postamble ,(f-read-text "~/checkouts/eshelyaron.com/org/html_postamble.html"))
-        ("static"
-         :base-directory "~/checkouts/eshelyaron.com/org"
-         :base-extension "ico\\|css\\|jpg\\|gif\\|png\\|txt\\|pdf"
-         :recursive t
-         :publishing-directory "/ssh:root@eshelyaron.com:/var/www/html"
-         :publishing-function org-publish-attachment)
-        ("eshelyaron.com" :components ("index" "static"))))
+(setq tramp-cache-read-persistent-data t
+      tramp-allow-unsafe-temporary-files t)
 
+(defconst esy/source-path "~/checkouts/eshelyaron.com/dotfiles/.emacs.d/"
+  "Local path of my GNU Emacs configuration.")
+
+(defconst esy/website-source-root "~/checkouts/eshelyaron.com"
+  "Local path of my website sources.")
+
+(defconst esy/website-source-org (expand-file-name "org"
+                                                   esy/website-source-root)
+  "Local path of my website Org files.")
+
+(defconst esy/website-target-root "/ssh:root@direct.eshelyaron.com:/var/www"
+  "Remote path of my website pages.")
+
+(defconst esy/website-target-html (concat esy/website-target-root "/html")
+  "Remote path of my website pages.")
+
+(defconst esy/website-html-header
+  "<link rel=\"stylesheet\" href=\"/style.css\" type=\"text/css\"/>"
+  "HTML Header of my website pages.")
+
+(defconst esy/website-html-postamble
+  (f-read-text (expand-file-name "html_postamble.html" esy/website-source-org))
+  "HTML Postamble of my website pages.")
+
+(defun esy/publish-project-make-org-template (dir file)
+  "Return an `org-publish-project-alist' value template for Org FILE in DIR."
+  `( :base-extension "org"
+     :base-directory ,dir
+     :exclude ".*"
+     :include (,file)
+     :publishing-function org-html-publish-to-html
+     :html-head ,esy/website-html-header
+     :html-postamble ,esy/website-html-postamble))
+
+(defconst esy/publish-project-index-template
+  (esy/publish-project-make-org-template esy/website-source-org "index.org")
+  "Template for the index page of my website.")
+
+(defconst esy/publish-project-config-template
+  (esy/publish-project-make-org-template
+   (expand-file-name "dotfiles/.emacs.d" esy/website-source-root)
+   "esy.org")
+  "Template for the index page of my website.")
+
+(defconst esy/publish-project-static-template
+  `( :base-directory ,esy/website-source-org
+     :base-extension "ico\\|css\\|jpg\\|gif\\|png\\|txt\\|pdf"
+     :recursive t
+     :publishing-function org-publish-attachment)
+  "Template for the static assets of my website.")
+
+(with-eval-after-load 'ox-publish
+  (require 'ox-html)
+  (require 'htmlize)
+  (setq org-export-with-section-numbers nil
+        org-html-html5-fancy t
+        org-html-doctype "html5"
+        org-html-head-include-default-style nil
+        org-html-head-include-scripts nil
+        org-html-htmlize-output-type 'css
+        org-publish-project-alist
+        `(("index"
+           :publishing-directory ,esy/website-target-html
+           .
+           ,esy/publish-project-index-template)
+          ("static"
+           :publishing-directory ,esy/website-target-html
+           .
+           ,esy/publish-project-static-template)
+          ("config"
+           :publishing-directory ,esy/website-target-html
+           .
+           ,esy/publish-project-config-template)
+          ("eshelyaron.com" :components ("index"
+                                         "static"
+                                         "config"))
+          ("index.local"
+           :publishing-directory ,(expand-file-name "html"
+                                                    esy/website-source-root)
+           .
+           ,esy/publish-project-index-template)
+          ("config.local"
+           :publishing-directory ,(expand-file-name "html"
+                                                    esy/website-source-root)
+           .
+           ,esy/publish-project-config-template)
+          ("static.local"
+           :publishing-directory ,(expand-file-name "html"
+                                                    esy/website-source-root)
+           .
+           ,esy/publish-project-static-template)
+          ("eshelyaron.local" :components ("index.local"
+                                           "static.local"
+                                           "config.local")))))
+(setq org-confirm-babel-evaluate nil)
 
 (provide 'publish)
 ;;; publish.el ends here