commit 8957da7c28eda864d43699ccb657c9b48278d7c4 from: Omar Polo date: Fri Dec 08 10:42:50 2023 UTC gotwebd: dedup the bulk of the tree listing code commit - f6c7567b8a08e575b7caa23fcea4f93569553835 commit + 8957da7c28eda864d43699ccb657c9b48278d7c4 blob - 885a22e5fd3853508cf60ca2c14474a54087fb75 blob + 99a7c70488d6b2491287f77419bd029e71eaf201 --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -51,6 +51,7 @@ static int blame_line(struct template *, const char *, static inline int gotweb_render_more(struct template *, int); +static inline int tree_listing(struct template *); static inline int diff_line(struct template *, char *); static inline int tag_item(struct template *, struct repo_tag *); static inline int branch(struct template *, struct got_reflist_entry *); @@ -641,36 +642,18 @@ nextsep(char *s, char **t) {{ end }} -{{ define gotweb_render_tree(struct template *tp) }} +{{ define tree_listing(struct template *tp) }} {! const struct got_error *error; struct request *c = tp->tp_arg; struct transport *t = c->t; - struct querystring *qs = t->qs; - struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits); + struct querystring *qs = c->t->qs; struct gotweb_url url; char *readme = NULL; int binary; const uint8_t *buf; size_t len; !} -
-

Tree

-
-
- -
{{ render got_output_repo_tree(c, &readme, gotweb_render_tree_item) }}
@@ -718,9 +701,35 @@ nextsep(char *s, char **t) {{ end }} {{ end }} -
{{ finally }} -{! free(readme); !} + {! free(readme); !} +{{ end }} + +{{ define gotweb_render_tree(struct template *tp) }} +{! + struct request *c = tp->tp_arg; + struct transport *t = c->t; + struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits); +!} +
+

Tree

+
+
+ +
+ {{ render tree_listing(tp) }} +
{{ end }} {{ define gotweb_render_tree_item(struct template *tp, @@ -1084,16 +1093,10 @@ nextsep(char *s, char **t) {{ define gotweb_render_summary(struct template *tp) }} {! - const struct got_error *error; struct request *c = tp->tp_arg; struct server *srv = c->srv; struct transport *t = c->t; struct got_reflist_head *refs = &t->refs; - struct gotweb_url url; - char *readme = NULL; - int binary; - const uint8_t *buf; - size_t len; !}