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