Since version 0.9 `docutils` supports `code` directive. But this directive
can generate fullname classes for the `pygments` style classes.
For example, the following code
```reStructuredText
.. code:: c++
GetFoo()->do_something();
```
generate the following output
```html
<pre class="code c++ literal-block">
<span class="name">GetFoo</span>
<span class="punctuation">()</span>
<span class="operator">-></span>
<span class="name">do_something</span>
<span class="punctuation">();</span>
</pre>
```
Note, that fullname classes were used, when we need a short one
```html
<pre class="code c++ literal-block">
<span class="n">GetFoo</span>
<span class="p">()</span>
<span class="o">-></span>
<span class="n">do_something</span>
<span class="p">();</span>
</pre>
```
Making everything consistent is a bit awkward, since this is a
commonly used attribute, but I've done my best.
Reasons for not consolidating on `filename`:
* It is often used for the "basename" (last component in the path).
Using `source_path` makes it clear that this attribute can contain
multiple components.
Reasons for not consolidating on `filepath`:
* It is barely used in the Pelican source, and therefore easy to
change.
* `path` is more Pythonic. The only place `filepath` ever show up in
the documentation for `os`, `os.path`, and `shutil` is in the
`os.path.relpath` documentation [1].
Reasons for not consolidating on `path`:
* The Page elements have both a source (this attribute) and a
destination (.save_as). To avoid confusion for developers not aware
of this, make it painfully obvious that this attribute is for the
source. Explicit is better than implicit ;).
Where I was touching the line, I also updated the string formatting in
StaticGenerator.generate_output to use the forward compatible
'{}'.format() syntax.
[1]: http://docs.python.org/2/library/os.path.html#os.path.relpath
For reasons that are unclear to me, StaticContent introduces the
`filepath` attribute rather than using the existing (and semantically
equivalent) Page.filename. This has caused confusion before [1], and
it's probably a good idea to merge the two.
While I was touching the line, I also updated the string formatting in
StaticGenerator.generate_output to use the forward compatible
'{}'.format() syntax.
[1]: https://github.com/getpelican/pelican/issues/162#issuecomment-3000363
Python 2.7 chokes on Unicode locales:
$ python2.7
>>> import locale
>>> locale.setlocale(locale.LC_ALL, u'ja_JP.utf8')
Traceback (most recent call last):
...
ValueError: too many values to unpack
With the addition of:
from __future__ import unicode_literals
to tests/test_contents.py in:
commit bebb94c15b
Author: W. Trevor King <wking@tremily.us>
Date: Tue Jan 15 22:50:58 2013 -0500
test_contents.py: Add URLWrapper comparison tests
the locale strings in TestPage.test_datetime are interpreted as
Unicode. Rather than fixing the encoding there, this patch updates
Page to handle Unicode locales automatically.
There have been earlier attempts to sort categories and authors
[1,2,3], but they either sorted based on the object id [3], or only
sorted the main author and categories list.
This patch uses rich comparisons (keyed off URLWrapper.name, but
easily adjustable in subclasses) to make the objects sortable without
specifying a key for each sort. For example, now
{% for tag, articles in tags|sort %}
works as expected in a Jinja template.
The functools.total_ordering decorator fills in the missing rich
comparisons [4,5].
[1]: 877d454c8f
[2]: 7f36e0ed20
[3]: d0ec18f4db
[4]: http://docs.python.org/2/library/functools.html#functools.total_ordering
[5]: http://docs.python.org/3/library/functools.html#functools.total_ordering
I want to add `directory` metadata to each page in `content/pages/` to
place my non-article pages by hand:
PAGE_URL = '{directory}/{slug}'
PAGE_SAVE_AS = '{directory}/{slug}/index.html'
To do this, I need the `directory` metadata for formatting the URL.
This fix was applied previously to the relevant places in both the
"simple" and "notmyidea" themes, but the simple theme's index.html file
was apparently neglected.
Extending the Writer wasn't the complete answer because the static
generator also copies some files. Instead, I implemented the work as a
plugin that attaches to the finalized event.
1. Following up on bbinet's changes in f12a297, ensure that the notmyidea
theme's article.html template includes the SITEURL variable when
constructing URL links.
2. Add missing slash to the base.html template so that clicking on the
site header at top left refers to "/" instead of "" when SITEURL is not
defined. Otherwise, the "" target will cause the browser to load the
current page and not the site's root (as one would expect).