From: Omar Polo Subject: gotwebd: add links for actions in the blob page To: gameoftrees@openbsd.org Date: Thu, 30 Nov 2023 19:32:59 +0100 This adds the "history", "blame" and "raw file" links to the blob page. You can see them in action for example here: https://got.omarpolo.com/?action=blob&commit=6595d7300a0803b0372c4bae0ee3a077e4739f59&file=Makefile&folder=&path=got.git To be fair, I don't really like adding the "Action" line to the header, but I didn't had a better idea where to put it, and these links are useful to have. regarding the diff, the potentially scary {{ " — " | unsafe }} is actually safe ;-) template(1) implicitly removes the leading spaces, so having just — on a line would put it attached the links, hence I have a few {{" "}} around to make sure there are spaces. | unsafe is to disable the html escape that {{ ... }} would otherwise do. Overall, it's equivalent to {{" "}}—{{" "}} only maybe less awkward to read? (I still think that trimming whitespaces wasn't a bad idea overall, however it has its shortcomings.) Suggestions / Comments / OK? diff /home/op/w/got commit - 446026cb9332485a4c570afd42fb493d451f7251 path + /home/op/w/got blob - 05d50fd5f99362148873de51d2893430d624d249 file + gotwebd/pages.tmpl --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -541,8 +541,25 @@ nextsep(char *s, char **t) {! struct request *c = tp->tp_arg; struct transport *t = c->t; + struct querystring *qs = t->qs; struct got_blob_object *blob = t->blob; struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits); + struct gotweb_url briefs_url, blame_url, raw_url; + + memset(&briefs_url, 0, sizeof(briefs_url)); + briefs_url.index_page = -1, + briefs_url.page = -1, + briefs_url.action = BRIEFS, + briefs_url.path = qs->path, + briefs_url.commit = qs->commit, + briefs_url.folder = qs->folder, + briefs_url.file = qs->file, + + memcpy(&blame_url, &briefs_url, sizeof(blame_url)); + blame_url.action = BLAME; + + memcpy(&raw_url, &briefs_url, sizeof(raw_url)); + raw_url.action = BLOBRAW; !}

Blob

@@ -556,6 +573,20 @@ nextsep(char *s, char **t)
Message:
{{ rc->commit_msg }}
+
Actions:
+
+ + History + + {{ " — " | unsafe }} + + Blame + + {{ " — " | unsafe }} + + Raw File + +