diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Check every markup hook the README names
The README promised that t0005 checked them all, while fourteen went
unchecked, and three of its claims were too broad. A date shown in
full carries no age hooks, line anchors follow enable-tree-linenumbers
and cgit.css also styles html.cgit-standalone.
| -rw-r--r-- | README.txt | 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0005-markup.sh | 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 84 insertions, 8 deletions
@@ -88,11 +88,14 @@ script added through the css and js options has stable hooks to work with. table.commit-trailers, the diffstat is table.diffstat and each file of a diff is div.file, or tbody.file in the side by side view, with the path in data-path. The blob and blame pages open with div.blob-header. -* Ages are time elements with an age-* class and the timestamp in data-ut. Line - numbers are anchors named n followed by the line. +* Relative ages are time elements with an age-* class and the timestamp in + data-ut, while a date shown in full is a plain time element. Line numbers are + anchors named n followed by the line, while enable-tree-linenumbers is on. * Colours, fonts and metrics are custom properties on div#cgit, so a theme can - redefine those alone. Every rule in cgit.css starts with div#cgit, and a rule - of your own needs the same prefix to win. + redefine those alone. Every rule in cgit.css starts with div#cgit, apart from + the background and margins it sets on html.cgit-standalone, the class of the + document cgit writes when it is not embedded. A rule of your own needs the + div#cgit prefix to win. * The script exposes window.cgit.updateAges and window.cgit.highlightLines for a page that changes the rows or the lines after load. @@ -192,10 +195,10 @@ feed rather than a page and accepts h, path and all. The clone endpoints under info and objects implement the dumb HTTP protocol and are only present when http clone is enabled. -A url fragment can address lines inside a file. The tree and blame pages give -every line an anchor named n followed by its number, so #n17 jumps to line 17 -and highlights it, and a range written #n17-n24 highlights the whole run and -scrolls it into view. +A url fragment can address lines inside a file. While enable-tree-linenumbers is +on, as it is by default, the tree and blame pages give every line an anchor +named n followed by its number, so #n17 jumps to line 17 and highlights it, and +a range written #n17-n24 highlights the whole run and scrolls it into view. Some worked examples, in the url= form. diff --git a/tests/t0005-markup.sh b/tests/t0005-markup.sh index 2a8d572..bbf78b1 100755 --- a/tests/t0005-markup.sh +++ b/tests/t0005-markup.sh @@ -96,4 +96,77 @@ test_expect_success 'the stylesheet and the script name only the current hooks' grep "window.cgit.highlightLines" "$TEST_OUTPUT_DIRECTORY/../assets/cgit.js" ' +# The rest of the hooks need a tag, a symlink, a submodule, a trailer, clone +# urls and a second page of repositories, so they get a commit and a config +# of their own after the checks above have read the first ones. +test_expect_success 'set up the remaining kinds of entry' ' + ( + cd repos/hooks && + git tag -a -m "first release" v1 && + test_ln_s_add file-1 link && + git update-index --add --cacheinfo "160000,$(git rev-parse HEAD),sub" && + git commit -m "more kinds of entry" -m "Fixes: $(git rev-parse --short HEAD)" + ) && + { + echo "virtual-root=/" && + echo "cache-size=0" && + echo "enable-commit-trailers=1" && + echo "max-repo-count=1" && + echo "clone-url=https://example.com/clone.git" && + echo "repo.url=hooks" && + echo "repo.path=$PWD/repos/hooks/.git" && + echo "repo.url=again" && + echo "repo.path=$PWD/repos/hooks/.git" + } >morerc +' + +more() { CGIT_CONFIG="$PWD/morerc" QUERY_STRING="url=$1" cgit; } + +test_expect_success 'the refs, summary and tree name every section and row' ' + more "hooks/refs/" >tmp && + grep "<table class=.list refs. aria-label=.Branches and tags.>" tmp && + grep "<tbody class=.tags.>" tmp && + grep "<tr class=.tag.>" tmp && + more "hooks/" >tmp && + grep "<tbody class=.clone.>" tmp && + more "hooks/tree/" >tmp && + grep "<tbody class=.tree.>" tmp && + grep "<tr class=.link.>" tmp && + grep "<tr class=.mod.>" tmp +' + +test_expect_success 'the commit page has its trailer table and diffstat' ' + more "hooks/commit/" >tmp && + grep "<table class=.commit-trailers.>" tmp && + grep "<table class=.diffstat.>" tmp +' + +test_expect_success 'the breadcrumb, the pager and the ages carry their hooks' ' + more "hooks/tree/dir/" >tmp && + grep "<nav class=.path. aria-label=.breadcrumb.>" tmp && + more "" >tmp && + grep "<nav class=.pager. aria-label=.Pager.>" tmp && + grep "class=.current. aria-current=.page." tmp && + grep "<time class=.age-[a-z]*. datetime=.[^ ]* data-ut=.[0-9]*." tmp +' + +test_expect_success 'a date shown in full is a plain time element' ' + { + echo "enable-relative-dates=0" && + cat morerc + } >fullrc && + CGIT_CONFIG="$PWD/fullrc" QUERY_STRING="url=" cgit >tmp && + grep "<time datetime=" tmp && + ! grep "data-ut=" tmp +' + +test_expect_success 'embedded mode marks the root' ' + { + echo "embedded=1" && + cat hooksrc + } >embeddedrc && + CGIT_CONFIG="$PWD/embeddedrc" QUERY_STRING="url=hooks/" cgit >tmp && + grep "<div id=.cgit. class=.cgit-embedded. data-page=.summary." tmp +' + test_done |
