cat
This commit is contained in:
parent
0bcf5cdce7
commit
445a797c9a
6 changed files with 26 additions and 24 deletions
|
@ -1 +1 @@
|
|||
<span>{{ category }}</span>
|
||||
<span><a href="{{ url }}">{{ category }}</a></span>
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<article>
|
||||
<h1>{{ title }}</h1>
|
||||
<p class="meta">{{ category_label}} - {{ date }}</b></p>
|
||||
<p class="summary">
|
||||
{{ summary }}
|
||||
</p>
|
||||
<h1><a href="{{ base_path }}/{{ year }}/{{ slug }}.html">{{ title }}</a></h1>
|
||||
<p class="meta">{{ category_label}}<span>{{ date }}</span></p>
|
||||
<p class="summary">{{ summary }}</p>
|
||||
<div>
|
||||
<a class="more" href="{{ base_path }}/{{ year }}/{{ slug }}.html">Lire la suite...</a>
|
||||
</div>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<div class="pure-g">
|
||||
<div class="pure-u-1-12"></div>
|
||||
<div class="pure-u-1-6">
|
||||
<img src="/logos/logo@96px.png"></img>
|
||||
<a href="/"><img src="/logos/logo@96px.png"></img></a>
|
||||
</div>
|
||||
<div class="pure-u-2-3">
|
||||
<div id="menu-blog">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<article>
|
||||
<h1>{{ title }}</h1>
|
||||
<p class="meta">{{ category_label }} - {{ date }}</b></p>
|
||||
<p class="meta">{{ category_label}}<span>{{ date }}</span></p>
|
||||
{{ content }}
|
||||
</article>
|
||||
|
|
31
makesite.py
31
makesite.py
|
@ -35,6 +35,7 @@ import sys
|
|||
import json
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
import unicodedata
|
||||
|
||||
def fread(filename):
|
||||
"""Read file and close the file."""
|
||||
|
@ -76,6 +77,16 @@ def rfc_2822_format(date_str):
|
|||
return d.strftime('%a, %d %b %Y %H:%M:%S +0000')
|
||||
|
||||
|
||||
def slugify(value):
|
||||
"""
|
||||
Converts to lowercase, removes non-word characters (alphanumerics and
|
||||
underscores) and converts spaces to hyphens. Also strips leading and
|
||||
trailing whitespace.
|
||||
"""
|
||||
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
|
||||
value = re.sub('[^\w\s-]', '', value).strip().lower()
|
||||
return re.sub('[-\s]+', '-', value)
|
||||
|
||||
def read_content(filename):
|
||||
"""Read content and metadata from file into a dictionary."""
|
||||
# Read file content.
|
||||
|
@ -177,7 +188,7 @@ def make_posts(src, src_pattern, dst, layout, category_layout, **params):
|
|||
categories = get_categories(page_params)
|
||||
out_cats = []
|
||||
for category in categories:
|
||||
out_cat = render(category_layout, category=category)
|
||||
out_cat = render(category_layout, category=category, url=slugify(category))
|
||||
out_cats.append(out_cat.strip())
|
||||
page_params['category_label'] = ''.join(out_cats)
|
||||
|
||||
|
@ -195,8 +206,6 @@ def make_posts(src, src_pattern, dst, layout, category_layout, **params):
|
|||
content['year'] = page_params['year']
|
||||
content['category_label'] = page_params['category_label']
|
||||
|
||||
print(content['category_label'])
|
||||
|
||||
items.append(content)
|
||||
|
||||
# TODO DEBUG
|
||||
|
@ -218,22 +227,12 @@ def make_list(posts, dst, list_layout, item_layout, banner_layout, **params):
|
|||
items = []
|
||||
for post in posts:
|
||||
item_params = dict(params, **post)
|
||||
#print(item_params)
|
||||
#print(0/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
|
||||
if 'summary' not in item_params:
|
||||
item_params['summary'] = truncate(post['content'])
|
||||
item = render(item_layout, **item_params)
|
||||
items.append(item)
|
||||
|
||||
banner = render(banner_layout)
|
||||
banner = render(banner_layout, **params)
|
||||
params['banner'] = banner
|
||||
|
||||
params['content'] = ''.join(items)
|
||||
|
@ -281,8 +280,8 @@ def main():
|
|||
# Create site pages.
|
||||
make_pages('content/index.html', '_site/index.html',
|
||||
page_layout, **params)
|
||||
make_pages('content/[!_]*.html', '_site/{{ slug }}/index.html',
|
||||
page_layout, **params)
|
||||
#make_pages('content/[!_]*.html', '_site/{{ slug }}/index.html',
|
||||
# page_layout, **params)
|
||||
|
||||
# Create blogs.
|
||||
blog_posts = make_posts('posts', '**/*.md',
|
||||
|
|
|
@ -141,6 +141,11 @@ a:hover, a:active {
|
|||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.meta > span {
|
||||
display: inline;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
footer {
|
||||
background: #f0f0f0;
|
||||
|
|
Loading…
Add table
Reference in a new issue