Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some fixes for getnikola/nikola#1976
  • Loading branch information
ralsina committed Sep 2, 2015
1 parent 49a1760 commit 60a4ea7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion v7/import_feed/README.md
Expand Up @@ -4,6 +4,6 @@ To use it:

```
$ nikola plugin -i import_feed
$ nikola import_feed feed_url
$ nikola import_feed --url=feed_url
```

4 changes: 2 additions & 2 deletions v7/import_feed/import_feed.plugin
Expand Up @@ -4,7 +4,7 @@ Module = import_feed

[Documentation]
Author = Grzegorz Śliwiński
Version = 0.1
Version = 0.2
Website = http://www.fizyk.net.pl/
Description = Import a blog posts from a RSS/Atom dump
Description = Import a blog posts from a RSS/Atom feed

31 changes: 24 additions & 7 deletions v7/import_feed/import_feed.py
Expand Up @@ -53,9 +53,24 @@ class CommandImportFeed(Command, ImportMixin):

name = "import_feed"
needs_config = False
doc_usage = "[options] feed_file"
doc_purpose = "import a RSS/Atom dump"
cmd_options = ImportMixin.cmd_options
doc_usage = "[options] --url=feed_url"
doc_purpose = "import a RSS/Atom feed"
cmd_options = [
{
'name': 'output_folder',
'long': 'output-folder',
'short': 'o',
'default': 'new_site',
'help': 'Location to write imported content.'
},
{
'name': 'url',
'long': 'url',
'short': 'u',
'default': None,
'help': 'URL or filename of the feed to be imported.'
},
]

def _execute(self, options, args):
'''
Expand All @@ -65,16 +80,15 @@ def _execute(self, options, args):
req_missing(['feedparser'], 'import feeds')
return

if not args:
if not options['url']:
print(self.help())
return

options['filename'] = args[0]
self.feed_export_file = options['filename']
self.feed_url = options['url']
self.output_folder = options['output_folder']
self.import_into_existing_site = False
self.url_map = {}
channel = self.get_channel_from_file(self.feed_export_file)
channel = self.get_channel_from_file(self.feed_url)
self.context = self.populate_context(channel)
conf_template = self.generate_base_site()
self.context['REDIRECTIONS'] = self.configure_redirections(
Expand Down Expand Up @@ -160,6 +174,9 @@ def import_item(self, item, out_folder=None):
# FIXME: handle attachments
elif item.get('summary'):
content = item.get('summary')
else:
content = ''
LOGGER.warn('Entry without content! {}', item)

tags = []
for tag in item.get('tags', []):
Expand Down

0 comments on commit 60a4ea7

Please sign in to comment.