How I create and Publish This Site.

I am using Emacs (of course, it's a way of life, remember?) and the o-blog package, which turns Emacs into a blogging platform. If you don't know anything about Emacs, you are about to get into the wrong place!

o-blog is the package I am using. Turns out it needs to have htmlize to properly work.

(add-to-list 'load-path "~/projects/emacs/o-blog/lisp")
(require 'o-blog)
(emagician-expect-package 'htmlize)
(require 'htmlize)

You can just get o-blog from MELPA, but I went with the source version.

emagician-expect-package is a bit of code I wrote to snarf a given feature from MELPA if not currently enabled.

The Stylesheet

I like Less. I like sass less. Less is very declaritave, and much more like CSS+. Sass is just coffeescript in css's clothing.

This funciton here compiles my less stylesheet, and if there is an error it will pop up a message saying so.

(defun jonnay/compile-less ()
  (interactive)
  (let ((default-directory (expand-file-name "~/Dropbox/Creativity/Site3.0/templates/style/")))
    (if (= 0 (call-process "lessc" 
                       nil
                       '((:file "site.css") "less-error")
                       nil 
                       (expand-file-name "site.less")))
        (message "Successfully Compiled Jonnays less stylesheet")
      (progn 
        (pop-to-buffer (with-current-buffer (get-buffer-create "*Less error*")
                         (erase-buffer)
                         (insert-file-contents "less-error")
                         (ansi-color-apply-on-region (point-min) (point-max))))
        (display-warning 'jonnay-site "Error from jonnay less compilation." :error "*Less error*")))))

Compile the whole shebang

Use o-blog to publish it. Note that the publish function also tangles and compiles the stylesheet!

o-blog doens't handle assets nicely. So I make an assets dir.

Also, note the explicit chmodding. This is because the site is deployed with rsync. More on that later.

(defun jonnay/compile-site ()
  "Switch to Site.org, publish and browse."
  (interactive)
  (with-current-buffer "Site.org"
    (org-babel-tangle)
    (jonnay/compile-less)
    (o-blog-publish)
    (make-directory "out/assets" t)
    (shell-command "rsync -va ./assets/ ./out/assets/" nil "*Jonnay Rsync Error*")
    (shell-command "rsync -va ./projects/ ./out/projects/" nil "*Jonnay Rsync Error*")
    (shell-command "rsync -va ./bunny/ ./out/bunny/" nil "*Jonnay Rsync Error*")
    (browse-url-of-file (expand-file-name "./out/index.html"))))

(global-set-key (kbd "<f5>") 'jonnay/compile-site)

Grab deviations/tracks/youtubes through RSS

It's not perfect, but it's something. The next step is to use some transformations on the feeds.

(defun jonnay/get-feeds ()
  (let ((org-feed-alist `(("DeviantArt" 
                           "http://backend.deviantart.com/rss.xml?type=deviation&q=by%3Ajonnay+sort%3Atime+meta%3Aall"
                           ,(buffer-file-name (get-buffer "Site.org"))
                           "Deviant Art"
                           :template ,(concat "* DONE %h :art:deviantart:\n" 
                                               "  CLOSED: %t\n" 
                                               "  %a\n" 
                                               "  #+BEGIN_HTML\n%description\n#+END_HTML\n"))
                          ("Youtube"
                           "http://gdata.youtube.com/feeds/base/users/UCjxiBV69MHTof4QFnQmTFSg/uploads?alt=rss&client=ytapi-youtube-rss-redirect&orderby=updated&v=2"
                           ,(buffer-file-name (get-buffer "Site.org"))
                           "Uploaded YouTube Videos"
                           :template ,(concat "* DONE %h :video:youtube:\n" 
                                              "  CLOSED: %t\n" 
                      "  :PROPERTIES: \n  :CATEGORY: video\n  :END:"
                                              "  %a\n" 
                                              "  #+BEGIN_HTML\n%description\n#+END_HTML\n"))
                          ("Soundcloud"
                           "http://picklemonkey.net/cloudflipper/cloudflipper.php?feed=https://soundcloud.com/jonnay&#038;prefixuploader=1"
                           ,(buffer-file-name (get-buffer "Site.org"))
                           "Soundcloud Audio"
                           :template ,(concat "* DONE %h :song:soundcloud:\n"
                                              "  CLOSED: %t\n"
                      "  :PROPERTIES: \n  :CATEGORY: music\n  :END:"                        
                                              "  %a\n"
                                              "  #+BEGIN_HTML\n%description\n#+END_HTML\n")))))
    (org-feed-update-all)))

And Finally Publish

Just a simple rsync.

  (defvar jonnay/publishing nil)

  (defun jonnay/publish-site () 
    "Publish the whole shebang"
    (interactive)
    (let ((jonnay/publishing 't))
      (with-current-buffer "Site.org"
        (shell-command "chmod -R a+r out")
        (async-shell-command "rsync -avz -e ssh ./out/ jonnay@www.jonnay.net:~/jonnay.net/www")
        (message "Publishing jonnay.net complete"))))

(global-set-key (kbd "S-<f5>") 'jonnay/publish-site)

Sometimes the dir gets hosed

If less compilation fails, the default-directory gets all weird. (setq default-directory (expand-file-name "~/Dropbox/Creativity/Site3.0/"))