commit e3662697ead34d1fb3bcd51c379deea19361ac96 from: Omar Polo date: Fri Feb 03 08:51:23 2023 UTC gotwebd: fix briefs/tags navigation overlap Introduces a separate field for the "next" button (now called "More") and adjusted the CSS/HTML so it's used. Finally, drops the old code used to handle the pagination for the BRIEFS/COMMITS cases. Needs a small hack for the time being, setting the action to TAGS. This is due how qs->action is changed in gotweb.c while handling the request. ok jamsek commit - da76b65174488c46bf80a5af7896dfdc3ae60fee commit + e3662697ead34d1fb3bcd51c379deea19361ac96 blob - c8f7a859f74578199b84566a25e7a1b31a3717d9 blob + 5259d968ffb89ab3d1148ac90dc8dfffcada9857 --- gotwebd/files/htdocs/gotwebd/gotweb.css +++ gotwebd/files/htdocs/gotwebd/gotweb.css @@ -116,6 +116,10 @@ body { border-bottom: 1px dotted #444444; background-color: #f5fcfb; overflow: hidden; +} +#nav_more { + padding: 5px 0; + text-align: center; } #nav_prev { float: left; blob - e22d214bd2d3e68c26a5394cc271c0a6e204a5aa blob + 32737552a0cbb8a1adfcfa55e1c79061d1639cfc --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -418,8 +418,8 @@ got_get_repo_commits(struct request *c, int limit) */ if (chk_next && (qs->action == BRIEFS || qs->action == COMMITS || qs->action == SUMMARY)) { - t->next_id = strdup(repo_commit->commit_id); - if (t->next_id == NULL) { + t->more_id = strdup(repo_commit->commit_id); + if (t->more_id == NULL) { error = got_error_from_errno("strdup"); goto done; } blob - de3c351cbe1ced66e0a1e55b0df7afae4fe2b894 blob + 950bf547dcb54bd4de647bdc2afae1716e5ea0f3 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -782,6 +782,7 @@ gotweb_free_transport(struct transport *t) } gotweb_free_repo_dir(t->repo_dir); gotweb_free_querystring(t->qs); + free(t->more_id); free(t->next_id); free(t->prev_id); free(t); @@ -818,60 +819,6 @@ gotweb_get_navs(struct request *c, struct gotweb_url * }; } break; - case BRIEFS: - if (t->prev_id && qs->commit != NULL && - strcmp(qs->commit, t->prev_id) != 0) { - *have_prev = 1; - *prev = (struct gotweb_url){ - .action = BRIEFS, - .index_page = -1, - .page = qs->page - 1, - .path = qs->path, - .commit = t->prev_id, - .headref = qs->headref, - }; - } - if (t->next_id) { - *have_next = 1; - *next = (struct gotweb_url){ - .action = BRIEFS, - .index_page = -1, - .page = qs->page + 1, - .path = qs->path, - .commit = t->next_id, - .headref = qs->headref, - }; - } - break; - case COMMITS: - if (t->prev_id && qs->commit != NULL && - strcmp(qs->commit, t->prev_id) != 0) { - *have_prev = 1; - *prev = (struct gotweb_url){ - .action = COMMITS, - .index_page = -1, - .page = qs->page - 1, - .path = qs->path, - .commit = t->prev_id, - .headref = qs->headref, - .folder = qs->folder, - .file = qs->file, - }; - } - if (t->next_id) { - *have_next = 1; - *next = (struct gotweb_url){ - .action = COMMITS, - .index_page = -1, - .page = qs->page + 1, - .path = qs->path, - .commit = t->next_id, - .headref = qs->headref, - .folder = qs->folder, - .file = qs->file, - }; - } - break; case TAGS: if (t->prev_id && qs->commit != NULL && strcmp(qs->commit, t->prev_id) != 0) { blob - b84fe9526fa6e65fe446b6bdf8b85d2b63e73233 blob + 98e9f879c0f9fc272de90ddc649d0c9aa2d88875 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -189,6 +189,7 @@ struct transport { struct got_repository *repo; struct repo_dir *repo_dir; struct querystring *qs; + char *more_id; char *next_id; char *prev_id; unsigned int repos_total; blob - bd93fb21ec16695dbf29784ea4a8d2de3efdecac blob + 5683aa67e1614920350a5f6e25a4428aec463781 --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -42,6 +42,8 @@ static int gotweb_render_blob_line(struct template *, static int gotweb_render_tree_item(struct template *, struct got_tree_entry *); static int blame_line(struct template *, const char *, struct blame_line *, int, int); + +static inline int gotweb_render_more(struct template *, int); static inline int diff_line(struct template *, char *); static inline int tag_item(struct template *, struct repo_tag *); @@ -304,12 +306,34 @@ static inline int rss_author(struct template *, char *
{{ end }} - {{ if t->next_id || t->prev_id }} - {{ render gotweb_render_navs(tp) }} - {{ end }} + {{ render gotweb_render_more(tp, BRIEFS) }} {{ end }} +{{ define gotweb_render_more(struct template *tp, int action) }} +{! + struct request *c = tp->tp_arg; + struct transport *t = c->t; + struct querystring *qs = t->qs; + struct gotweb_url more = { + .action = action, + .index_page = -1, + .path = qs->path, + .commit = t->more_id, + .headref = qs->headref, + }; +!} + {{ if t->more_id }} +
+ +
+ {{ end }} +{{ end }} + {{ define gotweb_render_navs(struct template *tp) }} {! struct request *c = tp->tp_arg; @@ -404,9 +428,7 @@ static inline int rss_author(struct template *, char *
{{ end }} - {{ if t->next_id || t->prev_id }} - {{ render gotweb_render_navs(tp) }} - {{ end }} + {{ render gotweb_render_more(tp, COMMITS) }} {{ end }} @@ -590,6 +612,7 @@ static inline int rss_author(struct template *, char * {{ end }} {{ end }} {{ if t->next_id || t->prev_id }} + {! qs->action = TAGS; !} {{ render gotweb_render_navs(tp) }} {{ end }} {{ end }}