This file contains the code to export this repo for publishing on github

Index

Export the index in a manner amenable to jekyll processing. This code exports single files for processing by jekyll and could easily be reused in other projects.

(mapc
 (lambda (file)
   (let ((full-file (expand-file-name
                     (concat file ".org")
                     (file-name-directory (buffer-file-name))))
         (yaml-front-matter `(("layout" . "default")
                              ("title" . ,file)))
         html)
     ;; go to the top level tasks heading
     (find-file full-file)
     (setq html (org-export-as-html nil nil nil 'string t nil))
     (with-temp-file (concat file ".html")
       (when yaml-front-matter
         (insert "---\n")
         (mapc (lambda (pair) (insert (format "%s: %s\n" (car pair) (cdr pair))))
               yaml-front-matter)
         (insert "---\n\n"))
       (insert html)))) '("index" "publish" "dev-updates"))

Development Updates

This code will be used to publish posts for all Task and Bug items which have an associated date/time. This generates one blog post per headline and could easily be adapted for managing a blog through org-mode.

(save-excursion
  ;; map over all tasks entries
  (let ((dev-file (expand-file-name
                   "development.org"
                   (file-name-directory (buffer-file-name))))
        (posts-dir (expand-file-name
                    "_posts"
                    (file-name-directory (buffer-file-name))))
        (yaml-front-matter '(("layout" . "default")))
        (org-export-htmlize-output-type 'css))
    ;; go through both the tasks and bugs
    (mapc
     (lambda (top-level)
       (find-file dev-file)
       (goto-char (point-min))
       (org-shifttab)
       (outline-next-visible-heading top-level)
       (org-show-subtree)
       (org-map-tree
        (lambda ()
          (let* ((props (org-entry-properties))
                 (todo (cdr (assoc "TODO" props)))
                 (time (cdr (assoc "TIMESTAMP_IA" props))))
            ;; each task with a state and timestamp can be exported as a
            ;; jekyll blog post
            (when (and todo time)
              (message "time=%s" time)
              (let* ((heading (org-get-heading))
                     (title (replace-regexp-in-string
                             "[:=\(\)\?]" ""
                             (replace-regexp-in-string
                              "[ \t]" "-" heading)))
                     (str-time (and (string-match "\\([[:digit:]\-]+\\) " time)
                                    (match-string 1 time)))
                     (to-file (format "%s-%s.html" str-time title))
                     (org-buffer (current-buffer))
                     (yaml-front-matter (cons (cons "title" heading) yaml-front-matter))
                     html)
                (org-narrow-to-subtree)
                (let ((level (- (org-outline-level) 1))
                      (contents (buffer-substring (point-min) (point-max))))
                  (dotimes (n level nil) (org-promote-subtree))
                  (setq html (org-export-as-html nil nil nil 'string t nil))
                  (set-buffer org-buffer)
                  (delete-region (point-min) (point-max))
                  (insert contents)
                  (save-buffer))
                (widen)
                (with-temp-file (expand-file-name to-file posts-dir)
                  (when yaml-front-matter
                    (insert "---\n")
                    (mapc (lambda (pair) (insert (format "%s: %s\n" (car pair) (cdr pair))))
                          yaml-front-matter)
                    (insert "---\n\n"))
                  (insert html))
                (get-buffer org-buffer)))))))
     '(1 2))))
(message "successfully exported development updates")