Add a GitHub style repository card on index page (#620)

This commit is contained in:
Philipp Oppermann
2019-06-15 12:30:11 +02:00
committed by GitHub
parent 00978bd6c9
commit 361ba0c32b
8 changed files with 101 additions and 5 deletions

View File

@@ -12,7 +12,13 @@ one_month_ago = datetime.now() - timedelta(days=32)
def filter_date(issue):
return issue.closed_at > one_month_ago
with io.open("templates/recent-updates.html", 'w', encoding='utf8') as recent_updates:
def format_number(number):
if number > 1000:
return u"{:.1f}k".format(float(number) / 1000)
else:
return u"{}".format(number)
with io.open("templates/auto/recent-updates.html", 'w', encoding='utf8') as recent_updates:
recent_updates.truncate()
recent_updates.write(u"<ul>\n")
@@ -27,3 +33,13 @@ with io.open("templates/recent-updates.html", 'w', encoding='utf8') as recent_up
recent_updates.write(u" <li>" + link + datetime + "</li>\n")
recent_updates.write(u"</ul>")
repo = g.get_repo("phil-opp/blog_os")
with io.open("templates/auto/stars.html", 'w', encoding='utf8') as stars:
stars.truncate()
stars.write(format_number(repo.stargazers_count))
with io.open("templates/auto/forks.html", 'w', encoding='utf8') as forks:
forks.truncate()
forks.write(format_number(repo.forks_count))

View File

@@ -220,6 +220,7 @@ aside#all-posts-link {
aside#recent-updates {
position: absolute;
min-width: 11rem;
max-width: 17rem;
top: 4rem;
margin-left: 45rem;
@@ -227,6 +228,10 @@ aside#all-posts-link {
font-size: 90%;
}
aside#recent-updates .block {
margin-bottom: 1.5rem;
}
aside#recent-updates h2 {
font-size: 110%;
margin-bottom: .2rem;
@@ -331,3 +336,49 @@ details summary {
details summary h3, details summary h4, details summary h5, details summary h6 {
display: inline;
}
.gh-repo-box {
border: 1px solid #d1d5da;
border-radius: 3px;
padding: 16px;
margin-top: 0.5rem;
color: #586069;
font-size: 80%;
}
.gh-repo-box .repo-link {
color: #0366d6;
font-weight: 600;
font-size: 120%;
}
.gh-repo-box .subtitle {
margin-bottom: 16px;
}
.gh-repo-box .stars-forks {
margin-bottom: 0;
}
.gh-repo-box .stars-forks a {
color: #586069;
}
.gh-repo-box .stars-forks a:hover {
color: #0366d6;
text-decoration: none;
}
.gh-repo-box .stars-forks svg {
vertical-align: text-bottom;
fill: currentColor;
}
.gh-repo-box .stars {
display: inline-block;
}
.gh-repo-box .forks {
display: inline-block;
margin-left: 16px;
}

View File

View File

View File

View File

@@ -61,7 +61,7 @@
<aside id="recent-updates">
<h2>Recent Updates</h2>
{% include "recent-updates.html" %}
{% include "auto/recent-updates.html" %}
</aside>
{% endblock main %}

View File

@@ -1 +0,0 @@

View File

@@ -77,8 +77,38 @@
</ul>
<aside id="recent-updates">
<h2>Recent Updates</h2>
{% include "recent-updates.html" %}
<div class="block">
<h2>Recent Updates</h2>
{% include "auto/recent-updates.html" %}
</div>
<div class="block">
<h2>Repository</h2>
<div class="gh-repo-box">
<div>
<svg viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M4 9H3V8h1v1zm0-3H3v1h1V6zm0-2H3v1h1V4zm0-2H3v1h1V2zm8-1v12c0 .55-.45 1-1 1H6v2l-1.5-1.5L3 16v-2H1c-.55 0-1-.45-1-1V1c0-.55.45-1 1-1h10c.55 0 1 .45 1 1zm-1 10H1v2h2v-1h3v1h5v-2zm0-10H2v9h9V1z"></path></svg>
<a href="https://github.com/phil-opp/blog_os" class="repo-link">
<span title="blog_os">phil-opp/blog_os</span>
</a>
</div>
<p class="subtitle">
Writing an OS in Rust
</p>
<p class="stars-forks">
<a href="https://github.com/phil-opp/blog_os/stargazers" class="stars">
<svg aria-label="stars" viewBox="0 0 14 16" version="1.1" width="14" height="16" role="img"><path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74L14 6z"></path></svg>
{% include "auto/stars.html" %}
</a>
<a href="https://github.com/phil-opp/blog_os/network/members" class="forks">
<svg aria-label="forks" viewBox="0 0 10 16" version="1.1" width="10" height="16" role="img"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
{% include "auto/forks.html" %}
</a>
</p>
</div>
</div>
</aside>
{% endblock main %}