git documentation feature

This commit is contained in:
Joren de Graaf
2026-10-20 19:10:00 +02:00
parent 03d7afc6a1
commit a15c1f4c94
21 changed files with 1242 additions and 9 deletions
@@ -0,0 +1 @@
{% if nodes %}<ul class="list-unstyled ms-3">{% for node in nodes %}<li><a href="{% url 'projects:docs_home' project.id %}?path={{ node.path|urlencode }}"{% if node.path == prefix %} aria-current="page"{% endif %}>{{ node.name }}/</a>{% include 'projects/_docs_folder_tree.html' with nodes=node.children %}</li>{% endfor %}</ul>{% endif %}
+1 -1
View File
@@ -2,7 +2,7 @@
{% block content %}
<style>.htmx-indicator{display:none}.htmx-request.htmx-indicator,.htmx-request .htmx-indicator{display:inline}</style>
<div class="d-flex justify-content-between align-items-center mb-3">
<div><a href="{% url 'projects:list' %}">All projects</a><h1>{{ project.name }}</h1><p>{{ project.description }}</p>{% if project.git_repository_url %}<a href="{{ project.git_repository_url }}" rel="noopener noreferrer">Repository</a>{% endif %}<p>{{ done_count }} of {{ total_count }} cards done</p></div>
<div><a href="{% url 'projects:list' %}">All projects</a><h1>{{ project.name }}</h1><p>{{ project.description }}</p>{% if project.git_repository_url %}<a href="{{ project.git_repository_url }}" rel="noopener noreferrer">Repository</a>{% endif %} <a href="{% url 'projects:docs_home' project.id %}">Documentation</a><p>{{ done_count }} of {{ total_count }} cards done</p></div>
{% if can_edit %}<div><a class="btn btn-outline-secondary" href="{% url 'projects:edit' project.id %}">Edit project</a> {% if project.archived %}<form class="d-inline" method="post" action="{% url 'projects:restore' project.id %}">{% csrf_token %}<button class="btn btn-outline-success">Restore project</button></form>{% else %}<form class="d-inline" method="post" action="{% url 'projects:archive' project.id %}">{% csrf_token %}<button class="btn btn-outline-danger">Archive project</button></form> <a class="btn btn-success" href="{% url 'projects:card_create' project.id %}">New card</a>{% endif %}</div>{% endif %}
</div>
<div class="d-flex gap-3 flex-wrap mb-3">{% for label,count in priority_counts %}<span class="badge text-bg-light border">{{ label }}: {{ count }} open</span>{% endfor %}</div>
@@ -0,0 +1,10 @@
{% extends 'core/base.html' %}
{% block content %}
<nav aria-label="Breadcrumb" class="mb-3"><a href="{% url 'projects:board' project.id %}">{{ project.name }}</a> / <a href="{% url 'projects:docs_home' project.id %}">Documentation</a> / {% for crumb in breadcrumbs %}<a href="{% url 'projects:docs_home' project.id %}?path={{ crumb.path|urlencode }}">{{ crumb.name }}</a> / {% endfor %}{{ file_name }}</nav>
<div class="d-flex justify-content-between align-items-start gap-3 flex-wrap"><div><h1>{{ document.title }}</h1><p><code>{{ document.path }}</code></p></div>{% if source_url %}<a class="btn btn-outline-secondary" href="{{ source_url }}" rel="noopener noreferrer">View in Git</a>{% endif %}</div>
<div class="alert {% if sync.last_error %}alert-warning{% else %}alert-secondary{% endif %}" role="status"><strong>{{ sync_status }}</strong><span class="d-block">Source commit: <code>{{ document.source_commit }}</code> · SHA-256: <code>{{ document.content_hash }}</code></span>{% if document_commit_time %}<span class="d-block">Commit time: {{ document_commit_time }}</span>{% endif %}{% if sync.remote_head and sync.remote_head != sync.indexed_commit %}<span class="d-block">Last observed remote HEAD: <code>{{ sync.remote_head }}</code></span>{% endif %}{% if sync.last_success_at %}<span class="d-block">Fetched {{ sync.last_success_at }}</span>{% endif %}<span class="d-block">Documentation accuracy audit: {{ audit_label }}.</span></div>
{% if is_historical %}<p class="alert alert-info" role="status">Viewing a historical Git version. <a href="{% url 'projects:docs_document' project.id document.path %}">Return to indexed version</a>.</p>{% endif %}
<article class="card card-body markdown-body">{{ rendered }}</article>
<details class="mt-3"><summary>Raw Markdown</summary><pre class="card card-body overflow-auto">{{ document.markdown }}</pre></details>
{% if history %}<section class="mt-4" aria-labelledby="doc-history-heading"><h2 class="h5" id="doc-history-heading">Git history</h2><p class="text-muted">Recent commits for this path in the retained shallow mirror. Renames and deleted documents are not followed yet.</p><ol>{% for version in history %}<li><a href="?revision={{ version.commit }}"><code>{{ version.commit|slice:':12' }}</code></a> · {{ version.committed_at }}</li>{% endfor %}</ol></section>{% endif %}
{% endblock %}
@@ -0,0 +1,28 @@
{% extends 'core/base.html' %}
{% block content %}
<div class="d-flex justify-content-between align-items-start gap-3 flex-wrap mb-3">
<div><a href="{% url 'projects:board' project.id %}">← {{ project.name }}</a><h1 class="mt-2">Documentation</h1><p class="text-muted">Read-only Markdown from the project's Git repository.</p></div>
{% if can_edit and project.git_repository_url %}<form method="post" action="{% url 'projects:docs_refresh' project.id %}">{% csrf_token %}<button class="btn btn-outline-primary">Refresh from Git</button></form>{% endif %}
</div>
<div class="alert {% if sync.last_error %}alert-warning{% else %}alert-secondary{% endif %}" role="status">
<strong>{{ sync_status }}</strong>
{% if sync.indexed_commit %}<span class="d-block">Indexed commit: <code>{{ sync.indexed_commit }}</code>{% if sync.branch %} · {{ sync.branch }}{% endif %}{% if sync.commit_time %} · committed {{ sync.commit_time }}{% endif %}{% if sync.last_success_at %} · fetched {{ sync.last_success_at }}{% endif %}</span>{% endif %}
{% if sync.remote_head and sync.remote_head != sync.indexed_commit %}<span class="d-block">Last observed remote HEAD: <code>{{ sync.remote_head }}</code></span>{% endif %}
{% if sync.last_attempt_at %}<span class="d-block">Last fetch attempt: {{ sync.last_attempt_at }}</span>{% endif %}
<span class="d-block">Documentation accuracy audit: {{ audit_label }}.</span>
</div>
{% if not project.git_repository_url %}<p>No repository is configured. {% if can_edit %}Add its HTTPS Git URL in <a href="{% url 'projects:edit' project.id %}">project settings</a>.{% else %}Ask a project editor to configure its Git URL.{% endif %}</p>{% endif %}
<form method="get" action="{% url 'projects:docs_home' project.id %}" role="search" class="mb-4">
<label for="docs-search" class="form-label">Search documentation</label>
<div class="input-group"><input id="docs-search" class="form-control" name="q" value="{{ query }}" maxlength="200" placeholder="Path, heading or text"><button class="btn btn-outline-secondary">Search</button></div>
</form>
<div class="row g-4">
<nav class="col-md-4 col-lg-3" aria-label="Documentation folders"><h2 class="h5">Folders</h2><ul class="list-unstyled"><li><a href="{% url 'projects:docs_home' project.id %}">All documents</a></li></ul>{% include 'projects/_docs_folder_tree.html' with nodes=folder_tree %}</nav>
<section class="col-md-8 col-lg-9" aria-label="Document results">
<h2 class="h5">{% if query %}Search results{% elif prefix %}{{ prefix }}/{% else %}Documents{% endif %} <small class="text-muted">({{ total }})</small></h2>
{% if documents %}<ul class="list-group">{% if query %}{% for result in results %}<li class="list-group-item"><a href="{% url 'projects:docs_document' project.id result.document.path %}"><strong>{{ result.document.title }}</strong></a><br><small class="text-muted">{{ result.document.path }}</small><p class="mb-0 mt-1">{{ result.snippet }}</p></li>{% endfor %}{% else %}{% for document in documents %}<li class="list-group-item"><a href="{% url 'projects:docs_document' project.id document.path %}"><strong>{{ document.title }}</strong></a><br><small class="text-muted">{{ document.path }}</small></li>{% endfor %}{% endif %}</ul>
{% else %}<p>{% if query %}No matching documents.{% elif sync.last_error %}No indexed documents are available. The latest Git fetch failed.{% elif project.git_repository_url %}No Markdown documentation has been indexed yet.{% else %}Add a repository to begin.{% endif %}</p>{% endif %}
{% if has_previous or has_next %}<nav class="mt-3" aria-label="Document pages">{% if has_previous %}<a class="btn btn-outline-secondary btn-sm" href="?q={{ query|urlencode }}&amp;path={{ prefix|urlencode }}&amp;page={{ page|add:'-1' }}">Previous</a>{% endif %} <span>Page {{ page }}</span> {% if has_next %}<a class="btn btn-outline-secondary btn-sm" href="?q={{ query|urlencode }}&amp;path={{ prefix|urlencode }}&amp;page={{ page|add:'1' }}">Next</a>{% endif %}</nav>{% endif %}
</section>
</div>
{% endblock %}