commit 20bab626cf257964f66b059b436e4ce472971531 from: Omar Polo via: Thomas Adam date: Fri Feb 03 15:22:14 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 - d4628c48f397550f23bd780ae898625aacda2555 commit + 20bab626cf257964f66b059b436e4ce472971531 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 - 8110a126b6938540cfb09ea2d3ba8e7796fa9234 blob + 0b590b2ed3ab03fcf4861934072cbea80aedea25 --- 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 - fa82549de267b5966a36535f77026131c65ad216 blob + 761975ce8a9b4b3f7a1c3bf5726bd2248bdd9296 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -783,6 +783,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); @@ -819,60 +820,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 - 5feba0db0d8be996bd0d6f2896886ec579598d19 blob + 53749ebdda49e3367abdc4bd1723ef3b976c75ea --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -191,6 +191,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 - 96d1039d6fa50bb6df8ad6e766bb7edb55b5ff13 blob + 09489b1446ca8832ae2abb2b3f5e0e1290986530 --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -41,6 +41,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 *); @@ -303,12 +305,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; @@ -403,9 +427,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 }} @@ -589,6 +611,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 }}