Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: jss
Fetching contributors…

Cannot retrieve contributors at this time

99 lines (95 sloc) 4.393 kB

Code for publishing Org-babel development information

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


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.

 (lambda (file)
   (let ((full-file (expand-file-name
                     (concat file ".org")
                     (file-name-directory (buffer-file-name))))
         (yaml-front-matter `(("layout" . "default")
                              ("title" . ,file)))
     ;; 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))))
         (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.

  ;; map over all tasks entries
  (let ((dev-file (expand-file-name
                   (file-name-directory (buffer-file-name))))
        (posts-dir (expand-file-name
                    (file-name-directory (buffer-file-name))))
        (yaml-front-matter '(("layout" . "default")))
        (org-export-htmlize-output-type 'css))
    ;; go through both the tasks and bugs
     (lambda (top-level)
       (find-file dev-file)
       (goto-char (point-min))
       (outline-next-visible-heading top-level)
        (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
                             "[:=\(\)\?]" ""
                              "[ \t]" "-" heading)))
                     (str-time (and (string-match "\\([[:digit:]\-]+\\) " time)
                                    (match-string 1 time)))
                     (to-file (replace-regexp-in-string
                               "+" "" (replace-regexp-in-string
                                       "#" "" (format "%s-%s.html" str-time title))))
                     (org-buffer (current-buffer))
                     (yaml-front-matter (cons (cons "title" heading) yaml-front-matter))
                (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)
                (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))))
                    (insert "---\n\n"))
                  (insert html))
                (get-buffer org-buffer)))))))
     '(1 2))))
(message "successfully exported development updates")
Jump to Line
Something went wrong with that request. Please try again.