Skip to content

Move to a handrolled static site generator #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3a707ec
try to get a handrolled static site generator working
hjwp Mar 10, 2020
546d2c9
first cut of index.html with milligram
hjwp Mar 15, 2020
94298f1
up and running with milligram and pygments. done command handler blog
hjwp Mar 15, 2020
8e558d3
start on template inheritance structure
hjwp Mar 15, 2020
ce01de6
first stab at rendering index.html from index.md
hjwp Mar 15, 2020
6e7cae9
move stuff out of index.md into index.html
hjwp Mar 15, 2020
0656c02
Merge remote-tracking branch 'origin/master' into handrolled-static-s…
hjwp Mar 15, 2020
eae322f
continue moving stuff out of index.md
hjwp Mar 15, 2020
f0c6a59
more progress, looking ok tbh
hjwp Mar 15, 2020
6f2df32
move output dir to _site directory
hjwp Mar 16, 2020
4d1d1b1
rss too
hjwp Mar 16, 2020
3d4cf8b
add the html to version control
hjwp Mar 16, 2020
abf5f53
path to blog posts is /blog, match existing site
hjwp Mar 16, 2020
6a034ca
remove unused images folder
hjwp Mar 16, 2020
4dba4b7
remove old assets folder
hjwp Mar 16, 2020
4bce605
remove old jekyll config
hjwp Mar 16, 2020
c99755b
favicon. maybe
hjwp Mar 16, 2020
89a0ee5
makefile
hjwp Mar 16, 2020
97bdf18
update readme
hjwp Mar 16, 2020
cb28f68
add book as submodule
hjwp Mar 16, 2020
b284d61
add a script to copy the book sources across
hjwp Mar 16, 2020
b59bb68
book html
hjwp Mar 16, 2020
e879b41
book prepper mostly working, toc fixed
hjwp Mar 16, 2020
17a4cbd
rename book copier
hjwp Mar 16, 2020
1ecfef4
add buy-the-book banner
hjwp Mar 16, 2020
1aaee6a
mess about trying to style the front banner
hjwp Mar 16, 2020
6ff88f6
fix list styles
hjwp Mar 16, 2020
1f0eb65
add google analytics and disqus
hjwp Mar 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
try to get a handrolled static site generator working
  • Loading branch information
hjwp committed Mar 10, 2020
commit 3a707ec8971fc35dc63021dfd32482b9efc43be0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ _site/
.jekyll-cache/
.jekyll-metadata
.bundle
.venv
2 changes: 0 additions & 2 deletions Gemfile

This file was deleted.

247 changes: 0 additions & 247 deletions Gemfile.lock

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
---
layout: post
author: Bob
categories:
- ports & adapters
tags:
- python
- architecture
blog_heading: Introducing Command Handler
blog_author: Bob
---

The term DDD comes from the book by Eric Evans: ["Domain-Driven Design: Tackling
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
layout: post
author: Bob
categories:
- ports & adapters
tags:
- python
- architecture
blog_author: Bob
blog_heading: Repository and Unit of Work Pattern

---

In the previous part
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
layout: post
author: Bob
categories:
- ports & adapters
tags:
- python
- architecture
blog_author: Bob
blog_heading: Commands, Handlers, Queries and Views

---

In the first and second parts of this series I introduced the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
layout: post
author: Bob
categories:
- ports & adapters
tags:
- python
- architecture
blog_heading: Why use domain events?
blog_author: Bob

---

Nota bene: this instalment in the Ports and Adapters with Command Handlers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
---
title: Writing tests for external API calls
layout: post
author: Harry
categories:
- testing
tags:
- tdd
- fakes
- mocks
- adapters
blog_heading: Writing tests for external API calls
blog_author: Harry

---


Expand Down
5 changes: 0 additions & 5 deletions blog/index.html

This file was deleted.

48 changes: 48 additions & 0 deletions generate-html.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
# copied from https://github.com/tonybaloney/tonybaloney.github.io/blob/master/blog-gen.py
import markdown
import jinja2
import glob
from datetime import date, datetime
from email.utils import formatdate, format_datetime # for RFC2822 formatting

TEMPLATE_FILE = "templates/blog_post_template.html"
FEED_TEMPLATE_FILE = "templates/rss_feed_template.xml"
BASE_URL = "https://tonybaloney.github.io/"

def main():
posts = glob.glob("blog/*.md")
extensions = ['extra', 'smarty', 'meta']
_md = markdown.Markdown(extensions=extensions, output_format='html5')

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

all_posts = []
for post in posts:
print("rendering {0}".format(post))
post_date = date.fromisoformat(post[5:15])
url = post.replace(".md", ".html").replace("blog/", "posts/")
with open(post) as post_f:
html = _md.convert(post_f.read())
context = {
'blog_publish_date': post_date,
**_md.Meta
}
doc = env.get_template(TEMPLATE_FILE).render(content=html, baseurl=BASE_URL, url=url, **context)

post_html = url
with open(post_html, "w") as post_html_f:
post_html_f.write(doc)
# all_posts.append(dict(**_md.Meta, date=post_date, rfc2822_date=format_datetime(post_date), link="{0}{1}".format(BASE_URL, url)))
all_posts.append(dict(**_md.Meta, date=post_date, rfc2822_date='', link="{0}{1}".format(BASE_URL, url)))

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


if __name__ == "__main__":
main()
Loading