style
This commit is contained in:
parent
9d58aec4b2
commit
2ffeb6be03
3 changed files with 55 additions and 32 deletions
|
@ -1,10 +1,10 @@
|
||||||
<article>
|
<article>
|
||||||
<h1><a href="{{ base_path }}/{{ year }}/{{ slug }}.html">{{ title }}</a></h1>
|
<h1>{{ title }}</h1>
|
||||||
<p class="meta">{{ category_label}} - {{ date }}</b></p>
|
<p class="meta">{{ category_label}} - {{ date }}</b></p>
|
||||||
<p class="summary">
|
<p class="summary">
|
||||||
{{ summary }} <a class="more" href="{{ base_path }}/{{ year }}/{{ slug }}.html">...</a>
|
{{ summary }}
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<a class="more" href="{{ base_path }}/{{ year }}/{{ slug }}.html">Read More</a>
|
<a class="more" href="{{ base_path }}/{{ year }}/{{ slug }}.html">Lire la suite...</a>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
|
@ -1,5 +1,5 @@
|
||||||
<article>
|
<article>
|
||||||
<h1><a href="{{ base_path }}/{{ year }}/{{ slug }}.html">{{ title }}</a></h1>
|
<h1>{{ title }}</h1>
|
||||||
<p class="meta">{{ category_label }} - {{ date }}</b></p>
|
<p class="meta">{{ category_label }} - {{ date }}</b></p>
|
||||||
{{ content }}
|
{{ content }}
|
||||||
</article>
|
</article>
|
||||||
|
|
69
makesite.py
69
makesite.py
|
@ -123,6 +123,17 @@ def render(template, **params):
|
||||||
template)
|
template)
|
||||||
|
|
||||||
|
|
||||||
|
def get_categories(page_params):
|
||||||
|
cat = []
|
||||||
|
if 'category' in page_params:
|
||||||
|
cat.append(str(page_params['category']).strip())
|
||||||
|
elif 'categories' in page_params:
|
||||||
|
for s in page_params['categories'].split(' '):
|
||||||
|
if s.strip():
|
||||||
|
cat.append(s.strip())
|
||||||
|
return cat
|
||||||
|
|
||||||
|
|
||||||
def make_pages(src, dst, layout, **params):
|
def make_pages(src, dst, layout, **params):
|
||||||
"""Generate pages from page content."""
|
"""Generate pages from page content."""
|
||||||
items = []
|
items = []
|
||||||
|
@ -133,10 +144,10 @@ def make_pages(src, dst, layout, **params):
|
||||||
page_params = dict(params, **content)
|
page_params = dict(params, **content)
|
||||||
|
|
||||||
# Populate placeholders in content if content-rendering is enabled.
|
# Populate placeholders in content if content-rendering is enabled.
|
||||||
if page_params.get('render') == 'yes':
|
# if page_params.get('render') == 'yes':
|
||||||
rendered_content = render(page_params['content'], **page_params)
|
# rendered_content = render(page_params['content'], **page_params)
|
||||||
page_params['content'] = rendered_content
|
# page_params['content'] = rendered_content
|
||||||
content['content'] = rendered_content
|
# content['content'] = rendered_content
|
||||||
|
|
||||||
items.append(content)
|
items.append(content)
|
||||||
|
|
||||||
|
@ -161,28 +172,33 @@ def make_posts(src, src_pattern, dst, layout, **params):
|
||||||
page_params['date_path'] = page_params['date'].replace('-', '/')
|
page_params['date_path'] = page_params['date'].replace('-', '/')
|
||||||
page_params['year'] = page_params['date'].split('-')[0]
|
page_params['year'] = page_params['date'].split('-')[0]
|
||||||
|
|
||||||
cat = []
|
# categories
|
||||||
if 'category' in page_params:
|
categories = get_categories(page_params)
|
||||||
cat.append(str(page_params['category']).strip())
|
page_params['category'] = categories
|
||||||
elif 'categories' in page_params:
|
page_params['category_label'] = ' '.join(categories)
|
||||||
for s in page_params['categories'].split(' '):
|
|
||||||
if s.strip():
|
|
||||||
cat.append(s.strip())
|
# Populate placeholders in content if content-rendering is enabled.
|
||||||
page_params['category'] = cat
|
# if page_params.get('render') == 'yes':
|
||||||
page_params['category_label'] = ' '.join(cat)
|
# rendered_content = render(page_params['content'], **page_params)
|
||||||
|
# page_params['content'] = rendered_content
|
||||||
|
# content['content'] = rendered_content
|
||||||
|
|
||||||
|
summary_index = page_params['content'].find('<!-- more')
|
||||||
|
if summary_index > 0:
|
||||||
|
content['summary'] = render(page_params['content'][:summary_index], **page_params)
|
||||||
|
|
||||||
|
content['year'] = page_params['year']
|
||||||
|
content['category'] = page_params['category']
|
||||||
|
content['category_label'] = page_params['category_label']
|
||||||
|
|
||||||
|
items.append(content)
|
||||||
|
|
||||||
# TODO DEBUG
|
# TODO DEBUG
|
||||||
#print(page_params)
|
#print(page_params)
|
||||||
|
#print(content)
|
||||||
#break
|
#break
|
||||||
|
|
||||||
# Populate placeholders in content if content-rendering is enabled.
|
|
||||||
if page_params.get('render') == 'yes':
|
|
||||||
rendered_content = render(page_params['content'], **page_params)
|
|
||||||
page_params['content'] = rendered_content
|
|
||||||
content['content'] = rendered_content
|
|
||||||
|
|
||||||
items.append(content)
|
|
||||||
|
|
||||||
dst_path = render(dst, **page_params)
|
dst_path = render(dst, **page_params)
|
||||||
output = render(layout, **page_params)
|
output = render(layout, **page_params)
|
||||||
|
|
||||||
|
@ -199,9 +215,16 @@ def make_list(posts, dst, list_layout, item_layout, **params):
|
||||||
item_params = dict(params, **post)
|
item_params = dict(params, **post)
|
||||||
#print(item_params)
|
#print(item_params)
|
||||||
#print(0/0)
|
#print(0/0)
|
||||||
item_params['year'] = item_params['date'].split('-')[0]
|
#item_params['year'] = item_params['date'].split('-')[0]
|
||||||
|
|
||||||
|
# categories
|
||||||
|
# categories = get_categories(item_params)
|
||||||
|
# item_params['category'] = categories
|
||||||
|
# item_params['category_label'] = ' '.join(categories)
|
||||||
|
|
||||||
# TODO recuperer more
|
# TODO recuperer more
|
||||||
item_params['summary'] = truncate(post['content'])
|
if 'summary' not in item_params:
|
||||||
|
item_params['summary'] = truncate(post['content'])
|
||||||
item = render(item_layout, **item_params)
|
item = render(item_layout, **item_params)
|
||||||
items.append(item)
|
items.append(item)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue