1
0
Fork 0
forked from github/pelican
Commit graph

75 commits

Author SHA1 Message Date
Justin Mayer
fbc65e0d7b Merge pull request #1366 from Scheirle/paginated_relative_urls_fix2
Fixes wrongly generated relative urls for pagination.
2014-09-18 16:15:21 -07:00
Artemy Tregubenko
0093984861 Add feed_written signal 2014-08-28 20:09:42 +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
Bernhard Scheirle
af0899ae2a Fixes wrongly generated relative urls for pagination.
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.
2014-07-12 21:10:42 +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
OGINO Masanori
ca3aa1e75f Use six.moves.urllib.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-06-10 17:30:17 +09: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
Helmut Grohne
3f304a2e92 change the inhibition value of *_SAVE_AS to ''
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.
2014-03-31 19:38:49 +02:00
th3aftermath
990ddb5a5e Fix Issue #1165 allows extensions to be set by certain settings
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.
2014-03-08 20:33:23 -05:00
Simon Conseil
18e6ec9f02 Simplify a bit pagination code. 2014-01-05 23:34:46 +01:00
Simon Conseil
c90a62ea13 pep8 fixes 2014-01-05 23:34:46 +01:00
Florian Jacob
bd9d1b9539 The modified attribute no longer has a default value.
This allows for templates using {% if article.modified %}
instead of {% if article.modified != article.published %} .
2013-11-17 23:40:11 +01:00
Justin Mayer
ad74464e94 Merge pull request #1140 from gpoo/fix-invalid-atom-feed-uid
Fix #1039 Atom feed for sites using HTTPS or a subdirectory
2013-11-12 17:56:13 -08:00
Florian Jacob
4b2fcb09a4 Added a new ''modified:' metadata tag to be able to specify the
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.
2013-11-10 00:14:55 +01:00
Germán Poo-Caamaño
efc1d38efd Fix invalid atom feed id:tag
Fixes #1039: The atom feed generated produces an invalid attribute
id:tag when SITEURL has something different that http or it contain
a subdirectory, such as:
  * https://myblog.com/
  * https://mysite.com/blog
  * http://mysite.com/blog
2013-10-31 13:29:43 -07:00
Adrien Oliva
caa833877d Change StandardError to RuntimeError
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)
2013-10-11 15:52:47 +02:00
Alexis Métaireau
339955376e Add a content_written signal 2013-08-17 12:48:34 +02: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
Ross McFarland
e07b39dfcb more robust PAGINATION_(URL|SAVE_AS) support
- add base_name and number_seperator to context to give more flexibility
  when naming things
2013-07-29 08:09:44 -04:00
Ross McFarland
c5eecd23eb PAGINATION_URL/PAGINATION_SAVE_AS implementation
allows the use of custom urls for pagination similar to *_URLS
2013-07-29 08:09:44 -04: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
Chris Brannon
f8cf685c30 Use the builtin "open" on Python 3. 2013-05-27 14:49:57 +10:00
Rogdham
ff7410ce2a Check URL overwrite. Fixes #446.
Check that template-generated files don't overwrite each other. Log a critical
message otherwise, and exit with non-zero status.
2013-04-14 20:39:04 +01:00
Justin Mayer
0a8678a8ae Change RELATIVE_URLS default to False - Fixes #829 2013-04-11 16:12:55 -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
William Light
e045515b91 add "output_file" Jinja context variable
"output_file" contains the name of the HTML file that pelican is
currently rendering.
2013-03-10 23:53:41 -07:00
Alexis Métaireau
519dcdbcb3 Manual pass on sources for better standards. 2013-03-03 20:12:31 -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
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
Bruno Binet
a0504aeabe add support for relative cross-site links 2012-12-01 21:32:02 +01:00
Bruno Binet
c74abe579b Don't rewrite URLs
Remove the code that was appending ../static in front of some URLs, and add a
way to do cross-content linking.
2012-12-01 21:30:50 +01:00
Bruno Binet
c787e02dcc Merge branch 'pr/555'
Conflicts:
	pelican/contents.py
