mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add a DEFAULT_METADATA setting.
It is now possible to have soem default metadata defined in the settings. Fixes #98
This commit is contained in:
parent
e09444fa89
commit
56effc24cb
5 changed files with 11 additions and 1 deletions
|
|
@ -32,6 +32,8 @@ Setting name (default value) what does it do?
|
||||||
`DEFAULT_CATEGORY` (``'misc'``) The default category to fallback on.
|
`DEFAULT_CATEGORY` (``'misc'``) The default category to fallback on.
|
||||||
`DEFAULT_DATE_FORMAT` (``'%a %d %B %Y'``) The default date format you want to use.
|
`DEFAULT_DATE_FORMAT` (``'%a %d %B %Y'``) The default date format you want to use.
|
||||||
`DEFAULT_LANG` (``'en'``) The default language to use.
|
`DEFAULT_LANG` (``'en'``) The default language to use.
|
||||||
|
`DEFAULT_METADATA` (``()``) A list containing the default metadata for
|
||||||
|
each content (articles, pages, etc.)
|
||||||
`DEFAULT_ORPHANS` (0) The minimum number of articles allowed on the
|
`DEFAULT_ORPHANS` (0) The minimum number of articles allowed on the
|
||||||
last page. Use this when you don't want to
|
last page. Use this when you don't want to
|
||||||
have a last page with very few articles.
|
have a last page with very few articles.
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,10 @@ class Page(object):
|
||||||
self.translations = []
|
self.translations = []
|
||||||
|
|
||||||
self.status = "published" # default value
|
self.status = "published" # default value
|
||||||
for key, value in metadatas.items():
|
|
||||||
|
local_metadata = dict(settings['DEFAULT_METADATA'])
|
||||||
|
local_metadata.update(metadatas)
|
||||||
|
for key, value in local_metadata.items():
|
||||||
setattr(self, key.lower(), value)
|
setattr(self, key.lower(), value)
|
||||||
|
|
||||||
if not hasattr(self, 'author'):
|
if not hasattr(self, 'author'):
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ _DEFAULT_CONFIG = {'PATH': None,
|
||||||
'WITH_PAGINATION': False,
|
'WITH_PAGINATION': False,
|
||||||
'DEFAULT_PAGINATION': 5,
|
'DEFAULT_PAGINATION': 5,
|
||||||
'DEFAULT_ORPHANS': 0,
|
'DEFAULT_ORPHANS': 0,
|
||||||
|
'DEFAULT_METADATA': (),
|
||||||
}
|
}
|
||||||
|
|
||||||
def read_settings(filename):
|
def read_settings(filename):
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,6 @@ Article 1
|
||||||
#########
|
#########
|
||||||
|
|
||||||
:date: 2011-02-17
|
:date: 2011-02-17
|
||||||
|
:yeah: oh yeah !
|
||||||
|
|
||||||
Article 1
|
Article 1
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,7 @@ SOCIAL = (('twitter', 'http://twitter.com/ametaireau'),
|
||||||
('lastfm', 'http://lastfm.com/user/akounet'),
|
('lastfm', 'http://lastfm.com/user/akounet'),
|
||||||
('github', 'http://github.com/ametaireau'),)
|
('github', 'http://github.com/ametaireau'),)
|
||||||
|
|
||||||
|
# global metadata to all the contents
|
||||||
|
DEFAULT_METADATA = (('yeah', 'it is'),)
|
||||||
|
|
||||||
STATIC_PATHS = ["pictures",]
|
STATIC_PATHS = ["pictures",]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue