Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
beautification, truncate repos/commits to `:5`, add datetime.
- Loading branch information
|
@@ -24,12 +24,31 @@ a.commit-link { |
|
|
list-style: none; |
|
|
} |
|
|
|
|
|
.repo-title { |
|
|
padding-top: 20px; |
|
|
} |
|
|
|
|
|
.repo-more-link { |
|
|
padding-top: 30px; |
|
|
padding-left: 20px; |
|
|
} |
|
|
|
|
|
.commit-list { |
|
|
list-style: none; |
|
|
padding-bottom: 10px; |
|
|
} |
|
|
|
|
|
.commit-hash { |
|
|
.commit-header { |
|
|
width: 75%; |
|
|
padding-top: 30px; |
|
|
padding-bottom: 10px; |
|
|
margin-bottom: 20px; |
|
|
} |
|
|
|
|
|
.commit-hash { |
|
|
float: left; |
|
|
} |
|
|
|
|
|
.commit-dt { |
|
|
float: right; |
|
|
} |
|
@@ -15,7 +15,7 @@ |
|
|
{% for repo, blurb, commits in repos_list %} |
|
|
<li class="repo"> |
|
|
|
|
|
<h2 class="repo-title">Repository Name: <a href="{{ repo.html_url }}">{{ repo.name }}</a></h2> |
|
|
<h1 class="repo-title"><a href="{{ repo.html_url }}">{{ repo.name }}</a></h1> |
|
|
{% if repo.description %} |
|
|
<p class="repo-description shadow-box">{{ repo.description }}</p> |
|
|
{% endif %} {# repo.description #} |
|
@@ -24,18 +24,21 @@ <h2 class="repo-title">Repository Name: <a href="{{ repo.html_url }}">{{ repo.na |
|
|
<p class="blurb shadow-box">{{ blurb.blurb }}</p> |
|
|
{% endif %} {# blurb #} |
|
|
|
|
|
<h3>Commits...</h3> |
|
|
<ul class="commit-list"> |
|
|
{% for commit in commits %} |
|
|
<li class="commit"> |
|
|
<a class="commit-link" href="{{ commit.html_url }}"> |
|
|
<div class="commit-hash">{{ commit.sha }}</div> |
|
|
<div class="commit-header"> |
|
|
<div class="commit-hash">{{ commit.sha }}</div> |
|
|
<div class="commit-dt">{{ commit.dt }}</div> |
|
|
</div> |
|
|
<div class="rst"> |
|
|
<div class="commit-message shadow-box">{{ commit.message_html|safe }}</div> |
|
|
</div> |
|
|
</a> |
|
|
</li> |
|
|
{% endfor %} {# commits #} |
|
|
<li class="repo-more-link"><a href="{{ repo.html_url }}">more from {{ repo.name }}...</a></li> |
|
|
</ul> |
|
|
</li> |
|
|
{% endfor %} {# repos_list #} |
|
|
|
|
@@ -1,14 +1,19 @@ |
|
|
from dateutil.parser import parse as parse_dt |
|
|
|
|
|
from django.shortcuts import get_object_or_404, render |
|
|
from django.http import HttpResponseRedirect |
|
|
from .models import Repos, Commits, Blurbs |
|
|
|
|
|
def get_grouped_commits(): |
|
|
"""Return a list of the format |
|
|
|
|
|
`[(repo, blurb, [commit, commit, ...], ...]` |
|
|
`[(repo, blurb, [commit, commit, ...]), ...]` |
|
|
|
|
|
Each list of commits belongs to the corresponding `repo` (and `blurb`). The tuples are then sorted by |
|
|
the date of the first commit in the list of commits. |
|
|
|
|
|
Note that this code assumes a reasonably small amount of data (~ 5 repos x 5 commits). The below is not |
|
|
especially efficient... |
|
|
""" |
|
|
# a temporary dict used to group commits by repo |
|
|
by_repo = {} |
|
@@ -29,6 +34,15 @@ def get_grouped_commits(): |
|
|
commits = sorted(commits, |
|
|
key=lambda c: c.author_date, |
|
|
reverse=True) |
|
|
|
|
|
def add_friendly_dt(commit): |
|
|
commit.dt = parse_dt(commit.author_date).strftime('%Y-%m-%d, %H:%M UTC') |
|
|
return commit |
|
|
|
|
|
# truncate to 5 commits |
|
|
commits = commits[:5] |
|
|
# add a dt field formatted more nicely |
|
|
commits = list(map(add_friendly_dt, commits)) |
|
|
grouped_commits.append((repo, blurb, commits)) |
|
|
|
|
|
# sort the tuples by the date of the first commit |
|
@@ -37,6 +51,10 @@ def get_grouped_commits(): |
|
|
reverse=True) |
|
|
print(len(grouped_commits)) |
|
|
|
|
|
# truncate to 5 repos |
|
|
grouped_commits = grouped_commits[:5] |
|
|
#grouped_commits = map(lambda r: (r[0], r[1], r[2][:5]), grouped_commits) |
|
|
|
|
|
return grouped_commits |
|
|
|
|
|
|
|
|