Use same commit link style everywhere

This commit is contained in:
Joscha 2023-08-06 23:38:12 +02:00
parent 2b81d497bc
commit 794787a4be
10 changed files with 96 additions and 75 deletions

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT name, hash, tracked, message FROM refs JOIN commits USING (hash) ORDER BY name ASC ", "query": "SELECT name, hash, message, reachable, tracked FROM refs JOIN commits USING (hash) ORDER BY name ASC ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -14,14 +14,19 @@
"type_info": "Text" "type_info": "Text"
}, },
{ {
"name": "tracked", "name": "message",
"ordinal": 2, "ordinal": 2,
"type_info": "Text"
},
{
"name": "reachable",
"ordinal": 3,
"type_info": "Int64" "type_info": "Int64"
}, },
{ {
"name": "message", "name": "tracked",
"ordinal": 3, "ordinal": 4,
"type_info": "Text" "type_info": "Int64"
} }
], ],
"parameters": { "parameters": {
@ -31,8 +36,9 @@
false, false,
false, false,
false, false,
false,
false false
] ]
}, },
"hash": "39e21f75c4f68be1e4f64c4a9c0a38974f12556b6ac463f21f7729f758dec886" "hash": "c7a4115d81a3371d77afadfdad7dbe47c4d1d23211a35c0c68174f9ce82893c2"
} }

View file

@ -1,6 +1,6 @@
{ {
"db_name": "SQLite", "db_name": "SQLite",
"query": "SELECT id, hash, message, date AS \"date: time::OffsetDateTime\", priority FROM queue JOIN commits USING (hash) ORDER BY priority DESC, unixepoch(date) DESC, hash ASC ", "query": "SELECT id, hash, message, reachable, date AS \"date: time::OffsetDateTime\", priority FROM queue JOIN commits USING (hash) ORDER BY priority DESC, unixepoch(date) DESC, hash ASC ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@ -19,13 +19,18 @@
"type_info": "Text" "type_info": "Text"
}, },
{ {
"name": "date: time::OffsetDateTime", "name": "reachable",
"ordinal": 3, "ordinal": 3,
"type_info": "Int64"
},
{
"name": "date: time::OffsetDateTime",
"ordinal": 4,
"type_info": "Text" "type_info": "Text"
}, },
{ {
"name": "priority", "name": "priority",
"ordinal": 4, "ordinal": 5,
"type_info": "Int64" "type_info": "Int64"
} }
], ],
@ -37,8 +42,9 @@
false, false,
false, false,
false, false,
false,
false false
] ]
}, },
"hash": "02a0484f131cdd7420fb073dec5c9ed2758e21a6bf74026ba3e19cba1d274536" "hash": "ca4e47d1a7fa0bbe474992eafeca39fa12d022fc171b8e4195cf1899ccb0557b"
} }

View file

