Diff between dcfbea6521008e85a7822db6b26e84dd0d31b92c and 005c83b4c12f76d36dd4c3762d1f66d6f3f37bfa

Changed Files

File Additions Deletions Status
app.py +10 -1 modified
static/styles.css +10 -0 modified
templates/repo.html +16 -12 modified

Full Patch

diff --git a/app.py b/app.py
index 43885ba..c6504f0 100644
--- a/app.py
+++ b/app.py
@@ -104,7 +104,16 @@ def repo_detail(repo_name):
         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
@@ -154,5 +154,15 @@ table.commits-table .message-col {
     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
@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 
 {% block content %}
-<h1>Repository: {{ repo_name }}</h1>
+<h1>{{ repo_name }}</h1>
 <h2>Latest commits</h2>
 <table class="commits-table">
     <thead>
@@ -15,18 +15,22 @@
     </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