nikola.plugins.command package

Submodules

nikola.plugins.command.bootswatch_theme module

nikola.plugins.command.check module

Check the generated site.

class nikola.plugins.command.check.CommandCheck(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Check the generated site.

analyze(fname, find_sources=False, check_remote=False)

Analyze links on a page.

cache = {}
checked_remote_targets = {}
clean_files()

Remove orphaned files.

cmd_options = [{'long': 'check-links', 'help': 'Check for dangling links', 'name': 'links', 'type': <class 'bool'>, 'default': False, 'short': 'l'}, {'long': 'check-files', 'help': 'Check for unknown (orphaned and not generated) files', 'name': 'files', 'type': <class 'bool'>, 'default': False, 'short': 'f'}, {'long': 'clean-files', 'help': 'Remove all unknown files, use with caution', 'name': 'clean', 'default': False, 'type': <class 'bool'>}, {'long': 'find-sources', 'help': 'List possible source files for files with broken links.', 'name': 'find_sources', 'default': False, 'type': <class 'bool'>}, {'long': 'verbose', 'help': 'Be more verbose.', 'name': 'verbose', 'type': <class 'bool'>, 'default': False, 'short': 'v'}, {'long': 'remote', 'help': 'Check that remote links work.', 'name': 'remote', 'type': <class 'bool'>, 'default': False, 'short': 'r'}]
doc_purpose = 'check links and files in the generated site'
doc_usage = '[-v] (-l [--find-sources] [-r] | -f [--clean-files])'
existing_targets = set()
name = 'check'
scan_files()

Check files in the site, find missing and orphaned files.

Check links on the site.

nikola.plugins.command.check.fs_relpath_from_url_path(url_path)

Create a filesystem relative path from an URL path.

nikola.plugins.command.check.real_scan_files(site, cache=None)

Scan for files.

nikola.plugins.command.console module

Start debugging console.

class nikola.plugins.command.console.CommandConsole(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Start debugging console.

bpython(willful=True)

Run a bpython shell.

cmd_options = [{'long': 'bpython', 'help': 'Use bpython', 'name': 'bpython', 'type': <class 'bool'>, 'default': False, 'short': 'b'}, {'long': 'plain', 'help': 'Use IPython', 'name': 'ipython', 'type': <class 'bool'>, 'default': False, 'short': 'i'}, {'long': 'plain', 'help': 'Use the plain Python interpreter', 'name': 'plain', 'type': <class 'bool'>, 'default': False, 'short': 'p'}, {'long': 'command', 'help': 'Run a single command', 'name': 'command', 'type': <class 'str'>, 'default': None, 'short': 'c'}]
doc_description = 'The site engine is accessible as `site` and `nikola_site`, the config file as `conf`, and commands are available as `commands`.\nIf there is no console to use specified (as -b, -i, -p) it tries IPython, then falls back to bpython, and finally falls back to the plain Python console.'
doc_purpose = 'start an interactive Python console with access to your site'
header = 'Nikola v8.0.1 -- {0} Console (conf = configuration file, site, nikola_site = site engine, commands = nikola commands)'
ipython(willful=True)

Run an IPython shell.

name = 'console'
plain(willful=True)

Run a plain Python shell.

shells = ['ipython', 'bpython', 'plain']

nikola.plugins.command.deploy module

Deploy site.

class nikola.plugins.command.deploy.CommandDeploy(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Deploy site.

doc_description = 'Deploy the site by executing deploy commands from the presets listed on the command line. If no presets are specified, `default` is executed.'
doc_purpose = 'deploy the site'
doc_usage = '[preset [preset...]]'
name = 'deploy'

nikola.plugins.command.github_deploy module

Deploy site to GitHub Pages.

class nikola.plugins.command.github_deploy.CommandGitHubDeploy(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Deploy site to GitHub Pages.

cmd_options = [{'long': 'message', 'help': 'Commit message (default: Nikola auto commit.)', 'name': 'commit_message', 'default': 'Nikola auto commit.', 'type': <class 'str'>, 'short': 'm'}]
doc_description = 'This command can be used to deploy your site to GitHub Pages. It uses ghp-import to do this task. It also optionally commits to the source branch.\n\nConfiguration help: https://getnikola.com/handbook.html#deploying-to-github'
doc_purpose = 'deploy the site to GitHub Pages'
doc_usage = '[-m COMMIT_MESSAGE]'
name = 'github_deploy'
nikola.plugins.command.github_deploy.check_ghp_import_installed()

Check if ghp-import is installed.

nikola.plugins.command.github_deploy.uni_check_output(*args, **kwargs)

Run command and return output as Unicode (UTf-8).

nikola.plugins.command.import_wordpress module

Import a WordPress dump.

class nikola.plugins.command.import_wordpress.CommandImportWordpress(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`, :class:`nikola.plugins.basic_import.ImportMixin`

Import a WordPress dump.

all_tags = set()
cmd_options = [{'long': 'output-folder', 'help': 'Location to write imported content.', 'name': 'output_folder', 'default': 'new_site', 'short': 'o'}, {'long': 'no-drafts', 'help': "Don't import drafts", 'name': 'exclude_drafts', 'default': False, 'type': <class 'bool'>, 'short': 'd'}, {'long': 'exclude-privates', 'help': "Don't import private posts", 'name': 'exclude_privates', 'type': <class 'bool'>, 'default': False}, {'long': 'include-empty-items', 'help': 'Include empty posts and pages', 'name': 'include_empty_items', 'type': <class 'bool'>, 'default': False}, {'long': 'squash-newlines', 'help': 'Shorten multiple newlines in a row to only two newlines', 'name': 'squash_newlines', 'type': <class 'bool'>, 'default': False}, {'long': 'no-downloads', 'help': 'Do not try to download files for the import', 'name': 'no_downloads', 'type': <class 'bool'>, 'default': False}, {'long': 'download-auth', 'help': "Specify username and password for HTTP authentication (separated by ':')", 'name': 'download_auth', 'type': <class 'str'>, 'default': None}, {'long': 'qtranslate', 'help': 'Look for translations generated by qtranslate plugin', 'name': 'separate_qtranslate_content', 'type': <class 'bool'>, 'default': False}, {'long': 'translations_pattern', 'help': 'The pattern for translation files names', 'name': 'translations_pattern', 'type': <class 'str'>, 'default': None}, {'long': 'export-categories-as-categories', 'help': 'Export categories as categories, instead of treating them as tags', 'name': 'export_categories_as_categories', 'type': <class 'bool'>, 'default': False}, {'long': 'export-comments', 'help': 'Export comments as .wpcomment files', 'name': 'export_comments', 'type': <class 'bool'>, 'default': False}, {'long': 'html2text', 'help': 'Uses html2text (needs to be installed with pip) to transform WordPress posts to MarkDown during import', 'name': 'html2text', 'type': <class 'bool'>, 'default': False}, {'long': 'transform-to-markdown', 'help': 'Uses WordPress page compiler to transform WordPress posts to HTML and then use html2text to transform them to MarkDown during import', 'name': 'transform_to_markdown', 'type': <class 'bool'>, 'default': False}, {'long': 'transform-to-html', 'help': 'Uses WordPress page compiler to transform WordPress posts directly to HTML during import', 'name': 'transform_to_html', 'type': <class 'bool'>, 'default': False}, {'long': 'use-wordpress-compiler', 'help': 'Instead of converting posts to markdown, leave them as is and use the WordPress page compiler', 'name': 'use_wordpress_compiler', 'type': <class 'bool'>, 'default': False}, {'long': 'install-wordpress-compiler', 'help': 'Automatically installs the WordPress page compiler (either locally or in the new site) if required by other options.\nWarning: the compiler is GPL software!', 'name': 'install_wordpress_compiler', 'type': <class 'bool'>, 'default': False}, {'long': 'tag-sanitizing-strategy', 'help': 'lower: Convert all tag and category names to lower case\nfirst: Keep first spelling of tag or category name', 'name': 'tag_sanitizing_strategy', 'default': 'first'}, {'long': 'one-file', 'help': 'Save imported posts in the more modern one-file format.', 'name': 'one_file', 'type': <class 'bool'>, 'default': False}]
code_re1 = re.compile('\\[code.* lang.*?="(.*?)?".*\\](.*?)\\[/code\\]', re.MULTILINE|re.DOTALL)
code_re2 = re.compile('\\[sourcecode.* lang.*?="(.*?)?".*\\](.*?)\\[/sourcecode\\]', re.MULTILINE|re.DOTALL)
code_re3 = re.compile('\\[code.*?\\](.*?)\\[/code\\]', re.MULTILINE|re.DOTALL)
code_re4 = re.compile('\\[sourcecode.*?\\](.*?)\\[/sourcecode\\]', re.MULTILINE|re.DOTALL)
doc_purpose = 'import a WordPress dump'
doc_usage = '[options] wordpress_export_file'
download_url_content_to_file(url, dst_path)

Download some content (attachments) to a file.

classmethod get_channel_from_file(filename)

Get channel from XML file.

import_attachment(item, wordpress_namespace)

Import an attachment to the site.

import_postpage_item(item, wordpress_namespace, out_folder=None, attachments=None)

Take an item from the feed and creates a post file.

import_posts(channel)

Import posts into the site.

name = 'import_wordpress'
needs_config = False
populate_context(channel)

Populate context with config for the site.

process_item_if_attachment(item)

Process attachments.

process_item_if_post_or_page(item)

Process posts and pages.

classmethod read_xml_file(filename)

Read XML file into memory.

static transform_caption(content, use_html=False)

Transform captions.

transform_code(content)

Transform code blocks.

transform_content(content, post_format, attachments)

Transform content into appropriate format.

transform_multiple_newlines(content)

Replace multiple newlines with only two.

write_attachments_info(path, attachments)

Write attachments info file.

nikola.plugins.command.import_wordpress.get_text_tag(tag, name, default)

Get the text of an XML tag.

nikola.plugins.command.import_wordpress.install_plugin(site, plugin_name, output_dir=None, show_install_notes=False)

Install a Nikola plugin.

nikola.plugins.command.import_wordpress.separate_qtranslate_content(text)

Parse the content of a wordpress post or page and separate qtranslate languages.

qtranslate tags: <!–:LL–>blabla<!–:–>

nikola.plugins.command.init module

Create a new site.

class nikola.plugins.command.init.CommandInit(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Create a new site.

static ask_questions(target, demo=False)

Ask some questions about Nikola.

cmd_options = [{'long': 'quiet', 'help': 'Do not ask questions about config.', 'name': 'quiet', 'default': False, 'type': <class 'bool'>, 'short': 'q'}, {'long': 'demo', 'help': 'Create a site filled with example data.', 'name': 'demo', 'default': False, 'type': <class 'bool'>, 'short': 'd'}]
classmethod copy_sample_site(target)

Copy sample site data to target directory.

static create_configuration(target)

Create configuration file.

static create_configuration_to_string()

Return configuration file as a string.

classmethod create_empty_site(target)

Create an empty site with directories only.

doc_purpose = 'create a Nikola site in the specified folder'
doc_usage = '[--demo] [--quiet] folder'
name = 'init'
needs_config = False
nikola.plugins.command.init.format_default_translations_config(additional_languages)

Adapt TRANSLATIONS setting for all additional languages.

Return the string to configure NAVIGATION_LINKS.

nikola.plugins.command.init.prepare_config(config)

Parse sample config with JSON.

nikola.plugins.command.init.test_destination(destination, demo=False)

Check if the destination already exists, which can break demo site creation.

nikola.plugins.command.install_theme module

nikola.plugins.command.new_page module

Create a new page.

class nikola.plugins.command.new_page.CommandNewPage(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Create a new page.

cmd_options = [{'long': 'title', 'help': 'Title for the page.', 'name': 'title', 'type': <class 'str'>, 'default': '', 'short': 't'}, {'long': 'author', 'help': 'Author of the post.', 'name': 'author', 'type': <class 'str'>, 'default': '', 'short': 'a'}, {'help': 'Create the page with embedded metadata (single file format)', 'name': 'onefile', 'type': <class 'bool'>, 'default': False, 'short': '1'}, {'help': 'Create the page with separate metadata (two file format)', 'name': 'twofile', 'type': <class 'bool'>, 'default': False, 'short': '2'}, {'help': 'Open the page (and meta file, if any) in $EDITOR after creation.', 'name': 'edit', 'type': <class 'bool'>, 'default': False, 'short': 'e'}, {'long': 'format', 'help': 'Markup format for the page (use --available-formats for list)', 'name': 'content_format', 'type': <class 'str'>, 'default': '', 'short': 'f'}, {'long': 'available-formats', 'help': 'List all available input formats', 'name': 'available-formats', 'type': <class 'bool'>, 'default': False, 'short': 'F'}, {'long': 'import', 'help': 'Import an existing file instead of creating a placeholder', 'name': 'import', 'type': <class 'str'>, 'default': '', 'short': 'i'}]
doc_purpose = 'create a new page in the site'
doc_usage = '[options] [path]'
name = 'new_page'

nikola.plugins.command.new_post module

Create a new post.

class nikola.plugins.command.new_post.CommandNewPost(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Create a new post.

cmd_options = [{'long': 'page', 'help': 'Create a page instead of a blog post. (see also: `nikola new_page`)', 'name': 'is_page', 'type': <class 'bool'>, 'default': False, 'short': 'p'}, {'long': 'title', 'help': 'Title for the post.', 'name': 'title', 'type': <class 'str'>, 'default': '', 'short': 't'}, {'long': 'author', 'help': 'Author of the post.', 'name': 'author', 'type': <class 'str'>, 'default': '', 'short': 'a'}, {'long': 'tags', 'help': 'Comma-separated tags for the post.', 'name': 'tags', 'default': '', 'type': <class 'str'>}, {'help': 'Create the post with embedded metadata (single file format)', 'name': 'onefile', 'type': <class 'bool'>, 'default': False, 'short': '1'}, {'help': 'Create the post with separate metadata (two file format)', 'name': 'twofile', 'type': <class 'bool'>, 'default': False, 'short': '2'}, {'help': 'Open the post (and meta file, if any) in $EDITOR after creation.', 'name': 'edit', 'type': <class 'bool'>, 'default': False, 'short': 'e'}, {'long': 'format', 'help': 'Markup format for the post (use --available-formats for list)', 'name': 'content_format', 'type': <class 'str'>, 'default': '', 'short': 'f'}, {'long': 'available-formats', 'help': 'List all available input formats', 'name': 'available-formats', 'type': <class 'bool'>, 'default': False, 'short': 'F'}, {'help': 'Schedule the post based on recurrence rule', 'name': 'schedule', 'type': <class 'bool'>, 'default': False, 'short': 's'}, {'long': 'import', 'help': 'Import an existing file instead of creating a placeholder', 'name': 'import', 'type': <class 'str'>, 'default': '', 'short': 'i'}, {'long': 'date-path', 'help': 'Create post with date path (eg. year/month/day, see NEW_POST_DATE_PATH_FORMAT in config)', 'name': 'date-path', 'type': <class 'bool'>, 'default': False, 'short': 'd'}]
doc_purpose = 'create a new blog post or site page'
doc_usage = '[options] [path]'
filter_post_pages(compiler, is_post)

Return the correct entry from post_pages.

Information based on: * selected compilers * available compilers * post/page status

name = 'new_post'
print_compilers()

List all available compilers in a human-friendly format.

nikola.plugins.command.new_post.get_date(schedule=False, rule=None, last_date=None, tz=None, iso8601=False)

Return a date stamp, given a recurrence rule.

schedule - bool:
whether to use the recurrence rule or not
rule - str:
an iCal RRULE string that specifies the rule for scheduling posts
last_date - datetime:
timestamp of the last post
tz - tzinfo:
the timezone used for getting the current time.
iso8601 - bool:
whether to force ISO 8601 dates (instead of locale-specific ones)
nikola.plugins.command.new_post.get_default_compiler(is_post, compilers, post_pages)

Given compilers and post_pages, return a reasonable default compiler for this kind of post/page.

nikola.plugins.command.orphans module

List all orphans.

class nikola.plugins.command.orphans.CommandOrphans(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

List all orphans.

doc_description = 'List all orphans, i.e. all files that are in the output directory,\nbut are not generated by Nikola.\n\nOutput contains filenames only (it is passable to `xargs rm` or the like).'
doc_purpose = 'list all orphans'
name = 'orphans'

nikola.plugins.command.plugin module

Manage plugins.

class nikola.plugins.command.plugin.CommandPlugin(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Manage plugins.

cmd_options = [{'long': 'install', 'help': 'Install a plugin.', 'name': 'install', 'type': <class 'str'>, 'default': '', 'short': 'i'}, {'long': 'uninstall', 'help': 'Uninstall a plugin.', 'name': 'uninstall', 'type': <class 'str'>, 'default': '', 'short': 'r'}, {'long': 'list', 'help': 'Show list of available plugins.', 'name': 'list', 'type': <class 'bool'>, 'default': False, 'short': 'l'}, {'long': 'url', 'help': 'URL for the plugin repository (default: https://plugins.getnikola.com/v8/plugins.json)', 'name': 'url', 'type': <class 'str'>, 'default': 'https://plugins.getnikola.com/v8/plugins.json', 'short': 'u'}, {'long': 'user', 'help': 'Install user-wide, available for all sites.', 'name': 'user', 'default': False, 'type': <class 'bool'>}, {'long': 'upgrade', 'help': 'Upgrade all installed plugins.', 'name': 'upgrade', 'default': False, 'type': <class 'bool'>}, {'long': 'list-installed', 'help': 'List the installed plugins with their location.', 'name': 'list_installed', 'default': False, 'type': <class 'bool'>}]
do_install(url, name, show_install_notes=True)

Download and install a plugin.

do_uninstall(name)

Uninstall a plugin.

do_upgrade(url)

Upgrade all installed plugins.

doc_purpose = 'manage plugins'
doc_usage = '[-u url] [--user] [-i name] [-r name] [--upgrade] [-l] [--list-installed]'
get_json(url)

Download the JSON file with all plugins.

json = None
list_available(url)

List all available plugins.

list_installed()

List installed plugins.

name = 'plugin'
needs_config = False
output_dir = None

nikola.plugins.command.serve module

Start test server.

class nikola.plugins.command.serve.CommandServe(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Start test server.

cmd_options = ({'long': 'port', 'help': 'Port number (default: 8000)', 'name': 'port', 'default': 8000, 'type': <class 'int'>, 'short': 'p'}, {'long': 'address', 'help': 'Address to bind (default: 0.0.0.0 -- all local IPv4 interfaces)', 'name': 'address', 'type': <class 'str'>, 'default': '', 'short': 'a'}, {'long': 'detach', 'help': 'Detach from TTY (work in the background)', 'name': 'detach', 'type': <class 'bool'>, 'default': False, 'short': 'd'}, {'long': 'browser', 'help': 'Open the test server in a web browser', 'name': 'browser', 'type': <class 'bool'>, 'default': False, 'short': 'b'}, {'long': 'ipv6', 'help': 'Use IPv6', 'name': 'ipv6', 'type': <class 'bool'>, 'default': False, 'short': '6'})
dns_sd = None
doc_purpose = 'start the test webserver'
doc_usage = '[options]'
name = 'serve'
shutdown(signum=None, _frame=None)

Shut down the server that is running detached.

class nikola.plugins.command.serve.IPv6Server(server_address, RequestHandlerClass, bind_and_activate=True)

Bases: :class:`http.server.HTTPServer`

An IPv6 HTTPServer.

address_family = 10
class nikola.plugins.command.serve.OurHTTPRequestHandler(request, client_address, server)

Bases: :class:`http.server.SimpleHTTPRequestHandler`

A request handler, modified for Nikola.

extensions_map = {'': 'text/plain', '.%': 'application/x-trash', '.323': 'text/h323', '.3gp': 'video/3gpp', '.7z': 'application/x-7z-compressed', '.a': 'application/octet-stream', '.abw': 'application/x-abiword', '.ai': 'application/postscript', '.aif': 'audio/x-aiff', '.aifc': 'audio/x-aiff', '.aiff': 'audio/x-aiff', '.alc': 'chemical/x-alchemy', '.amr': 'audio/amr', '.anx': 'application/annodex', '.apk': 'application/vnd.android.package-archive', '.appcache': 'text/cache-manifest', '.application': 'application/x-ms-application', '.art': 'image/x-jg', '.asc': 'text/plain', '.asf': 'video/x-ms-asf', '.asn': 'chemical/x-ncbi-asn1-spec', '.aso': 'chemical/x-ncbi-asn1-binary', '.asx': 'video/x-ms-asf', '.atom': 'application/atom+xml', '.atomcat': 'application/atomcat+xml', '.atomsrv': 'application/atomserv+xml', '.au': 'audio/basic', '.avi': 'video/x-msvideo', '.awb': 'audio/amr-wb', '.axa': 'audio/annodex', '.axv': 'video/annodex', '.b': 'chemical/x-molconn-Z', '.bak': 'application/x-trash', '.bat': 'application/x-msdos-program', '.bcpio': 'application/x-bcpio', '.bib': 'text/x-bibtex', '.bin': 'application/octet-stream', '.bmp': 'image/x-ms-bmp', '.boo': 'text/x-boo', '.book': 'application/x-maker', '.brf': 'text/plain', '.bsd': 'chemical/x-crossfire', '.c': 'text/plain', '.c++': 'text/x-c++src', '.c3d': 'chemical/x-chem3d', '.cab': 'application/x-cab', '.cac': 'chemical/x-cache', '.cache': 'chemical/x-cache', '.cap': 'application/vnd.tcpdump.pcap', '.cascii': 'chemical/x-cactvs-binary', '.cat': 'application/vnd.ms-pki.seccat', '.cbin': 'chemical/x-cactvs-binary', '.cbr': 'application/x-cbr', '.cbz': 'application/x-cbz', '.cc': 'text/x-c++src', '.cda': 'application/x-cdf', '.cdf': 'application/x-cdf', '.cdr': 'image/x-coreldraw', '.cdt': 'image/x-coreldrawtemplate', '.cdx': 'chemical/x-cdx', '.cdy': 'application/vnd.cinderella', '.cef': 'chemical/x-cxf', '.cer': 'chemical/x-cerius', '.chm': 'chemical/x-chemdraw', '.chrt': 'application/x-kchart', '.cif': 'chemical/x-cif', '.class': 'application/java-vm', '.cls': 'text/x-tex', '.cmdf': 'chemical/x-cmdf', '.cml': 'chemical/x-cml', '.cod': 'application/vnd.rim.cod', '.com': 'application/x-msdos-program', '.cpa': 'chemical/x-compass', '.cpio': 'application/x-cpio', '.cpp': 'text/x-c++src', '.cpt': 'image/x-corelphotopaint', '.cr2': 'image/x-canon-cr2', '.crl': 'application/x-pkcs7-crl', '.crt': 'application/x-x509-ca-cert', '.crw': 'image/x-canon-crw', '.csd': 'audio/csound', '.csf': 'chemical/x-cache-csf', '.csh': 'text/x-csh', '.csm': 'chemical/x-csml', '.csml': 'chemical/x-csml', '.css': 'text/css', '.csv': 'text/csv', '.ctab': 'chemical/x-cactvs-binary', '.ctx': 'chemical/x-ctx', '.cu': 'application/cu-seeme', '.cub': 'chemical/x-gaussian-cube', '.cxf': 'chemical/x-cxf', '.cxx': 'text/x-c++src', '.d': 'text/x-dsrc', '.davmount': 'application/davmount+xml', '.dcm': 'application/dicom', '.dcr': 'application/x-director', '.ddeb': 'application/vnd.debian.binary-package', '.deb': 'application/x-debian-package', '.deploy': 'application/octet-stream', '.dif': 'video/dv', '.diff': 'text/x-diff', '.dir': 'application/x-director', '.djv': 'image/vnd.djvu', '.djvu': 'image/vnd.djvu', '.dl': 'video/dl', '.dll': 'application/x-msdos-program', '.dmg': 'application/x-apple-diskimage', '.dms': 'application/x-dms', '.doc': 'application/msword', '.docm': 'application/vnd.ms-word.document.macroEnabled.12', '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', '.dot': 'application/msword', '.dotm': 'application/vnd.ms-word.template.macroEnabled.12', '.dotx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', '.dv': 'video/dv', '.dvi': 'application/x-dvi', '.dx': 'chemical/x-jcamp-dx', '.dxr': 'application/x-director', '.emb': 'chemical/x-embl-dl-nucleotide', '.embl': 'chemical/x-embl-dl-nucleotide', '.eml': 'message/rfc822', '.ent': 'chemical/x-pdb', '.eot': 'application/vnd.ms-fontobject', '.eps': 'application/postscript', '.eps2': 'application/postscript', '.eps3': 'application/postscript', '.epsf': 'application/postscript', '.epsi': 'application/postscript', '.erf': 'image/x-epson-erf', '.es': 'application/ecmascript', '.etx': 'text/x-setext', '.exe': 'application/x-msdos-program', '.ez': 'application/andrew-inset', '.fb': 'application/x-maker', '.fbdoc': 'application/x-maker', '.fch': 'chemical/x-gaussian-checkpoint', '.fchk': 'chemical/x-gaussian-checkpoint', '.fig': 'application/x-xfig', '.flac': 'audio/flac', '.fli': 'video/fli', '.flv': 'video/x-flv', '.fm': 'application/x-maker', '.frame': 'application/x-maker', '.frm': 'application/x-maker', '.gal': 'chemical/x-gaussian-log', '.gam': 'chemical/x-gamess-input', '.gamin': 'chemical/x-gamess-input', '.gan': 'application/x-ganttproject', '.gau': 'chemical/x-gaussian-input', '.gcd': 'text/x-pcs-gcd', '.gcf': 'application/x-graphing-calculator', '.gcg': 'chemical/x-gcg8-sequence', '.gen': 'chemical/x-genbank', '.gf': 'application/x-tex-gf', '.gif': 'image/gif', '.gjc': 'chemical/x-gaussian-input', '.gjf': 'chemical/x-gaussian-input', '.gl': 'video/gl', '.gnumeric': 'application/x-gnumeric', '.gpt': 'chemical/x-mopac-graph', '.gsf': 'application/x-font', '.gsm': 'audio/x-gsm', '.gtar': 'application/x-gtar', '.gz': 'application/gzip', '.h': 'text/plain', '.h++': 'text/x-c++hdr', '.hdf': 'application/x-hdf', '.hh': 'text/x-c++hdr', '.hin': 'chemical/x-hin', '.hpp': 'text/x-c++hdr', '.hqx': 'application/mac-binhex40', '.hs': 'text/x-haskell', '.hta': 'application/hta', '.htc': 'text/x-component', '.htm': 'text/html', '.html': 'text/html', '.hwp': 'application/x-hwp', '.hxx': 'text/x-c++hdr', '.ica': 'application/x-ica', '.ice': 'x-conference/x-cooltalk', '.ico': 'image/vnd.microsoft.icon', '.ics': 'text/calendar', '.icz': 'text/calendar', '.ief': 'image/ief', '.iges': 'model/iges', '.igs': 'model/iges', '.iii': 'application/x-iphone', '.info': 'application/x-info', '.inp': 'chemical/x-gamess-input', '.ins': 'application/x-internet-signup', '.iso': 'application/x-iso9660-image', '.isp': 'application/x-internet-signup', '.ist': 'chemical/x-isostar', '.istr': 'chemical/x-isostar', '.jad': 'text/vnd.sun.j2me.app-descriptor', '.jam': 'application/x-jam', '.jar': 'application/java-archive', '.java': 'text/x-java', '.jdx': 'chemical/x-jcamp-dx', '.jmz': 'application/x-jmol', '.jng': 'image/x-jng', '.jnlp': 'application/x-java-jnlp-file', '.jp2': 'image/jp2', '.jpe': 'image/jpeg', '.jpeg': 'image/jpeg', '.jpf': 'image/jpx', '.jpg': 'image/jpeg', '.jpg2': 'image/jp2', '.jpm': 'image/jpm', '.jpx': 'image/jpx', '.js': 'application/javascript', '.json': 'application/json', '.kar': 'audio/midi', '.key': 'application/pgp-keys', '.kil': 'application/x-killustrator', '.kin': 'chemical/x-kinemage', '.kml': 'application/vnd.google-earth.kml+xml', '.kmz': 'application/vnd.google-earth.kmz', '.kpr': 'application/x-kpresenter', '.kpt': 'application/x-kpresenter', '.ksh': 'text/plain', '.ksp': 'application/x-kspread', '.kwd': 'application/x-kword', '.kwt': 'application/x-kword', '.latex': 'application/x-latex', '.lha': 'application/x-lha', '.lhs': 'text/x-literate-haskell', '.lin': 'application/bbolin', '.lsf': 'video/x-la-asf', '.lsx': 'video/x-la-asf', '.ltx': 'text/x-tex', '.ly': 'text/x-lilypond', '.lyx': 'application/x-lyx', '.lzh': 'application/x-lzh', '.lzx': 'application/x-lzx', '.m1v': 'video/mpeg', '.m3g': 'application/m3g', '.m3u': 'audio/x-mpegurl', '.m3u8': 'application/x-mpegURL', '.m4a': 'audio/mpeg', '.maker': 'application/x-maker', '.man': 'application/x-troff-man', '.manifest': 'application/x-ms-manifest', '.mbox': 'application/mbox', '.mcif': 'chemical/x-mmcif', '.mcm': 'chemical/x-macmolecule', '.mdb': 'application/msaccess', '.me': 'application/x-troff-me', '.mesh': 'model/mesh', '.mht': 'message/rfc822', '.mhtml': 'message/rfc822', '.mid': 'audio/midi', '.midi': 'audio/midi', '.mif': 'application/x-mif', '.mkv': 'video/x-matroska', '.mm': 'application/x-freemind', '.mmd': 'chemical/x-macromodel-input', '.mmf': 'application/vnd.smaf', '.mml': 'text/mathml', '.mmod': 'chemical/x-macromodel-input', '.mng': 'video/x-mng', '.moc': 'text/x-moc', '.mol': 'chemical/x-mdl-molfile', '.mol2': 'chemical/x-mol2', '.moo': 'chemical/x-mopac-out', '.mop': 'chemical/x-mopac-input', '.mopcrt': 'chemical/x-mopac-input', '.mov': 'video/quicktime', '.movie': 'video/x-sgi-movie', '.mp2': 'audio/mpeg', '.mp3': 'audio/mpeg', '.mp4': 'video/mp4', '.mpa': 'video/mpeg', '.mpc': 'chemical/x-mopac-input', '.mpe': 'video/mpeg', '.mpeg': 'video/mpeg', '.mpega': 'audio/mpeg', '.mpg': 'video/mpeg', '.mpga': 'audio/mpeg', '.mph': 'application/x-comsol', '.mpv': 'video/x-matroska', '.ms': 'application/x-troff-ms', '.msh': 'model/mesh', '.msi': 'application/x-msi', '.msp': 'application/octet-stream', '.msu': 'application/octet-stream', '.mvb': 'chemical/x-mopac-vib', '.mxf': 'application/mxf', '.mxu': 'video/vnd.mpegurl', '.nb': 'application/mathematica', '.nbp': 'application/mathematica', '.nc': 'application/x-netcdf', '.nef': 'image/x-nikon-nef', '.nwc': 'application/x-nwc', '.nws': 'message/rfc822', '.o': 'application/x-object', '.obj': 'application/octet-stream', '.oda': 'application/oda', '.odb': 'application/vnd.oasis.opendocument.database', '.odc': 'application/vnd.oasis.opendocument.chart', '.odf': 'application/vnd.oasis.opendocument.formula', '.odg': 'application/vnd.oasis.opendocument.graphics', '.odi': 'application/vnd.oasis.opendocument.image', '.odm': 'application/vnd.oasis.opendocument.text-master', '.odp': 'application/vnd.oasis.opendocument.presentation', '.ods': 'application/vnd.oasis.opendocument.spreadsheet', '.odt': 'application/vnd.oasis.opendocument.text', '.oga': 'audio/ogg', '.ogg': 'audio/ogg', '.ogv': 'video/ogg', '.ogx': 'application/ogg', '.old': 'application/x-trash', '.one': 'application/onenote', '.onepkg': 'application/onenote', '.onetmp': 'application/onenote', '.onetoc2': 'application/onenote', '.opf': 'application/oebps-package+xml', '.opus': 'audio/ogg', '.orc': 'audio/csound', '.orf': 'image/x-olympus-orf', '.otf': 'application/font-sfnt', '.otg': 'application/vnd.oasis.opendocument.graphics-template', '.oth': 'application/vnd.oasis.opendocument.text-web', '.otp': 'application/vnd.oasis.opendocument.presentation-template', '.ots': 'application/vnd.oasis.opendocument.spreadsheet-template', '.ott': 'application/vnd.oasis.opendocument.text-template', '.oza': 'application/x-oz-application', '.p': 'text/x-pascal', '.p12': 'application/x-pkcs12', '.p7c': 'application/pkcs7-mime', '.p7r': 'application/x-pkcs7-certreqresp', '.pac': 'application/x-ns-proxy-autoconfig', '.pas': 'text/x-pascal', '.pat': 'image/x-coreldrawpattern', '.patch': 'text/x-diff', '.pbm': 'image/x-portable-bitmap', '.pcap': 'application/vnd.tcpdump.pcap', '.pcf': 'application/x-font-pcf', '.pcf.Z': 'application/x-font-pcf', '.pcx': 'image/pcx', '.pdb': 'chemical/x-pdb', '.pdf': 'application/pdf', '.pfa': 'application/x-font', '.pfb': 'application/x-font', '.pfr': 'application/font-tdpfr', '.pfx': 'application/x-pkcs12', '.pgm': 'image/x-portable-graymap', '.pgn': 'application/x-chess-pgn', '.pgp': 'application/pgp-encrypted', '.pk': 'application/x-tex-pk', '.pl': 'text/x-perl', '.pls': 'audio/x-scpls', '.pm': 'text/x-perl', '.png': 'image/png', '.pnm': 'image/x-portable-anymap', '.pot': 'text/plain', '.potm': 'application/vnd.ms-powerpoint.template.macroEnabled.12', '.potx': 'application/vnd.openxmlformats-officedocument.presentationml.template', '.ppa': 'application/vnd.ms-powerpoint', '.ppam': 'application/vnd.ms-powerpoint.addin.macroEnabled.12', '.ppm': 'image/x-portable-pixmap', '.pps': 'application/vnd.ms-powerpoint', '.ppsm': 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', '.ppsx': 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', '.ppt': 'application/vnd.ms-powerpoint', '.pptm': 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', '.prf': 'application/pics-rules', '.prt': 'chemical/x-ncbi-asn1-ascii', '.ps': 'application/postscript', '.psd': 'image/x-photoshop', '.pwz': 'application/vnd.ms-powerpoint', '.py': 'text/plain', '.pyc': 'application/x-python-code', '.pyo': 'application/x-python-code', '.qgs': 'application/x-qgis', '.qt': 'video/quicktime', '.qtl': 'application/x-quicktimeplayer', '.ra': 'audio/x-realaudio', '.ram': 'audio/x-pn-realaudio', '.rar': 'application/rar', '.ras': 'image/x-cmu-raster', '.rb': 'application/x-ruby', '.rd': 'chemical/x-mdl-rdfile', '.rdf': 'application/rdf+xml', '.rdp': 'application/x-rdp', '.rgb': 'image/x-rgb', '.rm': 'audio/x-pn-realaudio', '.roff': 'application/x-troff', '.ros': 'chemical/x-rosdal', '.rpm': 'application/x-redhat-package-manager', '.rss': 'application/x-rss+xml', '.rtf': 'application/rtf', '.rtx': 'text/richtext', '.rxn': 'chemical/x-mdl-rxnfile', '.scala': 'text/x-scala', '.sce': 'application/x-scilab', '.sci': 'application/x-scilab', '.sco': 'audio/csound', '.scr': 'application/x-silverlight', '.sct': 'text/scriptlet', '.sd': 'chemical/x-mdl-sdfile', '.sd2': 'audio/x-sd2', '.sda': 'application/vnd.stardivision.draw', '.sdc': 'application/vnd.stardivision.calc', '.sdd': 'application/vnd.stardivision.impress', '.sdf': 'chemical/x-mdl-sdfile', '.sds': 'application/vnd.stardivision.chart', '.sdw': 'application/vnd.stardivision.writer', '.ser': 'application/java-serialized-object', '.sfd': 'application/vnd.font-fontforge-sfd', '.sfv': 'text/x-sfv', '.sgf': 'application/x-go-sgf', '.sgl': 'application/vnd.stardivision.writer-global', '.sgm': 'text/x-sgml', '.sgml': 'text/x-sgml', '.sh': 'text/x-sh', '.shar': 'application/x-shar', '.shp': 'application/x-qgis', '.shtml': 'text/html', '.shx': 'application/x-qgis', '.sid': 'audio/prs.sid', '.sig': 'application/pgp-signature', '.sik': 'application/x-trash', '.silo': 'model/mesh', '.sis': 'application/vnd.symbian.install', '.sisx': 'x-epoc/x-sisx-app', '.sit': 'application/x-stuffit', '.sitx': 'application/x-stuffit', '.skd': 'application/x-koan', '.skm': 'application/x-koan', '.skp': 'application/x-koan', '.skt': 'application/x-koan', '.sldm': 'application/vnd.ms-powerpoint.slide.macroEnabled.12', '.sldx': 'application/vnd.openxmlformats-officedocument.presentationml.slide', '.smi': 'application/smil+xml', '.smil': 'application/smil+xml', '.snd': 'audio/basic', '.so': 'application/octet-stream', '.spc': 'chemical/x-galactic-spc', '.spl': 'application/x-futuresplash', '.spx': 'audio/ogg', '.sql': 'application/x-sql', '.src': 'application/x-wais-source', '.srt': 'text/plain', '.stc': 'application/vnd.sun.xml.calc.template', '.std': 'application/vnd.sun.xml.draw.template', '.sti': 'application/vnd.sun.xml.impress.template', '.stl': 'application/sla', '.stw': 'application/vnd.sun.xml.writer.template', '.sty': 'text/x-tex', '.sv4cpio': 'application/x-sv4cpio', '.sv4crc': 'application/x-sv4crc', '.svg': 'image/svg+xml', '.svgz': 'image/svg+xml', '.sw': 'chemical/x-swissprot', '.swf': 'application/x-shockwave-flash', '.swfl': 'application/x-shockwave-flash', '.sxc': 'application/vnd.sun.xml.calc', '.sxd': 'application/vnd.sun.xml.draw', '.sxg': 'application/vnd.sun.xml.writer.global', '.sxi': 'application/vnd.sun.xml.impress', '.sxm': 'application/vnd.sun.xml.math', '.sxw': 'application/vnd.sun.xml.writer', '.t': 'application/x-troff', '.tar': 'application/x-tar', '.taz': 'application/x-gtar-compressed', '.tcl': 'text/x-tcl', '.tex': 'text/x-tex', '.texi': 'application/x-texinfo', '.texinfo': 'application/x-texinfo', '.text': 'text/plain', '.tgf': 'chemical/x-mdl-tgf', '.tgz': 'application/x-gtar-compressed', '.thmx': 'application/vnd.ms-officetheme', '.tif': 'image/tiff', '.tiff': 'image/tiff', '.tk': 'text/x-tcl', '.tm': 'text/texmacs', '.torrent': 'application/x-bittorrent', '.tr': 'application/x-troff', '.ts': 'video/MP2T', '.tsp': 'application/dsptype', '.tsv': 'text/tab-separated-values', '.ttf': 'application/font-sfnt', '.ttl': 'text/turtle', '.txt': 'text/plain', '.udeb': 'application/x-debian-package', '.uls': 'text/iuls', '.ustar': 'application/x-ustar', '.val': 'chemical/x-ncbi-asn1-binary', '.vcard': 'text/vcard', '.vcd': 'application/x-cdlink', '.vcf': 'text/vcard', '.vcs': 'text/x-vcalendar', '.vmd': 'chemical/x-vmd', '.vms': 'chemical/x-vamas-iso14976', '.vrm': 'x-world/x-vrml', '.vrml': 'x-world/x-vrml', '.vsd': 'application/vnd.visio', '.vss': 'application/vnd.visio', '.vst': 'application/vnd.visio', '.vsw': 'application/vnd.visio', '.wad': 'application/x-doom', '.wav': 'audio/x-wav', '.wax': 'audio/x-ms-wax', '.wbmp': 'image/vnd.wap.wbmp', '.wbxml': 'application/vnd.wap.wbxml', '.webm': 'video/webm', '.wiz': 'application/msword', '.wk': 'application/x-123', '.wm': 'video/x-ms-wm', '.wma': 'audio/x-ms-wma', '.wmd': 'application/x-ms-wmd', '.wml': 'text/vnd.wap.wml', '.wmlc': 'application/vnd.wap.wmlc', '.wmls': 'text/vnd.wap.wmlscript', '.wmlsc': 'application/vnd.wap.wmlscriptc', '.wmv': 'video/x-ms-wmv', '.wmx': 'video/x-ms-wmx', '.wmz': 'application/x-ms-wmz', '.woff': 'application/font-woff', '.wp5': 'application/vnd.wordperfect5.1', '.wpd': 'application/vnd.wordperfect', '.wrl': 'x-world/x-vrml', '.wsc': 'text/scriptlet', '.wsdl': 'application/xml', '.wvx': 'video/x-ms-wvx', '.wz': 'application/x-wingz', '.x3d': 'model/x3d+xml', '.x3db': 'model/x3d+binary', '.x3dv': 'model/x3d+vrml', '.xbm': 'image/x-xbitmap', '.xcf': 'application/x-xcf', '.xcos': 'application/x-scilab-xcos', '.xht': 'application/xhtml+xml', '.xhtml': 'application/xhtml+xml', '.xlam': 'application/vnd.ms-excel.addin.macroEnabled.12', '.xlb': 'application/vnd.ms-excel', '.xls': 'application/vnd.ms-excel', '.xlsb': 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', '.xlsm': 'application/vnd.ms-excel.sheet.macroEnabled.12', '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', '.xlt': 'application/vnd.ms-excel', '.xltm': 'application/vnd.ms-excel.template.macroEnabled.12', '.xltx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', '.xml': 'application/xml', '.xpdl': 'application/xml', '.xpi': 'application/x-xpinstall', '.xpm': 'image/x-xpixmap', '.xsd': 'application/xml', '.xsl': 'application/xslt+xml', '.xslt': 'application/xslt+xml', '.xspf': 'application/xspf+xml', '.xtel': 'chemical/x-xtel', '.xul': 'application/vnd.mozilla.xul+xml', '.xwd': 'image/x-xwindowdump', '.xyz': 'chemical/x-xyz', '.xz': 'application/x-xz', '.zip': 'application/zip', '.zmt': 'chemical/x-mopac-input', '.~': 'application/x-trash'}
log_message(*args)

Log messages. Or not, depending on a setting.

quiet = False
send_head()

Send response code and MIME header.

This is common code for GET and HEAD commands.

Return value is either a file object (which has to be copied to the outputfile by the caller unless the command was HEAD, and must be closed by the caller under all circumstances), or None, in which case the caller has nothing further to do.

nikola.plugins.command.status module

Display site status.

class nikola.plugins.command.status.CommandStatus(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Display site status.

cmd_options = [{'long': 'list-drafts', 'help': 'List all drafts', 'name': 'list_drafts', 'type': <class 'bool'>, 'default': False, 'short': 'd'}, {'long': 'list-modified', 'help': 'List all modified files since last deployment', 'name': 'list_modified', 'type': <class 'bool'>, 'default': False, 'short': 'm'}, {'long': 'list-private', 'help': 'List all private posts', 'name': 'list_private', 'type': <class 'bool'>, 'default': False, 'short': 'p'}, {'long': 'list-published', 'help': 'List all published posts', 'name': 'list_published', 'type': <class 'bool'>, 'default': False, 'short': 'P'}, {'long': 'list-scheduled', 'help': 'List all scheduled posts', 'name': 'list_scheduled', 'type': <class 'bool'>, 'default': False, 'short': 's'}]
doc_description = 'Show information about the posts and site deployment.'
doc_purpose = 'display site status'
doc_usage = '[-d|--list-drafts] [-m|--list-modified] [-p|--list-private] [-P|--list-published] [-s|--list-scheduled]'
human_time(dt)

Translate time into a human-friendly representation.

logger = None
name = 'status'

nikola.plugins.command.theme module

Manage themes.

class nikola.plugins.command.theme.CommandTheme(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Manage themes.

cmd_options = [{'long': 'install', 'help': 'Install a theme.', 'name': 'install', 'type': <class 'str'>, 'default': '', 'short': 'i'}, {'long': 'uninstall', 'help': 'Uninstall a theme.', 'name': 'uninstall', 'type': <class 'str'>, 'default': '', 'short': 'r'}, {'long': 'list', 'help': 'Show list of available themes.', 'name': 'list', 'type': <class 'bool'>, 'default': False, 'short': 'l'}, {'long': 'list-installed', 'help': 'List the installed themes with their location.', 'name': 'list_installed', 'default': False, 'type': <class 'bool'>}, {'long': 'url', 'help': 'URL for the theme repository (default: https://themes.getnikola.com/v8/themes.json)', 'name': 'url', 'type': <class 'str'>, 'default': 'https://themes.getnikola.com/v8/themes.json', 'short': 'u'}, {'long': 'get-path', 'help': 'Print the path for installed theme', 'name': 'getpath', 'type': <class 'str'>, 'default': '', 'short': 'g'}, {'long': 'copy-template', 'help': 'Copy a built-in template into templates/ or your theme', 'name': 'copy-template', 'type': <class 'str'>, 'default': '', 'short': 'c'}, {'long': 'new', 'help': 'Create a new theme', 'name': 'new', 'type': <class 'str'>, 'default': '', 'short': 'n'}, {'long': 'engine', 'help': 'Engine to use for new theme (mako or jinja -- default: mako)', 'name': 'new_engine', 'default': 'mako', 'type': <class 'str'>}, {'long': 'parent', 'help': 'Parent to use for new theme (default: base)', 'name': 'new_parent', 'default': 'base', 'type': <class 'str'>}, {'long': 'legacy-meta', 'help': 'Create legacy meta files for new theme', 'name': 'new_legacy_meta', 'default': False, 'type': <class 'bool'>}]
copy_template(template)

Copy the named template file from the parent to a local theme or to templates/.

do_install(name, data)

Download and install a theme.

do_install_deps(url, name)

Install themes and their dependencies.

do_uninstall(name)

Uninstall a theme.

doc_purpose = 'manage themes'
doc_usage = '[-u url] [-i theme_name] [-r theme_name] [-l] [--list-installed] [-g] [-n theme_name] [-c template_name]'
get_json(url)

Download the JSON file with all plugins.

get_path(name)

Get path for an installed theme.

json = None
list_available(url)

List all available themes.

list_installed()

List all installed themes.

name = 'theme'
new_theme(name, engine, parent, create_legacy_meta=False)

Create a new theme.

output_dir = 'themes'

nikola.plugins.command.version module

Print Nikola version.

class nikola.plugins.command.version.CommandVersion(*args, **kwargs)

Bases: :class:`nikola.plugin_categories.Command`

Print Nikola version.

cmd_options = [{'long': 'check', 'help': 'Check for new versions.', 'name': 'check', 'default': False, 'type': <class 'bool'>, 'short': ''}]
doc_purpose = 'print the Nikola version number'
doc_usage = '[--check]'
name = 'version'
needs_config = False

Module contents

Commands for Nikola.