mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Link to actual post, not the pull request
This commit is contained in:
@@ -2,12 +2,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import io
|
import io
|
||||||
|
import urllib2
|
||||||
|
import datetime
|
||||||
from github import Github
|
from github import Github
|
||||||
from datetime import datetime, timedelta
|
|
||||||
|
|
||||||
g = Github()
|
g = Github()
|
||||||
|
|
||||||
one_month_ago = datetime.now() - timedelta(days=32)
|
one_month_ago = datetime.datetime.now() - datetime.timedelta(days=32)
|
||||||
|
|
||||||
def filter_date(issue):
|
def filter_date(issue):
|
||||||
return issue.closed_at > one_month_ago
|
return issue.closed_at > one_month_ago
|
||||||
@@ -33,8 +34,8 @@ with io.open("templates/auto/recent-updates.html", 'w', encoding='utf8') as rece
|
|||||||
link = '<a href="' + pr.html_url + '">' + pr.title + "</a> "
|
link = '<a href="' + pr.html_url + '">' + pr.title + "</a> "
|
||||||
iso_date = pr.closed_at.isoformat()
|
iso_date = pr.closed_at.isoformat()
|
||||||
readable_date = pr.closed_at.strftime("%b %d")
|
readable_date = pr.closed_at.strftime("%b %d")
|
||||||
datetime = '<time datetime="' + iso_date + '">' + readable_date + '</time>'
|
datetime_str = '<time datetime="' + iso_date + '">' + readable_date + '</time>'
|
||||||
recent_updates.write(u" <li>" + link + datetime + "</li>\n")
|
recent_updates.write(u" <li>" + link + datetime_str + "</li>\n")
|
||||||
|
|
||||||
recent_updates.write(u"</ul>")
|
recent_updates.write(u"</ul>")
|
||||||
|
|
||||||
@@ -48,11 +49,41 @@ with io.open("templates/auto/forks.html", 'w', encoding='utf8') as forks:
|
|||||||
forks.truncate()
|
forks.truncate()
|
||||||
forks.write(format_number(repo.forks_count))
|
forks.write(format_number(repo.forks_count))
|
||||||
|
|
||||||
|
|
||||||
|
# query "This week in Rust OSDev posts"
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
year = 2020
|
||||||
|
month = 4
|
||||||
|
while True:
|
||||||
|
url = "https://rust-osdev.com/this-month/" + str(year) + "-" + str(month).zfill(2) + "/"
|
||||||
|
try:
|
||||||
|
urllib2.urlopen(url)
|
||||||
|
except urllib2.HTTPError as e:
|
||||||
|
break
|
||||||
|
|
||||||
|
month_str = datetime.date(1900, month, 1).strftime('%B')
|
||||||
|
|
||||||
|
link = '<a href="' + url + '">This Month in Rust OSDev (' + month_str + " " + str(year) + ")</a> "
|
||||||
|
lines.append(u" <li>" + link + "</li>\n")
|
||||||
|
|
||||||
|
month = month + 1
|
||||||
|
if month > 12:
|
||||||
|
month = 0
|
||||||
|
year = year + 1
|
||||||
|
|
||||||
|
lines.reverse()
|
||||||
|
|
||||||
with io.open("templates/auto/status-updates.html", 'w', encoding='utf8') as status_updates:
|
with io.open("templates/auto/status-updates.html", 'w', encoding='utf8') as status_updates:
|
||||||
status_updates.truncate()
|
status_updates.truncate()
|
||||||
|
|
||||||
pulls = g.search_issues("is:merged", repo="rust-osdev/homepage", type="pr", label="next-post")[:5]
|
for line in lines:
|
||||||
|
status_updates.write("<b>" + line + "</b>")
|
||||||
|
|
||||||
for pr in sorted(pulls, key=lambda issue: issue.closed_at, reverse=True):
|
with io.open("templates/auto/status-updates-truncated.html", 'w', encoding='utf8') as status_updates:
|
||||||
link = '<a href="' + pr.html_url + '">' + pr.title + "</a> "
|
status_updates.truncate()
|
||||||
status_updates.write(u" <li>" + link + "</li>\n")
|
|
||||||
|
for index, line in enumerate(lines):
|
||||||
|
if index == 5:
|
||||||
|
break
|
||||||
|
status_updates.write(line)
|
||||||
|
|||||||
0
blog/templates/auto/status-updates-truncated.html
Normal file
0
blog/templates/auto/status-updates-truncated.html
Normal file
@@ -59,7 +59,7 @@
|
|||||||
{% set status_updates = get_section(path = "status-update/_index.md") %}
|
{% set status_updates = get_section(path = "status-update/_index.md") %}
|
||||||
<p>{{ status_updates.description }}</p>
|
<p>{{ status_updates.description }}</p>
|
||||||
<ul>
|
<ul>
|
||||||
{% include "auto/status-updates.html" %}
|
{% include "auto/status-updates-truncated.html" %}
|
||||||
<li><a href="{{ get_url(path="@/status-update/_index.md") | safe }}"><em>view all »</em></a></li>
|
<li><a href="{{ get_url(path="@/status-update/_index.md") | safe }}"><em>view all »</em></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user