1
0
Fork 0
forked from github/pelican
Commit graph

112 commits

Author SHA1 Message Date
Alexis Métaireau
e39dc95c3b Bug #1493 — Memoize slugify when possible 2014-10-09 11:42:11 +02:00
Justin Mayer
1d9981b4f9 Merge pull request #1348 from vjousse/davidmarble-page-order-by
Support ordering pages and articles when iterating in templates.
2014-09-18 16:12:51 -07:00
Justin Mayer
1fae9534d5 Merge pull request #1446 from avaris/enhanced_strftime
Fixes #1395: extends pelican.utils.strftime with `-` prefix to strip leading zeros
2014-08-28 11:17:28 -07:00
Justin Mayer
2ecd85d7b3 Merge pull request #1412 from avaris/refactor_logging
Refactor logging handling
2014-08-13 14:17:09 -07:00
Deniz Turgut
ed3209888a Refactor logging handling
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).
2014-07-22 12:39:39 -04:00
Deniz Turgut
7c3cc8fc0d Fixes #1395: extends pelican.utils.strftime with - prefix to strip leading zeros
Adds the ability to use `-` prefix with C89 format codes to strip any
leading zeros.
2014-07-16 03:40:53 -04:00
OGINO Masanori
2c50ccb764 Add timezone to datetime objects. Refs #962.
Based on https://github.com/getpelican/pelican/pull/977, but it adds
timezone information before formatting.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-07-04 01:23:57 +09:00
Deniz Turgut
009543b7e4 Fix test errors on OSX
On OSX, if LC_TIME and LC_CTYPE differs the output of strftime is not properly decoded
in Python 3. This makes sure that the 'utils.DateFormatter' and the related Jinja filter
'strftime' set the same value for LC_TIME and LC_CTYPE while formatting.

Also, '%a' is removed from DEFAULT_DATE_FORMAT in 'custom_locale' tests. OSX and *nix have
different conversions for '%a' ('Jeu' vs 'jeu.') and there is not a feasible way to handle
the difference for tests.
2014-06-26 01:01:42 -04:00
Ondrej Grover
3f6b130d6e Fix #1198, enable custom locale in template rendering, fixes links
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.
2014-06-26 00:00:19 -04:00
Ondrej Grover
ef96705677 catch arbitrary exceptions during cache unpickling
It is hard to forsee what could be raised.
2014-06-08 11:32:10 +02:00
Mark Lee
b572cbeef1 Addressed comments from @avaris in PR getpelican/pelican#1348 2014-05-27 11:42:37 -07:00
Mark Lee
144cddaf39 Address code review comments from PR getpelican/pelican#1348
The text about the sort-by-key function comes from:
https://docs.python.org/2/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange

Minor style cleanup as well.
2014-05-20 13:53:02 -07:00
Vincent Jousse
ebf0da0f7b Merge remote-tracking branch 'remotes/malept/davidmarble-page-order-by' into davidmarble-page-order-by
Conflicts:
	docs/settings.rst
	pelican/generators.py
	pelican/tests/test_generators.py
2014-05-14 10:48:41 +02:00
Ondrej Grover
5bad061c19 rename CACHE_DIR -> CACHE_PATH to unify with rest of Pelican
CACHE_PATH can now be relative to settings file like OUTPUT_PATH.
Also add --cache-path commandline option.
Change cache loading warning to a less scary and more helpful message.
2014-05-02 18:08:32 +02:00
Ondrej Grover
c1324b0206 split content caching into two layers
This is a reworked and improved version of content caching.
Notable changes:
- by default only raw content and metadata returned by readers are
  cached which should prevent conficts with plugins, the speed benefit
  of content objects caching is not very big with a simple setup
- renamed --full-rebuild to --ignore-cache
- added more elaborate logging to caching code
2014-04-20 14:34:52 +02:00
Justin Mayer
06080dd873 Merge pull request #1318 from smartass101/fix_cacher_open_func
set _cache_open func even if not loading cache, fixes autoreload
2014-04-18 11:27:22 -07:00
Ondrej Grover
676981c621 set _cache_open func even if not loading cache, fixes autoreload
The _cache_open attribute of the FileDataCacher class was not set when
settings[load_policy_key] was not True, so saving later failed.
As a precaution, replaced the `if ...: return` style with a plain
if structure to prevent such readability issues and added tests.
2014-04-18 07:15:26 +02:00
Ondrej Grover
6703950abe enable writing of only selected output paths
- add WRITE_SELECTED setting
- add --write-selected commandline option
2014-04-17 19:36:18 +02:00
Ondrej Grover
fd77926700 Cache content to speed up reading. Fixes #224.
Cache read content so that it doesn't have to be read next time if its
source has not been modified.
2014-04-15 08:57:38 -04:00
Stefan hr Berder
7f2bc2a23b change date metadata parsing to dateutil.parser 2014-02-23 11:21:44 +01:00
Rogdham
fd7fc2e202 Simplify usage of utils.copy
Remove confusing parameters, clarify usage in __doc__
2013-12-07 21:11:15 +01:00
Rogdham
7da0506f2d Fix utils.copy for copying files, add unit tests
`copy('', 'a/b.ext0', 'c/d.ext1')` is copying `a/b.ext0` into `c/d.ext1/b.ext0`
(creating folder `c/d.ext1` in the process) instead of `c/d.ext1`.
Bug introduced by e03cf3f517.
2013-12-07 20:58:19 +01:00
David Marble
0c69f4ad84 Support ordering pages and articles when iterating in templates.
Order can be set to a metadata attribute or a sorting function.
Default to order by slug for articles and order by filename for pages.
2013-11-14 12:35:50 -08:00
zhouji
eb6d4bb008 Preserve file metadata (esp. timestamps) when copy static files to output folder. 2013-10-15 10:37:03 +08:00
bmcorser
e03cf3f517 Fix utils.copy behaviour
Previously, the copy util failed if only a directory containing only
files was specified in THEME_STATIC_PATHS
2013-09-14 16:18:53 +01:00
bmcorser
b144c3cfbd Hack out overwrite param 2013-08-24 14:38:06 +01:00
bmcorser
9d583961e7 Fix for THEME_STATIC_PATHS by copying sensitively
If more than one path is defined in THEME_STATIC_PATHS, the theme's
static directory in output is deleted and replaced by the following
path's files.

Using `shutil.rmtree` to remove the entire destination tree if overwrite
is `True` assumes that we didn't want anything at all that was there. We
should recurse through the directory and their subdirs instead, leaving
things put there by the previous path where they were.

I lazily copied almost verbatim the solution for recursively copying a
diectory from http://stackoverflow.com/a/1994840.

The reason for this is patch is that without it, my plugin is broken! It
also makes my code a lot less crazy:

a83f066
2013-08-21 20:28:22 +01:00
Simon Conseil
41970cb2c6 Refactor pelican_open using contextmanager 2013-08-04 14:47:03 +02:00
Andy Pearce
39518e15ef Allow text substitutions when generating slugs
The `slugify()` function used by Pelican is in general very good at
coming up with something both readable and URL-safe. However, there are
a few specific cases where it causes conflicts. One that I've run into
is using the strings `C++` and `C` as tags, both of which transform to
the slug `c`. This commit adds an optional `SLUG_SUBSTITUTIONS` setting
which is a list of 2-tuples of substitutions to be carried out
case-insensitively just prior to stripping out non-alphanumeric
characters. This allows cases like `C++` to be transformed to `CPP` or
similar. This can also improve the readability of slugs.
2013-07-04 12:17:21 +01:00
Justin Mayer
6f36b0a246 Keep certain files when cleaning output; fix #574
If DELETE_OUTPUT_DIRECTORY is set to True, all files and directories are
deleted from the output directory. There are, however, several reasons
one might want to retain certain files/directories and avoid their
deletion from the output directory. One such use case is version control
system data: a versioned output directory can facilitate deployment via
Heroku and/or allow the user to easily revert to a prior version of the
site without having to rely on regeneration via Pelican.

This change introduces the OUTPUT_RETENTION setting, a tuple of
filenames that will be preserved when the clean_output_dir function in
pelican.utils is run. Setting OUTPUT_RETENTION = (".hg", ".git") would,
for example, prevent the relevant VCS data from being deleted when the
output directory is cleaned.
2013-06-25 19:03:32 -07:00
Justin Mayer
dd9f55c8bb Clean up minor text formatting, spelling, grammar 2013-06-22 12:28:37 -07:00
W. Trevor King
1102143c33 utils: Use pytz instead of datetime.timezone for timezones
datetime.timezone is new in Python 3.2 [1], so pytz allows us to keep
support for Python 2.7.

