diff --git a/app.py b/app.py
index 43885ba..c6504f0 100644
--- a/app.py
+++ b/app.py
abort(400, "Invalid ref")
commits = get_commits(f"{repo_path}/{repo_name}", ref=ref, max_count=10)
refs = get_refs(f"{repo_path}/{repo_name}")
- return render_template("repo.html", repo_name=repo_name, refs=refs, commits=commits)
+ readme = None
+ for filename in ['README.md', 'README']:
+ try:
+ readme_blob = get_blob(f"{repo_path}/{repo_name}", ref, filename)
+ if readme_blob:
+ readme = readme_blob['content']
+ break
+ except:
+ pass
+ return render_template("repo.html", repo_name=repo_name, refs=refs, commits=commits, readme=readme)
@app.route("/<repo_name>/commits")
def repo_commits(repo_name):
diff --git a/static/styles.css b/static/styles.css
index 36fd90a..311cd91 100644
--- a/static/styles.css
+++ b/static/styles.css
overflow-x: auto;
}
+.readme-box {
+ border: 1px solid lightgray;
+ padding: 1em;
+ margin: 0.5em 0;
+ background-color: #f9f9f9;
+ border-radius: 4px;
+ white-space: pre-wrap;
+ overflow-x: auto;
+}
+
diff --git a/templates/repo.html b/templates/repo.html
index 4bfa6c0..6b4a0f7 100644
--- a/templates/repo.html
+++ b/templates/repo.html
{% extends "base.html" %}
{% block content %}
-<h1>Repository: {{ repo_name }}</h1>
+<h1>{{ repo_name }}</h1>
<h2>Latest commits</h2>
<table class="commits-table">
<thead>
</thead>
<tbody>
{% for commit in commits %}
- <tr>
- <td class="commit-col"><a href="{{ url_for('commit_detail', repo_name=repo_name, commit_id=commit.id) }}">{{ commit.id[:8] }}</a></td>
- <td class="message-col">{{ commit.message }}</td>
- <td class="author-col">{{ commit.author.name }}</td>
- <td class="age-col">{{ commit.date | age }}</td>
- <td class="changes-col">
- <span class="files-changed">{{ commit.diff_stats.files_changed }} file{% if commit.diff_stats.files_changed != 1 %}s{% endif %}</span>
- <span class="insertions">+{{ commit.diff_stats.insertions }}</span>
- <span class="deletions">-{{ commit.diff_stats.deletions }}</span>
- </td>
- </tr>
+ <tr>
+ <td class="commit-col"><a href="{{ url_for('commit_detail', repo_name=repo_name, commit_id=commit.id) }}">{{ commit.id[:8] }}</a></td>
+ <td class="message-col">{{ commit.message }}</td>
+ <td class="author-col">{{ commit.author.name }}</td>
+ <td class="age-col">{{ commit.date | age }}</td>
+ <td class="changes-col">
+ <span class="files-changed">{{ commit.diff_stats.files_changed }} file{% if commit.diff_stats.files_changed != 1 %}s{% endif %}</span>
+ <span class="insertions">+{{ commit.diff_stats.insertions }}</span>
+ <span class="deletions">-{{ commit.diff_stats.deletions }}</span>
+ </td>
+ </tr>
{% endfor %}
</tbody>
</table>
+{% if readme %}
+<h2>README</h2>
+<pre class="readme-box">{{ readme }}</pre>
+{% endif %}
{% endblock %}
\ No newline at end of file