1
0
Fork 0
forked from github/pelican
Commit graph

208 commits

Author SHA1 Message Date
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
Alexis Métaireau
93c04cd79f merge with master 2012-10-25 13:20:27 +02:00
Trae Blain
41fdfa63b1 Fixed page_name call to adapt to the link structure provided by the
Settings file. Also updated the documentation accordingly.

Update documentation to cover new page_name behavior

Fixed page_name to adapt to the links provided by the Settings file. Includes documentation updates as well.

Updated terms to maintain better syntax and consistancy

Added docstring to _from_settings() to clarify the get_page_name argument that was added. Explains why/when this argument is used.

Revert contents.py back to commit 2f29c51

Re-added docstring to _get_settings method, but this time not deleting things I shouldn't

Corrected readability change that was altered during revert.
2012-09-04 08:55:43 -05:00
Rachid Belaid
6100773c24 Add a new signal content_object_init
It's sent when a new content object is created: Page, Article
2012-09-02 19:20:42 +01:00
tBunnyMan
644fd4ed5f Deep copy _DEFAULT_SETTINGS instead of linking.
This caused the defaults to be overwritten and edge case bugs with tests.
The test for empty setting needed to be updated to reflect that the method
for setting up the local settings sets extra settings.
2012-08-29 13:36:15 -07:00
tBunnyMan
dff5b3589b Add per page templates. Closes #376
Also set up helper classes in test_generators.py for cleaner tests
2012-07-07 14:15:43 -07:00
dave mankoff
9fb5969c59 Allow settings to specify a summary length, optionally allowing unlimited summary length 2012-06-10 17:58:05 -04:00
Pavel Puchkin
19cfe00397 Checking for basestring isinstance, not (str, unicode) 2012-04-29 14:45:34 +11:00
Pavel Puchkin
898ac3808f Last fix? 2012-04-20 11:28:00 +11:00
Pavel Puchkin
9dcf612f9d Fixes after review 2012-04-18 23:07:57 +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
Dafydd Crosby
28a1e0f432 Fix some typos and grammar 2012-04-07 18:02:40 -06:00
Alexis Metaireau
b845db30de Add a way to know what metadata exists.
This allows in a theme to have a look at the "metadata" attribute of a content
to know what are the metadata fields defined by it.
2012-04-03 11:58:31 +02:00
m-r-r
fc584969c9 patch for bug #271 (Unicode issue in category name) 2012-03-23 19:31:44 +01:00