Skip to content

Instantly share code, notes, and snippets.

@SamStudio8
Created September 17, 2023 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SamStudio8/06ea0656d15d88367713f4307a51b019 to your computer and use it in GitHub Desktop.
Save SamStudio8/06ea0656d15d88367713f4307a51b019 to your computer and use it in GitHub Desktop.
Samposium v1 index
---
title: "Samposium v1"
url: "/v1/"
layout: "old_archive"
---
This listing enumerates the posts from the previous iteration of Samposium.
Posts range between long rambling posts about my PhD that I never expected anyone to read, and things that I did to distract myself from finishing my PhD that I hoped people would read.
Each link will take you to a static snapshot of the decommissioned Wordpress post.
{{ '{{' }}< unsafe >{{ '}}' }}
{% for year, months in posts.items() -%}
<div class='archive-year'>
<h2 class='archive-year-header'>{{ year }}</h2>
{% for month_i, month in months.items() -%}
<div class='archive-month'>
<h3 class='archive-month-header'>{{ month.name }}</h2>
<div class='archive-posts'>
{% for post in month.posts -%}
<div class='archive-entry'>
<h3 class='archive-entry-title'>{{ post.title }}</h3>
<div class='archive-meta'>
<span>{{ post.month }} {{ post.day }}, {{ post.year }}</span>
</div>
<a class='entry-link' href='https://samnicholls.net/{{ post.url }}'></a>
</div>
{%- endfor %}
</div>
</div>
{%- endfor %}
{%- endfor %}
{{ '{{' }}< /unsafe >{{ '}}' }}
import calendar
import sys
import jinja2
posts = {}
for line in sys.stdin:
fn, title = line.strip().split(' ', 1)
fn = fn.replace("/index.html", "")
year, month, day, slug = fn.split('/')
month_name = calendar.month_name[int(month)]
if year not in posts:
posts[year] = {}
if month not in posts[year]:
posts[year][month] = {
"name": month_name,
"posts": [],
}
posts[year][month]["posts"].append({
"title": title,
"day": day,
"month": month_name,
"year": year,
"url": fn,
})
environment = jinja2.Environment()
with open('template.j2') as f:
template = jinja2.Template(f.read())
print(template.render(posts=posts))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment