mirror of
https://github.com/getpelican/pelican.git
synced 2026-05-27 20:16:14 +02:00
Support embed post id in article meta, and used in url structure
This commit is contained in:
parent
cb82e48636
commit
e84e5782f0
1 changed files with 8 additions and 5 deletions
|
|
@ -124,13 +124,14 @@ def wp2fields(xml):
|
||||||
logger.warn('Post "%s" is lacking a proper title' % title)
|
logger.warn('Post "%s" is lacking a proper title' % title)
|
||||||
|
|
||||||
content = item.find('encoded').string
|
content = item.find('encoded').string
|
||||||
|
post_id = item.find('post_id').string
|
||||||
filename = item.find('post_name').string
|
filename = item.find('post_name').string
|
||||||
|
|
||||||
raw_date = item.find('post_date').string
|
raw_date = item.find('post_date').string
|
||||||
date_object = time.strptime(raw_date, "%Y-%m-%d %H:%M:%S")
|
date_object = time.strptime(raw_date, "%Y-%m-%d %H:%M:%S")
|
||||||
date = time.strftime("%Y-%m-%d %H:%M", date_object)
|
date = time.strftime("%Y-%m-%d %H:%M", date_object)
|
||||||
author = item.find('creator').string
|
author = item.find('creator').string
|
||||||
|
|
||||||
categories = [cat.string for cat in item.findAll('category', {'domain' : 'category'})]
|
categories = [cat.string for cat in item.findAll('category', {'domain' : 'category'})]
|
||||||
# caturl = [cat['nicename'] for cat in item.find(domain='category')]
|
# caturl = [cat['nicename'] for cat in item.find(domain='category')]
|
||||||
|
|
||||||
|
|
@ -140,7 +141,7 @@ def wp2fields(xml):
|
||||||
if item.find('post_type').string == 'page':
|
if item.find('post_type').string == 'page':
|
||||||
kind = 'page'
|
kind = 'page'
|
||||||
|
|
||||||
yield (title, content, filename, date, author, categories, tags,
|
yield (title, content, filename, date, author, post_id, categories, tags,
|
||||||
kind, "wp-html")
|
kind, "wp-html")
|
||||||
|
|
||||||
def dc2fields(file):
|
def dc2fields(file):
|
||||||
|
|
@ -440,13 +441,15 @@ def build_header(title, date, author, categories, tags, slug):
|
||||||
header += '\n'
|
header += '\n'
|
||||||
return header
|
return header
|
||||||
|
|
||||||
def build_markdown_header(title, date, author, categories, tags, slug):
|
def build_markdown_header(title, date, author, post_id, categories, tags, slug):
|
||||||
"""Build a header from a list of fields"""
|
"""Build a header from a list of fields"""
|
||||||
header = 'Title: %s\n' % title
|
header = 'Title: %s\n' % title
|
||||||
if date:
|
if date:
|
||||||
header += 'Date: %s\n' % date
|
header += 'Date: %s\n' % date
|
||||||
if author:
|
if author:
|
||||||
header += 'Author: %s\n' % author
|
header += 'Author: %s\n' % author
|
||||||
|
if post_id:
|
||||||
|
header += 'Post_ID: %s\n' % post_id
|
||||||
if categories:
|
if categories:
|
||||||
header += 'Category: %s\n' % ', '.join(categories)
|
header += 'Category: %s\n' % ', '.join(categories)
|
||||||
if tags:
|
if tags:
|
||||||
|
|
@ -459,14 +462,14 @@ 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, filter_author=None):
|
dirpage=False, filename_template=None, filter_author=None):
|
||||||
for (title, content, filename, date, author, categories, tags,
|
for (title, content, filename, date, author, post_id, categories, tags,
|
||||||
kind, in_markup) in fields:
|
kind, in_markup) in fields:
|
||||||
if filter_author and filter_author != author:
|
if filter_author and filter_author != author:
|
||||||
continue
|
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'
|
||||||
header = build_markdown_header(title, date, author, categories, tags, slug)
|
header = build_markdown_header(title, date, author, post_id, categories, tags, slug)
|
||||||
else:
|
else:
|
||||||
out_markup = "rst"
|
out_markup = "rst"
|
||||||
ext = '.rst'
|
ext = '.rst'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue