commit - ebe6ec920b98ddf1b63687d78857f37af34b691f
commit + 617497a67c0b438c75afefd4fd599a8f88c32bcd
blob - ed309bdb7eafa2433c8ac9cc34326e71ceb50c80
blob + 0b1abd81d62518e120ff27f91b622b4d30edf168
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
gotweb_render_tags(struct request *c)
{
const struct got_error *error = NULL;
- struct repo_tag *rt = NULL;
struct server *srv = c->srv;
struct transport *t = c->t;
struct querystring *qs = t->qs;
- struct repo_dir *repo_dir = t->repo_dir;
- char *age = NULL, *tagname = NULL, *msg = NULL, *newline;
- int r, commit_found = 0;
if (qs->action == BRIEFS) {
qs->action = TAGS;
if (error)
goto done;
- r = fcgi_printf(c, "<div id='tags_title_wrapper'>\n"
- "<div id='tags_title'>Tags</div>\n"
- "</div>\n" /* #tags_title_wrapper */
- "<div id='tags_content'>\n");
- if (r == -1)
+ if (gotweb_render_tags_tmpl(c->tp) == -1)
goto done;
-
- if (t->tag_count == 0) {
- r = fcgi_printf(c, "<div id='err_content'>%s\n</div>\n",
- "This repository contains no tags");
- if (r == -1)
- goto done;
- }
-
- TAILQ_FOREACH(rt, &t->repo_tags, entry) {
- if (commit_found == 0 && qs->commit != NULL) {
- if (strcmp(qs->commit, rt->commit_id) != 0)
- continue;
- else
- commit_found = 1;
- }
- error = gotweb_get_time_str(&age, rt->tagger_time, TM_DIFF);
- if (error)
- goto done;
-
- tagname = rt->tag_name;
- if (strncmp(tagname, "refs/tags/", 10) == 0)
- tagname += 10;
- error = gotweb_escape_html(&tagname, tagname);
- if (error)
- goto done;
-
- if (rt->tag_commit != NULL) {
- newline = strchr(rt->tag_commit, '\n');
- if (newline)
- *newline = '\0';
- error = gotweb_escape_html(&msg, rt->tag_commit);
- if (error)
- goto done;
- }
-
- if (fcgi_printf(c, "<div class='tag_age'>%s</div>\n"
- "<div class='tag'>%s</div>\n"
- "<div class='tag_log'>", age, tagname) == -1)
- goto done;
-
- r = gotweb_link(c, &(struct gotweb_url){
- .action = TAG,
- .index_page = -1,
- .page = -1,
- .path = repo_dir->name,
- .commit = rt->commit_id,
- }, "%s", msg ? msg : "");
- if (r == -1)
- goto done;
-
- if (fcgi_printf(c, "</div>\n" /* .tag_log */
- "<div class='navs_wrapper'>\n"
- "<div class='navs'>") == -1)
- goto done;
-
- r = gotweb_link(c, &(struct gotweb_url){
- .action = TAG,
- .index_page = -1,
- .page = -1,
- .path = repo_dir->name,
- .commit = rt->commit_id,
- }, "tag");
- if (r == -1)
- goto done;
-
- if (fcgi_printf(c, " | ") == -1)
- goto done;
-
- r = gotweb_link(c, &(struct gotweb_url){
- .action = BRIEFS,
- .index_page = -1,
- .page = -1,
- .path = repo_dir->name,
- .commit = rt->commit_id,
- }, "commit briefs");
- if (r == -1)
- goto done;
-
- if (fcgi_printf(c, " | ") == -1)
- goto done;
-
- r = gotweb_link(c, &(struct gotweb_url){
- .action = COMMITS,
- .index_page = -1,
- .page = -1,
- .path = repo_dir->name,
- .commit = rt->commit_id,
- }, "commits");
- if (r == -1)
- goto done;
- r = fcgi_printf(c,
- "</div>\n" /* .navs */
- "</div>\n" /* .navs_wrapper */
- "<div class='dotted_line'></div>\n");
- if (r == -1)
- goto done;
-
- free(age);
- age = NULL;
- free(tagname);
- tagname = NULL;
- free(msg);
- msg = NULL;
- }
- if (t->next_id || t->prev_id) {
- if (gotweb_render_navs(c->tp) == -1)
- goto done;
- }
- fcgi_printf(c, "</div>\n"); /* #tags_content */
done:
- free(age);
- free(tagname);
- free(msg);
return error;
}
blob - b3f1e23a856b74f0e7fa42acdbab7498cfd2e4b8
blob + 9b3c0f6a5f288391333fc845d5c6aaa3a7dbc34d
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
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_rss(struct template *);
/* parse.y */
blob - 8a0f3a6a63e803f10ad778864e6fadb30cfb618a
blob + ae744ae1953c7666bc7ab0d79a6bf1846a89e58f
--- gotwebd/pages.tmpl
+++ gotwebd/pages.tmpl
static int gotweb_render_blob_line(struct template *, const char *, size_t);
static int gotweb_render_tree_item(struct template *, struct got_tree_entry *);
+static inline int tag_item(struct template *, struct repo_tag *);
static inline int rss_tag_item(struct template *, struct repo_tag *);
static inline int rss_author(struct template *, char *);
{{ finally }}
{!
free(dir);
+!}
+{{ end }}
+
+{{ define gotweb_render_tags_tmpl(struct template *tp) }}
+{!
+ struct request *c = tp->tp_arg;
+ struct transport *t = c->t;
+ struct querystring *qs = t->qs;
+ struct repo_tag *rt;
+ int commit_found;
+
+ commit_found = qs->commit == NULL;
!}
+<div id="tags_title_wrapper">
+ <div id="tags_title">Tags</div>
+</div>
+<div id="tags_content">
+ {{ if t->tag_count == 0 }}
+ <div id="err_content">
+ This repository contains no tags
+ </div>
+ {{ else }}
+ {{ tailq-foreach rt &t->repo_tags entry }}
+ {{ if commit_found || !strcmp(qs->commit, rt->commit_id) }}
+ {! commit_found = 1; !}
+ {{ render tag_item(tp, rt) }}
+ {{ end }}
+ {{ end }}
+ {{ if t->next_id || t->prev_id }}
+ {{ render gotweb_render_navs(tp) }}
+ {{ end }}
+ {{ end }}
+</div>
{{ end }}
+{{ define tag_item(struct template *tp, struct repo_tag *rt) }}
+{!
+ struct request *c = tp->tp_arg;
+ struct transport *t = c->t;
+ struct repo_dir *repo_dir = t->repo_dir;
+ char *tag_name = rt->tag_name;
+ char *msg = rt->tag_commit;
+ char *nl;
+ struct gotweb_url url = {
+ .action = TAG,
+ .index_page = -1,
+ .page = -1,
+ .path = repo_dir->name,
+ .commit = rt->commit_id,
+ };
+
+ if (strncmp(tag_name, "refs/tags/", 10) == 0)
+ tag_name += 10;
+
+ if (msg) {
+ nl = strchr(msg, '\n');
+ if (nl)
+ *nl = '\0';
+ }
+!}
+<div class="tag_age">
+ {{ render gotweb_render_age(tp, rt->tagger_time, TM_DIFF) }}
+</div>
+<div class="tag">{{ tag_name }}</div>
+<div class="tag_log">
+ <a href="{{ render gotweb_render_url(c, &url) }}">
+ {{ msg }}
+ </a>
+</div>
+<div class="navs_wrapper">
+ <div class="navs">
+ <a href="{{ render gotweb_render_url(c, &url) }}">tag</a>
+ {{ " | " }}
+ {! url.action = BRIEFS; !}
+ <a href="{{ render gotweb_render_url(c, &url) }}">commit briefs</a>
+ {{ " | " }}
+ {! url.action = COMMITS; !}
+ <a href="{{ render gotweb_render_url(c, &url) }}">commits</a>
+ </div>
+</div>
+<div class="dotted_line"></div>
+{{ end }}
+
{{ define gotweb_render_rss(struct template *tp) }}
{!
struct request *c = tp->tp_arg;