build_a_blog: remove some wes

This commit is contained in:
Collin Lefeber 2024-06-17 19:58:08 -04:00
parent f90f97a2d3
commit dbbeec3f0c

View file

@ -64,7 +64,7 @@ With that, we should have the exotic Markdown dependency figured out.
First, lets read 1 post file and render some html.
We'll store posts in `posts/` like `posts/build_a_blog.md`.
I'll store posts in `posts/` like `posts/build_a_blog.md`.
And we'll store the HTML output in the same directory: `posts/build_a_blog.html`.
@ -167,7 +167,7 @@ But I want a few more features:
I thought I'd need to build something here, but turns out it's exactly what I need to assign a few extra attributes to a post.
We'll adjust our "spec" for posts such that each post must include the following metadata at the top of the file:
I'll adjust our "spec" for posts such that each post must include the following metadata at the top of the file:
```txt
Title: Build-a-blog
@ -351,7 +351,7 @@ I think I want my blog to just maintain the overall layout from the index page a
So lets make that template rendering a bit more general.
We'll redefine the content area template variable to replace as `${content}` too.
I'll redefine the content area template variable to replace as `${content}` too.
```python
def render_template(tpl_fname, out_fname, content_html):
@ -383,7 +383,7 @@ After running you should see the each `post/*.html` file where each post file us
### Post sorting
With everything wired up now we just need to sort the posts lists by the date metadata.
With everything wired up now just need to sort the posts lists by the date metadata.
Lets do a bit of python repl sort testing because I never remember `datetime` usage.
@ -450,7 +450,7 @@ So `index.html.tmpl`
<title>cfebs.com${more_title}</title>
```
And where we're using the title template `more_title` will default to empty string.
And where using the title template `more_title` will default to empty string.
```python
def render_index(posts):
@ -526,7 +526,7 @@ def render_post(fname):
render_template('index.html.tmpl', destpath, {'content': out, 'more_title': ' - ' + title})
```
And now we can hack away at RSS generation:
And now can hack away at RSS generation:
```
def render_rss_index(posts):
@ -541,7 +541,7 @@ def render_rss_index(posts):
render_template('index.xml.tmpl', 'index.xml', subs)
```
After this initial test and a `python3 ./main.py` run, we should see xml filled out.
After this initial test and a `python3 ./main.py` run, should see xml filled out.
```
cat ./index.xml
@ -609,7 +609,7 @@ def render_rss_index(posts):
render_template('index.xml.tmpl', 'index.xml', subs)
```
* Need to use `html.escape` anywhere we could have quotes or HTML tags in output.
* Need to use `html.escape` anywhere there could be HTML tags in output.
* `posts[:5]` should always take the most recent 5 posts to add to the RSS feed.
## Wrapping up