@ -11,6 +11,7 @@ struct Ref {
name: String, name: String,
hash: String, hash: String,
short: String, short: String,
reachable: i64,
tracked: bool, tracked: bool,
} }
@ -28,16 +29,18 @@ pub async fn get(
) -> somehow::Result<impl IntoResponse> { ) -> somehow::Result<impl IntoResponse> {
let refs = sqlx::query!( let refs = sqlx::query!(
"\ "\
SELECT name, hash, tracked, message FROM refs \ SELECT name, hash, message, reachable, tracked \
FROM refs \
JOIN commits USING (hash) \ JOIN commits USING (hash) \
ORDER BY name ASC \ ORDER BY name ASC \
" "
) )
.fetch(&db) .fetch(&db)
.map_ok(|r| Ref { .map_ok(|r| Ref {
name: r.name,
short: util::format_commit_short(&r.hash, &r.message), short: util::format_commit_short(&r.hash, &r.message),
name: r.name,
hash: r.hash, hash: r.hash,
reachable: r.reachable,
tracked: r.tracked != 0, tracked: r.tracked != 0,
}) })
.try_collect::<Vec<_>>() .try_collect::<Vec<_>>()

View file

@ -10,6 +10,7 @@ use super::{Base, Tab};
struct Task { struct Task {
id: String, id: String,
short: String, short: String,
reachable: i64,
since: String, since: String,
priority: i64, priority: i64,
odd: bool, odd: bool,
@ -22,6 +23,7 @@ async fn get_queue(db: &SqlitePool) -> somehow::Result<Vec<Task>> {
id, \ id, \
hash, \ hash, \
message, \ message, \
reachable, \
date AS \"date: time::OffsetDateTime\", \ date AS \"date: time::OffsetDateTime\", \
priority \ priority \
FROM queue \ FROM queue \
@ -33,6 +35,7 @@ async fn get_queue(db: &SqlitePool) -> somehow::Result<Vec<Task>> {
.map_ok(|r| Task { .map_ok(|r| Task {
id: r.id, id: r.id,
short: util::format_commit_short(&r.hash, &r.message), short: util::format_commit_short(&r.hash, &r.message),
reachable: r.reachable,
since: util::format_delta_from_now(r.date), since: util::format_delta_from_now(r.date),
priority: r.priority, priority: r.priority,
odd: false, odd: false,

View file

@ -51,6 +51,13 @@ td+td {
padding-left: 2ch; padding-left: 2ch;
} }
.reachable {
color: #777;
}
.orphaned {
color: #a33;
}
/* Nav bar */ /* Nav bar */
@ -115,16 +122,6 @@ nav img {
column-gap: 1ch; column-gap: 1ch;
} }
.commit .reachable,
.commit .reachable a {
color: #777;
}
.commit .orphaned,
.commit .orphaned a {
color: #a33;
}
.commit pre { .commit pre {
margin: 1em 0ch 1em 4ch; margin: 1em 0ch 1em 4ch;
white-space: pre-wrap; white-space: pre-wrap;

View file

@ -1,27 +1,8 @@
{% extends "base.html" %} {% extends "base.html" %}
{% import "util.html" as util %}
{% block title %}{{ summary }}{% endblock %} {% block title %}{{ summary }}{% endblock %}
{% macro r_class(reachable) %}
{%- if reachable == 0 -%}
orphaned
{%- else if reachable == 1 -%}
reachable
{%- else -%}
tracked
{%- endif -%}
{% endmacro %}
{% macro r_title(reachable) %}
{%- if reachable == 0 -%}
This commit is orphaned. It can't be reached from any ref.
{%- else if reachable == 1 -%}
This commit can only be reached from untracked refs.
{%- else -%}
This commit can be reached from a tracked ref.
{%- endif -%}
{% endmacro %}
{% block body %} {% block body %}
<h2>Commit</h2> <h2>Commit</h2>
<div class="commit"> <div class="commit">
@ -40,19 +21,23 @@ This commit can be reached from a tracked ref.
<dd>{{ commit_date }}</dd> <dd>{{ commit_date }}</dd>
{% for commit in parents %} {% for commit in parents %}
<dt class="{% call r_class(commit.reachable) %}" title="{% call r_title(commit.reachable) %}">Parent:</dt> <dt>Parent:</dt>
<dd class="{% call r_class(commit.reachable) %}" title="{% call r_title(commit.reachable) %}"> <dd>
<a href="{{ commit.hash }}">{{ commit.short }}</a> <a href="{{ commit.hash }}">
{% call util::commit_short(commit.short, commit.reachable)%}
</a>
</dd> </dd>
{% endfor %} {% endfor %}
{% for commit in children %} {% for commit in children %}
<dt class="{% call r_class(commit.reachable) %}" title="{% call r_title(commit.reachable) %}">Child:</dt> <dt>Child:</dt>
<dd class="{% call r_class(commit.reachable) %}" title="{% call r_title(commit.reachable) %}"> <dd>
<a href="{{ commit.hash }}">{{ commit.short }}</a> <a href="{{ commit.hash }}">
{% call util::commit_short(commit.short, commit.reachable)%}
</a>
</dd> </dd>
{% endfor %} {% endfor %}
</dl> </dl>
<pre class="{% call r_class(reachable) %}" title="{% call r_title(reachable) %}">{{ message }}</pre> <pre class="{% call util::r_class(reachable) %}" title="{% call util::r_title(reachable) %}">{{ message }}</pre>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -1,4 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% import "util.html" as util %}
{% block title %}overview{% endblock %} {% block title %}overview{% endblock %}
@ -9,7 +10,11 @@
<dl> <dl>
{% for ref in tracked_refs %} {% for ref in tracked_refs %}
<dt>{{ ref.name }}</dt> <dt>{{ ref.name }}</dt>
<dd><a href="{{ base.root }}/commit/{{ ref.hash }}">{{ ref.short }}</a></dd> <dd>
<a href="{{ base.root }}/commit/{{ ref.hash }}">
{% call util::commit_short(ref.short, ref.reachable) %}
</a>
</dd>
{% endfor %} {% endfor %}
</dl> </dl>
</details> </details>
@ -18,7 +23,11 @@
<dl> <dl>
{% for ref in untracked_refs %} {% for ref in untracked_refs %}
<dt>{{ ref.name }}</dt> <dt>{{ ref.name }}</dt>
<dd><a href="{{ base.root }}/commit/{{ ref.hash }}">{{ ref.short }}</a></dd> <dd>
<a href="{{ base.root }}/commit/{{ ref.hash }}">
{% call util::commit_short(ref.short, ref.reachable) %}
</a>
</dd>
{% endfor %} {% endfor %}
</dl> </dl>
</details> </details>

View file

@ -1,27 +1,8 @@
{% extends "base.html" %} {% extends "base.html" %}
{% import "util.html" as util %}
{% block title %}{{ summary }}{% endblock %} {% block title %}{{ summary }}{% endblock %}
{% macro r_class(reachable) %}
{%- if reachable == 0 -%}
orphaned
{%- else if reachable == 1 -%}
reachable
{%- else -%}
tracked
{%- endif -%}
{% endmacro %}
{% macro r_title(reachable) %}
{%- if reachable == 0 -%}
This commit is orphaned. It can't be reached from any ref.
{%- else if reachable == 1 -%}
This commit can only be reached from untracked refs.
{%- else -%}
This commit can be reached from a tracked ref.
{%- endif -%}
{% endmacro %}
{% block body %} {% block body %}
<h2>Task</h2> <h2>Task</h2>
<div class="task"> <div class="task">
@ -33,9 +14,11 @@ This commit can be reached from a tracked ref.
<dt>Priority:</dt> <dt>Priority:</dt>
<dd>{{ priority }}</dd> <dd>{{ priority }}</dd>
<dt class="{% call r_class(reachable) %}" title="{% call r_title(reachable) %}">Commit:</dt> <dt>Commit:</dt>
<dd class="{% call r_class(reachable) %}" title="{% call r_title(reachable) %}"> <dd>
<a href="{{ base.root }}/commit/{{ hash }}">{{ short }}</a> <a href="{{ base.root }}/commit/{{ hash }}">
{% call util::commit_short(short, reachable) %}
</a>
</dd> </dd>
</dl> </dl>
</div> </div>

View file

@ -1,3 +1,5 @@
{% import "util.html" as util %}
<table class="queue"> <table class="queue">
<thead> <thead>
<tr> <tr>
@ -9,7 +11,11 @@
<tbody> <tbody>
{% for task in tasks %} {% for task in tasks %}
<tr {% if task.odd %} class="odd" {% endif %}> <tr {% if task.odd %} class="odd" {% endif %}>
<td><a href="{{ task.id }}">{{ task.short }}</a></td> <td>
<a href="{{ task.id }}">
{% call util::commit_short(task.short, task.reachable) %}
</a>
</td>
<td>{{ task.since }}</td> <td>{{ task.since }}</td>
<td>{{ task.priority }}</td> <td>{{ task.priority }}</td>
</tr> </tr>

23
templates/util.html Normal file
View file

@ -0,0 +1,23 @@
{% macro r_class(reachable) %}
{%- if reachable == 0 -%}
orphaned
{%- else if reachable == 1 -%}
reachable
{%- else -%}
tracked
{%- endif -%}
{% endmacro %}
{% macro r_title(reachable) %}
{%- if reachable == 0 -%}
This commit is orphaned. It can't be reached from any ref.
{%- else if reachable == 1 -%}
This commit can only be reached from untracked refs.
{%- else -%}
This commit can be reached from a tracked ref.
{%- endif -%}
{% endmacro %}
{% macro commit_short(short, reachable) -%}
<span class="{% call r_class(reachable) %}" title="{% call r_title(reachable) %}">{{ short }}</span>
{%- endmacro %}