Add before_build script

This commit is contained in:
Philipp Oppermann
2017-03-12 00:09:25 +01:00
parent 0fc98f2a92
commit cfa93f1c46
4 changed files with 22 additions and 2 deletions

21
blog/before_build.py Normal file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import io
from github import Github
g = Github("e62e298b2a46ca5cf474cb9a4c0c1bc950b09d46")
with io.open("layouts/partials/recent-updates.html", 'w', encoding='utf8') as recent_updates:
recent_updates.truncate()
recent_updates.write(u"<ul>\n")
for pr in g.search_issues("is:merged", repo="phil-opp/blog_os", type="pr", label="relnotes")[:5]:
link = '<a href="' + pr.html_url + '">' + pr.title + "</a> "
iso_date = pr.closed_at.isoformat()
readable_date = pr.closed_at.strftime("%b&nbsp;%d")
datetime = '<time datetime="' + iso_date + '">' + readable_date + '</datetime>'
recent_updates.write(u" <li>" + link + datetime + "</li>\n")
recent_updates.write(u"</ul>")

View File

@@ -1 +0,0 @@
<ul><li><a href='https://github.com/phil-opp/blog_os/pull/235'>Add a “Recent Updates” section to the front page</a> <time datetime="2016-10-04 17:32:57 UTC">Oct 04</datetime><li><a href='https://github.com/phil-opp/blog_os/pull/230'>Use crates.io version of multiboot2</a> <time datetime="2016-09-27 11:49:36 UTC">Sep 27</datetime><li><a href='https://github.com/phil-opp/blog_os/pull/229'>Update bit_field to 0.5.0 and use new trait based API</a> <time datetime="2016-09-27 11:36:29 UTC">Sep 27</datetime><li><a href='https://github.com/phil-opp/blog_os/pull/221'>Use rustup for cross compiling and also explain xargo</a> <time datetime="2016-09-22 13:59:20 UTC">Sep 22</datetime><li><a href='https://github.com/phil-opp/blog_os/pull/219'>“Returning from Exceptions”</a> <time datetime="2016-09-21 13:26:16 UTC">Sep 21</datetime></ul>