;;;; org-mode pour blogger

(require 'ox-publish)
(require 'htmlize)

(setq org-publish-project-alist
        `(("pages"
           :base-directory "~/Documents/Repositories/études_doctorat/org/"
           :publishing-directory "~/Documents/Repositories/études_doctorat/public/"
           :base-extension "org"
           :recursive t
           :publishing-function org-html-publish-to-html
           :section-numbers 3
           :with-toc t

           ;; sitemap
           :auto-sitemap t
           :sitemap-title "Un doctorat au CRESCO"
           :sitemap-filename "index.org"
           ;; https://m13o.jp/201901052018
           :sitemap-format-entry blog-sitemap-format-entry
           :sitemap-sort-files anti-chronologically

           ;; generic properties
           :author "Jean-Christophe Helary"
           :email "jean.helary@univ-tlse2.fr"
           :language "fr"
           
           ;; HTML
           :html-doctype "html5"
           :html-indent t
           :html-html5-fancy t
           :html-head-include-scripts nil
           :html-head-include-default-style nil
           :html-htmlize-output-type css
           :htmlized-source t
           :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/stylesheet.css\" />"
           :html-preamble "<nav>
  <a href=\"/\">Index</a>
</nav>"
           :html-postamble "<hr/>
<footer>
  <div class=\"description\">Ce blog est une tentative de publication irrégulière de l’avancée de ma recherche et de mes réflexions concernant la publication.<br/> Les contenus sont distribués avec la licence <a rel=\"license\" href=\"https://creativecommons.org/licenses/by/4.0/deed.fr\">CC BY 4.0</a> sauf indication contraire.</div>
  <div class=\"copyright\"> Mise à jour le %C. Copyright &copy; 2025 <a href=\"https://sr.ht/~brandelune/\">Jean-Christophe Helary</a>.</div>
</footer>"
           :section-numbers nil
           :with-toc nil)

          ("static"
           :base-directory "~/Documents/Repositories/études_doctorat/org/"
           :publishing-directory "~/Documents/Repositories/études_doctorat/public/"
           :base-extension "css\\|txt\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|html"
           :recursive t
           :publishing-function org-publish-attachment)

          ("brandelune.srht.site"
           :components ("pages" "static"))))


;; modification de l’index
;; https://m13o.jp/201901052018
(defun blog-sitemap-format-entry (entry style project)
  (cond ((not (directory-name-p entry))
         (format "%s [[file:%s][%s]]"
                 (format-time-string "%Y-%m-%d - " (org-publish-find-date entry project))
                 entry
                 (org-publish-find-title entry project)))
        ((eq style 'tree)
         (file-name-nondirectory (directory-file-name entry)))
        (t entry)))

;; je devine qu’il y a un moyen de traiter automatiquement la conversion de ce code en html dans la préparation des fichiers, mais je n’y arrive pas, donc cette action se fera manuellement :
(htmlize-file "~/Documents/Repositories/études_doctorat/org/code/org-publish.el")

;; pour publier, évaluer cette ligne :
(org-publish "brandelune.srht.site" t)

;;;; mise à jour du 8 juin 2025