mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add filter-author option to importer
Allow to import post from only one author when importing data
This commit is contained in:
parent
7ec4d5faa2
commit
cb650c1c99
2 changed files with 8 additions and 2 deletions
|
|
@ -69,6 +69,7 @@ Optional arguments
|
||||||
(default: False)
|
(default: False)
|
||||||
--dir-page Put files recognised as pages in "pages/" sub-
|
--dir-page Put files recognised as pages in "pages/" sub-
|
||||||
directory (wordpress import only) (default: False)
|
directory (wordpress import only) (default: False)
|
||||||
|
--filter-author Import only post from the specified author.
|
||||||
--strip-raw Strip raw HTML code that can't be converted to markup
|
--strip-raw Strip raw HTML code that can't be converted to markup
|
||||||
such as flash embeds or iframes (wordpress import
|
such as flash embeds or iframes (wordpress import
|
||||||
only) (default: False)
|
only) (default: False)
|
||||||
|
|
|
||||||
|
|
@ -376,9 +376,11 @@ def build_markdown_header(title, date, author, categories, tags, slug):
|
||||||
|
|
||||||
def fields2pelican(fields, out_markup, output_path,
|
def fields2pelican(fields, out_markup, output_path,
|
||||||
dircat=False, strip_raw=False, disable_slugs=False,
|
dircat=False, strip_raw=False, disable_slugs=False,
|
||||||
dirpage=False, filename_template=None):
|
dirpage=False, filename_template=None, filter_author=None):
|
||||||
for (title, content, filename, date, author, categories, tags,
|
for (title, content, filename, date, author, categories, tags,
|
||||||
kind, in_markup) in fields:
|
kind, in_markup) in fields:
|
||||||
|
if filter_author and filter_author != author:
|
||||||
|
continue
|
||||||
slug = not disable_slugs and filename or None
|
slug = not disable_slugs and filename or None
|
||||||
if (in_markup == "markdown") or (out_markup == "markdown") :
|
if (in_markup == "markdown") or (out_markup == "markdown") :
|
||||||
ext = '.md'
|
ext = '.md'
|
||||||
|
|
@ -487,6 +489,8 @@ def main():
|
||||||
parser.add_argument('--dir-page', action='store_true', dest='dirpage',
|
parser.add_argument('--dir-page', action='store_true', dest='dirpage',
|
||||||
help=('Put files recognised as pages in "pages/" sub-directory'
|
help=('Put files recognised as pages in "pages/" sub-directory'
|
||||||
' (wordpress import only)'))
|
' (wordpress import only)'))
|
||||||
|
parser.add_argument('--filter-author', dest='author',
|
||||||
|
help='Import only post from the specified author')
|
||||||
parser.add_argument('--strip-raw', action='store_true', dest='strip_raw',
|
parser.add_argument('--strip-raw', action='store_true', dest='strip_raw',
|
||||||
help="Strip raw HTML code that can't be converted to "
|
help="Strip raw HTML code that can't be converted to "
|
||||||
"markup such as flash embeds or iframes (wordpress import only)")
|
"markup such as flash embeds or iframes (wordpress import only)")
|
||||||
|
|
@ -537,4 +541,5 @@ def main():
|
||||||
dircat=args.dircat or False,
|
dircat=args.dircat or False,
|
||||||
dirpage=args.dirpage or False,
|
dirpage=args.dirpage or False,
|
||||||
strip_raw=args.strip_raw or False,
|
strip_raw=args.strip_raw or False,
|
||||||
disable_slugs=args.disable_slugs or False)
|
disable_slugs=args.disable_slugs or False,
|
||||||
|
filter_author=args.author)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue