From 794787a4be07ca8546edd4d3c16251ecdb81b512 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 6 Aug 2023 23:38:12 +0200 Subject: [PATCH] Use same commit link style everywhere --- ...be47c4d1d23211a35c0c68174f9ce82893c2.json} | 18 ++++++--- ...39fa12d022fc171b8e4195cf1899ccb0557b.json} | 14 +++++-- src/web/index.rs | 7 +++- src/web/queue.rs | 3 ++ static/base.css | 17 ++++---- templates/commit_hash.html | 39 ++++++------------- templates/index.html | 13 ++++++- templates/queue_id.html | 29 +++----------- templates/queue_table.html | 8 +++- templates/util.html | 23 +++++++++++ 10 files changed, 96 insertions(+), 75 deletions(-) rename .sqlx/{query-39e21f75c4f68be1e4f64c4a9c0a38974f12556b6ac463f21f7729f758dec886.json => query-c7a4115d81a3371d77afadfdad7dbe47c4d1d23211a35c0c68174f9ce82893c2.json} (64%) rename .sqlx/{query-02a0484f131cdd7420fb073dec5c9ed2758e21a6bf74026ba3e19cba1d274536.json => query-ca4e47d1a7fa0bbe474992eafeca39fa12d022fc171b8e4195cf1899ccb0557b.json} (64%) create mode 100644 templates/util.html diff --git a/.sqlx/query-39e21f75c4f68be1e4f64c4a9c0a38974f12556b6ac463f21f7729f758dec886.json b/.sqlx/query-c7a4115d81a3371d77afadfdad7dbe47c4d1d23211a35c0c68174f9ce82893c2.json similarity index 64% rename from .sqlx/query-39e21f75c4f68be1e4f64c4a9c0a38974f12556b6ac463f21f7729f758dec886.json rename to .sqlx/query-c7a4115d81a3371d77afadfdad7dbe47c4d1d23211a35c0c68174f9ce82893c2.json index 0e6da13..69f7400 100644 --- a/.sqlx/query-39e21f75c4f68be1e4f64c4a9c0a38974f12556b6ac463f21f7729f758dec886.json +++ b/.sqlx/query-c7a4115d81a3371d77afadfdad7dbe47c4d1d23211a35c0c68174f9ce82893c2.json @@ -1,6 +1,6 @@ { "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": { "columns": [ { @@ -14,14 +14,19 @@ "type_info": "Text" }, { - "name": "tracked", + "name": "message", "ordinal": 2, + "type_info": "Text" + }, + { + "name": "reachable", + "ordinal": 3, "type_info": "Int64" }, { - "name": "message", - "ordinal": 3, - "type_info": "Text" + "name": "tracked", + "ordinal": 4, + "type_info": "Int64" } ], "parameters": { @@ -31,8 +36,9 @@ false, false, false, + false, false ] }, - "hash": "39e21f75c4f68be1e4f64c4a9c0a38974f12556b6ac463f21f7729f758dec886" + "hash": "c7a4115d81a3371d77afadfdad7dbe47c4d1d23211a35c0c68174f9ce82893c2" } diff --git a/.sqlx/query-02a0484f131cdd7420fb073dec5c9ed2758e21a6bf74026ba3e19cba1d274536.json b/.sqlx/query-ca4e47d1a7fa0bbe474992eafeca39fa12d022fc171b8e4195cf1899ccb0557b.json similarity index 64% rename from .sqlx/query-02a0484f131cdd7420fb073dec5c9ed2758e21a6bf74026ba3e19cba1d274536.json rename to .sqlx/query-ca4e47d1a7fa0bbe474992eafeca39fa12d022fc171b8e4195cf1899ccb0557b.json index 51d4969..8ab3490 100644 --- a/.sqlx/query-02a0484f131cdd7420fb073dec5c9ed2758e21a6bf74026ba3e19cba1d274536.json +++ b/.sqlx/query-ca4e47d1a7fa0bbe474992eafeca39fa12d022fc171b8e4195cf1899ccb0557b.json @@ -1,6 +1,6 @@ { "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": { "columns": [ { @@ -19,13 +19,18 @@ "type_info": "Text" }, { - "name": "date: time::OffsetDateTime", + "name": "reachable", "ordinal": 3, + "type_info": "Int64" + }, + { + "name": "date: time::OffsetDateTime", + "ordinal": 4, "type_info": "Text" }, { "name": "priority", - "ordinal": 4, + "ordinal": 5, "type_info": "Int64" } ], @@ -37,8 +42,9 @@ false, false, false, + false, false ] }, - "hash": "02a0484f131cdd7420fb073dec5c9ed2758e21a6bf74026ba3e19cba1d274536" + "hash": "ca4e47d1a7fa0bbe474992eafeca39fa12d022fc171b8e4195cf1899ccb0557b" } diff --git a/src/web/index.rs b/src/web/index.rs index b1177dc..7d5a221 100644 --- a/src/web/index.rs +++ b/src/web/index.rs @@ -11,6 +11,7 @@ struct Ref { name: String, hash: String, short: String, + reachable: i64, tracked: bool, } @@ -28,16 +29,18 @@ pub async fn get( ) -> somehow::Result { let refs = sqlx::query!( "\ - SELECT name, hash, tracked, message FROM refs \ + SELECT name, hash, message, reachable, tracked \ + FROM refs \ JOIN commits USING (hash) \ ORDER BY name ASC \ " ) .fetch(&db) .map_ok(|r| Ref { - name: r.name, short: util::format_commit_short(&r.hash, &r.message), + name: r.name, hash: r.hash, + reachable: r.reachable, tracked: r.tracked != 0, }) .try_collect::>() diff --git a/src/web/queue.rs b/src/web/queue.rs index 0c702fb..6d4aa61 100644 --- a/src/web/queue.rs +++ b/src/web/queue.rs @@ -10,6 +10,7 @@ use super::{Base, Tab}; struct Task { id: String, short: String, + reachable: i64, since: String, priority: i64, odd: bool, @@ -22,6 +23,7 @@ async fn get_queue(db: &SqlitePool) -> somehow::Result> { id, \ hash, \ message, \ + reachable, \ date AS \"date: time::OffsetDateTime\", \ priority \ FROM queue \ @@ -33,6 +35,7 @@ async fn get_queue(db: &SqlitePool) -> somehow::Result> { .map_ok(|r| Task { id: r.id, short: util::format_commit_short(&r.hash, &r.message), + reachable: r.reachable, since: util::format_delta_from_now(r.date), priority: r.priority, odd: false, diff --git a/static/base.css b/static/base.css index 41e14b2..e67ada9 100644 --- a/static/base.css +++ b/static/base.css @@ -51,6 +51,13 @@ td+td { padding-left: 2ch; } +.reachable { + color: #777; +} + +.orphaned { + color: #a33; +} /* Nav bar */ @@ -115,16 +122,6 @@ nav img { column-gap: 1ch; } -.commit .reachable, -.commit .reachable a { - color: #777; -} - -.commit .orphaned, -.commit .orphaned a { - color: #a33; -} - .commit pre { margin: 1em 0ch 1em 4ch; white-space: pre-wrap; diff --git a/templates/commit_hash.html b/templates/commit_hash.html index 0689e88..1600b11 100644 --- a/templates/commit_hash.html +++ b/templates/commit_hash.html @@ -1,27 +1,8 @@ {% extends "base.html" %} +{% import "util.html" as util %} {% 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 %}

Commit

@@ -40,19 +21,23 @@ This commit can be reached from a tracked ref.
{{ commit_date }}
{% for commit in parents %} -
Parent:
-
- {{ commit.short }} +
Parent:
+
+ + {% call util::commit_short(commit.short, commit.reachable)%} +
{% endfor %} {% for commit in children %} -
Child:
-
- {{ commit.short }} +
Child:
+
+ + {% call util::commit_short(commit.short, commit.reachable)%} +
{% endfor %} -
{{ message }}
+
{{ message }}
{% endblock %} diff --git a/templates/index.html b/templates/index.html index ff2c94e..75f0891 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% import "util.html" as util %} {% block title %}overview{% endblock %} @@ -9,7 +10,11 @@
{% for ref in tracked_refs %}
{{ ref.name }}
-
{{ ref.short }}
+
+ + {% call util::commit_short(ref.short, ref.reachable) %} + +
{% endfor %}
@@ -18,7 +23,11 @@
{% for ref in untracked_refs %}
{{ ref.name }}
-
{{ ref.short }}
+
+ + {% call util::commit_short(ref.short, ref.reachable) %} + +
{% endfor %}
diff --git a/templates/queue_id.html b/templates/queue_id.html index 06cae4f..f756af5 100644 --- a/templates/queue_id.html +++ b/templates/queue_id.html @@ -1,27 +1,8 @@ {% extends "base.html" %} +{% import "util.html" as util %} {% 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 %}

Task

@@ -33,9 +14,11 @@ This commit can be reached from a tracked ref.
Priority:
{{ priority }}
-
Commit:
-
- {{ short }} +
Commit:
+
+ + {% call util::commit_short(short, reachable) %} +
diff --git a/templates/queue_table.html b/templates/queue_table.html index 54be72d..4320995 100644 --- a/templates/queue_table.html +++ b/templates/queue_table.html @@ -1,3 +1,5 @@ +{% import "util.html" as util %} + @@ -9,7 +11,11 @@ {% for task in tasks %} - + diff --git a/templates/util.html b/templates/util.html new file mode 100644 index 0000000..aa9fead --- /dev/null +++ b/templates/util.html @@ -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) -%} +{{ short }} +{%- endmacro %}
{{ task.short }} + + {% call util::commit_short(task.short, task.reachable) %} + + {{ task.since }} {{ task.priority }}