1
0
Fork 0
forked from github/pelican
Commit graph

337 commits

Author SHA1 Message Date
Simon Conseil
c90a62ea13 pep8 fixes 2014-01-05 23:34:46 +01:00
Stefan hr Berder
f750f38d60 add a signal on article writing 2014-01-03 05:03:25 +01:00
Rogdham
fd7fc2e202 Simplify usage of utils.copy
Remove confusing parameters, clarify usage in __doc__
2013-12-07 21:11:15 +01:00
Jamie Culpon
c9b84abe46 Make marking articles as drafts case-insensitive
Previously if you tried to mark an article as a draft by using a different
casing (for example, draft) you would get a warning when building:
`Unknown status Draft for file foo.md, skipping it.` This uses a
case-insensitive comparison when looking at article status instead. I
believe this behavior is a little easier for new Pelican users.
2013-12-04 09:32:52 -08:00
Justin Mayer
f4e78d7254 Merge pull request #1144 from idning/master
Check IGNORE_FILES on get_files. Closes #1130.
2013-11-27 16:52:03 -08: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
idning
7fadbd682a check IGNORE_FILES on get_files 2013-11-03 18:08:08 +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
b144c3cfbd Hack out overwrite param 2013-08-24 14:38:06 +01:00
Ken Jung
6191b2919e StaticGenerator now stores file list in context.
This allows plugins and other generators to easily add files to be
simply copied over.
2013-08-16 13:31:14 -07:00
Simon Conseil
4bc4b1500c Refactor readers and remove MARKUP
Add a `Readers` class which contains a dict of file extensions / `Reader`
instances. This dict can be overwritten with a `READERS` settings, for instance
to avoid processing *.html files:

    READERS = {'html': None}

Or to add a custom reader for the `foo` extension:

    READERS = {'foo': FooReader}

This dict is no storing the Reader classes as it was done before with
`EXTENSIONS`. It stores the instances of the Reader classes to avoid instancing
for each file reading.
2013-08-06 23:42:41 +02:00
Kyle Mahan
dfc3a7ce2f Move PDF generation to a plugin. Fixes #1009 2013-08-04 18:01:56 -07:00
Rogdham
a495527e2b Delib. overriding and overwrite detect. Fixes #938
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.
2013-08-04 12:09:26 +01:00
Dane Knecht
10dc5ef0b7 sort author and category pages same way as tags 2013-08-03 19:17:14 -07:00
Justin Mayer
76fa457654 Normalize whitespace via lstrip Jinja parameter
This adds the lstrip_blocks Jinja parameter and removes unnecessary
whitespace from a few notmyidea templates.

Note: The lstrip_blocks parameter requires Jinja 2.7+, which has been
noted in Pelican's setup.py.

Credit for this commit goes entirely to Russ Webber, who has earned my
eternal thanks for discovering and applying this useful Jinja parameter.

Refs #969
2013-08-03 16:17:26 -07:00
Russ Webber
89034f8b3f added THEME_STATIC_DIR setting
The theme static output directory path is now customisable via settings.
i.e. you can now use 'assets' instead of 'theme'.
2013-08-01 11:02:38 +08:00
Justin Mayer
2188f4de68 Merge pull request #898 from saimn/fix-markup-cli
Ensure that markup is a tuple.
2013-06-19 06:51:59 -07:00
W. Trevor King
12dd35ef36 generators: Remove wonky argument handling from Generator.__init__ 2013-06-16 13:31:16 -04:00
W. Trevor King
9b42b2a130 generators: get_files() should use paths relative to Generator.path
All paths should be relative to Generator.path unless we're actively
accessing the filesystem.  This makes the argument less ambiguous, so
we have less likelyhood of joining paths multiple times.
2013-06-12 17:37:22 -04:00
W. Trevor King
1ca0e06a27 Remove the FILES_TO_COPY setting
We no longer instantiate the Static object in the StaticGenerator, so
we can't set the save_as argument anymore.  If you want to adjust the
output path, use the upcoming EXTRA_PATH_METADATA setting.
2013-06-12 15:02:31 -04:00
W. Trevor King
1bc5b100ec generators: Convert StaticGenerator to use the new read_file 2013-06-12 15:02:31 -04:00
W. Trevor King
7be16dd524 generators: Update PagesGenerator to use new read_file
Also standardize signal names.  If `article_generator_*` is singular,
`page_generator_*` should be as well.  Fix it from the older
`pages_generator_*`.
2013-06-12 15:02:31 -04:00
W. Trevor King
a9c530281e Move Article metadata extraction from generators to readers
There's no reason why this information should be Article-specific.

