An open API service indexing awesome lists of open source software.

https://github.com/theasp/org-publish-script

Publish org-mode projects outside of emacs
https://github.com/theasp/org-publish-script

Last synced: 2 months ago
JSON representation

Publish org-mode projects outside of emacs

Awesome Lists containing this project

README

        

Org Publish Script

<!--/*--><![CDATA[/*><!--*/
.title { text-align: center; }
.todo { font-family: monospace; color: red; }
.done { color: green; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.right { margin-left: auto; margin-right: 0px; text-align: right; }
.left { margin-left: 0px; margin-right: auto; text-align: left; }
.center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }

table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.right { text-align: center; }
th.left { text-align: center; }
th.center { text-align: center; }
td.right { text-align: right; }
td.left { text-align: left; }
td.center { text-align: center; }
dt { font-weight: bold; }
.footpara:nth-child(2) { display: inline; }
.footpara { display: block; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/-->

/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.

Copyright (C) 2012-2013 Free Software Foundation, Inc.

The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.

@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->


Org Publish Script



Table of Contents





1 Examples






1.1 Using Mini-CI and git




This assumes you have a git repository in ~/.git-repo/org.git on the same machine you will be running Mini-CI on. Adjust as needed.




1.1.1 Step 1: Add Org Publish Init Script to Org




Make the publish directory:


mkdir ~/org/publish



Put the following in ~/org/publish/org-publish-init.el:


(prefer-coding-system 'utf-8)

;; Add extra elpa repos
(add-to-list 'package-archives '("ELPA" . "http://tromey.com/elpa/"))
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("mepla-stable" . "http://stable.melpa.org/packages/"))
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))

(org-publish/install-packages '(graphviz-dot-mode
lua-mode
org-plus-contrib
css-mode
ess
htmlize
gnuplot))

(require 'ox-odt)

;; active Babel languages
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(awk . t)
(sh . t)
(perl . t)
(dot . t)
(calc . t)
(R . t)
(gnuplot . t)
(awk . t)))

;; Allow babel to execute commands and not ask about them. Note that
;; this is unsafe.
(setq org-confirm-babel-evaluate nil)
(setq org-export-babel-evaluate t)

;; Don't make backups
(setq make-backup-files nil)

;; Publish planning information by default
(setq org-export-with-planning t)

;; Fontify source
(setq org-html-htmlize-output-type 'css)

;; Use unicode characters for checkboxes. Comment to disable
(defun unicode-for-org-html-checkbox (checkbox)
"Format CHECKBOX into Unicode Characters."
(case checkbox (on "&#x22A0;")
(off "&#x25FB;")
(trans "&#x22A1;")
(t "")))
(defadvice org-html-checkbox (around unicode-checkbox activate)
(setq ad-return-value (unicode-for-org-html-checkbox (ad-get-arg 0))))

(org-publish/publish-project
'("org-dynamic"
:base-directory "./"
:recursive t
:exclude "^\\(publish\\|calendars\\|.PRIVATE\\)$"
:publishing-directory "./publish/output"
:publishing-function org-html-publish-to-html
:auto-sitemap t
:sitemap-title "My Org-Mode Files"
:sitemap-filename "index.org"
:sitemap-ignore-case t))

(org-publish/publish-project
'("org-static"
:base-directory "./"
:base-extension "js\\|css\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|svg"
:recursive t
:exclude "^\\(publish\\|.PRIVATE\\)$"
:publishing-directory "./publish/output"
:publishing-function org-publish-attachment))



Check the file in and push to your repository.





1.1.2 Step 2: Install Mini-CI




See Mini-CI.





1.1.3 Step 3: Set up Mini-CI Project




Make a directory:


mkdir -p ~/var/mini-ci/org



Put the follwing into ~/var/mini-ci/org/config:


REPO_PLUGIN=git

GIT_URL=~/.git-repo/org
POLL_FREQ=0
BUILD_KEEP=5


Make the tasks directory:


mkdir ~/var/mini-ci/org/tasks.d



Put the following into ~/var/mini-ci/org/tasks.d/500-org-publish


#!/bin/bash

set -ex

org-publish ./publish/org-publish-init.el



Put the following into ~/var/mini-ci/org/tasks.d/800-rsync-to-web:


#!/bin/bash

set -ex

OUTDIR=./publish/output
PUBLISHDIR=~/public_html/org

rsync --delete -a $OUTDIR/ $PUBLISHDIR/



Make the tasks executable:


chmod +x ~/var/mini-ci/org/tasks.d/*






1.1.4 Step 4: Start the Mini-CI Daemon




Start the Mini-CI daemon by running:


mini-ci -d ~/var/mini-ci/org poll



If everything works, you should have files in your web directory, otherwise examine the Mini-CI log files.


Add the following to cron to ensure the daemon is always running:



*/5 * * * * test -d var/mini-ci/org && mini-ci --oknodo -d var/mini-ci/org poll




1.1.5 Step 5: Add Hook to git that Notifies Mini-CI




Add the following to ~/.git-repo/org.git/hooks/post-update:


#!/bin/bash

set -e

mini-ci -d ~/var/mini-ci/org -m update



Make the hook executable:



chmod +x ~/.git-repo/org.git/hooks/post-update


Now anytime something is pushed to your repository it will trigger Mini-CI to build a new copy of the website.








Author: Andrew Phillips <[email protected]>


Date: 2015-07-20 Mon 12:55