qr-code

结构

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: 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 post 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: disqus account (called a forum on Disqus) this system belongs to. Defined by the \"#DISQUS\" header.
  • filename-sanitizer: 1-argument function to be used to sanitize post filenames. Defined by #+FILENAME_SANITIZER: or ob-sanitize-string.

Example:

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

Structures: ob:post

  • id: the post 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: string defying the tag name.
  • safe: web safe tag name for URL.
  • count: how many time the tag is used.
  • size: the font size in percent.

Example:

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

变量

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 what is exported).
  • ALL-POSTS: A copy of POSTS except this always contents 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): post (or static page) being currently published.
  • TAG (ob:tags): tag being currently published.
  • CATEGORY (string): the category being published.
  • YEAR, MONTH (=integer): the year and month being published.
  • PATH-TO-ROOT (string): (intern use only, use ob:path-to-root instead) path to blog root used by ob:path-to-root.