work-site/work.el
Sergiu Ivanov 7516937675 Change the name of the output directory.
Easier with sftp.
2024-09-25 16:27:51 +02:00

119 lines
3.9 KiB
EmacsLisp

;; work.el
;;
;; The file setting up Org-mode to publish my work page.
;;
;; This file should be evaluated from within Emacs using the
;; 'eval-buffer' command.
;; Produce the string about the update date and time in French if lang
;; is 'fr and in English if lang is 'en or anything else.
(defun make-update-time (lang)
(let ((date (format-time-string "%Y-%m-%d"))
(time (format-time-string "%H:%M")))
(cond ((eq lang 'en) (concat "Updated on " date " at " time "."))
((eq lang 'fr) (concat "Mis à jour le " date " à " time "."))
(t (concat "Updated on " date " at " time ".")))))
;; Produce the string Powered by Org-mode in the appropriate language.
(defun make-powered-by (lang)
(let ((orgmode "<a href=\"https://orgmode.org/\">Org-mode</a>")
(src "<a href=\"https://git.marvid.fr/scolobb/work-site\">source</a>"))
(cond ((eq lang 'fr)
(concat "Propulsé par " orgmode " (" src ")."))
(t
(concat "Powered by " orgmode " (" src ").")))))
;; Produce the postamble in the given language (same convention as for
;; make-update-time).
(defun make-postamble (lang)
(concat "<span class=\"updated\">"
(make-update-time lang)
"</span> <span class=\"poweredby\">"
(make-powered-by lang)
"</span>"))
;; Produce the <link> tag including the stylesheet relative to the
;; given root.
(defun make-styles (root)
(concat "<link rel=\"stylesheet\" type=\"text/css\" href=\"" root "content/css/default.css\" />"))
;; Produce the preamble with links relative to the given root.
(defun make-preamble (root)
(concat "
<span class=\"myname\">Sergiu Ivanov</span>
<span class=\"logos\">
<a href=\"https://www.ibisc.univ-evry.fr/\"><img src=\"" root "content/imgs/ibisc.png\" alt=\"lab logo\" class=\"ibisclogo\" /></a>
<a href=\"https://www.univ-evry.fr/accueil.html\"><img src=\"" root "content/imgs/ueve.png\" alt=\"university logo\" class=\"uevelogo\" /></a>
</span>"))
;; Set up org-publish for my work site.
(let* ((work-base "~/Candies/Sites/work/")
(publishing-base (concat work-base "public_html/")))
(setq org-publish-project-alist
`(("work-site"
:components ("work-site-en" "work-site-en-index" "work-site-fr" "work-site-content"))
("work-site-en"
:base-extension "org"
:base-directory ,(concat work-base "en/")
:publishing-directory ,(concat publishing-base "en/")
:publishing-function org-html-publish-to-html
:section-numbers nil
:with-toc nil
:with-latex t
:html-head-include-default-style nil
:html-head-include-scripts nil
:html-head-extra ,(make-styles "../")
:html-preamble ,(make-preamble "../")
:html-postamble ,(make-postamble 'en))
;; We are going to need an index.html in the root directory.
;; We'll have a separate subproject for that file.
("work-site-en-index"
:base-extension ""
:base-directory ,work-base
:include ("index.org")
:publishing-directory ,publishing-base
:publishing-function org-html-publish-to-html
:section-numbers nil
:with-toc nil
:with-latex t
:html-head-include-default-style nil
:html-head-include-scripts nil
:html-head-extra ,(make-styles "")
:html-preamble ,(make-preamble "")
:html-postamble ,(make-postamble 'en))
("work-site-fr"
:base-extension "org"
:base-directory ,(concat work-base "fr/")
:publishing-directory ,(concat publishing-base "fr/")
:publishing-function org-html-publish-to-html
:section-numbers nil
:with-toc nil
:with-latex t
:html-head-include-default-style nil
:html-head-include-scripts nil
:html-head-extra ,(make-styles "../")
:html-preamble ,(make-preamble "../")
:html-postamble ,(make-postamble 'fr))
("work-site-content"
:base-extension any
:base-directory ,(concat work-base "content/")
:publishing-directory ,(concat publishing-base "content/")
:publishing-function org-publish-attachment
:recursive t))))