Currently it was only possible to use page "save as" name or part of it
for generating pagination links. That's not sufficient when page URLs
differ a lot from actual filenames. With this patch it's possible to use
the `{url}` placeholder in PAGINATION_PATTERNS setting. For example, the
paginated archives would be saved to:
blog/index.html
blog/2/index.html
blog/3/index.html
while the actual URLs would be like this (with the help of Apache's
mod_rewrite):
http://blog.my.site/http://blog.my.site/2/http://blog.my.site/3/
The configuration that corresponds to this is roughly the following:
ARCHIVES_SAVE_AS = 'blog/index.html'
ARCHIVES_URL = 'http://blog.my.site/'
PAGINATION_PATTERNS = [
(1, '/{url}', '{base_name}/index.html'),
(2, '/{url}{number}/', '{base_name}/{number}/index.html')
]
Also added YEAR_ARCHIVE_URL, MONTH_ARCHIVE_URL and DAY_ARCHIVE_URL
settings, as they were missing and now they make sense.
With this patch, there are new FEED_*_URL configuration options that
allow to specify custom URLs for feeds, which is helpful in case the
feed filename and the actual URL differ a lot -- for example if a feed
is saved to
blog/feeds/all.atom.xml
but the actual URL from the user PoV is
http://blog.your.site/feeds/all.atom.xml
This setting currently affects only the generated feed XML. This change
is also fully backwards compatible, so if the FEED_*_URL setting is not
present, the value of FEED_* is used for both file location and URL.
For some reason, feedgenerator.py uses the `description` argument only
for RSS and the `subtitle` argument only for Atom. So setting both to
the same value.
In order to avoid unnecessary changes, if SITESUBTITLE is not present,
the subtitle is set to None instead of '', so the generated Atom feed
doesn't contain an empty <subtitle></subtitle> tag (in contrast, the RSS
feed contains an empty <description></description> tag now, though).
This adheres more closely to the specs, especially Atom, where the
'description' arg becomes <summary>.
Note that this means full article content will no longer appear in RSS
feeds.
The write_feed function now takes an override_output parameter that
does the same thing as override_output does to write_file. Implemented
for custom generators.
Old system was using manual string formatting for log messages.
This caused issues with common operations like exception logging
because often they need to be handled differently for Py2/Py3
compatibility. In order to unify the effort:
- All logging is changed to `logging.level(msg, arg1, arg2)` style.
- A `SafeLogger` is implemented to auto-decode exceptions properly
in the args (ref #1403).
- Custom formatters were overriding useful logging functionality
like traceback outputing (ref #1402). They are refactored to be
more transparent. Traceback information is provided in `--debug`
mode for `read_file` errors in generators.
- Formatters will now auto-format multiline log messages in order
to make them look related. Similarly, traceback will be formatted in
the same fashion.
- `pelican.log.LimitFilter` was (ab)using logging message which
would result in awkward syntax for argumented logging style. This
functionality is moved to `extra` keyword argument.
- Levels for errors that would result skipping a file (`read_file`)
changed from `warning` to `error` in order to make them stand out
among other logs.
- Small consistency changes to log messages (i.e. changing all
to start with an uppercase letter) and quality-of-life improvements
(some log messages were dumping raw object information).
When `RELATIVE_URLS` is `True` and the `PAGINATION_PATTERNS` adds folder to the path, the relative urls to these pages does not respect these additional folders.
Example:
Settings:
RELATIVE_URLS = True
PAGINATION_PATTERNS = (
(1, '{base_name}/', '{base_name}/index.html'),
(2, '{base_name}/page/{number}/', '{base_name}/page/{number}/index.html'),)
Theme:
<link href="{{ SITEURL }}/theme/css/style.css" rel="stylesheet">
If you are on page 2 then "{{ SITEURL }}/theme/css/style.css" expands to "./theme/css/style.css" instead of "./../../theme/css/style.css".
Fix:
Simply compute the relative url from the paginated url instead of the not paginated one.
reverts getpelican/pelican@ddcccfeaa9
If one used a locale that made use of unicode characters (like fr_FR.UTF-8)
the files on disk would be in correct locale while links would be to C.
Uses a SafeDatetime class that works with unicode format strigns
by using custom strftime to prevent ascii decoding errors with Python2.
Also added unicode decoding for the calendar module to fix period
archives.
Previously, the documentation claimed the value of None for this purpose
even though False was used for certain defaults. The values False and
None cause warnings to be emitted from URLWrapper._from_settings though,
so the new way of inhibiting page generation is to set a *_SAVE_AS value
to the empty string.
PAGINATION_PATTERNS was hard coded so that all files had a ".html" extension. This fixes that and add a test to
ensure that the pagination code is not changing the filename incorrectly.
publication time and date and the last modified time and date
independently.
This makes it possible to access the last updated date with {{ article.locale_modified }} in templates.
Additionally, an already delivered feed entry can be corrected by changing the modified date and time, as it is used for atom:update
/ rss pubDate field now.
Since built-in exception "StandardError" does not exist in the latest python version (at least in version 3.3), use RuntimeError instead (which exists from python2.6 to python3.4)
Make deliberate overriding (*) works with overwrites detection.
(*) first introduced by d0e9c52410
The following are decided to be deliberate override:
- articles using the `save_as` metadata
- pages using the `save_as` metadata
- template pages (always)
Pelican now exits in the following 2 cases:
- at least 2 not deliberate writes to the same file name (behaviour introduced
by the overwrite detection feature ff7410ce2a)
- at least 2 deliberate writes to the same file name (new behaviour)
Also added info logging when deliberate overrides are performed.
Switched to StandardError instead of IOError, thanks to @ametaireau and
@russkel.
If a setting exists in DEFAULT_CONFIG, assume it will be there
(instead of checking and/or providing a local default). The earlier
code was split between the two idioms, which was confusing.
The old get_relative_path() implementation assumed os.sep == '/',
which doesn't hold on MS Windows. The new implementation uses
split_all() for a more general component count.
I added path_to_url(), because the:
'/'.join(split_all(path))
idiom was showing up in a number of cases, and it's easier to
understand what's going on when that reads:
path_to_url(path)
This will fix a number of places where I think paths and URLs were
conflated, and should improve MS Windows support.