commit - 60c140aebbd1069094e75d8358cb305bc305b7f8
commit + 067396e6118227d9aa15a49c7d49238c0fff8d94
blob - a8fdd952ec48f1a229440e115de67205cf20f049
blob + b0073bd432cd5dcf72ae7f82e1d97d8ae4f6a8f0
--- 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 - e633c57fe7cd48fed7a5ed3beb070b4acddc97c9
blob + 82411f713d7bde00ef0d95f07bf0b914771735ed
--- 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 - 4990d4532fe8a87678d718337343c8101501b84d
blob + 8bf0a13026da2c453ceba474ad9e4fd12b90c713
--- 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;