;;; 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