Structures

Some variables are available when publishing lisp parts of templates. These variables are defined using defstruct, then any slot (or property) is available using a (type-slot variable) form.

Structures

Structures: ob:blog

Structure used to define a blog:

  • file: The blog source file (read-only).
  • buffer: Buffer visiting the blog file (read-only).
  • publish-dir: Where to publish the blog, defined by the #+PUBLISH_DIR: header directive or out in the same directory as the blog source file.
  • template-dir: Location of the template directory defined by the #+TEMPLATE_DIR: header directive or the templates directory of the o-blog library.
  • style-dir: Path of the css files defined by the #STYLE_DIR: header directive or style. This directory is relative to template-dir.
  • posts-filter: Default filter for posts defined by the #POSTS_FILTER: header directive or +TODO={DONE}.
  • static-filter: Default filter for static pages defined by the #STATIC_FILTER: header directive or +PAGES={.*}.
  • snippet-filter Default filter for snippets defined by the #SNIPPET_FILTER: header directive or +SNIPPET={.*}.
  • title: Blog title defined by the #+TITLE: header directive.
  • description: Blog description defined by the #+DESCRIPTION: header directive.
  • url: Blog base URL defined by the #+URL: header.
  • default-category: Default category for posts defined by the #DEFAULT_CATEGORY: header or Blog.
  • disqus: The Disqus account (called a forum on Disqus) this o-blog site belongs to. Defined by the #+DISQUS: header.
  • filename-sanitizer: A 1-argument function to be used to sanitize post filenames. Defined by #+FILENAME_SANITIZER: or ob-sanitize-string.
  • post-sorter: A 2-argument function to be used to sort the posts. Defined by #+POST_SORTER: or ob-sort-posts-by-date.

Example:

;; get the title of the current blog defined in variable BLOG.
(ob:blog-title BLOG)

Structures: ob:post

  • id: The post's numerical id. Posts are sort by reversed chronological order. The most recent post get the id 0.
  • title: The post title, read from the entry title.
  • timestamp: The post timestamp given by the CLOSED property or the current time.
  • year: Numerical year computed from timestamp.
  • month: Numerical month computed from timestamp.
  • day: Numerical day computed from timestamp.
  • category: Category read from CATEGORY property org blog.
  • tags: List of ob:tags.
  • template: Template to use for current post read from TEMPLATE property or blog_post.html.
  • filepath: Relative path from the blog root directory to the post directory (directory only).
  • filename: Sanitized filename generated from title.
  • htmlfile: Full relative path to the post html file (file and directory).
  • path-to-root: Relative path from the post html file to the blog root.
  • content: Raw content of the post (Org-mode format).
  • content-html: HTML export of the post.

Example:

;; Get the HTML content of the post defined in variable POST.
(ob:post-content-html POST)

Structures: ob:tags

Structure used to define a tag:

  • name: The string defining the tag name.
  • safe: Web/URL-safe tag name.
  • count: How many times the tag is used across posts.
  • size: The font size in percent.

Example:

;; get the name of the tag defined in variable TAG.
(ob:tags-name TAG)

Variables

The following variables are always available when publishing a blog:

  • BLOG (ob:blog): Information about the blog being published.
  • POSTS (list of ob:post): List of all posts of the blog or restricted list of posts (depending on what is exported).
  • ALL-POSTS: A copy of POSTS except this always contains all the posts from the blog.
  • STATIC (list of ob:post): List of static pages.
  • SNIPPETS (list of ob:post): List of snippets pages.
  • TAGS (list of ob:tags): List of all tags.

Some variables may be defined in some functions:

  • POST (ob:post): The post (or static page) being currently published.
  • TAG (ob:tags): The tag being currently published.
  • CATEGORY (string): The category being published.
  • YEAR, MONTH (=integer): The year and month being published.
  • PATH-TO-ROOT (string): (internal use only, use ob:path-to-root instead) Path to blog root used by ob:path-to-root.