Org Mode Project Specification

Menu

Introduction

This page contains the specification to build this website using Org Mode. You might want to look and set some of the variables in the Configuration section.

It can be found here:

/home/adolfo/Sites/home/website-specification

To load this configuration, either M-x org-babel-execute-buffer this buffer or put in your Emacs initialization file (.emacs.el):

(setq project-location (expand-file-name "~/Sites/home/website-specification/org-project-specification.org"))

(if (file-exists-p project-location)
    (org-babel-load-file project-location)
  (message "Warning! project specification (%s) not found (check init.el)" project-location))

Static website functions

We use the functions defined in website.org, which provide facilities for defining a project, previewing it and deploying it:

(org-babel-load-file (expand-file-name "~/Sources/elisp/website.org"))

Project Specification

Configuration

The project name is:

(setq name "home")

On which port do we run it when previewing locally?

(setq preview-port 4700)

Where are the sources and where do we save resulting HTML files?

(setq sources (expand-file-name "~/Sites/home/"))
(setq local-dest (concat (file-name-as-directory sources) "_site/"))

Where do we deploy the generated HTML?

Set to nil if no remote deployment is necessary, in which case the website will be available in the local-dest directory:

(setq deploy-dest "adolfo@ict4g.net:/srv/http/ict4g_net/adolfo")

Add the project specification to the list of project managed with av/website functions (which is an association list like org-publish-project-alist.

(website-remove name)
(website-add name preview-port local-dest deploy-dest)

Project Setup

HTML websites projects:

(setq content (concat name "-content"))
(setq assets (concat name "-assets"))

;; this is a custom publishing function to choose the Reveal engine
;; for files ending with -reveal.
;; it replaces org-html-publish-to-html as the ":publishing-function"

(defun av/org-publish-html-or-reveal (plist filename pub-dir)
  "Publish using the standard HTML or Reveal engine, if filename ends with -reveal."
  (if (string-match "-reveal\\.org" filename)
      (org-publish-org-to 'reveal filename ".html" plist pub-dir)
    (org-html-publish-to-html plist filename pub-dir)))

;; this is pure magic to avoid an issue with client-multiplex undefined when publishing with reveal
(setq client-multiplex nil)

(setq project-specification
      `((,name
         :components (,content ,assets))

        (,content
         :base-directory ,sources
         :publishing-directory ,local-dest
         :publishing-function (av/org-publish-html-or-reveal org-org-publish-to-org)
         :base-extension "org"
         :exclude "\\(.git\\|_site\\|^_.*\\|.*~\\)"
         :recursive t

         :html-doctype "html5"
         :htmlized-source t

         :section-numbers nil
         :with-toc nil
         :with-broken-links nil
         :html-head-include-default-style nil
         :html-head-include-scripts nil
         :html-postamble "
 <div class=\"footer-contacts\">
    <script language=\"javascript\">
      var n = \"adolfo\"
      var s = \"villafiorita\"
      var d = \"shair.tech\"
      var content = \"<i class=\\\"fi-mail\\\"></i>\"
      document.write('<a href=\"mailto:' + n +'@' + d + '\">' + content + '</a>');

     </script>
     <a href=\"/adolfo/contacts.html\"><i class=\"fi-mobile\"></i></a>
     <a href=\"/adolfo\"><i class=\"fi-home\"></i></a>
 </div>
 <div class=\"footer-metadata\">
   <p class=\"author\">Author: %a</p>
   <p class=\"date\">Last modified: %C (created on: %d)</p>
   <p class=\"date\">Published: %T</p>
   <p id=\"source-link\" class=\"source\"></p>
 </div>"
         )

        (,assets
         :base-directory ,sources
         :publishing-directory ,local-dest
         :publishing-function org-publish-attachment
         :base-extension "atom\\|css\\|js\\|gif\\|jpg\\|png\\|svg\\|webm\\|pdf\\|txt\\|xml\\|ttf\\|woff\\|gz\\|vcf"
         :exclude "\\(.git\\|_site\\|^_.*\\|.*~\\)"
         :recursive t
         )

         ))

Remove the project specification, if already present, so that we can modify and re-evaluate this page:

(let ( (components (mapcar (lambda (x) (car x)) project-specification)) )
  (mapcar 
     (lambda (x) (setq org-publish-project-alist (assoc-delete-all x org-publish-project-alist)))
     components))

Add the project specification to the list of Org Mode projects:

(setq org-publish-project-alist (append project-specification org-publish-project-alist))