Skip to content

Commit f0c6a59

Browse files
committed
more progress, looking ok tbh
1 parent eae322f commit f0c6a59

17 files changed

+77
-59
lines changed

blog/2017-09-07-introducing-command-handler.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
blog_heading: Introducing Command Handler
2-
blog_author: Bob
1+
title: Introducing Command Handler
2+
author: Bob
3+
34
---
45

56
The term DDD comes from the book by Eric Evans: ["Domain-Driven Design: Tackling

blog/2017-09-08-repository-and-unit-of-work-pattern-in-python.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
blog_author: Bob
2-
blog_heading: Repository and Unit of Work Pattern
1+
title: Repository and Unit of Work Pattern
2+
author: Bob
33

44
---
55

blog/2017-09-13-commands-and-queries-handlers-and-views.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
blog_author: Bob
2-
blog_heading: Commands, Handlers, Queries and Views
1+
title: Commands, Handlers, Queries and Views
2+
author: Bob
33

44
---
55

blog/2017-09-19-why-use-domain-events.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
blog_heading: Why use domain events?
2-
blog_author: Bob
1+
title: Why use domain events?
2+
author: Bob
33

44
---
55

blog/2020-01-25-testing_external_api_calls.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
blog_heading: Writing tests for external API calls
2-
blog_author: Harry
1+
title: Writing tests for external API calls
2+
author: Harry
33

44
---
55

generate-html.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,49 @@
1010
FEED_TEMPLATE_FILE = "templates/rss_feed_template.xml"
1111
BASE_URL = "https://tonybaloney.github.io/"
1212

13+
from dataclasses import dataclass
14+
15+
@dataclass
16+
class Post:
17+
title: str
18+
author: str
19+
md_path: str
20+
date: date
21+
22+
@property
23+
def html_path(self):
24+
return self.md_path.replace('blog/', 'posts/').replace('.md', '.html')
25+
26+
1327

1428

1529
def main():
16-
md_post_paths = glob.glob("blog/*.md")
30+
md_post_paths = sorted(glob.glob("blog/*.md"))
1731
extensions = ['extra', 'smarty', 'meta', 'codehilite']
1832
_md = markdown.Markdown(extensions=extensions, output_format='html5')
1933

2034
loader = jinja2.FileSystemLoader(searchpath="./")
2135
env = jinja2.Environment(loader=loader)
2236

2337
all_posts = []
24-
for post in md_post_paths:
25-
print("rendering {0}".format(post))
26-
post_date = date.fromisoformat(post[5:15])
27-
post_html_path = post.replace(".md", ".html").replace("blog/", "posts/")
28-
with open(post) as f:
38+
for md_post_path in md_post_paths:
39+
print("rendering", md_post_path)
40+
post_date = date.fromisoformat(md_post_path[5:15])
41+
with open(md_post_path) as f:
2942
html = _md.convert(f.read())
30-
context = {
31-
'blog_publish_date': post_date,
32-
**_md.Meta
33-
}
34-
doc = env.get_template(TEMPLATE_FILE).render(content=html, baseurl=BASE_URL, url=post_html_path, **context)
43+
post = Post(
44+
md_path=md_post_path, date=post_date,
45+
author=_md.Meta['author'][0],
46+
title=_md.Meta['title'][0],
47+
)
48+
doc = env.get_template(TEMPLATE_FILE).render(
49+
content=html, baseurl=BASE_URL, url=post.html_path, post=post,
50+
)
3551

36-
with open(post_html_path, "w") as f:
52+
with open(post.html_path, "w") as f:
3753
f.write(doc)
3854
# all_posts.append(dict(**_md.Meta, date=post_date, rfc2822_date=format_datetime(post_date), link="{0}{1}".format(BASE_URL, url)))
39-
all_posts.append(dict(**_md.Meta, date=post_date, rfc2822_date='', link="{0}{1}".format(BASE_URL, post_html_path))) # TODO fix date
55+
all_posts.append(post) # TODO fix date
4056

4157
# index
4258
print("rendering index.html")
@@ -50,7 +66,7 @@ def main():
5066
f.write(doc)
5167

5268
# Order blog posts by date published
53-
all_posts.sort(key=lambda item: item['date'], reverse=True)
69+
all_posts.sort(key=lambda p: p.date, reverse=True)
5470
# Make the RSS feed
5571
with open("rss.xml", "w") as rss_f:
5672
rss_f.write(env.get_template(FEED_TEMPLATE_FILE).render(posts=all_posts, date=formatdate()))

index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<nav class="navigation">
1919
<section class="container">
20-
<a class="navigation-title" href="https://cosmicpython.com">
20+
<a class="navigation-title" href="/">
2121
<h1 class="title">Cosmic Python</h1>
2222
</a>
2323
</section>
@@ -80,7 +80,7 @@ <h3>Recent posts</h3>
8080

8181

8282
<li>
83-
<a href="">2020-01-25 </a>
83+
<a href="posts/2020-01-25-testing_external_api_calls.html">2020-01-25 Writing tests for external API calls</a>
8484
</li>
8585

8686

@@ -93,25 +93,25 @@ <h3>Classic 2017 Episodes on Ports & Adapters, by Bob</h3>
9393

9494

9595
<li>
96-
<a href="https://tonybaloney.github.io/posts/2017-09-07-introducing-command-handler.html">2017-09-07 </a>
96+
<a href="posts/2017-09-07-introducing-command-handler.html">2017-09-07 Introducing Command Handler</a>
9797
</li>
9898

9999

100100

101101
<li>
102-
<a href="https://tonybaloney.github.io/posts/2017-09-19-why-use-domain-events.html">2017-09-19 </a>
102+
<a href="posts/2017-09-08-repository-and-unit-of-work-pattern-in-python.html">2017-09-08 Repository and Unit of Work Pattern</a>
103103
</li>
104104

105105

106106

107107
<li>
108-
<a href="https://tonybaloney.github.io/posts/2017-09-13-commands-and-queries-handlers-and-views.html">2017-09-13 </a>
108+
<a href="posts/2017-09-13-commands-and-queries-handlers-and-views.html">2017-09-13 Commands, Handlers, Queries and Views</a>
109109
</li>
110110

111111

112112

113113
<li>
114-
<a href="https://tonybaloney.github.io/posts/2017-09-08-repository-and-unit-of-work-pattern-in-python.html">2017-09-08 </a>
114+
<a href="posts/2017-09-19-why-use-domain-events.html">2017-09-19 Why use domain events?</a>
115115
</li>
116116

117117

posts/2017-09-07-introducing-command-handler.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<nav class="navigation">
1919
<section class="container">
20-
<a class="navigation-title" href="https://cosmicpython.com">
20+
<a class="navigation-title" href="/">
2121
<h1 class="title">Cosmic Python</h1>
2222
</a>
2323
</section>
@@ -26,10 +26,11 @@ <h1 class="title">Cosmic Python</h1>
2626
<section class="container">
2727

2828
<h1> Introducing Command Handler</h1>
29-
<p>by Bob, </p>
29+
<p>by Bob, 2017-09-07</p>
3030

3131
<div class="content">
32-
<p>The term DDD comes from the book by Eric Evans: <a href="[https://www.amazon.co.uk/Domain-driven-Design-Tackling-Complexity-Software/dp/0321125215">&ldquo;Domain-Driven Design: Tackling
32+
<hr>
33+
<p>The term DDD comes from the book by Eric Evans: <a href="[https://www.amazon.co.uk/Domain-driven-Design-Tackling-Complexity-Software/dp/0321125215">&ldquo;Domain-Driven Design: Tackling
3334
Complexity in the Heart of Software&rdquo;</a>.
3435
In his book he describes a set of practices that aim to help us build
3536
maintainable, rich, software systems that solve customer&rsquo;s problems. The book is

posts/2017-09-08-repository-and-unit-of-work-pattern-in-python.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<nav class="navigation">
1919
<section class="container">
20-
<a class="navigation-title" href="https://cosmicpython.com">
20+
<a class="navigation-title" href="/">
2121
<h1 class="title">Cosmic Python</h1>
2222
</a>
2323
</section>
@@ -26,7 +26,7 @@ <h1 class="title">Cosmic Python</h1>
2626
<section class="container">
2727

2828
<h1> Repository and Unit of Work Pattern</h1>
29-
<p>by Bob, </p>
29+
<p>by Bob, 2017-09-08</p>
3030

3131
<div class="content">
3232
<hr>

posts/2017-09-13-commands-and-queries-handlers-and-views.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<nav class="navigation">
1919
<section class="container">
20-
<a class="navigation-title" href="https://cosmicpython.com">
20+
<a class="navigation-title" href="/">
2121
<h1 class="title">Cosmic Python</h1>
2222
</a>
2323
</section>
@@ -26,7 +26,7 @@ <h1 class="title">Cosmic Python</h1>
2626
<section class="container">
2727

2828
<h1> Commands, Handlers, Queries and Views</h1>
29-
<p>by Bob, </p>
29+
<p>by Bob, 2017-09-13</p>
3030

3131
<div class="content">
3232
<hr>

0 commit comments

Comments
 (0)