Skip to content

Commit

Permalink
Merge pull request getpelican#883 from ben2367/author-filter
Browse files Browse the repository at this point in the history
Add filter-author option to importer
  • Loading branch information
justinmayer committed Jul 16, 2013
2 parents f43742c + cb650c1 commit 9b0cfd9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/importer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Optional arguments
(default: False)
--dir-page Put files recognised as pages in "pages/" sub-
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
such as flash embeds or iframes (wordpress import
only) (default: False)
Expand Down
9 changes: 7 additions & 2 deletions pelican/tools/pelican_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,11 @@ def build_markdown_header(title, date, author, categories, tags, slug):

def fields2pelican(fields, out_markup, output_path,
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,
kind, in_markup) in fields:
if filter_author and filter_author != author:
continue
slug = not disable_slugs and filename or None
if (in_markup == "markdown") or (out_markup == "markdown") :
ext = '.md'
Expand Down Expand Up @@ -487,6 +489,8 @@ def main():
parser.add_argument('--dir-page', action='store_true', dest='dirpage',
help=('Put files recognised as pages in "pages/" sub-directory'
' (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',
help="Strip raw HTML code that can't be converted to "
"markup such as flash embeds or iframes (wordpress import only)")
Expand Down Expand Up @@ -537,4 +541,5 @@ def main():
dircat=args.dircat or False,
dirpage=args.dirpage 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)

0 comments on commit 9b0cfd9

Please sign in to comment.