[1]: http://docs.python.org/dev/library/datetime.html#datetime.timezone
2013-06-11 22:54:01 -04:00
W. Trevor King
228fc82fc9 utils: Add some ISO 8601 forms to get_date()
Support the forms listed by the W3C [1].  I also removed the
'%Y-%d-%m' form, which can be confused with the '%Y-%m-%d' ISO form.
The new ISO forms can use 'Z' to designate UTC or '[+-]HHMM' to
specify offsets from UTC.  Other time zone designators are not
supported.

The '%z' directive has only been supported since Python 3.2 [2], so if
you're running Pelican on Python 2.7, you're stuck with 'Z' for UTC.
Conveniently, we get ValueErrors for both invalid directives and
data/format missmatches, so we don't need special handling for the 2.7
case inside get_date().

[1]: http://www.w3.org/TR/NOTE-datetime
[2]: http://bugs.python.org/issue6641
2013-06-11 22:53:21 -04:00
Alexis Metaireau
dcc17bbfa4 Merge pull request #848 from Rogdham/no_overwrite
Check URL overwrite. Fixes #446.
2013-05-13 00:17:26 -07:00
Justin Mayer
30c2490f88 Merge pull request #862 from avaris/emacs-autoreload
ignore emacs lock files and exception handling for watchers
2013-04-22 20:04:24 -07:00
Deniz Turgut
be8837963a ignore emacs lock files and exception handling for watchers 2013-04-22 20:50:11 -04:00
Deniz Turgut
2790446906 adds a 'strftime' jinja fiter that uses LOCALE 2013-04-21 18:00:12 -04:00
Deniz Turgut
e86f4eedcf bugfix and tests for no settings path (no -s option) 2013-04-19 23:35:09 -04:00
Deniz Turgut
5ccbbcc7d1 add feedback to user and refactor 'autoreload' code 2013-04-19 13:35:20 -04:00
Rogdham
3aea29fb2b Fix bug with MacOS in utils.strftime
Force using C89 directives (i.e. mentioned in the Python documentation).
2013-04-17 21:24:45 +01:00
Deniz Turgut
48f7132ba8 refactored utils.strftime 2013-04-16 20:53:27 -04:00
Rogdham
73ca6a1316 Add non unique slug warnings for translations 2013-04-14 20:39:04 +01:00
Deniz Turgut
bc4bd773a0 remove unittest2 and fix various warnings in py3 2013-04-13 16:36:05 -04:00
unknown
8e254e8cd7 Fixed path_to_url when os.sep is not '/'. 2013-04-12 15:44:53 +08:00
Rogdham
eb640b09e6 Add translation metadata support.
Allows user to control which posts are the translations independently of the
DEFAULT_LANG setting.
2013-04-06 18:36:37 +01:00
Irfan Ahmad
385a18563c Fixes #630 2013-03-23 20:16:31 -07:00
W. Trevor King
ae4fc5a25e utils: Add path_to_url() and generalize get_relative_path()
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.
2013-03-21 12:44:44 -04:00
W. Trevor King
b59da89e80 Convert '.' and '..' to the less magical os.curdir and os.pardir
While I'm cleaning up path manipulation, I might as well make things
more semantic.
2013-03-21 12:44:44 -04:00
W. Trevor King
33c60a78cd pelican/utils: Add split_all() and rework static URL generation
I think the conversion from native paths to URLs is best put off until
we are actually trying to generate the URL.  The old handling
(introduced in 2692586, Fixes #645 - Making cross-content linking
windows compatible, 2012-12-19) converted the path at StaticContent
initialization, which left you with a bogus StaticContent.src.

Once we drop the 'static' subdirectory, we will be able to drop the
`dest` and `url` parts from the StaticGenerator.generate_context()
handling, which will leave things looking a good deal cleaner than
they do now.
2013-03-10 23:21:38 -07:00
Alexis Métaireau
14cf5f014c Some doc + various enhancements 2013-03-10 22:57:08 -07:00