diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep each snapshot link in one piece
On a narrow screen the download column broke a snapshot name at a
hyphen or left its signature link alone on the next line. Each file and
its signature now stay together, and a line breaks only between them.
Diffstat (limited to '')
| -rw-r--r-- | assets/cgit.css | 4 | |
| -rw-r--r-- | source/ui-shared.c | 4 | |
| -rwxr-xr-x | tests/t0110-snapshot.sh | 22 |
3 files changed, 30 insertions, 0 deletions
diff --git a/assets/cgit.css b/assets/cgit.css index bb4963f..af7ea3d 100644 --- a/assets/cgit.css +++ b/assets/cgit.css @@ -1038,6 +1038,10 @@ div#cgit .oid { overflow-wrap: anywhere; } +div#cgit span.snapshot { + white-space: nowrap; +} + div#cgit .left { text-align: left; } diff --git a/source/ui-shared.c b/source/ui-shared.c index d1b9994..ff691f8 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1943,6 +1943,9 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, co continue; strbuf_setlen(&filename, prefixlen); strbuf_addstr(&filename, f->suffix); + // A file and its signature are one unit, which the stylesheet + // keeps from breaking across lines. + html("<span class='snapshot'>"); snapshot_link(filename.buf, NULL, NULL, NULL, NULL, filename.buf); if (cgit_snapshot_get_sig(ref, f)) { strbuf_addstr(&filename, ".asc"); @@ -1962,6 +1965,7 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, co snapshot_link("sig", NULL, NULL, NULL, NULL, filename.buf); html(")"); } + html("</span>"); html(separator); } strbuf_release(&filename); diff --git a/tests/t0110-snapshot.sh b/tests/t0110-snapshot.sh index c38b3c3..bec0e3d 100755 --- a/tests/t0110-snapshot.sh +++ b/tests/t0110-snapshot.sh @@ -202,4 +202,26 @@ test_expect_success 'a signature past max-blob-size is refused' ' grep "^Status: 413" tmp ' +test_expect_success 'a snapshot and its signature are linked as one unit' ' + test_create_repo repos/signed && + ( + cd repos/signed && + echo one >file && + git add file && + git commit -m one && + git tag one && + sig=$(echo signature | git hash-object -w --stdin) && + git notes --ref signatures/tar.gz add -C $sig one + ) && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "snapshots=tar.gz" && + echo "repo.url=signed" && + echo "repo.path=$PWD/repos/signed/.git" + } >signedrc && + CGIT_CONFIG="$PWD/signedrc" QUERY_STRING="url=signed/refs/" cgit >tmp && + grep "<span class=.snapshot.><a href=./signed/snapshot/signed-one.tar.gz.>signed-one.tar.gz</a> (<a href=./signed/snapshot/signed-one.tar.gz.asc.>sig</a>)</span>" tmp +' + test_done |
