The impact of MiFID II
This article was written based on a request from UQBS marketing by the ASX. An excerpt was subsequently published in the Listed@ASX Winter Edition 2018. Below is the full copy of the article
This article was written based on a request from UQBS marketing by the ASX. An excerpt was subsequently published in the Listed@ASX Winter Edition 2018. Below is the full copy of the article
Nikola is a static site and blog generator. So is Jekyll. While I like what we have done with Nikola, I do admit that Jekyll (and others!) have many more, and nicer themes than Nikola does.
This document is an attempt at making it easier for 3rd parties (that means you people! ;-) to create themes. Since I suck at designing websites, I asked for opinions on themes to port, and got some feedback. Since this is Not So Hard™, I will try to make time to port a few and see what happens.
If you are looking for a reference, check out Theming reference and Template variables.
Today’s theme is Lanyon which is written by @mdo and released under a MIT license, which is liberal enough.
So, let’s get started.
The first step in porting a theme is making the original theme work. Lanyon is awesome in that its GitHub project is a full site!
So:
# Get jekyll sudo apt-get install jekyll # Get Lanyon git clone git@github.com:poole/lanyon.git # Build it cd lanyon && jekyll build # Look at it jekyll serve & google-chrome http://localhost:4000
If you do not want to install Jekyll, you can also see it in action at http://lanyon.getpoole.com/
Some things jump to my mind:
This is one fine looking theme
Very clear and readable
Nice hidden navigation-thingy
Also, from looking at the project’s README it supports some nice configuration options:
Color schemes
Reverse layout
Sidebar overlay instead of push
Open the sidebar by default, or on a per-page basis by using its metadata
Let’s try to make all those nice things survive the porting.
Nikola has a nice, clean, base theme from which you can start when writing your own theme. Why start from that instead of from a clean slate? Because theme inheritance is going to save you a ton of work, that’s why. If you start from scratch you won’t be able to build anything until you have a bunch of templates written. Starting from base, you just need to hack on the things you need to change.
First, we create a site with some content in it. We’ll use the nikola init
wizard (with the --demo
option) for that:
$ nikola init --demo lanyon-port Creating Nikola Site ==================== This is Nikola v7.8.0. We will now ask you a few easy questions about your new site. If you do not want to answer and want to go with the defaults instead, simply restart with the `-q` parameter. --- Questions about the site --- Site title [My Nikola Site]: Site author [Nikola Tesla]: Site author's e-mail [n.tesla@example.com]: Site description [This is a demo site for Nikola.]: Site URL [https://example.com/]: --- Questions about languages and locales --- We will now ask you to provide the list of languages you want to use. Please list all the desired languages, comma-separated, using ISO 639-1 codes. The first language will be used as the default. Type '?' (a question mark, sans quotes) to list available languages. Language(s) to use [en]: Please choose the correct time zone for your blog. Nikola uses the tz database. You can find your time zone here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones Time zone [UTC]: Current time in UTC: 16:02:07 Use this time zone? [Y/n] --- Questions about comments --- You can configure comments now. Type '?' (a question mark, sans quotes) to list available comment systems. If you do not want any comments, just leave the field blank. Comment system: That's it, Nikola is now configured. Make sure to edit conf.py to your liking. If you are looking for themes and addons, check out https://themes.getnikola.com/ and https://plugins.getnikola.com/. Have fun! [2015-05-28T16:02:08Z] INFO: init: A new site with example data has been created at lanyon-port. [2015-05-28T16:02:08Z] INFO: init: See README.txt in that folder for more information.
Then, we create an empty theme inheriting from base. This theme will use Mako templates. If you prefer Jinja2,
then you should use base-jinja
as a parent and jinja
as engine instead:
$ cd lanyon-port/ $ nikola theme -n lanyon --parent base --engine mako
Edit conf.py
and set THEME = 'lanyon'
. Also set USE_BUNDLES = False
(just do it for now, we’ll get to bundles later).
Also, if you intend to publish your theme on the Index, or want to use it with older versions (v7.8.5 or older), use the --legacy-meta
option for nikola theme -n
.
You can now build that site using nikola build
and it will look like this:
The next step is to know exactly how Lanyon’s pages work. To do this, we read its HTML. First let’s look at the head element:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us"> <head> <link href="http://gmpg.org/xfn/11" rel="profile"> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <!-- Enable responsiveness on mobile devices--> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1"> <title> Lanyon · A Jekyll theme </title> <!-- CSS --> <link rel="stylesheet" href="/public/css/poole.css"> <link rel="stylesheet" href="/public/css/syntax.css"> <link rel="stylesheet" href="/public/css/lanyon.css"> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700|PT+Sans:400"> <!-- Icons --> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/public/apple-touch-icon-144-precomposed.thumbnail.png"> <link rel="shortcut icon" href="/public/favicon.ico"> <!-- RSS --> <link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml"> <!-- Google Analytics --> [...] </head>
The interesting part there is that it loads a few CSS files. If you check the source of your Nikola site, you will see something fairly similar:
<!DOCTYPE html> <html prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article# " vocab="http://ogp.me/ns" lang="en"> <head> <meta charset="utf-8"> <meta name="description" content="This is a demo site for Nikola."> <meta name="viewport" content="width=device-width"> <title>My Nikola Site | My Nikola Site</title> <link href="assets/css/rst_base.css" rel="stylesheet" type="text/css"> <link href="assets/css/code.css" rel="stylesheet" type="text/css"> <link href="assets/css/theme.css" rel="stylesheet" type="text/css"> <link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml"> <link rel="canonical" href="https://example.com/index.html"> <!--[if lt IE 9]><script src="assets/js/html5.js"></script><![endif]--><link rel="prefetch" href="posts/welcome-to-nikola.html" type="text/html"> </head>
Luckily, since this is all under a very liberal license, we can just copy these CSS files into Nikola, adapting the paths a little so that they follow our conventions:
$ mkdir -p themes/lanyon/assets/css $ cp ../lanyon/public/css/poole.css themes/lanyon/assets/css/ $ cp ../lanyon/public/css/lanyon.css themes/lanyon/assets/css/
Notice I am not copying syntax.css
? That’s because Nikola handles that styles for syntax highlighting
in a particular way, using a setting called CODE_COLOR_SCHEME
where you can configure
what color scheme the syntax highlighter uses. You can use your own assets/css/code.css
if you
don’t like the provided ones.
Nikola requires assets/css/rst_base.css
and assets/css/code.css
to function properly.
We will also add themes for Jupyter (assets/css/ipython.min.css
and assets/css/nikola_ipython.css
) into the template; note that they are
activated only if you configured your POSTS
/PAGES
with ipynb support.
There’s also assets/css/nikola_rst.css
, which adds Bootstrap 3-style reST notes etc.
But how do I tell our lanyon theme to use those CSS files instead of whatever it’s using now? By giving our theme its own base_helper.tmpl.
That file is a template used to generate parts of the pages. It’s large and
complicated but we don’t need to change a lot of it. First, make a copy in your
theme (note this command requires setting your THEME
in conf.py
to
lanyon
):
$ nikola theme -c base_helper.tmpl
The part we want to change is this:
<%def name="html_stylesheets()"> %if use_bundles: %if use_cdn: <link href="/assets/css/all.css" rel="stylesheet" type="text/css"> %else: <link href="/assets/css/all-nocdn.css" rel="stylesheet" type="text/css"> %endif %else: <link href="/assets/css/rst_base.css" rel="stylesheet" type="text/css"> <link href="/assets/css/nikola_rst.css" rel="stylesheet" type="text/css"> <link href="/assets/css/code.css" rel="stylesheet" type="text/css"> <link href="/assets/css/theme.css" rel="stylesheet" type="text/css"> %if has_custom_css: <link href="/assets/css/custom.css" rel="stylesheet" type="text/css"> %endif %endif % if needs_ipython_css: <link href="/assets/css/ipython.min.css" rel="stylesheet" type="text/css"> <link href="/assets/css/nikola_ipython.css" rel="stylesheet" type="text/css"> % endif </%def>
And we will change it so it uses the lanyon styles instead of theme.css (again, ignore the bundles for now!):
<%def name="html_stylesheets()"> %if use_bundles: <link href="/assets/css/all.css" rel="stylesheet" type="text/css"> %else: <link href="/assets/css/rst_base.css" rel="stylesheet" type="text/css"> <link href="/assets/css/nikola_rst.css" rel="stylesheet" type="text/css"> <link href="/assets/css/poole.css" rel="stylesheet" type="text/css"> <link href="/assets/css/lanyon.css" rel="stylesheet" type="text/css"> <link href="/assets/css/code.css" rel="stylesheet" type="text/css"> %if has_custom_css: <link href="/assets/css/custom.css" rel="stylesheet" type="text/css"> %endif %endif % if needs_ipython_css: <link href="/assets/css/ipython.min.css" rel="stylesheet" type="text/css"> <link href="/assets/css/nikola_ipython.css" rel="stylesheet" type="text/css"> % endif <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Serif:400,400italic,700|PT+Sans:400"> </%def>
This is trickier but should be no problem for people with a basic understanding of HTML and a desire to make a theme!
Lanyon’s content is split in two parts: a sidebar and the rest. The sidebar looks like this (shortened for comprehension):
<body> <!-- Target for toggling the sidebar `.sidebar-checkbox` is for regular styles, `#sidebar-checkbox` for behavior. --> <input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox"> <!-- Toggleable sidebar --> <div class="sidebar" id="sidebar"> <div class="sidebar-item"> <p>A reserved <a href="http://jekyllrb.com" target="_blank">Jekyll</a> theme that places the utmost gravity on content with a hidden drawer. Made by <a href="https://twitter.com/mdo" target="_blank">@mdo</a>.</p> </div> <nav class="sidebar-nav"> <a class="sidebar-nav-item active" href="/">Home</a> <a class="sidebar-nav-item" href="/about/">About</a> [...] </nav> </div>
So, a plain body, with an input element that controls the sidebar, a div which is the sidebar itself. Inside that, div.sidebar-item for items, and a nav with "navigational links". This is followed by the "masthead" and the content itself, which we will look at in a bit.
If we look for the equivalent code in Nikola’s side, we see this:
<body> <a href="#content" class="sr-only sr-only-focusable">Skip to main content</a> <div id="container"> <header id="header" role="banner"> <h1 id="brand"><a href="https://example.com/" title="My Nikola Site" rel="home"> <span id="blog-title">My Nikola Site</span> </a></h1> <nav id="menu" role="navigation"><ul> <li><a href="../archive.html">Archive</a></li> <li><a href="../categories/index.html">Tags</a></li> <li><a href="../rss.xml">RSS feed</a></li>
So Nikola has the "masthead" above the nav element, and uses list elements in nav instead of bare links. Not all that different is it?
Let’s make it lanyon-like! We will need 2 more templates: base.tmpl and base_header.tmpl. Get them and put them in your themes/lanyon/templates
folder.
Let’s look at base.tmpl
first. It’s short and nice, it looks like a webpage without
all the interesting stuff:
## -*- coding: utf-8 -*- <%namespace name="base" file="base_helper.tmpl" import="*"/> <%namespace name="header" file="base_header.tmpl" import="*"/> <%namespace name="footer" file="base_footer.tmpl" import="*"/> ${set_locale(lang)} ${base.html_headstart()} <%block name="extra_head"> ### Leave this block alone. </%block> ${template_hooks['extra_head']()} </head> <body> <a href="#content" class="sr-only sr-only-focusable">${messages("Skip to main content")}</a> <div id="container"> ${header.html_header()} <main id="content" role="main"> <%block name="content"></%block> </main> ${footer.html_footer()} </div> ${body_end} ${template_hooks['body_end']()} ${base.late_load_js()} </body> </html>
That link which says "Skip to main content" is very important for accessibility, so we will leave it in
place. But below, you can see how it creates the "container" div we see in the Nikola page, and the content is
created by html_header()
which is defined in base_header.tmpl
The actual nav
element is done
by the html_navigation_links
function out of the NAVIGATION_LINKS
and NAVIGATION_ALT_LINKS
options. (Let's put the alt links after regular ones; Bootstrap puts it on the right side, for example.)
So, first, lets change that base template to be more lanyon-like:
## -*- coding: utf-8 -*- <%namespace name="base" file="base_helper.tmpl" import="*"/> <%namespace name="header" file="base_header.tmpl" import="*"/> <%namespace name="footer" file="base_footer.tmpl" import="*"/> ${set_locale(lang)} ${base.html_headstart()} <%block name="extra_head"> ### Leave this block alone. </%block> ${template_hooks['extra_head']()} </head> <body> <a href="#content" class="sr-only sr-only-focusable">${messages("Skip to main content")}</a> <!-- Target for toggling the sidebar `.sidebar-checkbox` is for regular styles, `#sidebar-checkbox` for behavior. --> <input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox"> <!-- Toggleable sidebar --> <div class="sidebar" id="sidebar"> <div class="sidebar-item"> <p>A reserved <a href="http://getnikola.com" target="_blank">Nikola</a> theme that places the utmost gravity on content with a hidden drawer. Made by <a href="https://twitter.com/mdo" target="_blank">@mdo</a> for Jekyll, ported to Nikola by <a href="https://twitter.com/ralsina" target="_blank">@ralsina</a>.</p> </div> ${header.html_navigation_links()} </div> <main id="content" role="main"> <%block name="content"></%block> </main> ${footer.html_footer()} ${body_end} ${template_hooks['body_end']()} ${base.late_load_js()} </body> </html>
One problem, which causes that yellow color in the sidebar is a CSS conflict.
We are loading rst_base.css
which specifies
the background color of div.sidebar
which is more specific than
lanyon.css
, which specifies for .sidebar
alone.
There are many ways to fix this, I chose to change lanyon.css to also use div.sidebar:
div.sidebar,.sidebar { position: fixed; top: 0; bottom: 0; left: -14rem; width: 14rem; [...]
This is annoying but it will happen when you just grab CSS from different places. The "Inspect Element" feature of your web browser is your best friend for these situations.
Another problem is that the contents of the nav element are wrong. They are not bare links. We will fix that in
base_header.html
, like this:
<%def name="html_navigation_links()"> <nav id="menu" role="navigation" class="sidebar-nav"> %for url, text in navigation_links[lang]: <a class="sidebar-nav-item" href="${url}">${text}</a> %endfor ${template_hooks['menu']()} %for url, text in navigation_alt_links[lang]: <a class="sidebar-nav-item" href="${url}">${text}</a> %endfor ${template_hooks['menu_alt']()} </nav> </%def>
Note: this means this theme will not support submenus in navigation. If you want that, I’ll happily take a patch.
Now let’s look at the content. In Lanyon, this is how the "main" content looks:
<!-- Wrap is the content to shift when toggling the sidebar. We wrap the content to avoid any CSS collisions with our real content. --> <div class="wrap"> <div class="masthead"> <div class="container"> <h3 class="masthead-title"> <a href="/" title="Home">Lanyon</a> <small>A Jekyll theme</small> </h3> </div> </div> <div class="container content"> <div class="post"> <h1 class="post-title">Introducing Lanyon</h1> <span class="post-date">02 Jan 2014</span> <p>Lanyon is an unassuming <a href="http://jekyllrb.com">Jekyll</a> theme [...] </div> </div> </div> <label for="sidebar-checkbox" class="sidebar-toggle"></label> </body> </html>
Everything inside the "container content" div is… the content. The rest is a masthead with the site title
and at the bottom a label for the sidebar toggle. Easy to do in base.tmpl
(only showing the relevant part):
<!-- Wrap is the content to shift when toggling the sidebar. We wrap the content to avoid any CSS collisions with our real content. --> <div class="wrap"> <div class="masthead"> <div class="container"> <h3 class="masthead-title"> <a href="/" title="Home">Lanyon</a> <small>A Jekyll theme</small> </h3> </div> </div> <div class="container content" id="content"> <%block name="content"></%block> </div> </div> <label for="sidebar-checkbox" class="sidebar-toggle"></label> ${footer.html_footer()} ${body_end} ${template_hooks['body_end']()} ${base.late_load_js()} </body> </html>
The sidebar looks bad because of yet more CSS conflicts with rst_base.css
. By
adding some extra styling in lanyon.css
, it will look better.
/* Style and "hide" the sidebar */ div.sidebar, .sidebar { position: fixed; top: 0; bottom: 0; left: -14rem; width: 14rem; visibility: hidden; overflow-y: auto; padding: 0; margin: 0; border: none; font-family: "PT Sans", Helvetica, Arial, sans-serif; font-size: .875rem; /* 15px */ color: rgba(255,255,255,.6); background-color: #202020; -webkit-transition: all .3s ease-in-out; transition: all .3s ease-in-out; }
Also, the accessibility link on top is visible when it should not. That’s
because we removed theme.css
from the base theme, and with it, we lost a
couple of classes. We can add them in lanyon.css
, along with others used by other
pieces of the site:
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; } .sr-only-focusable:active, .sr-only-focusable:focus { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; } .breadcrumb { padding: 8px 15px; margin-bottom: 20px; list-style: none; } .breadcrumb > li { display: inline-block; margin-right: 0; margin-left: 0; } .breadcrumb > li:after { content: ' / '; color: #888; } .breadcrumb > li:last-of-type:after { content: ''; margin-left: 0; } .thumbnails > li { display: inline-block; margin-right: 10px; } .thumbnails > li:last-of-type { margin-right: 0; }
One clear problem is that the title "Lanyon · A Jekyll theme" is set in the
theme itself. We don’t do that sort of thing in Nikola, we have settings for
that. So, let’s use them. There is a html_site_title
function in
base_helper.tmpl
which is just the thing. So we change base.tmpl to use it:
<div class="wrap"> <div class="masthead"> <div class="container"> ${header.html_site_title()} </div> </div>
That’s a <h1>
instead of a <h3>
like Lanyon does, but hey, it’s the
right thing to do. If you want to go with an <h3>
, just
change html_site_title
itself.
And now we more or less have the correct page layout and styles. Except for a rather large thing…
You can see in the previous screenshot that text still looks quite different in our port: Serif versus Sans-Serif content, and the titles have different colors!
Let’s start with the titles. Here’s how they look in Lanyon:
<h3 class="masthead-title"> <a href="/" title="Home">Lanyon</a> <small>A Jekyll theme</small> </h3>
Versus our port:
<h1 id="brand"><a href="https://example.com/" title="My Nikola Site" rel="home">
So, it looks like we will have to fix html_site_title
after all:
<%def name="html_site_title()"> <h3 id="brand" class="masthead-title"> <a href="${abs_link(_link("root", None, lang))}" title="${blog_title}" rel="home">${blog_title}</a> </h3> </%def>
As for the actual content, that’s not in any of the templates we have seen so far. The page you see is an "index.tmpl" page, which means it’s a list of blog posts shown one below the other. Obviously it’s not doing things in the way the Lanyon CSS expects it to. Here’s the original, which you can find in Nikola’s source code:
## -*- coding: utf-8 -*- <%namespace name="helper" file="index_helper.tmpl"/> <%namespace name="comments" file="comments_helper.tmpl"/> <%inherit file="base.tmpl"/> <%block name="extra_head"> ${parent.extra_head()} % if posts and (permalink == '/' or permalink == '/' + index_file): <link rel="prefetch" href="${posts[0].permalink()}" type="text/html"> % endif </%block> <%block name="content"> <%block name="content_header"></%block> <div class="postindex"> % for post in posts: <article class="h-entry post-${post.meta('type')}"> <header> <h1 class="p-name entry-title"><a href="${post.permalink()}" class="u-url">${post.title()|h}</a></h1> <div class="metadata"> <p class="byline author vcard"><span class="byline-name fn">${post.author()}</span></p> <p class="dateline"><a href="${post.permalink()}" rel="bookmark"><time class="published dt-published" datetime="${post.date.isoformat()}" title="${post.formatted_date(date_format)}">${post.formatted_date(date_format)}</time></a></p> % if not post.meta('nocomments') and site_has_comments: <p class="commentline">${comments.comment_link(post.permalink(), post._base_path)} % endif </div> </header> %if index_teasers: <div class="p-summary entry-summary"> ${post.text(teaser_only=True)} %else: <div class="e-content entry-content"> ${post.text(teaser_only=False)} %endif </div> </article> % endfor </div> ${helper.html_pager()} ${comments.comment_link_script()} ${helper.mathjax_script(posts)} </%block>
And this is how it looks after I played with it for a while, making it generate code that looks closer to the Lanyon original:
<%block name="content"> <%block name="content_header"></%block> <div class="posts"> % for post in posts: <article class="post h-entry post-${post.meta('type')}"> <header> <h1 class="post-title p-name"><a href="${post.permalink()}" class="u-url">${post.title()|h}</a></h1> <div class="metadata"> <p class="byline author vcard"><span class="byline-name fn">${post.author()}</span></p> <p class="dateline"><a href="${post.permalink()}" rel="bookmark"><time class="post-date published dt-published" datetime="${post.date.isoformat()}" title="${post.formatted_date(date_format)}">${post.formatted_date(date_format)}</time></a></p> % if not post.meta('nocomments') and site_has_comments: <p class="commentline">${comments.comment_link(post.permalink(), post._base_path)} % endif </div> </header> %if index_teasers: <div class="p-summary entry-summary"> ${post.text(teaser_only=True)} %else: <div class="e-content entry-content"> ${post.text(teaser_only=False)} %endif </div> </article> % endfor </div> ${helper.html_pager()} ${comments.comment_link_script()} ${helper.mathjax_script(posts)} </%block>
With these changes, it looks… similar?
Similar changes (basically adding class names to elements) needed to be done in post_header.tmpl
:
<%def name="html_post_header()"> <header> ${html_title()} <div class="metadata"> <p class="byline author vcard"><span class="byline-name fn">${post.author()}</span></p> <p class="dateline"><a href="${post.permalink()}" rel="bookmark"><time class="post-date published dt-published" datetime="${post.date.isoformat()}" itemprop="datePublished" title="${post.formatted_date(date_format)}">${post.formatted_date(date_format)}</time></a></p> % if not post.meta('nocomments') and site_has_comments: <p class="commentline">${comments.comment_link(post.permalink(), post._base_path)} % endif %if post.description(): <meta name="description" itemprop="description" content="${post.description()}"> %endif </div> ${html_translations(post)} </header> </%def>
The original Lanyon theme supports some personalization options. It suggests you do them by tweaking the templates, and you can also do that in the Nikola port. But we prefer to use options for that, so that you can get a later, better version of the theme and it will still "just work".
Let’s see the color schemes first. They apply easily, just tweak your body
element like this:
<body class="theme-base-08"> ... </body>
We can tweak base.tmpl
to do just that:
% if lanyon_subtheme: <body class="${lanyon_subtheme}"> %else: <body> %endif
And then we can put the options in conf.py’s GLOBAL_CONTEXT
:
GLOBAL_CONTEXT = { "lanyon_subtheme": "theme-base-08" }
Doing the same for layout-reverse, sidebar-overlay and the rest is left as an exercise for the reader.
If the USE_BUNDLES
option set to True,
Nikola can put several CSS or JS files together in a larger file, which can
makes site load faster for some deployments. To do this, your theme needs
a bundles
file. The file format is a modified
config file with no
defined section; the basic syntax is:
outputfile1.js= thing1.js, thing2.js, ... outputfile2.css= thing1.css, thing2.css, ...
For the Lanyon theme, it should look like this:
assets/css/all.css= rst_base.css, nikola_rst.css, code.css, poole.css, lanyon.css, custom.css,
Note: trailing commas are optional
Note: Some themes also support the USE_CDN
option meaning that in some cases it will load one bundle with all CSS and in other will load some CSS files
from a CDN and others from a bundle. This is complicated and probably not worth the effort.
And that’s it, that’s a whole theme. Eventually, once people start using it, they will notice small broken details, which will need handling one at a time.
This theme should be available in http://themes.getnikola.com/v7/lanyon/ and you can see it in action at https://themes.getnikola.com/v7/lanyon/demo/ .
What if you want to extend other parts of the theme? Check out the Theming reference. You can also contribute your improvements to the nikola-themes <https://github.com/getnikola/nikola> repository on GitHub.
If you are using reStructuredText and install pygal, Nikola has support for rather nice charts with little effort, and i's even semi-interactive (hover your pointer over the legend!):
.. chart:: StackedLine :title: 'Browser usage evolution (in %)' :fill: True :x_labels: ['2002','2003','2004','2005','2006','2007','2008','2009','2010','2011','2012'] :width: 600 :height: 400 :explicit_size: True :style: BlueStyle ('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5]) ('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1]) ('Firefox', [None, None, None, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1]) ('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3])
Here's how it works:
Next to the directive, use the chart type you want
Any option you can set in a chart? Use it like :title:
in this example. Syntax on
the value is just like in the pygal examples.
For each data series do it like the line that says Firefox
in this example. The first element
is the label, then comes the data.
Easy, right? Please explore the pygal site for more information, and just take this example and tweak stuff.
By Default, the themes provided with Nikola will add to your pages a "slide in" widget at the bottom right of the page, provided by Addthis. This is the HTML code for that:
<!-- Social buttons --> <div id="addthisbox" class="addthis_toolbox addthis_peekaboo_style addthis_default_style addthis_label_style addthis_32x32_style"> <a class="addthis_button_more">Share</a> <ul><li><a class="addthis_button_facebook"></a> <li><a class="addthis_button_google_plusone_share"></a> <li><a class="addthis_button_linkedin"></a> <li><a class="addthis_button_twitter"></a> </ul> </div> <script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4f7088a56bb93798"></script> <!-- End of social buttons --> """
You can change that using the SOCIAL_BUTTONS_CODE
option in your conf.py. In some cases, just
doing that will be enough but in others, it won't. This document tries to describe all the bits
involved in making this work correctly.
SOCIAL_BUTTONS_CODE
Social sharing services like addthis and others will provide you a HTML snippet.
If it is self-contained, then just setting SOCIAL_BUTTONS_CODE
may be enough.
Try :-)
The SOCIAL_BUTTONS_CODE
HTML fragment will be embedded somewhere by the theme. Whether that
is the correct place or not is not something the theme author can truly know, so it is possible that
you may have to tweak the base.html
template to make it look good.
BODY_END
and EXTRA_HEAD_DATA
Some social sharing code requires JS execution that depends on JQuery being available
(example: SocialSharePrivacy). It's good
practice (and often, the only way that will work) to put those at the end of <BODY>
,
and one easy way to do that is to put them in BODY_END
On the other hand, it's possible that it requires you to load some CSS files.
The right place for that is in the document's <HEAD>
so they should be added
in EXTRA_HEAD_DATA
For sharing code that doesn't rely on a social sharing service, you may need to add CSS, Image, or JS files to your site
Author of “Dr. Nikola,” “The Beautiful White Devil,” etc., etc.
The Project Gutenberg EBook of A Bid for Fortune, by Guy Boothby
This eBook is for the use of anyone anywhere at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this eBook or online at www.gutenberg.org
Title: A Bid for Fortune or Dr. Nikola’s Vendetta
Author: Guy Boothby
Release Date: May 29, 2007 [EBook #21640]
Language: English
Produced by Marilynda Fraser-Cunliffe, Mary Meehan and the Online Distributed Proofreading Team at http://www.pgdp.net
Originally published by:
WARD, LOCK & CO., LIMITED LONDON, MELBOURNE AND TORONTO 1918
The manager of the new Imperial Restaurant on the Thames Embankment went into his luxurious private office and shut the door. Having done so, he first scratched his chin reflectively, and then took a letter from the drawer in which it had reposed for more than two months and perused it carefully. Though he was not aware of it, this was the thirtieth time he had read it since breakfast that morning. And yet he was not a whit nearer understanding it than he had been at the beginning. He turned it over and scrutinized the back, where not a sign of writing was to be seen; he held it up to the window, as if he might hope to discover something from the water-mark; but there was nothing in either of these places of a nature calculated to set his troubled mind at rest. Then he took a magnificent repeater watch from his waistcoat pocket and glanced at the dial; the hands stood at half-past seven. He immediately threw the letter on the table, and as he did so his anxiety found relief in words.
“It’s really the most extraordinary affair I ever had to do with,” he remarked. “And as I’ve been in the business just three-and-thirty years at eleven a.m. next Monday morning, I ought to know something about it. I only hope I’ve done right, that’s all.”
As he spoke, the chief bookkeeper, who had the treble advantage of being tall, pretty, and just eight-and-twenty years of age, entered the room. She noticed the open letter and the look upon her chief’s face, and her curiosity was proportionately excited.
“You seem worried, Mr. McPherson,” she said tenderly, as she put down the papers she had brought in for his signature.
“You have just hit it, Miss O’Sullivan,” he answered, pushing them farther on to the table. “I am worried about many things, but particularly about this letter.”
He handed the epistle to her, and she, being desirous of impressing him with her business capabilities, read it with ostentatious care. But it was noticeable that when she reached the signature she too turned back to the beginning, and then deliberately read it over again. The manager rose, crossed to the mantelpiece, and rang for the head waiter. Having relieved his feelings in this way, he seated himself again at his writing-table, put on his glasses, and stared at his companion, while waiting for her to speak.
“It’s very funny,” she said. “Very funny indeed!”
“It’s the most extraordinary communication I have ever received,” he replied with conviction. “You see it is written from Cuyaba, Brazil. The date is three months ago to a day. Now I have taken the trouble to find out where and what Cuyaba is.”
He made this confession with an air of conscious pride, and having done so, laid himself back in his chair, stuck his thumbs into the armholes of his waistcoat, and looked at his fair subordinate for approval. Nor was he destined to be disappointed. He was a bachelor in possession of a snug income, and she, besides being pretty, was a lady with a keen eye to the main chance.
“And where is Cuyaba?” she asked humbly.
“Cuyaba,” he replied, rolling his tongue with considerable relish round his unconscious mispronunciation of the name, “is a town almost on the western or Bolivian border of Brazil. It is of moderate size, is situated on the banks of the river Cuyaba, and is considerably connected with the famous Brazilian Diamond Fields.”
“And does the writer of this letter live there?”
“I cannot say. He writes from there—that is enough for us.”
“And he orders dinner for four—here, in a private room overlooking the river, three months ahead—punctually at eight o’clock, gives you a list of the things he wants, and even arranges the decoration of the table. Says he has never seen either of his three friends before; that one of them hails from (here she consulted the letter again) Hang-chow, another from Bloemfontein, while the third resides, at present, in England. Each one is to present an ordinary visiting card with a red dot on it to the porter in the hall, and to be shown to the room at once. I don’t understand it at all.”
The manager paused for a moment, and then said deliberately,—”Hang-chow is in China, Bloemfontein is in South Africa.”
“What a wonderful man you are, to be sure, Mr. McPherson! I never can think how you manage to carry so much in your head.”
There spoke the true woman. And it was a move in the right direction, for the manager was susceptible to her gentle influence, as she had occasion to know.
At this juncture the head waiter appeared upon the scene, and took up a position just inside the doorway, as if he were afraid of injuring the carpet by coming farther.
“Is No. 22 ready, Williams?”
“Quite ready, sir. The wine is on the ice, and cook tells me he’ll be ready to dish punctual to the moment.”
“The letter says, ‘no electric light; candles with red shades.’ Have you put on those shades I got this morning?”
“Just seen it done this very minute, sir.”
“And let me see, there was one other thing.” He took the letter from the chief bookkeeper’s hand and glanced at it. “Ah, yes, a porcelain saucer, and a small jug of new milk upon the mantelpiece. An extraordinary request, but has it been attended to?”
“I put it there myself, sir.”
“Who wait?”
“Jones, Edmunds, Brooks, and Tomkins.”
“Very good. Then I think that will do. Stay! You had better tell the hall porter to look out for three gentlemen presenting plain visiting cards with a little red spot on them. Let Brooks wait in the hall, and when they arrive tell him to show them straight up to the room.”
“It shall be done, sir.”
The head waiter left the room, and the manager stretched himself in his chair, yawned by way of showing his importance, and then said solemnly,—
“I don’t believe they’ll any of them turn up; but if they do, this Dr. Nikola, whoever he may be, won’t be able to find fault with my arrangements.”
Then, leaving the dusty high road of Business, he and his companion wandered in the shady bridle-paths of Love—to the end that when the chief bookkeeper returned to her own department she had forgotten the strange dinner party about to take place upstairs, and was busily engaged upon a calculation as to how she would look in white satin and orange blossoms, and, that settled, fell to wondering whether it was true, as Miss Joyce, a subordinate, had been heard to declare, that the manager had once shown himself partial to a certain widow with reputed savings and a share in an extensive egg and dairy business.
At ten minutes to eight precisely a hansom drew up at the steps of the hotel. As soon as it stopped, an undersized gentleman, with a clean shaven countenance, a canonical corporation, and bow legs, dressed in a decidedly clerical garb, alighted. He paid and discharged his cabman, and then took from his ticket pocket an ordinary white visiting card, which he presented to the gold-laced individual who had opened the apron. The latter, having noted the red spot, called a waiter, and the reverend gentleman was immediately escorted upstairs.
Hardly had the attendant time to return to his station in the hall, before a second cab made its appearance, closely followed by a third. Out of the second jumped a tall, active, well-built man of about thirty years of age. He was dressed in evening dress of the latest fashion, and to conceal it from the vulgar gaze, wore a large Inverness cape of heavy texture. He also in his turn handed a white card to the porter, and, having done so, proceeded into the hall, followed by the occupant of the last cab, who had closely copied his example. This individual was also in evening dress, but it was of a different stamp. It was old-fashioned and had seen much use. The wearer, too, was taller than the ordinary run of men, while it was noticeable that his hair was snow-white, and that his face was deeply pitted with smallpox. After disposing of their hats and coats in an ante-room, they reached room No. 22, where they found the gentleman in clerical costume pacing impatiently up and down.
Left alone, the tallest of the trio, who for want of a better title we may call the Best Dressed Man, took out his watch, and having glanced at it, looked at his companions. “Gentlemen,” he said, with a slight American accent, “it is three minutes to eight o’clock. My name is Eastover!”
“I’m glad to hear it, for I’m most uncommonly hungry,” said the next tallest, whom I have already described as being so marked by disease. “My name is Prendergast!”
“We only wait for our friend and host,” remarked the clerical gentleman, as if he felt he ought to take a share in the conversation, and then, as an afterthought, he continued, “My name is Baxter!”
They shook hands all round with marked cordiality, seated themselves again, and took it in turns to examine the clock.
“Have you ever had the pleasure of meeting our host before?” asked Mr. Baxter of Mr. Prendergast.
“Never,” replied that gentleman, with a shake of his head. “Perhaps Mr. Eastover has been more fortunate?”
“Not I,” was the brief rejoinder. “I’ve had to do with him off and on for longer than I care to reckon, but I’ve never set eyes on him up to date.”
“And where may he have been the first time you heard from him?”
“In Nashville, Tennessee,” said Eastover. “After that, Tahupapa, New Zealand; after that, Papeete, in the Society Islands; then Pekin, China. And you?”
“First time, Brussels; second, Monte Video; third, Mandalay, and then the Gold Coast, Africa. It’s your turn, Mr. Baxter.”
The clergyman glanced at the timepiece. It was exactly eight o’clock. “First time, Cabul, Afghanistan; second, Nijni Novgorod, Russia; third, Wilcannia, Darling River, Australia; fourth, Valparaiso, Chili; fifth, Nagasaki, Japan.”
“He is evidently a great traveller and a most mysterious person.”
“He is more than that,” said Eastover with conviction; “he is late for dinner!”
Prendergast looked at his watch.
“That clock is two minutes fast. Hark, there goes Big Ben! Eight exactly.”
As he spoke the door was thrown open and a voice announced “Dr. Nikola.”
The three men sprang to their feet simultaneously, with exclamations of astonishment, as the man they had been discussing made his appearance.
It would take more time than I can spare the subject to give you an adequate and inclusive description of the person who entered the room at that moment. In stature he was slightly above the ordinary, his shoulders were broad, his limbs perfectly shaped and plainly muscular, but very slim. His head, which was magnificently set upon his shoulders, was adorned with a profusion of glossy black hair; his face was destitute of beard or moustache, and was of oval shape and handsome moulding; while his skin was of a dark olive hue, a colour which harmonized well with his piercing black eyes and pearly teeth. His hands and feet were small, and the greatest dandy must have admitted that he was irreproachably dressed, with a neatness that bordered on the puritanical. In age he might have been anything from eight-and-twenty to forty; in reality he was thirty-three. He advanced into the room and walked with out-stretched hand directly across to where Eastover was standing by the fireplace.
“Mr. Eastover, I feel certain,” he said, fixing his glittering eyes upon the man he addressed, and allowing a curious smile to play upon his face.
“That is my name, Dr. Nikola,” the other answered with evident surprise. “But how on earth can you distinguish me from your other guests?”
“Ah! it would surprise you if you knew. And Mr. Prendergast, and Mr. Baxter. This is delightful; I hope I am not late. We had a collision in the Channel this morning, and I was almost afraid I might not be up to time. Dinner seems ready; shall we sit down to it?” They seated themselves, and the meal commenced. The Imperial Restaurant has earned an enviable reputation for doing things well, and the dinner that night did not in any way detract from its lustre. But, delightful as it all was, it was noticeable that the three guests paid more attention to their host than to his excellent menu. As they had said before his arrival, they had all had dealings with him for several years, but what those dealings were they were careful not to describe. It was more than possible that they hardly liked to remember them themselves.
When coffee had been served and the servants had withdrawn, Dr. Nikola rose from the table, and went across to the massive sideboard. On it stood a basket of very curious shape and workmanship. This he opened, and as he did so, to the astonishment of his guests, an enormous cat, as black as his master’s coat, leaped out on to the floor. The reason for the saucer and jug of milk became evident.
Seating himself at the table again, the host followed the example of his guests and lit a cigar, blowing a cloud of smoke luxuriously through his delicately chiselled nostrils. His eyes wandered round the cornice of the room, took in the pictures and decorations, and then came down to meet the faces of his companions. As they did so, the black cat, having finished its meal, sprang on to his shoulder to crouch there, watching the three men through the curling smoke drift with its green blinking, fiendish eyes. Dr. Nikola smiled as he noticed the effect the animal had upon his guests.
“Now shall we get to business?” he said briskly.
The others almost simultaneously knocked the ashes off their cigars and brought themselves to attention. Dr. Nikola’s dainty, languid manner seemed to drop from him like a cloak, his eyes brightened, and his voice, when he spoke, was clean cut as chiselled silver.
“You are doubtless anxious to be informed why I summoned you from all parts of the globe to meet me here to-night? And it is very natural you should be. But then, from what you know of me, you should not be surprised at anything I do.”
His voice dropped back into its old tone of gentle languor. He drew in a great breath of smoke and then sent it slowly out from his lips again. His eyes were half closed, and he drummed with one finger on the table edge. The cat looked through the smoke at the three men, and it seemed to them that he grew every moment larger and more ferocious. Presently his owner took him from his perch, and seating him on his knee fell to stroking his fur, from head to tail, with his long slim fingers. It was as if he were drawing inspiration for some deadly mischief from the uncanny beast.
“To preface what I have to say to you, let me tell you that this is by far the most important business for which I have ever required your help. (Three slow strokes down the centre of the back, and one round each ear.) When it first came into my mind I was at a loss who to trust in the matter. I thought of Vendon, but I found Vendon was dead. I thought of Brownlow, but Brownlow was no longer faithful. (Two strokes down the back and two on the throat.) Then bit by bit I remembered you. I was in Brazil at the time. So I sent for you. You came. So far so good.”
He rose, and crossed over to the fireplace. As he went the cat crawled back to its original position on his shoulder. Then his voice changed once more to its former business-like tone.
“I am not going to tell you very much about it. But from what I do tell you, you will be able to gather a great deal and imagine the rest. To begin with, there is a man living in this world to-day who has done me a great and lasting injury. What that injury is is no concern of yours. You would not understand if I told you. So we’ll leave that out of the question. He is immensely rich. His cheque for £300,000 would be honoured by his bank at any minute. Obviously he is a power. He has had reason to know that I am pitting my wits against his, and he flatters himself that so far he has got the better of me. That is because I am drawing him on. I am maturing a plan which will make him a poor and a very miserable man at one and the same time. If that scheme succeeds, and I am satisfied with the way you three men have performed the parts I shall call on you to play in it, I shall pay to each of you the sum of £10,000. If it doesn’t succeed, then you will each receive a thousand and your expenses. Do you follow me?”
It was evident from their faces that they hung upon his every word.
“But, remember, I demand from you your whole and entire labour. While you are serving me you are mine body and soul. I know you are trustworthy. I have had good proof that you are—pardon the expression—unscrupulous, and I flatter myself you are silent. What is more, I shall tell you nothing beyond what is necessary for the carrying out of my scheme, so that you could not betray me if you would. Now for my plans!”
He sat down again and took a paper from his pocket. Having perused it, he turned to Eastover.
“You will leave at once—that is to say, by the boat on Wednesday—for Sydney. You will book your passage to-morrow morning, first thing, and join her in Plymouth. You will meet me to-morrow evening at an address I will send you, and receive your final instructions. Good-night.”
Seeing that he was expected to go, Eastover rose, shook hands, and left the room without a word. He was too astonished to hesitate or to say anything.
Nikola took another letter from his pocket and turned to Prendergast. “You will go down to Dover to-night, cross to Paris to-morrow morning, and leave this letter personally at the address you will find written on it. On Thursday, at half-past two precisely, you will deliver me an answer in the porch at Charing Cross. You will find sufficient money in that envelope to pay all your expenses. Now go!”
“At half-past two you shall have your answer. Good-night.”
“Good-night.”
When Prendergast had left the room, Dr. Nikola lit another cigar and turned his attentions to Mr. Baxter.
“Six months ago, Mr. Baxter, I found for you a situation as tutor to the young Marquis of Beckenham. You still hold it, I suppose?”
“I do.”
“Is the father well disposed towards you?”
“In every way. I have done my best to ingratiate myself with him. That was one of your instructions.”
“Yes, yes! But I was not certain that you would succeed. If the old man is anything like what he was when I last met him he must still be a difficult person to deal with. Does the boy like you?”
“I hope so.”
“Have you brought me his photograph as I directed?”
“I have. Here it is.”
Baxter took a photograph from his pocket and handed it across the table.
“Good. You have done very well, Mr. Baxter. I am pleased with you. To-morrow morning you will go back to Yorkshire——”
“I beg your pardon, Bournemouth. His Grace owns a house near Bournemouth, which he occupies during the summer months.”
“Very well—then to-morrow morning you will go back to Bournemouth and continue to ingratiate yourself with father and son. You will also begin to implant in the boy’s mind a desire for travel. Don’t let him become aware that his desire has its source in you—but do not fail to foster it all you can. I will communicate with you further in a day or two. Now go.”
Baxter in his turn left the room. The door closed. Dr. Nikola picked up the photograph and studied it.
“The likeness is unmistakable—or it ought to be. My friend, my very dear friend, Wetherell, my toils are closing on you. My arrangements are perfecting themselves admirably. Presently, when all is complete, I shall press the lever, the machinery will be set in motion, and you will find yourself being slowly but surely ground into powder. Then you will hand over what I want, and be sorry you thought fit to baulk Dr. Nikola!”
He rang the bell and ordered his bill. This duty discharged, he placed the cat back in its prison, shut the lid, descended with the basket to the hall, and called a hansom. The porter inquired to what address he should order the cabman to drive. Dr. Nikola did not reply for a moment, then he said, as if he had been thinking something out: “The Green Sailor public-house, East India Dock Road.”
You can read the rest of “A Bid For Fortune; Or, Dr. Nikola’s Vendetta” at Open Library
Nikola supports special links with the syntax link://kind/name
. In
templates you can also use _link(kind, name)
. You can add query strings
(?key=value
) for extra arguments, or pass keyword arguments to _link
in
templates (support and behavior depends on path handlers themselves). Fragments
(#anchor
) will be appended to the transformed link.
Here are the descriptions for all the supported kinds.
Link to archive path, name is the year.
Example:
link://archive/2013 => /archives/2013/index.html
Link to an author's page.
Example:
link://author/joe => /authors/joe.html
Link to an author's Atom feed.
Example:
link://author_atom/joe => /authors/joe.atom
Link to the authors index.
Example:
link://authors/ => /authors/index.html
Link to an author's RSS feed.
Example:
link://author_rss/joe => /authors/joe.xml
A link to a category. Takes page number as optional keyword argument.
Example:
link://category/dogs => /categories/dogs.html
A link to a category's Atom feed.
Example:
link://category_atom/dogs => /categories/dogs.atom
A link to the category index.
Example:
link://category_index => /categories/index.html
A link to a category's RSS feed.
Example:
link://category_rss/dogs => /categories/dogs.xml
Link to post or page by source filename.
Example:
link://filename/manual.txt => /docs/handbook.html
Link to an image gallery's path.
It will try to find a gallery with that name if it's not ambiguous or with that path. For example:
link://gallery/london => /galleries/trips/london/index.html
link://gallery/trips/london => /galleries/trips/london/index.html
Link to the global gallery path, which contains all the images in galleries.
There is only one copy of an image on multilingual blogs, in the site root.
link://gallery_global/london => /galleries/trips/london/index.html
link://gallery_global/trips/london => /galleries/trips/london/index.html
(a gallery
link could lead to eg. /en/galleries/trips/london/index.html)
Link to an image gallery's RSS feed.
It will try to find a gallery with that name if it's not ambiguous or with that path. For example:
link://gallery_rss/london => /galleries/trips/london/rss.xml
link://gallery_rss/trips/london => /galleries/trips/london/rss.xml
Link to a numbered index.
Example:
link://index/3 => /index-3.html
Link to a numbered Atom index.
Example:
link://index_atom/3 => /index-3.atom
A link to the RSS feed path.
Example:
link://rss => /blog/rss.xml
Return a link to a listing.
It will try to use the file name if it's not ambiguous, or the file path.
Example:
link://listing/hello.py => /listings/tutorial/hello.py.html
link://listing/tutorial/hello.py => /listings/tutorial/hello.py.html
Return a link to the source code for a listing.
It will try to use the file name if it's not ambiguous, or the file path.
Example:
link://listing_source/hello.py => /listings/tutorial/hello.py
link://listing_source/tutorial/hello.py => /listings/tutorial/hello.py
Link to the destination of an element in the POSTS/PAGES settings.
Example:
link://post_path/posts => /blog
Link to the current language's root.
Example:
link://root_path => /
link://root_path => /translations/spanish/
A link to the RSS feed path.
Example:
link://rss => /blog/rss.xml
Return a link to a post with given slug, if not ambiguous.
Example:
link://slug/yellow-camaro => /posts/cars/awful/yellow-camaro/index.html
A link to a tag's page. Takes page number as optional keyword argument.
Example:
link://tag/cats => /tags/cats.html
A link to a tag's Atom feed.
Example:
link://tag_atom/cats => /tags/cats.atom
A link to the tag index.
Example:
link://tag_index => /tags/index.html
A link to a tag's RSS feed.
Example:
link://tag_rss/cats => /tags/cats.xml
Contents
The text below contains links that look like "(quickref)". These are relative links that point to the Quick reStructuredText user reference. If these links don't work, please refer to the master quick reference document.
Note
This document is an informal introduction to reStructuredText. The What Next? section below has links to further resources, including a formal reference.
From the outset, let me say that "Structured Text" is probably a bit of a misnomer. It's more like "Relaxed Text" that uses certain consistent patterns. These patterns are interpreted by a HTML converter to produce "Very Structured Text" that can be used by a web browser.
The most basic pattern recognised is a paragraph (quickref). That's a chunk of text that is separated by blank lines (one is enough). Paragraphs must have the same indentation -- that is, line up at their left edge. Paragraphs that start indented will result in indented quote paragraphs. For example:
This is a paragraph. It's quite short. This paragraph will result in an indented block of text, typically used for quoting other text. This is another one.
Results in:
This is a paragraph. It's quite short.
This paragraph will result in an indented block of text, typically used for quoting other text.
This is another one.
(quickref)
Inside paragraphs and other bodies of text, you may additionally mark
text for italics with "*italics*
" or bold with
"**bold**
". This is called "inline markup".
If you want something to appear as a fixed-space literal, use
"``double back-quotes``
". Note that no further fiddling is done
inside the double back-quotes -- so asterisks "*
" etc. are left
alone.
If you find that you want to use one of the "special" characters in
text, it will generally be OK -- reStructuredText is pretty smart.
For example, this lone asterisk * is handled just fine, as is the
asterisk in this equation: 5*6=30. If you actually
want text *surrounded by asterisks* to not be italicised, then
you need to indicate that the asterisk is not special. You do this by
placing a backslash just before it, like so "\*
" (quickref), or
by enclosing it in double back-quotes (inline literals), like this:
``*``
Tip
Think of inline markup as a form of (parentheses) and use it the same way: immediately before and after the text being marked up. Inline markup by itself (surrounded by whitespace) or in the middle of a word won't be recognized. See the markup spec for full details.
Lists of items come in three main flavours: enumerated, bulleted and definitions. In all list cases, you may have as many paragraphs, sublists, etc. as you want, as long as the left-hand side of the paragraph or whatever aligns with the first line of text in the list item.
Lists must always start a new paragraph -- that is, they must appear after a blank line.
Start a line off with a number or letter followed by a period ".", right bracket ")" or surrounded by brackets "( )" -- whatever you're comfortable with. All of the following forms are recognised:
1. numbers A. upper-case letters and it goes over many lines with two paragraphs and all! a. lower-case letters 3. with a sub-list starting at a different number 4. make sure the numbers are in the correct sequence though! I. upper-case roman numerals i. lower-case roman numerals (1) numbers again 1) and again
Results in (note: the different enumerated list styles are not always supported by every web browser, so you may not get the full effect here):
numbers
upper-case letters and it goes over many lines
with two paragraphs and all!
lower-case letters
with a sub-list starting at a different number
make sure the numbers are in the correct sequence though!
upper-case roman numerals
lower-case roman numerals
numbers again
and again
Just like enumerated lists, start the line off with a bullet point character - either "-", "+" or "*":
* a bullet point using "*" - a sub-list using "-" + yet another sub-list - another item
Results in:
a bullet point using "*"
a sub-list using "-"
yet another sub-list
another item
Unlike the other two, the definition lists consist of a term, and the definition of that term. The format of a definition list is:
what Definition lists associate a term with a definition. *how* The term is a one-line phrase, and the definition is one or more paragraphs or body elements, indented relative to the term. Blank lines are not allowed between term and definition.
Results in:
Definition lists associate a term with a definition.
The term is a one-line phrase, and the definition is one or more paragraphs or body elements, indented relative to the term. Blank lines are not allowed between term and definition.
(quickref)
To just include a chunk of preformatted, never-to-be-fiddled-with
text, finish the prior paragraph with "::
". The preformatted
block is finished when the text falls back to the same indentation
level as a paragraph prior to the preformatted block. For example:
An example:: Whitespace, newlines, blank lines, and all kinds of markup (like *this* or \this) is preserved by literal blocks. Lookie here, I've dropped an indentation level (but not far enough) no more example
Results in:
An example:
Whitespace, newlines, blank lines, and all kinds of markup (like *this* or \this) is preserved by literal blocks. Lookie here, I've dropped an indentation level (but not far enough)no more example
Note that if a paragraph consists only of "::
", then it's removed
from the output:
:: This is preformatted text, and the last "::" paragraph is removed
Results in:
This is preformatted text, and the last "::" paragraph is removed
(quickref)
To break longer text up into sections, you use section headers.
These are a single line of text (one or more words) with adornment: an
underline alone, or an underline and an overline together, in dashes
"-----
", equals "======
", tildes "~~~~~~
" or any of the
non-alphanumeric characters = - ` : ' " ~ ^ _ * + # < >
that you
feel comfortable with. An underline-only adornment is distinct from
an overline-and-underline adornment using the same character. The
underline/overline must be at least as long as the title text. Be
consistent, since all sections marked with the same adornment style
are deemed to be at the same level:
Chapter 1 Title =============== Section 1.1 Title ----------------- Subsection 1.1.1 Title ~~~~~~~~~~~~~~~~~~~~~~ Section 1.2 Title ----------------- Chapter 2 Title ===============
This results in the following structure, illustrated by simplified pseudo-XML:
<section> <title> Chapter 1 Title <section> <title> Section 1.1 Title <section> <title> Subsection 1.1.1 Title <section> <title> Section 1.2 Title <section> <title> Chapter 2 Title
(Pseudo-XML uses indentation for nesting and has no end-tags. It's not possible to show actual processed output, as in the other examples, because sections cannot exist inside block quotes. For a concrete example, compare the section structure of this document's source text and processed output.)
Note that section headers are available as link targets, just using
their name. To link to the Lists heading, I write "Lists_
". If
the heading has a space in it like text styles, we need to quote
the heading "`text styles`_
".
The title of the whole document is distinct from section titles and may be formatted somewhat differently (e.g. the HTML writer by default shows it as a centered heading).
To indicate the document title in reStructuredText, use a unique adornment style at the beginning of the document. To indicate the document subtitle, use another unique adornment style immediately after the document title. For example:
================ Document Title ================ ---------- Subtitle ---------- Section Title ============= ...
Note that "Document Title" and "Section Title" above both use equals signs, but are distinct and unrelated styles. The text of overline-and-underlined titles (but not underlined-only) may be inset for aesthetics.
(quickref)
To include an image in your document, you use the the image
directive.
For example:
.. image:: /images/nikola.png
results in:
The /images/nikola.png
part indicates the filename of the image
you wish to appear in the document. There's no restriction placed on
the image (format, size etc). If the image is to appear in HTML and
you wish to supply additional information, you may:
.. image:: /images/nikola.png :height: 100 :width: 200 :scale: 50 :alt: alternate text
See the full image directive documentation for more info.
This primer introduces the most common features of reStructuredText, but there are a lot more to explore. The Quick reStructuredText user reference is a good place to go next. For complete details, the reStructuredText Markup Specification is the place to go 1.
Users who have questions or need assistance with Docutils or reStructuredText should post a message to the Docutils-users mailing list.
If that relative link doesn't work, try the master document: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html.
SocialSharePrivacy
The Hard Way
SocialSharePrivacy is "a jQuery plugin that lets you add social share buttons to your website that don't allow the social sites to track your users." Nice!
Let's go step-by-step into integrating SocialSharePrivacy into a Nikola site. To improve privacy, they recommend you not use the hosted service so we'll do it the hard way, by getting and distributing everything in our own site.
https://github.com/panzi/SocialSharePrivacy
For testing purposes, let's do it on a demo site:
To see what's going on, let's start Nikola in "auto mode". This should build the site and open a web browser showing the default configuration, with the AddThis widget:
Now, download the current version and unzip it. You will have a
SocialSharePrivacy-master
folder with lots of stuff in it.First, we need to build it (this requires a working and modern uglifyjs, this may not be easy):
You will now have several files in a
build
folder. We need to bring them into the site:Edit your
conf.py
:In my experience this produces a broken, duplicate, semi-working thing. YMMV and if you make it work correctly, let me know how :-)
The Easy Way
Go to http://panzi.github.io/SocialSharePrivacy/ and use the provided form to get the code. Make sure you check "I already use JQuery" if you are using one of the themes that require it, like site or default, select the services you want, and use your disqus name if you have one.
It will give you 3 code snippets:
Put it in
BODY_END
Put it in
SOCIAL_BUTTONS_CODE
Put it in
BODY_END
That should give you a working integration (not tested)