commit 6e7d5e742fc400b2e52525cfeb475b7326a52485 from: Omar Polo via: Thomas Adam date: Fri Dec 08 12:30:59 2023 UTC gotwebd: dedup the bulk of the tree listing code commit - b58a46769ec24ecc91246a4846d87b4bf57cc2dc commit + 6e7d5e742fc400b2e52525cfeb475b7326a52485 blob - 756d29f0c6107f6975112ba33cbd7f812c38c261 blob + 66fc2ec246ed0902a2966cc268ca02e2e4376dbe --- 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; !}