This commit breaks the other generators for the moment.  I'll fix them
shortly.
2013-06-12 15:02:30 -04:00
Simon Conseil
3f91165f09 Ensure that markup is a tuple.
`self.markup` is a list when using the `-m|--markup` cli option, but testing the
extension with `endswith` works only with tuples.
2013-06-02 22:49:16 +02:00
W. Trevor King
8ff34e6c5d Replace settings.get(key) with settings[key] for default settings
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.
2013-06-02 14:24:27 -04:00
Deniz Turgut
2790446906 adds a 'strftime' jinja fiter that uses LOCALE 2013-04-21 18:00:12 -04:00
Rogdham
ec8e257fde Output sources for translations as well. 2013-04-14 22:19:57 +01:00
Deniz Turgut
e6f3126ba6 Fix for issue #219: tags should list only main articles, not translations 2013-03-26 01:28:42 -04:00
W. Trevor King
29cdb37af3 generators: Use the static format to read Static metadata
This cuts down on the remaining difference between static files and
articles/pages.  The main difference is that path-based metadata is
now parsed for static content.
2013-03-21 14:17:50 -04: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
e5e455e0e5 Replace os.sep.join with the more robust os.path.join
From the Python docs for os.sep [1]:

  Note that knowing this is not sufficient to be able to parse or
  concatenate pathnames - use os.path.split() and os.path.join()...

Where I touched a line, I also changed double quoted string literals
to single quotes, since they are used more often in the source:

  wking@mjolnir ~/src/pelican $ git grep "'" pelican/*.py | wc -l
  683
  wking@mjolnir ~/src/pelican $ git grep '"' pelican/*.py | wc -l
  181

[1]: http://docs.python.org/3/library/os.html#os.sep
2013-03-21 11:38:14 -04:00
John Mastro
f92c800216 Add a period archives feature and brief docs.
Allows users to have per-year, per-month, and per-day archives of posts
automatically generated. The feature is disabled by default; to enable
it a user must supply format strings for a period's respective
`_SAVE_AS` setting.
2013-03-15 17:22:42 -07:00
Alexis Métaireau
14d548fc44 Introduce all_articles where articles is shadowed. 2013-03-11 23:07:54 -07:00
tehkonst
ab035795bc fix slug for feed urls
Conflicts:

	pelican/contents.py
2013-03-10 23:41:02 -07: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
W. Trevor King
49bf80ec39 contents: Convert StaticContent to Static, a Page subclass
Static needs a lot of the same handling as other pages, so make it a
subclass of Page.  The rename from StaticContent to Static makes for
cleaner configuration settings (STATIC_URL instead of
STATICCONTENT_URL).

All currently generated Static instances override the save_as
attribute explicitly on initialization, but it isn't hard to imagine
wanting to adjust STATIC file output based on metadata (e.g. extracted
from their source filename).  With this union, the framework for
manipulating URLs and filenames is shared between all source file
types.
2013-03-10 23:19:56 -07:00
Alexis Métaireau
964f7d96d6 endswith can take a list as an argument ;) 2013-03-06 11:46:17 -08:00
W. Trevor King
3f26f9af5b generators: Teach Generator.get_files to handle non-directory input
This makes it easier for StaticGenerator to walk FILES_TO_COPY, where
the input may be a directory or a bare filename.

Non-traversable file types (e.g. everything but directories and
symlinks to directories) are not checked against the exclude list.
The user-level effect of this is that explicit entries in STATIC_PATHS
or FILES_TO_COPY will override a hypothetical STATIC_EXCLUDES setting,
which seems like a reasonable approach.

I also removed the Python 2.5 compatibility check for `followlinks` in
os.walk, since Pelican is now Python >=2.7.
2013-03-06 08:38:45 -05:00
Irfan Ahmad
2692586abe Fixes #645 - Making cross-content linking windows compatible 2013-03-06 00:04:44 -08:00
nfletton
4a63695ae2 Fixed pagination link error when <DIRECT_TEMPLATE_NAME>_SAVE_AS setting used.
The unit test for this scenario was passing as it was testing for an incorrect 'page_name' variable being set.
2013-03-03 22:11:09 -08:00
Alexis Métaireau
3e364bb8a4 Don't overwrite output_path. Fix #750 2013-03-03 21:00:52 -08:00
Alexis Métaireau
519dcdbcb3 Manual pass on sources for better standards. 2013-03-03 20:12:31 -08:00
Chris Streeter
de44644700 Add a pages_generator_finalized signal.
I wrote a plugin that I'd like to also be able to run on pages in
addition to articles. Adding this signal will let me update the content
when a page is finished being generated.
2013-02-10 12:42:54 -08:00
Bruno Binet
d9855ae346 Merge pull request #662 from wking/rich-urlwrapper-comparisons
contents: Add rich comparisons to URLWrapper for easy sorting
2013-01-21 13:30:02 -08:00
W. Trevor King
004adfa5cc content: Convert Path.filename to .source_path
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
2013-01-18 07:57:35 -05:00
W. Trevor King
61f05672e6 content: Convert StaticContent.filepath to .filename
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
2013-01-18 07:40:42 -05:00
W. Trevor King
2c434ebac1 contents: Add rich comparisons to URLWrapper for easy sorting
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
2013-01-15 22:51:53 -05:00
Alexis Métaireau
149ca493e0 Annotate py3k code when needed. 2013-01-11 18:55:04 +01:00
Dirk Makowski
71995d5e1b Port pelican to python 3.
Stays compatible with 2.x series, thanks to an unified codebase.
2013-01-11 03:20:09 +01:00