|
|
@ -53,8 +53,6 @@ def convert_comment(db, site, filename):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
content = content + line
|
|
|
|
content = content + line
|
|
|
|
logger.debug(d)
|
|
|
|
|
|
|
|
logger.debug(content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# create DB record
|
|
|
|
# create DB record
|
|
|
|
comment = Comment(site=site, author_name=d['author'], content=content)
|
|
|
|
comment = Comment(site=site, author_name=d['author'], content=content)
|
|
|
@ -67,7 +65,7 @@ def convert_comment(db, site, filename):
|
|
|
|
# else:
|
|
|
|
# else:
|
|
|
|
# comment.url = d['article']
|
|
|
|
# comment.url = d['article']
|
|
|
|
if 'date' in d:
|
|
|
|
if 'date' in d:
|
|
|
|
comment.date = d['date']
|
|
|
|
comment.published = d['date']
|
|
|
|
comment.save()
|
|
|
|
comment.save()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -86,14 +84,13 @@ def convert(db, site_name, url, comment_dir):
|
|
|
|
|
|
|
|
|
|
|
|
site = Site.create(name=site_name, url=url, token='')
|
|
|
|
site = Site.create(name=site_name, url=url, token='')
|
|
|
|
|
|
|
|
|
|
|
|
logger.info('Comment directory %s' % comment_dir)
|
|
|
|
|
|
|
|
for dirpath, dirs, files in os.walk(comment_dir):
|
|
|
|
for dirpath, dirs, files in os.walk(comment_dir):
|
|
|
|
for filename in files:
|
|
|
|
for filename in files:
|
|
|
|
if filename.endswith(('.md',)):
|
|
|
|
if filename.endswith(('.md',)):
|
|
|
|
comment_file = '/'.join([dirpath, filename])
|
|
|
|
comment_file = '/'.join([dirpath, filename])
|
|
|
|
convert_comment(db, site, comment_file)
|
|
|
|
convert_comment(db, site, comment_file)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logger.debug('ignore file %s' % filename)
|
|
|
|
logger.warn('ignore file %s' % filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@clize
|
|
|
|
@clize
|
|
|
|