commit - 92a569072371e5e179a2b20bf0b80990f42f4038
commit + 00abe30b6011e389018622a47995f9390b166182
blob - 0aaee33b34d4307c8d7df683a17c20a159cc2b57
blob + ecb30578057b82335c755ebafb9d9c1fdd24cf97
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
static const struct got_error *gotweb_render_blame(struct request *);
static const struct got_error *gotweb_render_summary(struct request *);
static const struct got_error *gotweb_render_tags(struct request *);
-static const struct got_error *gotweb_render_branches(struct request *);
static void gotweb_free_querystring(struct querystring *);
static void gotweb_free_repo_dir(struct repo_dir *);
}
static const struct got_error *
-gotweb_render_branches(struct request *c)
+gotweb_render_summary(struct request *c)
{
const struct got_error *error = NULL;
struct got_reflist_head refs;
- struct got_reflist_entry *re;
struct transport *t = c->t;
- struct querystring *qs = t->qs;
- struct got_repository *repo = t->repo;
- char *escaped_refname = NULL;
- char *age = NULL;
+ struct got_repository *repo = t->repo;
+ struct server *srv = c->srv;
int r;
TAILQ_INIT(&refs);
got_ref_cmp_by_name, NULL);
if (error)
goto done;
-
- r = fcgi_printf(c, "<div id='branches_title_wrapper'>\n"
- "<div id='branches_title'>Branches</div>\n"
- "</div>\n" /* #branches_title_wrapper */
- "<div id='branches_content'>\n");
- if (r == -1)
- goto done;
-
- TAILQ_FOREACH(re, &refs, entry) {
- const char *refname = NULL;
-
- if (got_ref_is_symbolic(re->ref))
- continue;
-
- refname = got_ref_get_name(re->ref);
- if (refname == NULL) {
- error = got_error_from_errno("strdup");
- goto done;
- }
- if (strncmp(refname, "refs/heads/", 11) != 0)
- continue;
-
- error = got_get_repo_age(&age, c, refname, TM_DIFF);
- if (error)
- goto done;
-
- if (strncmp(refname, "refs/heads/", 11) == 0)
- refname += 11;
- error = gotweb_escape_html(&escaped_refname, refname);
- if (error)
- goto done;
-
- r = fcgi_printf(c, "<div class='branches_wrapper'>\n"
- "<div class='branches_age'>%s</div>\n"
- "<div class='branches_space'> </div>\n"
- "<div class='branch'>", age);
- if (r == -1)
- goto done;
-
- r = gotweb_link(c, &(struct gotweb_url){
- .action = SUMMARY,
- .index_page = -1,
- .page = -1,
- .path = qs->path,
- .headref = refname,
- }, "%s", escaped_refname);
- if (r == -1)
- goto done;
-
- if (fcgi_printf(c, "</div>\n" /* .branch */
- "<div class='navs_wrapper'>\n"
- "<div class='navs'>") == -1)
- goto done;
-
- r = gotweb_link(c, &(struct gotweb_url){
- .action = SUMMARY,
- .index_page = -1,
- .page = -1,
- .path = qs->path,
- .headref = refname,
- }, "summary");
- 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 = qs->path,
- .headref = refname,
- }, "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 = qs->path,
- .headref = refname,
- }, "commits");
- if (r == -1)
- goto done;
-
- r = fcgi_printf(c, "</div>\n" /* .navs */
- "</div>\n" /* .navs_wrapper */
- "<div class='dotted_line'></div>\n"
- "</div>\n"); /* .branches_wrapper */
- if (r == -1)
- goto done;
-
- free(age);
- age = NULL;
- free(escaped_refname);
- escaped_refname = NULL;
- }
- fcgi_printf(c, "</div>\n"); /* #branches_content */
-done:
- free(age);
- free(escaped_refname);
- got_ref_list_free(&refs);
- return error;
-}
-
-static const struct got_error *
-gotweb_render_summary(struct request *c)
-{
- const struct got_error *error = NULL;
- struct transport *t = c->t;
- struct server *srv = c->srv;
- int r;
-
if (fcgi_printf(c, "<div id='summary_wrapper'>\n") == -1)
goto done;
goto done;
}
- error = gotweb_render_branches(c);
- if (error)
- log_warnx("%s: %s", __func__, error->msg);
+ gotweb_render_branches(c->tp, &refs);
done:
+ got_ref_list_free(&refs);
return error;
}
blob - 65e48fe2675590393e47fbe9907d11d81c91340c
blob + 01a426c9ded760150f5157900a24d3874a0f178d
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
/* Forward declaration */
struct got_blob_object;
struct got_tree_entry;
+struct got_reflist_head;
enum imsg_type {
IMSG_CFG_SRV = IMSG_PROC_MAX,
int gotweb_render_tags_tmpl(struct template *);
int gotweb_render_tag(struct template *);
int gotweb_render_diff(struct template *, FILE *);
+int gotweb_render_branches(struct template *, struct got_reflist_head *);
int gotweb_render_rss(struct template *);
/* parse.y */
blob - 8d491248536264e58b0f129b544f0fbff2c4066f
blob + 1ee4d93d857e50deb09f255fd23369630dd7c910
--- gotwebd/pages.tmpl
+++ gotwebd/pages.tmpl
#include <string.h>
#include <imsg.h>
-#include "got_compat.h"
+#include "got_error.h"
#include "got_object.h"
+#include "got_reference.h"
#include "proc.h"
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 *);
static inline int rss_tag_item(struct template *, struct repo_tag *);
static inline int rss_author(struct template *, char *);
<div class="diff_line {{ color }}">{{ line }}</div>
{{ end }}
+{{ define gotweb_render_branches(struct template *tp,
+ struct got_reflist_head *refs) }}
+{!
+ struct got_reflist_entry *re;
+!}
+<div id="branches_title_wrapper">
+ <div id="branches_title">Branches</div>
+</div>
+<div id="branches_content">
+ {{ tailq-foreach re refs entry }}
+ {{ if !got_ref_is_symbolic(re->ref) }}
+ {{ render branch(tp, re) }}
+ {{ end }}
+ {{ end }}
+</div>
+{{ end }}
+
+{{ define branch(struct template *tp, struct got_reflist_entry *re) }}
+{!
+ const struct got_error *err;
+ struct request *c = tp->tp_arg;
+ struct querystring *qs = c->t->qs;
+ const char *refname;
+ char *age = NULL;
+ struct gotweb_url url = {
+ .action = SUMMARY,
+ .index_page = -1,
+ .page = -1,
+ .path = qs->path,
+ };
+
+ refname = got_ref_get_name(re->ref);
+
+ err = got_get_repo_age(&age, c, refname, TM_DIFF);
+ if (err) {
+ log_warnx("%s: %s", __func__, err->msg);
+ return -1;
+ }
+
+ if (strncmp(refname, "refs/heads/", 11) == 0)
+ refname += 11;
+
+ url.headref = refname;
+!}
+<div class="branches_wrapper">
+ <div class="branches_age">{{ age }}</div>
+ <div class="branches_space"> </div>
+ <div class="branch">
+ <a href="{{ render gotweb_render_url(c, &url) }}">{{ refname }}</a>
+ </div>
+ <div class="navs_wrapper">
+ <div class="navs">
+ <a href="{{ render gotweb_render_url(c, &url) }}">summary</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>
+</div>
+{{ finally }}
+{! free(age); !}
+{{ end }}
+
{{ define gotweb_render_rss(struct template *tp) }}
{!
struct request *c = tp->tp_arg;