commit dc07f76c4f8d4418ce30fd4eb087756fe9fb6ded from: Omar Polo date: Mon Jan 09 17:42:20 2023 UTC gotwebd: templateify gotweb_render_tag ok tracey@ commit - 067396e6118227d9aa15a49c7d49238c0fff8d94 commit + dc07f76c4f8d4418ce30fd4eb087756fe9fb6ded blob - b0073bd432cd5dcf72ae7f82e1d97d8ae4f6a8f0 blob + 309aef401c71adbc97aca9f379c2f05fb4470122 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -96,7 +96,6 @@ static const struct got_error *gotweb_get_clone_url(ch static const struct got_error *gotweb_render_blame(struct request *); static const struct got_error *gotweb_render_diff(struct request *); static const struct got_error *gotweb_render_summary(struct request *); -static const struct got_error *gotweb_render_tag(struct request *); static const struct got_error *gotweb_render_tags(struct request *); static const struct got_error *gotweb_render_branches(struct request *); @@ -291,11 +290,18 @@ render: } break; case TAG: - error = gotweb_render_tag(c); + error = got_get_repo_tags(c, 1); if (error) { log_warnx("%s: %s", __func__, error->msg); + goto err; + } + if (c->t->tag_count == 0) { + error = got_error_msg(GOT_ERR_BAD_OBJ_ID, + "bad commit id"); goto err; } + if (gotweb_render_tag(c->tp) == -1) + goto done; break; case TAGS: error = gotweb_render_tags(c); @@ -1257,77 +1263,6 @@ done: } static const struct got_error * -gotweb_render_tag(struct request *c) -{ - const struct got_error *error = NULL; - struct repo_tag *rt = NULL; - struct transport *t = c->t; - char *tagname = NULL, *age = NULL, *author = NULL, *msg = NULL; - - error = got_get_repo_tags(c, 1); - if (error) - goto done; - - if (t->tag_count == 0) { - error = got_error_set_errno(GOT_ERR_BAD_OBJ_ID, - "bad commit id"); - goto done; - } - - rt = TAILQ_LAST(&t->repo_tags, repo_tags_head); - - error = gotweb_get_time_str(&age, rt->tagger_time, TM_LONG); - if (error) - goto done; - error = gotweb_escape_html(&author, rt->tagger); - if (error) - goto done; - error = gotweb_escape_html(&msg, rt->commit_msg); - if (error) - goto done; - - tagname = rt->tag_name; - if (strncmp(tagname, "refs/", 5) == 0) - tagname += 5; - error = gotweb_escape_html(&tagname, tagname); - if (error) - goto done; - - fcgi_printf(c, "
\n" - "
Tag
\n" - "
\n" /* #tags_title_wrapper */ - "
\n" - "
\n" - "
\n" - "
Commit:
\n" - "
%s" - " (%s)
\n" - "
Tagger:
\n" - "
%s
\n" - "
Date:
\n" - "
%s
\n" - "
Message:
\n" - "
%s
\n" - "
\n" /* #tag_header */ - "
\n" - "
\n%s
" - "
" /* #tag_header_wrapper */ - "
", /* #tags_content */ - rt->commit_id, - tagname, - author, - age, - msg, - rt->tag_commit); - -done: - free(age); - free(author); - free(msg); - return error; -} - -static const struct got_error * gotweb_render_tags(struct request *c) { const struct got_error *error = NULL; blob - 82411f713d7bde00ef0d95f07bf0b914771735ed blob + ebc2cd4755644f05a3fdaeaf2fe96f60466272ce --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -470,6 +470,7 @@ int gotweb_render_commits(struct template *); int gotweb_render_blob(struct template *, struct got_blob_object *); int gotweb_render_tree(struct template *); int gotweb_render_tags_tmpl(struct template *); +int gotweb_render_tag(struct template *); int gotweb_render_rss(struct template *); /* parse.y */ blob - 8bf0a13026da2c453ceba474ad9e4fd12b90c713 blob + c86368b829792b47babd7f6fcae03da0daa1a225 --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -648,7 +648,50 @@ gotweb_render_age(struct template *tp, time_t time, in
{{ end }} + +{{ define gotweb_render_tag(struct template *tp) }} +{! + struct request *c = tp->tp_arg; + struct transport *t = c->t; + struct repo_tag *rt; + const char *tag_name; + rt = TAILQ_LAST(&t->repo_tags, repo_tags_head); + tag_name = rt->tag_name; + + if (strncmp(tag_name, "refs/", 5) == 0) + tag_name += 5; +!} +
+
Tag
+
+
+
+
+
Commit:
+
+ {{ rt->commit_id }} + {{ " " }} + ({{ tag_name }}) +
+
Tagger:
+
{{ rt->tagger }}
+
Date:
+
+ {{ render gotweb_render_age(tp, rt->tagger_time, TM_LONG)}} +
+
Message:
+
{{ rt->commit_msg }}
+
+
+
+ {{ "\n" }} + {{ rt->tag_commit }} +
+
+
+{{ end }} + {{ define gotweb_render_rss(struct template *tp) }} {! struct request *c = tp->tp_arg;