mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
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.
This commit is contained in:
parent
e89b32511d
commit
41fdfa63b1
4 changed files with 31 additions and 22 deletions
|
|
@ -152,12 +152,12 @@ Setting name (default value) what does it do?
|
||||||
use the default language.
|
use the default language.
|
||||||
`PAGE_LANG_SAVE_AS` ('pages/{slug}-{lang}.html') The location we will save the page which doesn't
|
`PAGE_LANG_SAVE_AS` ('pages/{slug}-{lang}.html') The location we will save the page which doesn't
|
||||||
use the default language.
|
use the default language.
|
||||||
`AUTHOR_URL` ('author/{name}.html') The URL to use for an author.
|
`AUTHOR_URL` ('author/{slug}.html') The URL to use for an author.
|
||||||
`AUTHOR_SAVE_AS` ('author/{name}.html') The location to save an author.
|
`AUTHOR_SAVE_AS` ('author/{slug}.html') The location to save an author.
|
||||||
`CATEGORY_URL` ('category/{name}.html') The URL to use for a category.
|
`CATEGORY_URL` ('category/{slug}.html') The URL to use for a category.
|
||||||
`CATEGORY_SAVE_AS` ('category/{name}.html') The location to save a category.
|
`CATEGORY_SAVE_AS` ('category/{slug}.html') The location to save a category.
|
||||||
`TAG_URL` ('tag/{name}.html') The URL to use for a tag.
|
`TAG_URL` ('tag/{slug}.html') The URL to use for a tag.
|
||||||
`TAG_SAVE_AS` ('tag/{name}.html') The location to save the tag page.
|
`TAG_SAVE_AS` ('tag/{slug}.html') The location to save the tag page.
|
||||||
`<DIRECT_TEMPLATE_NAME>_SAVE_AS` The location to save content generated from direct
|
`<DIRECT_TEMPLATE_NAME>_SAVE_AS` The location to save content generated from direct
|
||||||
templates. Where <DIRECT_TEMPLATE_NAME> is the
|
templates. Where <DIRECT_TEMPLATE_NAME> is the
|
||||||
upper case template name.
|
upper case template name.
|
||||||
|
|
|
||||||
|
|
@ -93,8 +93,8 @@ author.html
|
||||||
This template will be processed for each of the existing authors, with
|
This template will be processed for each of the existing authors, with
|
||||||
output generated at output/author/`author_name`.html.
|
output generated at output/author/`author_name`.html.
|
||||||
|
|
||||||
If pagination is active, subsequent pages will reside at
|
If pagination is active, subsequent pages will reside as defined by setting
|
||||||
output/author/`author_name``n`.html.
|
AUTHOR_SAVE_AS (`Default:` output/author/`author_name'n'`.html).
|
||||||
|
|
||||||
=================== ===================================================
|
=================== ===================================================
|
||||||
Variable Description
|
Variable Description
|
||||||
|
|
@ -109,8 +109,8 @@ dates_paginator A paginator object for the article list, ordered by
|
||||||
date, ascending.
|
date, ascending.
|
||||||
dates_page The current page of articles, ordered by date,
|
dates_page The current page of articles, ordered by date,
|
||||||
ascending.
|
ascending.
|
||||||
page_name 'author/`author_name`' -- useful for pagination
|
page_name AUTHOR_URL where everything after `{slug}` is
|
||||||
links
|
removed -- useful for pagination links
|
||||||
=================== ===================================================
|
=================== ===================================================
|
||||||
|
|
||||||
category.html
|
category.html
|
||||||
|
|
@ -119,8 +119,8 @@ category.html
|
||||||
This template will be processed for each of the existing categories, with
|
This template will be processed for each of the existing categories, with
|
||||||
output generated at output/category/`category_name`.html.
|
output generated at output/category/`category_name`.html.
|
||||||
|
|
||||||
If pagination is active, subsequent pages will reside at
|
If pagination is active, subsequent pages will reside as defined by setting
|
||||||
output/category/`category_name``n`.html.
|
CATEGORY_SAVE_AS (`Default:` output/category/`category_name'n'`.html).
|
||||||
|
|
||||||
=================== ===================================================
|
=================== ===================================================
|
||||||
Variable Description
|
Variable Description
|
||||||
|
|
@ -135,8 +135,8 @@ dates_paginator A paginator object for the list of articles,
|
||||||
ordered by date, ascending
|
ordered by date, ascending
|
||||||
dates_page The current page of articles, ordered by date,
|
dates_page The current page of articles, ordered by date,
|
||||||
ascending
|
ascending
|
||||||
page_name 'category/`category_name`' -- useful for pagination
|
page_name CATEGORY_URL where everything after `{slug}` is
|
||||||
links
|
removed -- useful for pagination links
|
||||||
=================== ===================================================
|
=================== ===================================================
|
||||||
|
|
||||||
article.html
|
article.html
|
||||||
|
|
@ -171,8 +171,8 @@ tag.html
|
||||||
This template will be processed for each tag, with corresponding .html files
|
This template will be processed for each tag, with corresponding .html files
|
||||||
saved as output/tag/`tag_name`.html.
|
saved as output/tag/`tag_name`.html.
|
||||||
|
|
||||||
If pagination is active, subsequent pages will reside at
|
If pagination is active, subsequent pages will reside as defined in setting
|
||||||
output/tag/`tag_name``n`.html.
|
TAG_SAVE_AS (`Default:` output/tag/`tag_name'n'`.html).
|
||||||
|
|
||||||
=================== ===================================================
|
=================== ===================================================
|
||||||
Variable Description
|
Variable Description
|
||||||
|
|
@ -187,7 +187,8 @@ dates_paginator A paginator object for the list of articles,
|
||||||
ordered by date, ascending
|
ordered by date, ascending
|
||||||
dates_page The current page of articles, ordered by date,
|
dates_page The current page of articles, ordered by date,
|
||||||
ascending
|
ascending
|
||||||
page_name 'tag/`tag_name`' -- useful for pagination links
|
page_name TAG_URL where everything after `{slug}` is removed
|
||||||
|
-- useful for pagination links
|
||||||
=================== ===================================================
|
=================== ===================================================
|
||||||
|
|
||||||
Inheritance
|
Inheritance
|
||||||
|
|
|
||||||
|
|
@ -183,15 +183,23 @@ class URLWrapper(object):
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def _from_settings(self, key):
|
def _from_settings(self, key, get_page_name=False):
|
||||||
|
"""Returns URL information as defined in settings.
|
||||||
|
When get_page_name=True returns URL without anything after {slug}
|
||||||
|
e.g. if in settings: CATEGORY_URL="cat/{slug}.html" this returns "cat/{slug}"
|
||||||
|
Useful for pagination."""
|
||||||
setting = "%s_%s" % (self.__class__.__name__.upper(), key)
|
setting = "%s_%s" % (self.__class__.__name__.upper(), key)
|
||||||
value = self.settings[setting]
|
value = self.settings[setting]
|
||||||
if not isinstance(value, basestring):
|
if not isinstance(value, basestring):
|
||||||
logger.warning(u'%s is set to %s' % (setting, value))
|
logger.warning(u'%s is set to %s' % (setting, value))
|
||||||
return value
|
return value
|
||||||
else:
|
else:
|
||||||
return unicode(value).format(**self.as_dict())
|
if get_page_name:
|
||||||
|
return unicode(value[:value.find('{slug}') + len('{slug}')]).format(**self.as_dict())
|
||||||
|
else:
|
||||||
|
return unicode(value).format(**self.as_dict())
|
||||||
|
|
||||||
|
page_name = property(functools.partial(_from_settings, key='URL', get_page_name=True))
|
||||||
url = property(functools.partial(_from_settings, key='URL'))
|
url = property(functools.partial(_from_settings, key='URL'))
|
||||||
save_as = property(functools.partial(_from_settings, key='SAVE_AS'))
|
save_as = property(functools.partial(_from_settings, key='SAVE_AS'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ class ArticlesGenerator(Generator):
|
||||||
write(tag.save_as, tag_template, self.context, tag=tag,
|
write(tag.save_as, tag_template, self.context, tag=tag,
|
||||||
articles=articles, dates=dates,
|
articles=articles, dates=dates,
|
||||||
paginated={'articles': articles, 'dates': dates},
|
paginated={'articles': articles, 'dates': dates},
|
||||||
page_name=u'tag/%s' % tag)
|
page_name=tag.page_name)
|
||||||
|
|
||||||
def generate_categories(self, write):
|
def generate_categories(self, write):
|
||||||
"""Generate category pages."""
|
"""Generate category pages."""
|
||||||
|
|
@ -208,7 +208,7 @@ class ArticlesGenerator(Generator):
|
||||||
write(cat.save_as, category_template, self.context,
|
write(cat.save_as, category_template, self.context,
|
||||||
category=cat, articles=articles, dates=dates,
|
category=cat, articles=articles, dates=dates,
|
||||||
paginated={'articles': articles, 'dates': dates},
|
paginated={'articles': articles, 'dates': dates},
|
||||||
page_name=u'category/%s' % cat)
|
page_name=cat.page_name)
|
||||||
|
|
||||||
def generate_authors(self, write):
|
def generate_authors(self, write):
|
||||||
"""Generate Author pages."""
|
"""Generate Author pages."""
|
||||||
|
|
@ -218,7 +218,7 @@ class ArticlesGenerator(Generator):
|
||||||
write(aut.save_as, author_template, self.context,
|
write(aut.save_as, author_template, self.context,
|
||||||
author=aut, articles=articles, dates=dates,
|
author=aut, articles=articles, dates=dates,
|
||||||
paginated={'articles': articles, 'dates': dates},
|
paginated={'articles': articles, 'dates': dates},
|
||||||
page_name=u'author/%s' % aut)
|
page_name=aut.page_name)
|
||||||
|
|
||||||
def generate_drafts(self, write):
|
def generate_drafts(self, write):
|
||||||
"""Generate drafts pages."""
|
"""Generate drafts pages."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue