From 83c1c6bedbf9d6be1c7e0220dd69844c7265f527 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 17 Jan 2021 19:27:59 +0000 Subject: Use
 and  to print diffs

This correctly preserves whitespace in browsers without CSS, as an
alternative to [1].

[1]: https://80x24.org/cgit.git/commit/?id=7c692e6137697de8a8473c4de5c3de4fb03a2989
---
 www/git.causal.agency/cgit/cgit.css  | 14 ++++----------
 www/git.causal.agency/cgit/ui-diff.c | 30 +++++++++++++++++-------------
 2 files changed, 21 insertions(+), 23 deletions(-)

(limited to 'www')

diff --git a/www/git.causal.agency/cgit/cgit.css b/www/git.causal.agency/cgit/cgit.css
index dac791b6..36826b07 100644
--- a/www/git.causal.agency/cgit/cgit.css
+++ b/www/git.causal.agency/cgit/cgit.css
@@ -533,26 +533,20 @@ div#cgit table.diff {
 	width: 100%;
 }
 
-div#cgit table.diff td {
-	font-family: monospace;
-	white-space: pre;
-}
-
-div#cgit table.diff td div.head {
+div#cgit table.diff td span.head {
 	font-weight: bold;
-	margin-top: 1em;
 	color: black;
 }
 
-div#cgit table.diff td div.hunk {
+div#cgit table.diff td span.hunk {
 	color: #009;
 }
 
-div#cgit table.diff td div.add {
+div#cgit table.diff td span.add {
 	color: green;
 }
 
-div#cgit table.diff td div.del {
+div#cgit table.diff td span.del {
 	color: red;
 }
 
diff --git a/www/git.causal.agency/cgit/ui-diff.c b/www/git.causal.agency/cgit/ui-diff.c
index 329c3506..97c1ca02 100644
--- a/www/git.causal.agency/cgit/ui-diff.c
+++ b/www/git.causal.agency/cgit/ui-diff.c
@@ -231,11 +231,11 @@ static void print_line(char *line, int len)
 	else if (line[0] == '@')
 		class = "hunk";
 
-	htmlf("
", class); + htmlf("", class); line[len-1] = '\0'; html_txt(line); - html("
"); line[len-1] = c; + html("
\n"); } static void header(const struct object_id *oid1, char *path1, int mode1, @@ -245,22 +245,23 @@ static void header(const struct object_id *oid1, char *path1, int mode1, int subproject; subproject = (S_ISGITLINK(mode1) || S_ISGITLINK(mode2)); - html("
"); + html(""); html("diff --git a/"); html_txt(path1); html(" b/"); html_txt(path2); + html("\n"); if (mode1 == 0) - htmlf("
new file mode %.6o", mode2); + htmlf("new file mode %.6o\n", mode2); if (mode2 == 0) - htmlf("
deleted file mode %.6o", mode1); + htmlf("deleted file mode %.6o\n", mode1); if (!subproject) { abbrev1 = xstrdup(find_unique_abbrev(oid1, DEFAULT_ABBREV)); abbrev2 = xstrdup(find_unique_abbrev(oid2, DEFAULT_ABBREV)); - htmlf("
index %s..%s", abbrev1, abbrev2); + htmlf("index %s..%s", abbrev1, abbrev2); free(abbrev1); free(abbrev2); if (mode1 != 0 && mode2 != 0) { @@ -268,28 +269,31 @@ static void header(const struct object_id *oid1, char *path1, int mode1, if (mode2 != mode1) htmlf("..%.6o", mode2); } + html("\n"); if (is_null_oid(oid1)) { path1 = "dev/null"; - html("
--- /"); + html("--- /"); } else - html("
--- a/"); + html("--- a/"); if (mode1 != 0) cgit_tree_link(path1, NULL, NULL, ctx.qry.head, oid_to_hex(old_rev_oid), path1); else html_txt(path1); + html("\n"); if (is_null_oid(oid2)) { path2 = "dev/null"; - html("
+++ /"); + html("+++ /"); } else - html("
+++ b/"); + html("+++ b/"); if (mode2 != 0) cgit_tree_link(path2, NULL, NULL, ctx.qry.head, oid_to_hex(new_rev_oid), path2); else html_txt(path2); + html("\n"); } - html("
"); + html(""); } static void filepair_cb(struct diff_filepair *pair) @@ -488,12 +492,12 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, html(""); } else { html("
"); - html(""); + html(""); html("
"); + html("
");
 	}
 	cgit_diff_tree(old_rev_oid, new_rev_oid, filepair_cb, prefix,
 		       ctx.qry.ignorews);
 	if (!use_ssdiff)
-		html("
"); if (show_ctrls) -- cgit 1.4.1 calico is passing us sockets it already accepted, so we don't need inet anymore. 2021-09-03OpenBSD: Drop no longer needed unveils and pledge promisesJune McEnroe 2021-09-03Reorder file loading in mainJune McEnroe 2021-09-02Be nice and call tls_close(3) on the serverJune McEnroe 2021-09-02Separate client QUIT and ERROR messagesJune McEnroe So each can be logged properly with its prefix. 2021-09-02Remove redundant clientDiff functionJune McEnroe 2021-09-02OpenBSD: pledge(2) the genCert code pathJune McEnroe 2021-09-02OpenBSD: pledge(2) the hashPass code pathJune McEnroe 2021-09-02OpenBSD: pledge(2) printCert code path separatelyJune McEnroe Ported from catgirl. 2021-09-02Call serverConfig() with NULLs for -oJune McEnroe Always use insecure, and trust, clientCert, clientPriv are irrelevant for printing the remote certificate. 2021-09-02Read from /dev/urandom instead of using getentropy(3)June McEnroe getentropy(3) is kind of an awkward function. May as well be generic as possible and read some random bytes from /dev/urandom, since for -x we don't really need to worry about being in some execution environment where that's unavailable. I'm also happy to remove that special-case include for macOS since its crypt(3) isn't even usable anyway. 2021-08-31Separate stateSync intro messagesJune McEnroe So each message can be logged with its prefix. All other calls to clientFormat and serverFormat write one message at a time. 2021-08-30Correct handling of colons in SASL PLAINJune McEnroe Only the first colon should be replaced with a null byte. 2021-08-28Declare producer staticJune McEnroe 2021-08-28Use CapBits as length of FiltersJune McEnroe This should hopefully prevent accidentally using CapSomething rather than CapSomethingBit as an index in the future. 2021-08-21Don't create new tls_server(3), just reconfigureJune McEnroe 2021-08-21Zero local-key memory before freeing itJune McEnroe 2021-08-21Avoid overwriting manual AWAY messagesJune McEnroe Setting an AWAY message then disconnecting will no longer replace the AWAY message with the default one. Reconnecting continues to always clear AWAY. 2021-08-20Replace verbose colors with two types of arrowsJune McEnroe While the colors were easy to identify in blocks, the meaning of arrows is easier to remember, and survive logs being pasted for debugging. 2021-08-20Explicitly clear TLS secrets after handshakeJune McEnroe Ported from catgirl ae64d277b8204c156a30d2e8b6a958e5a31f2a7f. 2021-08-20Handle TLS_WANT_POLL{IN,OUT} from tls_handshake(3) with serverJune McEnroe 2021-08-20Use "secure" libtls ciphersJune McEnroe Ported from catgirl: commit 585039fb6e5097cfd16bc083c6d1c9356b237882 Author: Klemens Nanni <klemens@posteo.de> Date: Sun Jun 20 14:42:10 2021 +0000 Use "secure" libtls ciphers d3e90b6 'Use libtls "compat" ciphers' from 2018 fell back to "compat" ciphers to support irc.mozilla.org which now yields NXDOMAIN. All modern networks (should) support secure ciphers, so drop the hopefully unneeded list of less secure ciphers by avoiding tls_config_set_ciphers(3) and therefore sticking to the "secure" aka. "default" set of ciphers in libtls. A quick check shows that almost all of the big/known IRC networks support TLS1.3 already; those who do not at least comply with SSL_CTX_set_cipher_list(3)'s "HIGH" set as can be tested like this: echo \ irc.hackint.org \ irc.tilde.chat \ irc.libera.chat \ irc.efnet.nl \ irc.oftc.net | xargs -tn1 \ openssl s_client -quiet -cipher HIGH -no_ign_eof -port 6697 -host 2021-07-08Use seprintf to build final 005June McEnroe Rather than causing a tls_write(3) for each remaining token. 2021-06-19Fix LDADD.crypt on DarwinJune McEnroe 2021-06-18Add -m mode option to set user modesJune McEnroe 2021-06-18Document channel keys in join optionJune McEnroe 2021-06-18Use | to separate flags from config optionsJune McEnroe This lets mandoc generate tags for the option names as well, so you can ":t away" in less(1), for example, and anchor links in HTML output. The added No's prevent the equals signs from being part of the anchor links. 2021-06-18Stop referring to server-time as IRCv3.2June McEnroe IRCv3 has moved away from grouping specs together into versions like this. SASL is still referred to as IRCv3.2 because there are two different versions of that spec. 2021-06-17Add mailing list archive to READMEJune McEnroe 2021-06-10Stop accumulating ISUPPORT tokens once MOTD startsJune McEnroe This avoids duplicating tokens when a client sends VERSION and the server responds with its 005s again. 2021-06-09Use seprintf for snip, removing strlcpynJune McEnroe 2021-06-09Use seprintf for reserializeJune McEnroe 2021-06-09Use seprintf for capListJune McEnroe 2021-06-09Add seprintfJune McEnroe Based on seprint(2) from Plan 9. I'm not sure if my return value exactly matches Plan 9's in the case of truncation. seprint(2) is described only as returning a pointer to the terminating '\0', but if it does so even in the case of truncation, it is awkward for the caller to detect. This implementation returns end in the truncation case, so that (ptr == end) indicates truncation. 2021-05-27Add pounce-notify to README 2.4June McEnroe 2021-05-27Fix ENVIRONMENT formatting in pounce-notify(1)June McEnroe 2021-05-27Add note about Libera.Chat SASL-only rangesJune McEnroe 2021-05-25Add QUIRKS fileJune McEnroe 2021-05-19Replace freenode with tilde.chatJune McEnroe 2021-05-04notify: Reword pounce-notify manualJune McEnroe 2021-05-02Clean up Makefiles, configure scriptsJune McEnroe Default MANDIR to ${PREFIX}/man since it turns out man-db includes /usr/local/man by default. Add support for BINDIR. Separate libs out into LDADD variables. 2021-04-30palaver: Exit on getopt failureJune McEnroe Oops. 2021-04-30notify: Implement pounce-notifyJune McEnroe