Org Mode Project Specification
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 Project Specification section.
This file can be found here:
To load this configuration, either
M-x org-babel-execute-buffer this
buffer or put in your Emacs initialization file (
(setq project-location (expand-file-name "~/Sites/home/project-specification/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-management.html, to preview and publish the website
- ./website-metadata.html, to read metadata from pages, which can be used for generating list of posts, etc.
(setq load-path (append load-path '("."))) (require 'website-management nil t) (require 'website-metadata nil t)
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, where do we save resulting HTML files and
from which directory do we start serving local preview?
(Notice that flexibility between
allows to run a local server on a suburi.)
(setq sources (expand-file-name "~/Sites/home/")) (setq local-dest (concat (file-name-as-directory sources) "_site/adolfo")) (setq preview-dir (concat (file-name-as-directory sources) "_site/"))
Where do we deploy the generated HTML?
nil if no remote deployment is necessary, in which case the
website will be available in the
(setq deploy-dest "adolfo@home:/srv/http/ict4g_net/adolfo")
The project will be structured in two components, content and assets:
(setq content (concat name "-content")) (setq assets (concat name "-assets"))
This is a custom publishing function to choose the Reveal engine for files whose name ends with -reveal (before the extension). it replaces org-html-publish-to-html as the “:publishing-function”
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))
Building, Previewing, Deploying
Once you have everything in place, you can use the following functions
(the first is syntactic sugar for
Generating Dynamic content
The functions in
website-metadata read the metadata of all files of
a project and provide facilities for generating “dynamic” content,
such as, for instance, the list of posts. This is achieved using
source code blocks in pages.
For instance, this snippet generates a list of posts in chronological order:
#+BEGIN_SRC emacs-lisp :exports results :results output html :dir . (org-babel-load-file "../project-specification/website-metadata.org") ;; get metadata of all the files from here (setq metadata (files-metadata ".")) ;; remove files in this directory (which are index files) (setq metadata (seq-filter (lambda (x) (< 2 (length (split-string (cdr (assoc "FILENAME" x)) "/")))) metadata)) (princ (group-to-html (sort-group-by-year (group-by-year (sort-metadata metadata "DATE_ISO8601" 'string-greaterp))) t)) #+END_SRC