mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit 8bcf823b667010195c71d729da44801e823bd7c3
parent e4db0cff90509105822c3a52df56e0b57c801dca
Author: Johann150 <johann@qwertqwefsday.eu>
Date:   Thu, 18 Mar 2021 23:13:35 +0100

improve file output on page

Do not render a space as that would be included when copying.
Use a CSS margin instead. Also replace the spaces in the line number by
styling the line number with CSS.

Diffstat:
Msrc/main.rs | 4++--
Mtemplates/static/style.css | 13+++++++------
2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -393,8 +393,8 @@ async fn repo_file(req: Request<()>) -> tide::Result { for (n, line) in syntect::util::LinesWithEndings::from(file_string).enumerate() { let regions = highlighter.highlight(line, &syntax_set); output.push_str(&format!( - "<a href='#L{0}' id='L{0}' class='line'>{0:>6}</a>&nbsp;", - n + "<a href='#L{0}' id='L{0}' class='line'>{0}</a>", + n + 1 )); syntect::html::append_highlighted_html_for_styled_line( &regions[..], diff --git a/templates/static/style.css b/templates/static/style.css @@ -27,13 +27,17 @@ body { } .line { + display: inline-block; + width: 6em; + margin-right: .5em; + text-align: right; text-decoration: none; -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Safari */ -khtml-user-select: none; /* Konqueror HTML */ -moz-user-select: none; /* Old versions of Firefox */ -ms-user-select: none; /* Internet Explorer/Edge */ - user-select: none; /* Non-prefixed version, currently + user-select: none; /* Non-prefixed version, currently */ } .clone-url { @@ -49,10 +53,7 @@ hr.thin { border-bottom: 1px solid rgba(255, 255, 255, 0.3); } -h1 { - margin: 0px; -} -h2 { +h1, h2 { margin: 0px; } @@ -76,7 +77,7 @@ td { table td { padding: 0 0.1em; - } +} table.core { width: 100%;