This document presents the public API, meaning, the set of functions and classes that matter the most. If you are interested in all the nitty-gritty details, here’s a link to the epydoc documentation for the entire source code: restblog source code
Encapsulates a connection to a blog server and provides a simplified API to manage posts and pages.
copyright: | Copyright 2010 Luis Artola. |
---|---|
license: | BSD, see LICENSE.txt for details. |
connect( url=’‘, user=’‘, password=’‘, interactive=False ) -> Server
Convenience function to create a Server object. This is the preferred method over constructing a Server directly. It would attempt to use the given credentials if not empty. Otherwise, it would look into the .restblog directory, if it exists, to extract the default credentials.
Parameters:
Returns:
A Server instance.
Server( url, user=’‘, password=’’ ) -> instance
Provides a simplified API to a subset of methods from the various blogging APIs, i.e. Wordpress, MetaWeblog, Blogger, MoveableType. Manages the connection to a blog server using XMLRPC.
Parameters:
getRecentPostTitles( count=10 ) -> list
Returns a list with minimal information about the most recent posts.
Encapsulates MoveableType function mt.getRecentPostTitles.
Parameters:
Returns:
A list of dictionaries representing data from the post. Including postid, title and dateCreated.
newPost( contents, publish ) -> int
Creates a new post.
Encapsulates MetaWeblog function metaWeblog.newPost.
Parameters:
contents: A dictionary with the keys listed below.
- title: str
- description: str
- mt_excerpt: str
- mt_text_more: str
- mt_keywords: list
- categories: list
publish: Whether to publish immediately or not. Default is True.
Returns:
An integer with the post ID just created.
edit( contents, publish ) -> bool
Updates the post with the given id and contents.
Encapsulates MetaWeblog function metaWeblog.editPost.
Parameters:
contents: A dictionary with the keys listed below.
- title: str
- description: str
- mt_excerpt: str
- mt_text_more: str
- mt_keywords: list
- categories: list
publish: Whether to publish changes immediately or not. Default is True.
Returns:
True if the update was successful. False otherwise.
deletePost( id, publish ) -> bool
Deletes post with the given id.
Encapsulates MetaWeblog function metaWeblog.deletePost.
Parameters:
Returns:
True if the deletion was successful. False otherwise.
newPage( contents, publish ) -> int
Creates a new page. This function is practically identical to newPost. It receives the same parameters. One note though, contents may have some extra keys that do not quite apply to pages, e.g. tags and categories, but are gracefully ignored by the actual implementation on the server side.
Encapsulates Wordpress function wp.newPage.
Parameters:
Returns:
An integer with the page ID just created.
editPage( id, contents, publish ) -> bool
Edit page with the given id. This function is practically identical to editPost. It receives the same parameters. One note though, contents may have some extra keys that do not quite apply to pages, e.g. tags and categories, but are gracefully ignored by the actual implementation on the server side.
Encapsulates Wordpress function wp.editPage.
Parameters:
Returns:
True if the update was successful. False otherwise.
Functions to transform and manipulate a restblog post from XHTML.
copyright: | Copyright 2010 Luis Artola. |
---|---|
license: | BSD, see LICENSE.txt for details. |
createFormattedPost( file_name ) -> str
Translates the given file_name into an XHTML document.
Parameters:
Returns the name of a file with the XHTML document.
getPostContents( file_name ) -> ( xml.etree.ElementTree.Element, dict )
Extracts the relevant portions of the post from the given XHTML file_name.
Parameters:
Returns a tuple with the following values:
An xml.etree.ElementTree.Element that contains the post metadata. This is basically the options extracted from the .. restblog:: directive stored in the input reStructuredText file used to produce the given XHTML file_name. See restblog.directives.restblogheader for more information.
A dictionary with the actual portion of the XHTML document that contains the post contents. Contains the following keys:
- title: str
- description: str
- mt_excerpt: str
- mt_text_more: str
- mt_keywords: list
- categories: list
copyright: | Copyright 2010 Luis Artola. |
---|---|
license: | BSD, see LICENSE.txt for details. |
The restblog directive.
Usage:
.. restblog::
:type: post or page
:title: string
:categories: comma-separated list of strings
:tags: comma-separated list of strings
:publish: yes or no
:id: integer
:source: yes or no
copyright: | Copyright 2010 Luis Artola. |
---|---|
license: | BSD, see LICENSE.txt for details. |
The restblog fullstory directive.
Usage:
.. fullstory::
copyright: | Copyright 2010 Luis Artola. |
---|---|
license: | BSD, see LICENSE.txt for details. |
The restblog video directive.
Usage:
.. video:: url
Or:
.. video:: type id
Options:
:width: 400
:height: 300
:fullscreen: yes
:scriptaccess: yes
Options for vimeo only:
:title: yes
:byline: yes
:portrait: yes
Examples:
.. video:: http://vimeo.com/7809605
.. video:: vimeo 7809605
.. video:: http://www.youtube.com/watch?v=37GrbCUvZEM
.. video:: youtube 37GrbCUvZEM
copyright: | Copyright 2010 Luis Artola. |
---|---|
license: | BSD, see LICENSE.txt for details. |
This fragment is a Docutils 0.5 directive that renders source code (to HTML only, currently) via Pygments.
To use it, adjust the options below and copy the code into a module that you import on initialization. The code then automatically registers a sourcecode directive that you can use instead of normal code blocks like this:
.. sourcecode:: python
My code goes here.
If you want to have different code styles, e.g. one with line numbers and one without, add formatters with their names in the VARIANTS dict below. You can invoke them instead of the DEFAULT one by using a directive option:
.. sourcecode:: python
:linenos:
My code goes here.
Look at the directive documentation to get all the gory details.
copyright: | Copyright 2006-2009 by the Pygments team, see AUTHORS. |
---|---|
license: | BSD, see LICENSE for details. |
Utility module that converts a reStructuredText file into XHTML. Based on the rst2html script provided by docutils with some hard-coded options that are suitable for restblog.
copyright: | Copyright 2010 Luis Artola. |
---|---|
license: | BSD, see LICENSE.txt for details. |
Command-line interface to restblog.
copyright: | Copyright 2010 Luis Artola. |
---|---|
license: | BSD, see LICENSE.txt for details. |
run( arguments )
Parses and executes the given command-line arguments.
Parameters:
loadCommandByName( name ) -> module
Locates and imports a restblog subcommand by the given name.
Subcommands can be imported programmatically like this:
>>> import restblog.commandline
>>> command = restblog.commandline.loadCommandByName( 'list' )
>>> command.run( '--last=10' )
Returns a module object.