Show all refs on index page
This commit is contained in:
parent
f080b0fe4c
commit
72f762464d
4 changed files with 69 additions and 29 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT name, hash, message FROM refs JOIN commits USING (hash) WHERE tracked ",
|
||||
"query": "SELECT name, hash, tracked, message FROM refs JOIN commits USING (hash) ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -14,8 +14,13 @@
|
|||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"name": "tracked",
|
||||
"ordinal": 2,
|
||||
"type_info": "Int64"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"ordinal": 3,
|
||||
"type_info": "Text"
|
||||
}
|
||||
],
|
||||
|
|
@ -23,10 +28,11 @@
|
|||
"Right": 0
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "0ac905715f402ec22f28dad89ba60f21644418d1f483aecbcd425a0b69c16bb3"
|
||||
"hash": "1e09e422a6fd826b7dfdaf52a271e77672c4dbc933af42a59fd8a8459e495732"
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ use crate::{config::Config, db, somehow};
|
|||
struct Ref {
|
||||
name: String,
|
||||
hash: String,
|
||||
tracked: bool,
|
||||
short: String,
|
||||
}
|
||||
|
||||
|
|
@ -17,18 +18,17 @@ struct IndexTemplate {
|
|||
base: String,
|
||||
repo_name: String,
|
||||
current: String,
|
||||
tracked_refs: Vec<Ref>,
|
||||
refs: Vec<Ref>,
|
||||
}
|
||||
|
||||
pub async fn get(
|
||||
State(config): State<&'static Config>,
|
||||
State(db): State<SqlitePool>,
|
||||
) -> somehow::Result<impl IntoResponse> {
|
||||
let tracked_refs = sqlx::query!(
|
||||
let refs = sqlx::query!(
|
||||
"\
|
||||
SELECT name, hash, message FROM refs \
|
||||
SELECT name, hash, tracked, message FROM refs \
|
||||
JOIN commits USING (hash) \
|
||||
WHERE tracked \
|
||||
"
|
||||
)
|
||||
.fetch(&db)
|
||||
|
|
@ -36,6 +36,7 @@ pub async fn get(
|
|||
name: r.name,
|
||||
short: db::format_commit_short(&r.hash, &r.message),
|
||||
hash: r.hash,
|
||||
tracked: r.tracked != 0,
|
||||
})
|
||||
.try_collect::<Vec<_>>()
|
||||
.await?;
|
||||
|
|
@ -44,6 +45,6 @@ pub async fn get(
|
|||
base: config.web.base(),
|
||||
repo_name: config.repo.name(),
|
||||
current: "index".to_string(),
|
||||
tracked_refs,
|
||||
refs,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,37 @@
|
|||
color-scheme: light dark;
|
||||
}
|
||||
|
||||
/* General */
|
||||
|
||||
details,
|
||||
dl {
|
||||
margin: var(--lh) 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-left: 4ch;
|
||||
}
|
||||
|
||||
details {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
details>* {
|
||||
margin-left: 4ch;
|
||||
}
|
||||
|
||||
details>summary {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
/* Nav bar */
|
||||
|
||||
nav {
|
||||
|
|
@ -46,20 +77,6 @@ nav img {
|
|||
vertical-align: -20%;
|
||||
}
|
||||
|
||||
/* General */
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-left: 4ch;
|
||||
}
|
||||
|
||||
/* Commit */
|
||||
|
||||
.commit * {
|
||||
|
|
|
|||
|
|
@ -3,11 +3,27 @@
|
|||
{% block title %}overview{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h2>Tracked refs</h2>
|
||||
<dl>
|
||||
{% for ref in tracked_refs %}
|
||||
<dt>{{ ref.name }}</dt>
|
||||
<dd><a href="{{ base }}/commit/{{ ref.hash }}">{{ ref.short }}</a></dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
<h2>Refs</h2>
|
||||
<details>
|
||||
<summary>Tracked</summary>
|
||||
<dl>
|
||||
{% for ref in refs %}
|
||||
{% if ref.tracked %}
|
||||
<dt>{{ ref.name }}</dt>
|
||||
<dd><a href="{{ base }}/commit/{{ ref.hash }}">{{ ref.short }}</a></dd>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</dl>
|
||||
</details>
|
||||
<details>
|
||||
<summary>Untracked</summary>
|
||||
<dl>
|
||||
{% for ref in refs %}
|
||||
{% if !ref.tracked %}
|
||||
<dt>{{ ref.name }}</dt>
|
||||
<dd><a href="{{ base }}/commit/{{ ref.hash }}">{{ ref.short }}</a></dd>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</dl>
|
||||
</details>
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue