1
0
Fork 0
forked from github/pelican
Commit graph

121 commits

Author SHA1 Message Date
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
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
zhouji
e538aa2cde Fine-tune url-value HTML attributes list. 2013-10-17 11:33:34 +08:00
zhouji
04dba17b80 Fix #1117 Make intra-link support all url-value HTML attributes. 2013-10-16 17:06:56 +08:00
Honza Javorek
6fb0335269 Attempt to be compilant with Python 3. 2013-09-25 11:39:29 +02:00
Honza Javorek
7d43c4fa00 Support for params and fragments in intrasite links. Adresses #1063. 2013-09-24 15:18:09 +02:00
Honza Javorek
e5c0a54c57 Removed obsolete comment. 2013-09-24 14:19:47 +02:00
Talha Mansoor
48fa70c6a6 Add INTRASITE_LINK_REGEX to configuration that user can modify
This INTRASITE_LINK_REGEX is a string. It should have the capturing
group name which is `what`.

This change was made after discussions with @ametaireau and
@justinmayer.

1. https://github.com/getpelican/pelican/pull/1067
1. https://github.com/getpelican/pelican/pull/1071

Updates getpelican/pelican#1061
2013-09-09 00:06:18 +05:00
Talha Mansoor
2f34307e12 Change the regex so that it parse |filename| and {filename} equally
Updates getpelican/pelican#1061
2013-08-29 23:14:47 +05:00
Alexis Métaireau
e2ca6d7608 Add categories and tags to the replacement mechanism. 2013-08-17 17:36:13 +02:00
Nick Moore
6c5444eb68 do slug_substitutions on category and author ... 2013-07-14 23:01:16 +10: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
W. Trevor King
29f0aa39d2 content: Don't update static content 2013-06-12 17:37:21 -04:00
W. Trevor King
fdde17281d contents: Page fallbacks for context and localsiteurl 2013-06-12 17:37:21 -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
W. Trevor King
e9dc1dd478 settings: Make DEFAULT_CONFIG public
This dictionary is accessed by plugins (like `summary`) which add new
settings, so it should be public (i.e. no prefixed underscore).

The changed name length would have led to a re-indenting of the
default contents anyway, so I shifted them all to four spaces.
2013-06-02 13:32:10 -04:00
Dominique Plante
7024fe1192 adhere to pep8 2013-05-15 22:18:35 -07:00
Deniz Turgut
9af62414db Fixes #708 SUMMARY_MAX_LENGTH=0 should return empty string 2013-04-26 19:37:31 -04:00
Justin Mayer
bdd702384f Improve wording of "cannot find" errors 2013-04-20 08:08:31 -07:00
Justin Mayer
d0489758ad Minor English grammar correction 2013-04-07 14:43:07 -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
Alexis Métaireau
37f6190c69 URLWrapper moved! 2013-03-10 23:42:08 -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
c6856dec44 Replace \ with / when replacing the URLs. See #763 2013-03-10 23:09:43 -07:00
Alexis Métaireau
14cf5f014c Some doc + various enhancements 2013-03-10 22:57:08 -07:00
Alexis Métaireau
fa77c3d66a This should be a warning, not an error :) 2013-03-10 22:30:36 -07:00
Irfan Ahmad
2692586abe Fixes #645 - Making cross-content linking windows compatible 2013-03-06 00:04:44 -08:00
Justin Mayer
d0e9c52410 Merge pull request #623 from bbinet/url-save_as-override
Override page 'url' and 'save_as' directly from the page metadata. Fixes #400.
2013-03-04 10:11:45 -08:00
Alexis Métaireau
519dcdbcb3 Manual pass on sources for better standards. 2013-03-03 20:12:31 -08:00
Bruno Binet
ed907b4094 PageClass arg is useless in content_object_init 2013-03-01 00:06:05 +01:00
dave mankoff
3f4406dd6b support inline summary specification
update documentation

change summary cutoff to a plugin

remove backup file

fix 3.2 tests

update summary plugin initialization and documentation

update documentation

fix documentation formatting
2013-02-12 22:35:02 -05:00
Benoît HERVIER
5f3a3e4582 Update pelican/contents.py
Put a space in error message to not concatain word 'about' and the missing tag
2013-01-24 14:10:26 +01: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
13cd0a4cb3 contents: Add deprecation warnings for Page.filename and StaticContent.filepath 2013-01-18 08:48:26 -05: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
Bruno Binet
08a5ea6fdf Merge pull request #663 from wking/url-format-metadata
contents: Page.url_format should expose all metadata
2013-01-18 03:20:10 -08:00
W. Trevor King
d2a221c899 contents: Encode Unicode locales for Python 2 in Page.__init__
Python 2.7 chokes on Unicode locales:

  $ python2.7
  >>> import locale
  >>> locale.setlocale(locale.LC_ALL, u'ja_JP.utf8')
  Traceback (most recent call last):
    ...
  ValueError: too many values to unpack

With the addition of:

  from __future__ import unicode_literals

to tests/test_contents.py in:

  commit bebb94c15b
  Author: W. Trevor King <wking@tremily.us>
  Date:   Tue Jan 15 22:50:58 2013 -0500

    test_contents.py: Add URLWrapper comparison tests

the locale strings in TestPage.test_datetime are interpreted as
Unicode.  Rather than fixing the encoding there, this patch updates
Page to handle Unicode locales automatically.
2013-01-17 09:49:03 -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
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
W. Trevor King
88b5a27ddf contents: Page.url_format should expose all metadata
I want to add `directory` metadata to each page in `content/pages/` to
place my non-article pages by hand:

  PAGE_URL = '{directory}/{slug}'
  PAGE_SAVE_AS = '{directory}/{slug}/index.html'

To do this, I need the `directory` metadata for formatting the URL.
2013-01-03 18:18:18 -05:00
Bruno Binet
a5772bf3d6 allow override page url and save_as values directly from the metadata
this is similar to the template override implemented in #404
2012-12-07 00:10:39 +01:00
Bruno Binet
21e8087822 fix weird implementation for extension removal
this leads to raising exception when slug was not used to generate the url
2012-12-04 00:49:32 +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
a9cdf3c5a1 remove old import statement 2012-11-21 14:24:40 +01:00
Bruno Binet
c787e02dcc Merge branch 'pr/555'
Conflicts:
	pelican/contents.py
2012-11-13 01:23:31 +01:00
Martin Brochhaus
47c972e21a Added USE_FOLDER_AS_CATEGORY setting.
This allows users to organize their files in ways where the subfolder name
would not make a good category name (i.e. /2012/09/). Set this to ``False``
and the subfolder will no longer be used as a standard category,
`DEFAULT_CATEGORY` will be used instead.
2012-10-28 20:43:45 +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