diff --git a/NEWS.md b/NEWS.md index 825bba5..f8c2d85 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -## Changes for 0.9 (2013-xx-xx): +## Changes for 0.9 (2013-02-20): * INCOMPATIBLE CHANGE: All :plugins in .coleslawrc must be lists. (i.e. (mathjax) not mathjax) * Add support for analytics via Google. @@ -6,6 +6,7 @@ * Add support for deploying to Amazon S3. * Add a heroku plugin to ease hunchentoot deployments. (thanks @jsmpereira!) * Ensure coleslaw exits after MAIN. Fixes issue #13. +* Greatly improved docs for the various plugins and plugin API. ## Changes for 0.8 (2013-01-06): diff --git a/README.md b/README.md index 32ea116..6fe3285 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Coleslaw aims to be flexible blog software suitable for replacing a single-user * Currently supports: Common Lisp, Emacs Lisp, Scheme, C, C++, Java, Python, Erlang, Haskell, Obj-C, Diff. * [Multi-site publishing](http://blub.co.za/posts/Adding-multi-site-support-to-Coleslaw.html) support. -* A Plugin API and plugins for... +* A [Plugin API](http://github.com/redline6561/coleslaw/blob/master/docs/plugin-api.md) and [plugins](http://github.com/redline6561/coleslaw/blob/master/docs/plugin-use.md) for... * Comments via Disqus * Analytics via Google * Deploying to Amazon S3. @@ -53,21 +53,5 @@ format: html (for raw html) or md (for markdown) your post ``` -## Importing from Wordpress -There is a "plugin" to import from wordpress. At some point, it should be turned into a standalone script. Until then... - -1. Export your posts from wordpress. -2. In your lisp of choice, do the following: - 1. ```(ql:quickload 'coleslaw)``` - 2. ```(in-package :coleslaw)``` - 3. ```(load-plugins '(import))``` - 4. ```(coleslaw-import::import-posts "/path/to/export.xml")``` - -The XML will be read and placed into .post files in the :repo location specified in your [.coleslawrc](http://github.com/redline6561/coleslaw/blob/master/examples/single-site.coleslawrc). - -## Writing your own plugins -For now, see the [API](http://redlinernotes.com/docs/coleslaw.html) and the [existing plugins](https://github.com/redline6561/coleslaw/tree/master/plugins) for an example. -A proper guide about this will be written later. - ## Theming A default theme, hyde, is provided. Themes are made using Google's closure-template and the source for [hyde](https://github.com/redline6561/coleslaw/tree/master/themes/hyde) should be simple and instructive until I can provide better docs. diff --git a/docs/plugin-api.md b/docs/plugin-api.md new file mode 100644 index 0000000..7e7d569 --- /dev/null +++ b/docs/plugin-api.md @@ -0,0 +1,26 @@ +# General Use + +1. A lisp file should be created in coleslaw's ```plugins``` directory. +2. Any necessary lisp libraries not loaded by coleslaw should be included like so: + + ```(eval-when (:compile-toplevel :load-toplevel) (ql:quickload '(foo bar)))``` + +3. A package should be created for the plugin code like so: + + ```(defpackage :coleslaw-$NAME (:use :cl) (:export #:enable) ...)``` + + where $NAME is the pathname-name of the lisp file. (eg. `:coleslaw-disqus` for `disqus.lisp`) +4. An enable function should be present even if it's a no-op. Any work to enable the plugin is done there. + + +# Extension Points + +* **New functionality via JS**, for example the Disqus and Mathjax plugins. In this case, the plugin's `enable` function should call [`add-injection`](http://redlinernotes.com/docs/coleslaw.html#add-injection_func) with an injection and a keyword. The injection itself is a list of the string to insert and a lambda or function that can be called on a content instance to determine whether the injection should be included on the page. The keyword specifies whether the injected text goes in the HEAD or BODY element. The [Disqus plugin](http://github.com/redline6561/coleslaw/blob/master/plugins/disqus.lisp) is a good example of this. + +* **New markup formats**, for example the [ReStructuredText plugin](http://github.com/redline6561/coleslaw/blob/master/plugins/rst.lisp), can be created by definining an appropriate `render-content` method. The method takes `text` and `format` arguments and is [EQL-specialized](http://www.gigamonkeys.com/book/object-reorientation-generic-functions.html#defmethod) on the format. Format should be a keyword matching the file extension (or pathname-type) of the markup format. (eg. `rst` for ReStructuredText) + +* **New hosting options**, for example the [Amazon S3 plugin](http://github.com/redline6561/coleslaw/blob/master/plugins/s3.lisp), can be created by definining a `deploy :after` method. The method takes a staging directory, likely uninteresting in the `:after` stage. But by importing `*config*` from the coleslaw package and getting its deploy location with `(deploy *config*)` a number of interesting options become possible. + +* **New content types**, for example a bookmark-like content type such as ["shouts"](http://paste.lisp.org/display/134453). This has not yet been attempted as a plugin but should be possible without much difficulty. + +* **New service integrations**, for example crossposting to twitter/facebook/tumblr/livejournal/etc, should also be possible by adding an :after hook to the deploy method as with hosting. Alternately, an :after hook on the [`render`](the [`render`](http://redlinernotes.com/docs/coleslaw.html#render_func) method might be used. diff --git a/docs/plugin-use.md b/docs/plugin-use.md new file mode 100644 index 0000000..0796eda --- /dev/null +++ b/docs/plugin-use.md @@ -0,0 +1,41 @@ +# General Use + +* Add a list with the plugin name and settings to the ```:plugins``` section of your [.coleslawrc](http://github.com/redline6561/coleslaw/blob/master/examples/single-site.coleslawrc). Plugin settings are described below. + +* Available plugins are listed below with usage descriptions and config examples. + +## Analytics via Google + +**Description**: Provides traffic analysis through [Google Analytics](http://www.google.com/analytics/). + +**Example**: ```(analytics :tracking-code "google-provided-unique-id")``` + +## Comments via Disqus + +**Description**: Provides comment support through [Disqus](http://www.disqus.com/). + +**Example**: ```(disqus :shortname "disqus-provided-unique-id")``` + +## LaTeX via Mathjax + +**Description**: Provides LaTeX support through [Mathjax](http://www.mathjax.org/) for posts tagged with "math" and indexes containing such posts. Any text enclosed in $$ will be rendered, for example, ```$$ \lambda \scriptstyle{f}. (\lambda x. (\scriptstyle{f} (x x)) \lambda x. (\scriptstyle{f} (x x))) $$```. + +**Example**: ```(mathjax)``` + +## ReStructuredText + +**Description**: Some people really like [ReStructuredText](http://docutils.sourceforge.net/rst.html). Who knows why? But it only took one method to add, so yeah! Just create a post with ```format: rst``` and the plugin will do the rest. + +**Example**: ```(rst)``` + +## S3 Hosting + +**Description**: Allows hosting your blog entirely via [Amazon S3](http://aws.amazon.com/s3/). It is suggested you closely follow the relevant [AWS guide](http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html) to get the DNS setup correctly. Your ```:auth-file``` should match that described in the [ZS3 docs](http://www.xach.com/lisp/zs3/#file-credentials). + +**Example**: ```(s3 :auth-file "/home/redline/.aws_creds" :bucket "blog.redlinernotes.com")``` + +## Wordpress Importer + +**Description**: Import blog posts from Wordpress using their export tool. Blog entries will be read from the XML and converted into .post files. Afterwards the XML file will be deleted to prevent reimporting. Optionally an ```:output``` argument may be supplied to the plugin. If provided, it should be a directory in which to store the .post files. Otherwise, the value of ```:repo``` in your .coleslawrc will be used. + +**Example**: ```(import :filepath "/home/redline/redlinernotes-export.timestamp.xml" :output "/home/redlinernotes/blog/")``` diff --git a/plugins/import.lisp b/plugins/import.lisp index 4c045fa..d3437df 100644 --- a/plugins/import.lisp +++ b/plugins/import.lisp @@ -55,7 +55,7 @@ (defun import-posts (filepath output &optional since) (when (probe-file filepath) - (ensure-directories-exist (repo *config*)) + (ensure-directories-exist (or output (repo *config*))) (let* ((xml (cxml:parse-file filepath (cxml-dom:make-dom-builder))) (posts (dom:get-elements-by-tag-name xml "item"))) (loop for post across posts do (import-post post output since))