2012-11-13 01:23:31 +01:00
Brendan Wholihan
f7a2f8ea47 Removed AUTHOR defaulting to OS User /John Doe, so both a blank or undefined (None) author is possible.
Reverted templates back to checking author object, since a None object is possible. Name could be checked for blank if required
ATOM spec states an author element should be provided, so passes a blank name if not specified
Updated unit test
2012-10-26 18:20:05 +01:00
Alexis Métaireau
dd299d272b merge win-encoding 2012-10-25 14:47:57 +02:00
Brian St. Pierre
b1f65f6c9f Fix #535: pagination on files without an extension 2012-10-06 22:35:47 -04:00
Guillermo López
77a538e588 always return Unix-like relative paths, even on Windows 2012-09-04 00:29:02 +02:00
Simon
e9996b5cc6 strip tags for feed titles 2012-05-07 13:05:33 +02:00
Alexis Metaireau
58d98e918f Merge pull request #326 from neoascetic/_save_as_behavior
*_SAVE_AS = False fix
2012-04-26 10:39:56 -07:00
Pavel Puchkin
898ac3808f Last fix? 2012-04-20 11:28:00 +11:00
Pavel Puchkin
6116236ed9 *_SAVE_AS = None fix
Ability to disable creating some files when their `_SAVE_AS` setting is
set to none-value. Mostly for disabling creating of `authors` stuff
(when there only one user, see #320 for details)
2012-04-18 18:56:53 +11:00
Justin Mayer
e29b54e5e0 Replace omitted slash in feed URL generation
This slash was originally present, but I removed it at some point
because it was causing double-slashes. I believe the reason is that I
had a leading slash in my article URL pattern, which in retrospect
should not have been there. Omitting the slash caused problems for other
folks; I should have tested this better. This commit puts the slash back
where it belongs.
2012-04-16 09:10:20 -07:00
Justin Mayer
56b8a88b1f Improve uniqueness of feed entry ID
The ID of a feed entry should never change, but the previous method of
generating the ID -- i.e., using the entry URL -- results in an ID that
is not permanent and can change. Switching to the tag URI method from
RFC 4151 should help improve the long-term uniqueness and permanence of
entry IDs, as espoused here:
<http://web.archive.org/web/20110514113830/http://diveintomark.org/archives/2004/05/28/howto-atom-id>

Also added a trailing slash to the site URL inside the feed; the lack
thereof was causing a feed validation warning.
2012-03-31 10:08:16 -07:00
Justin Mayer
34310a61f5 Feed link inside feed should use FEED_DOMAIN
The initial work on enabling feeds to be served from a different domain
than the site domain focused on the feed link displayed inside the
base template. But there is also a feed link inside the generated feed
itself, which this commit updates to use the FEED_DOMAIN value (if
defined).

Also, it turns out that the FEED_MAIN_URL setting is not necessary; the
existing FEED and FEED_RSS functionality is simpler and can address the
targeted use case just as easily. That attribute has been removed from
the settings and template, along with corresponding changes to the docs.
Refs #177.
2012-03-31 08:10:40 -07:00
Andrea Crotti
0922efa371 change the way logging is done, using the standard log tree instead of
calling the module-level functions on an unitialised logging object.

This allows to
- simplify log.py
- use one logger object for each file
2012-03-20 13:01:21 +00:00
Alexis Metaireau
6cde7fd27a PEP8-ify.
Wrap to 80 chars, sanitize imports.
2012-03-09 16:21:38 +01:00
Stéphane Raimbault
9cced6be83 Sort imports and remove trailing whitespaces 2012-02-28 17:40:13 +01:00
Kyle Fuller
2be58aa51a Remove WITH_PAGINATION, only have a DEFAULT_PAGINATION setting
DEFAULT_PAGINATION can be set to False instead of using WITH_PAGINATION
2011-12-22 14:02:31 +00:00
Brian Hsu
b2919e9051 Add unique_id to RSS/ATOM feeds.
Reason:

    Without <guid> tag in RSS XML, some RSS reader will show all
    items in RSS as unread item.
2011-11-29 09:53:48 +08:00
Rémy HUBSCHER
32a6ecbcc5 Fix timezone bug for ATOM generation 2011-08-16 15:11:49 +02:00
Rémy HUBSCHER
acb65b77af GMT Time in ATOM feeds 2011-08-16 11:40:08 +02:00