1
0
Fork 0
forked from github/pelican
Commit graph

302 commits

Author SHA1 Message Date
Oliver Urs Lenz
576229ad19 allows pages to have draft status, like articles 2018-07-03 12:53:46 +02:00
Justin Mayer
5ca1cabe78
Merge pull request #2292 from oulenz/article_order
Remove hardcoded sorting of articles within categories, tags, authors, feeds
2018-04-06 12:08:29 -07:00
Justin Mayer
81b7e7481f
Merge pull request #2238 from mosra/feed-urls
Feed URL settings, making feeds aware of absolute URLs
2018-03-23 13:36:51 +01:00
Oliver Urs Lenz
c160cb73cc remove hardcoded sorting of articles within categories, tags, authors, feeds 2018-03-18 12:21:56 +01:00
Justin Mayer
72756a5c0d
Merge pull request #2072 from drounin/overrides_ref2021+merge_update
Add THEME_TEMPLATE_OVERRIDES. Refs #2021
2018-03-05 07:50:12 -08:00
Justin Mayer
f7681f7259
Merge pull request #2246 from mosra/theme-static-paths-files
Make THEME_STATIC_PATHS work for files as well
2018-02-10 11:29:06 -08:00
Justin Mayer
59fc1d02a7
Merge pull request #2235 from mosra/paginator-pattern-url
Allow using page URL in pagination patterns
2018-02-10 11:27:02 -08:00
Vladimír Vondruš
182fb11c80 Allow to use page URL in pagination pattern.
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.
2018-02-10 18:26:55 +01:00
Justin Mayer
e609641336
Merge pull request #2228 from skz169/page-generator-write-page-signal
Add a new signal: page_generator_write_page
2018-02-09 13:12:47 -08:00
Justin Mayer
2d24d6b997
Merge pull request #2288 from charlesfleche/fix-metadata-intrasite-links-squashed
Fix intrasite links for non-'summary' metadata

Metadata like `MyArticleBanner: ![alt text]({attach}banner.jpg)` would be properly parsed (as defined in `FORMATTED_FIELDS`), but the intrasite links would not be processed.

Only the summary gets its intrasite links processed, has its value is either generated from the content (calling self._update_content at some point) or self._update_content is explicitly called if summary is passed as metadata.

This PR expands the paths as soon as possible in (`Content.__init__`) for metadata defined in `FORMATTED_FIELDS`.
2018-02-09 11:41:30 -08:00
Charles Flèche
65daa9e537 Extract refresh_metadata_intersite_links methods 2018-02-09 10:39:11 +01:00
Vladimír Vondruš
430868e859 Make THEME_STATIC_PATHS work for files as well.
The test passes now.
2017-11-03 16:04:52 +01:00
Vladimír Vondruš
343e24a26f Make it possible to specify custom URLs for feeds.
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.
2017-10-29 21:35:23 +01:00
Dan Bate
88da1b89cb made template extensions configurable 2017-10-24 14:06:57 +01:00
Sergei K
17b37358e9 Add a new signal: page_generator_write_page 2017-10-17 07:38:18 +05:00
Pedro H
50af2ed45d Add THEME_TEMPLATE_OVERRIDES. Refs 2021
Allow for overriding individual templates from the theme by configuring
the Jinja2 `Environment` loader to search for templates in the
`THEME_TEMPLATES_OVERRIDES` path before the theme's `templates/`
directory.
2017-10-10 14:33:20 +08:00
winlu
089b46b7eb Consolidate validation of content (#2128)
* Consolidate validation of content

Previously we validated content outside of the content class via
calls to `is_valid_content` and some additional checks in page /
article generators (valid status).
This commit moves those checks all into content.valid() resulting
in a cleaner code structure.
This allows us to restructure how generators interact with content,
removing several old bugs in pelican (#1748, #1356, #2098).

- move verification function into content class
- move generator verifying content to contents class
- remove unused quote class
- remove draft class (no more rereading drafts)
- move auto draft status setter into Article.__init__
- add now parsing draft to basic test output
- remove problematic DEFAULT_STATUS setting
- add setter/getter for content.status
  removes need for lower() calls when verifying status

* expand c4b184fa32

Mostly implement feedback by @iKevinY.

* rename content.valid to content.is_valid
* rename valid_* functions to has_valid_*
* update tests and function calls in code accordingly
2017-07-24 10:01:14 -07:00
Alexandre de Verteuil
b46fbb7879 Add two STATIC_ settings. Fix #1982
STATIC_CREATE_LINKS = False

Create links instead of copying files. If the content and output
directories are on the same device, then create hard links. Falls
back to symbolic links if the output directory is on a different
filesystem. If symlinks are created, don’t forget to add the -L or
--copy-links option to rsync when uploading your site.

STATIC_CHECK_IF_MODIFIED = False

If set to True, and STATIC_CREATE_LINKS is False, compare mtimes of
content and output files, and only copy content files that are newer
than existing output files.
2016-12-30 02:45:37 -05:00
Deniz Turgut
fc52234986 Fix generator caching
With generator level caching, cached files weren't added to the
collections. Only new files were processed. This fixes the issue.
2016-12-10 02:05:35 -05:00
Ryan M
335c40d23e Allow setting Jinja environment arguments from settings
fix flake8 warnings

Set jinja environment defaults within settings

updating docs to remove JINJA_EXTENSIONS

update logger warning and defaults documentation

better way to grab jinja environment

updating settings after refactor
2016-12-03 10:27:27 -08:00
Kevin Yap
6cadbdf354 Fix extension-matching bug in generators.py
Addresses #1946.
2016-10-12 23:33:29 -07:00
Jerry Asher
f8031203d2 Python's shutil.copy2 fails on Android
Python's shutil.copy2 fails on Android when copying a file's meta data (perm bits, access times) onto certain filesystems. This is documented as python issue28141 https://bugs.python.org/issue28141

These commits workaround that bug by

+ creating a new function copy_file_metadata in utils.py
+ wrapping calls to copy2 in a try/except clause that logs any errors that occur but keep execution going
+ changing the calls to shutil.copy2 to calls to the new function
2016-10-07 11:10:09 -07:00
davidlesieur
3b6d059eac Fix #1291: Feeds have ambiguous titles on sites with multiple categories. 2016-04-17 10:42:52 -04:00
derwinlu
8993c55e6e fulfil pep8 standard 2015-08-17 13:34:32 +02:00
derwinlu
ec5c77b251 remove PAGES; use pages instead
* remove PAGES from context as pages is available
* add section to FAQ to provide guidance
2015-06-27 19:11:55 +02:00
Jonathan Lange
108b67282a Export hidden pages in context
The `PageGenerator` was building hidden pages, but was not making them
available in the context. This makes it difficult for other plugins to
operate on hidden pages.

This patch updates `PageGenerator` to export the hidden pages it finds
in the context as `hidden_pages`.

It also updates the article generator to export `drafts`.
2015-06-20 11:21:39 +01:00
Deniz Turgut
da8b469ab8 Fix #1647: Fix ARTICLE_ORDER_BY and add the ability to reverse order
ARTICLE_ORDER_BY wasn't doing anything because the ArticlesGenerator
was sorting articles after ARTICLE_ORDER_BY was applied. This fixes
that by adding the ability to reverse metadata order by adding the
option prefix 'reversed-' to metadata and changing the default value
to 'reversed-date'.

Relevant documentation is also updated and moved into a more appropriate
place ('Ordering Content' instead of 'URL settings').
2015-06-12 18:14:54 -04:00
Justin Mayer
1da84349c4 Merge pull request #1693 from zackw/static-honor-ignore-files
Honor 'IGNORE_FILES' in StaticGenerator._copy_paths (#1692).
2015-06-10 11:54:29 -07:00
derwinlu
b7e6390f04 fix caching
*  break out cache into cache.py
*  break out cache-tests into test_cache.py
*  fix broken cache tests
   *  replace non existing assert calls with self.assertEqual
   *  fix path for page caching test (was invalid)
   *  cleanup test code
*  restructure generate_context in Article and Path Generator
   * destinguish between valid/invalid files correctly and cache accordingly
*  use cPickle if available for increased performance
2015-06-08 09:34:30 +02:00
Zack Weinberg
1aac19caaf Honor 'IGNORE_FILES' in the static generator (issue 1692)
This means, for instance, that editor backups and similar will no
longer be copied out of a theme static directory into the built
website.
2015-06-04 17:58:14 -04:00
Zack Weinberg
c7b9a339eb Apply 'IGNORE_FILES' globs to directories as well (issue 1692)
This adjusts the only piece of code that currently looks at IGNORE_FILES.
A subsequent commit will add a new use, with the same semantics.
2015-06-04 17:57:06 -04:00
Justin Mayer
389d0cec52 Merge pull request #1453 from arty-name/period-archives-syntax-errors
Fix #1405: No error message for invalid syntax in period_archives.html
2015-05-30 09:29:53 -07:00
Justin Mayer
8786732044 Merge pull request #1703 from ingwinlu/remove_tag_cloud
Remove tag_cloud from Pelican core
2015-05-13 23:19:24 +02:00
Justin Mayer
807b3bced3 Merge pull request #1471 from roidelapluie/master
Add a new signal: page_writer_finalized
2015-05-06 13:13:48 +02:00
Justin Mayer
9a38f61e4d Merge pull request #1700 from avaris/1686
Fixes #1686: posixize paths in context['filenames'] to fix windows issues
2015-04-29 16:06:19 +02:00
Ingmar Steen
df54953032 Fix intra-site links to drafts.
Overwrite an article's source path registration when it is
'upgraded' to a draft.

Fixes #865
2015-04-29 15:13:08 +02:00
winlu
9dd4080fe6 remove tag_cloud from core 2015-04-20 12:16:05 +02:00
Deniz Turgut
90a283bc44 Fixes #1686: posixize paths in context['filenames'] to fix windows issues 2015-04-16 19:05:15 -04:00
Forest
db2e517450 Ignore empty metadata. Fixes #1469. Fixes #1398.
Some metadata values cause problems when empty.  For example, a markdown file
containing a Slug: line with no additional text causing Pelican to produce a
file named ".html" instead of generating a proper file name.  Others, like
those created by a PATH_METADATA regex, must be preserved even if empty,
so things like PAGE_URL="filename{customvalue}.html" will always work.
Essentially, we want to discard empty metadata that we know will be useless
or problematic.  This is better than raising an exception because (a) it
allows users to deliberately keep empty metadata in their source files for
filling in later, and (b) users shouldn't be forced to fix empty metadata
created by blog migration tools (see #1398).

The metadata processors are the ideal place to do this, because they know
the type of data they are handling and whether an empty value is wanted.
Unfortunately, they can't discard items, and neither can process_metadata(),
because their return values are always saved by calling code.  We can't
safely change the calling code, because some of it lives in custom reader
classes out in the field, and we don't want to break those working systems.
Discarding empty values at the time of use isn't good enough, because that
still allows useless empty values in a source file to override configured
defaults.

My solution:
- When processing a list of values, a metadata processor will omit any
  unwanted empty ones from the list it returns.
- When processing an entirely unwanted value, it will return something easily
  identifiable that will pass through the reader code.
- When collecting the processed metadata, read_file() will filter out items
  identified as unwanted.

These metadata are affected by this change:
author, authors, category, slug, status, tags.

I also removed a bit of now-superfluous code from generators.py that was
discarding empty authors at the time of use.
2015-03-24 11:37:07 -07:00
Forest
784d07e940 ArticlesGenerator: set blog=True consistently.
Fixes #1631.
2015-02-19 12:25:48 -08:00
Kevin Yap
954c85a593 Make PagesGenerator status check case-insensitive
Fixes #1620.
2015-02-09 17:11:45 -08:00
Forest
0fe290c321 Make PAGE_EXCLUDES work with subdirs. Fixes #1500.
The old code was naively comparing the strings in PAGE_EXCLUDES to the
subdirectory names produced by os.walk(). (Same with ARTICLE_EXCLUDES.)
This had two surprising effects:

Setting PAGE_EXCLUDES=['foo'] would exclude all directories named foo,
regardless of whether they were in the top-level content directory or
nested deep within a directory whose contents should not be excluded.

Setting PAGE_EXCLUDES=['subdir/foo'] would never exclude any directories.

In other words, there is no way to exclude a subdirectory without risking
the accidental exclusion of other directories with the same name elsewhere
in the file system.

This change fixes the problem, so 'subdir/foo' and 'foo' will be distinct
and both work as expected. If anyone out there is depending on the old
behavior, they will have to update their settings. I don't expect it to
affect most users yet, since Pelican doesn't yet make nested directory
structures very useful. When it does, this fix will become important to
more people.
2014-11-01 17:38:20 -07:00
Forest
48f4f0850d Make StaticGenerator skip content sources. Refs #1019.
This change partially addresses issue #1019, by teaching Pelican to distinguish
between static files and content source files. A user can now safely add the
same directory to both STATIC_PATHS and PAGE_PATHS (or ARTICLE_PATHS). Pelican
will then process the content source files in that directory normally, and
treat the remaining files as static, without copying the raw content source
files to the output directory. (The OUTPUT_SOURCES setting still works.)

In other words, images and markdown/reST files can now safely live together.

To keep those files together in the generated site, STATIC_SAVE_AS and
PAGE_SAVE_AS (or ARTICLE_SAVE_AS) should point to the same output directory.

There are two new configuration settings:

STATIC_EXCLUDES=[]  # This works just like PAGE_EXCLUDES and ARTICLE_EXCLUDES.
STATIC_EXCLUDE_SOURCES=True  # Set this to False to get the old behavior.

Two small but noteworthy internal changes:

StaticGenerator now runs after all the other generators. This allows it to see
which files are meant to be processed by other generators, and avoid them.

Generators now include files that they fail to process (e.g. those with missing
mandatory metadata) along with all the other paths in context['filenames'].
This allows such files to be excluded from StaticGenerator's file list, so they
won't end up accidentally published. Since these files have no Content object,
their value in context['filenames'] is None. The code that uses that dict has
been updated accordingly.
2014-10-31 16:46:01 -07:00
Julien Pivotto
c92e00f17b Add a new signal: page_writer_finalized 2014-09-19 10:12:42 +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
Artemy Tregubenko
304b16a9be Fixes #1405: No error message for invalid syntax in period_archives.html 2014-08-31 09:55:45 +02: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
Ondrej Grover
7fabd712a1 Generator.get_files backwards compatibility for 1 path
This should prevent outdated plugins with generators from failing.
Also fixes #1382.
2014-06-27 20:18:17 +02: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
d635a347d1 move {ARTICLE,PAGE}_DIR -> {ARTICLE,PAGE}_PATHS
Instead of one path a list can be given. This is due to popular request.
Should help people not wanting to use Pelican for blogging.
Maintain backward compatibility though.
Thanks to @ingwinlu for pointing out the change in StaticGenerator.
2014-05-14 14:04:50 +02:00