commit - 09c82ddfcfa03dbd3876ccd89df58a943efddb6e
commit + 46b9c89b72ffed3b1d8afaf5b211412c3d2fc6af
blob - 106ff970598595629b38dd4456b7d32c91379c50
blob + 8f9b2cf6f568f007f0e1d1cce187828cc667f290
--- Makefile.inc
+++ Makefile.inc
CPPFLAGS += -DGOT_LIBEXECDIR=${LIBEXECDIR} -DGOT_VERSION=${GOT_VERSION}
-#CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
+CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
#CFLAGS += -DGOT_PACK_NO_MMAP
#CFLAGS += -DGOT_NO_OBJ_CACHE
#CFLAGS += -DGOT_OBJ_CACHE_DEBUG
blob - 133211bd0a02daf443d1c7c66ab17778f60f23e7
blob + d9a860735bffd19f2d84ba0691bf3ab0e60ee222
--- gotweb/files/htdocs/gotweb/gotweb.css
+++ gotweb/files/htdocs/gotweb/gotweb.css
padding-left: 10px;
padding-top: 5px;
padding-bottom: 5px;
+}
+#description_title {
+ clear: left;
+ float: left;
+ width: 6.5em;
+ padding-left: 10px;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+#description {
+ float: left;
+ width: 72%;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+#repo_owner_title {
+ clear: left;
+ float: left;
+ width: 6.5em;
+ padding-left: 10px;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+#repo_owner {
+ float: left;
+ width: 72%;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+#last_change_title {
+ clear: left;
+ float: left;
+ width: 6.5em;
+ padding-left: 10px;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+#last_change {
+ float: left;
+ width: 72%;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+#cloneurl_title {
+ clear: left;
+ float: left;
+ width: 6.5em;
+ padding-left: 10px;
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+#cloneurl {
+ float: left;
+ width: 72%;
+ padding-top: 5px;
+ padding-bottom: 5px;
+ overflow: auto;
}
/* index.tmpl */
width: 100%;
background-color: Khaki;
}
-#summary_description_title {
- clear: left;
- float: left;
- width: 6.5em;
- padding-left: 10px;
- padding-top: 5px;
- padding-bottom: 5px;
-}
-#summary_description {
- float: left;
- width: 72%;
- padding-top: 5px;
- padding-bottom: 5px;
-}
-#summary_repo_owner_title {
- clear: left;
- float: left;
- width: 6.5em;
- padding-left: 10px;
- padding-top: 5px;
- padding-bottom: 5px;
-}
-#summary_repo_owner {
- float: left;
- width: 72%;
- padding-top: 5px;
- padding-bottom: 5px;
-}
-#summary_last_change_title {
- clear: left;
- float: left;
- width: 6.5em;
- padding-left: 10px;
- padding-top: 5px;
- padding-bottom: 5px;
-}
-#summary_last_change {
- float: left;
- width: 72%;
- padding-top: 5px;
- padding-bottom: 5px;
-}
-#summary_cloneurl_title {
- clear: left;
- float: left;
- width: 6.5em;
- padding-left: 10px;
- padding-top: 5px;
- padding-bottom: 5px;
-}
-#summary_cloneurl {
- float: left;
- width: 72%;
- padding-top: 5px;
- padding-bottom: 5px;
- overflow: auto;
-}
#summary_shortlog_title_wrapper {
clear: left;
float: left;
blob - 0f1b510a75fbfc590305ae7c3b34785006995a99
blob + e2d721fa97f66a118d60151b4434de04195a7e25
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
struct trans {
TAILQ_HEAD(dirs, gw_dir) gw_dirs;
+ struct gw_dir *gw_dir;
struct gotweb_conf *gw_conf;
struct ktemplate *gw_tmpl;
struct khtmlreq *gw_html_req;
TEMPL_SITEOWNER,
TEMPL_TITLE,
TEMPL_SEARCH,
- TEMPL_DESCRIPTION,
TEMPL_CONTENT,
- TEMPL_REPO_OWNER,
- TEMPL_REPO_AGE,
- TEMPL_CLONEURL,
TEMPL__MAX
};
"siteowner",
"title",
"search",
- "description",
"content",
- "repo_owner",
- "repo_age",
- "cloneurl",
};
static const struct kvalid gw_keys[KEY__MAX] = {
{ GW_RAW, "raw", gw_raw, "gw_tmpl/index.tmpl" },
{ GW_SHORTLOG, "shortlog", gw_shortlog, "gw_tmpl/index.tmpl" },
{ GW_SNAPSHOT, "snapshot", gw_snapshot, "gw_tmpl/index.tmpl" },
- { GW_SUMMARY, "summary", gw_summary, "gw_tmpl/summary.tmpl" },
+ { GW_SUMMARY, "summary", gw_summary, "gw_tmpl/index.tmpl" },
{ GW_TREE, "tree", gw_tree, "gw_tmpl/index.tmpl" },
};
gw_index(struct trans *gw_trans)
{
const struct got_error *error = NULL;
- struct gw_dir *dir = NULL;
+ struct gw_dir *gw_dir = NULL;
char *html, *navs, *next, *prev;
unsigned int prev_disp = 0, next_disp = 1, dir_c = 0;
+ error = apply_unveil(gw_trans->gw_conf->got_repos_path, NULL);
+ if (error)
+ return error;
+
error = gw_load_got_paths(gw_trans);
- if (error && error->code != GOT_ERR_OK)
+ if (error)
return error;
khttp_puts(gw_trans->gw_req, index_projects_header);
- TAILQ_FOREACH(dir, &gw_trans->gw_dirs, entry)
+ TAILQ_FOREACH(gw_dir, &gw_trans->gw_dirs, entry)
dir_c++;
- TAILQ_FOREACH(dir, &gw_trans->gw_dirs, entry) {
+ TAILQ_FOREACH(gw_dir, &gw_trans->gw_dirs, entry) {
if (gw_trans->page > 0 && (gw_trans->page *
gw_trans->gw_conf->got_max_repos_display) > prev_disp) {
prev_disp++;
}
prev_disp++;
- if((asprintf(&navs, index_navs, dir->name, dir->name, dir->name,
- dir->name)) == -1)
+ if((asprintf(&navs, index_navs, gw_dir->name, gw_dir->name,
+ gw_dir->name, gw_dir->name)) == -1)
return got_error_from_errno("asprintf");
- if ((asprintf(&html, index_projects, dir->name, dir->name,
- dir->description, dir->owner, dir->age, navs)) == -1)
+ if ((asprintf(&html, index_projects, gw_dir->name, gw_dir->name,
+ gw_dir->description, gw_dir->owner, gw_dir->age,
+ navs)) == -1)
return got_error_from_errno("asprintf");
khttp_puts(gw_trans->gw_req, html);
gw_summary(struct trans *gw_trans)
{
const struct got_error *error = NULL;
+ char *description_html, *repo_owner_html, *repo_age_html,
+ *cloneurl_html;
+ error = apply_unveil(gw_trans->gw_dir->path, NULL);
+ if (error)
+ return error;
+
+ khttp_puts(gw_trans->gw_req, summary_wrapper);
+ if (gw_trans->gw_conf->got_show_repo_description) {
+ if (gw_trans->gw_dir->description != NULL &&
+ (strcmp(gw_trans->gw_dir->description, "") != 0)) {
+ if ((asprintf(&description_html, description,
+ gw_trans->gw_dir->description)) == -1)
+ return got_error_from_errno("asprintf");
+
+ khttp_puts(gw_trans->gw_req, description_html);
+ free(description_html);
+ }
+ }
+
+ if (gw_trans->gw_conf->got_show_repo_owner) {
+ if (gw_trans->gw_dir->owner != NULL &&
+ (strcmp(gw_trans->gw_dir->owner, "") != 0)) {
+ if ((asprintf(&repo_owner_html, repo_owner,
+ gw_trans->gw_dir->owner)) == -1)
+ return got_error_from_errno("asprintf");
+
+ khttp_puts(gw_trans->gw_req, repo_owner_html);
+ free(repo_owner_html);
+ }
+ }
+
+ if (gw_trans->gw_conf->got_show_repo_age) {
+ if (gw_trans->gw_dir->age != NULL &&
+ (strcmp(gw_trans->gw_dir->age, "") != 0)) {
+ if ((asprintf(&repo_age_html, last_change,
+ gw_trans->gw_dir->age)) == -1)
+ return got_error_from_errno("asprintf");
+
+ khttp_puts(gw_trans->gw_req, repo_age_html);
+ free(repo_age_html);
+ }
+ }
+
+ if (gw_trans->gw_conf->got_show_repo_cloneurl) {
+ if (gw_trans->gw_dir->url != NULL &&
+ (strcmp(gw_trans->gw_dir->url, "") != 0)) {
+ if ((asprintf(&cloneurl_html, cloneurl,
+ gw_trans->gw_dir->url)) == -1)
+ return got_error_from_errno("asprintf");
+
+ khttp_puts(gw_trans->gw_req, cloneurl_html);
+ free(cloneurl_html);
+ }
+ }
+ khttp_puts(gw_trans->gw_req, div_end);
+
error = gw_shortlog(gw_trans);
error = gw_tags(gw_trans);
error = gw_heads(gw_trans);
struct gw_dir *gw_dir;
struct stat st;
unsigned int d_cnt, d_i;
-
- if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1) {
- error = got_error_from_errno("pledge");
- return error;
- }
- error = apply_unveil(gw_trans->gw_conf->got_repos_path, NULL);
- if (error)
- return error;
-
d = opendir(gw_trans->gw_conf->got_repos_path);
if (d == NULL) {
error = got_error_from_errno2("opendir",
error = got_error_from_errno("invalid action");
return error;
}
+ if ((gw_trans->gw_dir =
+ gw_init_gw_dir(gw_trans->repo_name)) == NULL)
+ return got_error_from_errno("gw_dir malloc");
+
+ error = gw_load_got_path(gw_trans, gw_trans->gw_dir);
+ if (error)
+ return error;
} else
gw_trans->action = GW_INDEX;
struct trans *gw_trans = arg;
char *gw_got_link, *gw_site_link;
char *site_owner_name, *site_owner_name_h;
- char *description, *description_h;
- char *repo_owner, *repo_owner_h;
- char *repo_age, *repo_age_h;
- char *cloneurl, *cloneurl_h;
switch (key) {
case (TEMPL_HEAD):
case (TEMPL_SEARCH):
khttp_puts(gw_trans->gw_req, search);
break;
- case(TEMPL_DESCRIPTION):
- if (gw_trans->gw_conf->got_show_repo_description) {
- description = gw_html_escape(
- gw_get_repo_description(gw_trans,
- gw_trans->repo_path));
- if (description != NULL &&
- (strcmp(description, "") != 0)) {
- if ((asprintf(&description_h,
- summary_description, description)) == -1)
- return 0;
-
- khttp_puts(gw_trans->gw_req, description_h);
- free(description);
- free(description_h);
- }
- }
- break;
case(TEMPL_SITEOWNER):
if (gw_trans->gw_conf->got_site_owner != NULL &&
gw_trans->gw_conf->got_show_site_owner) {
error = gw_query_funcs[gw_trans->action].func_main(gw_trans);
if (error)
khttp_puts(gw_trans->gw_req, error->msg);
-
- break;
- case(TEMPL_REPO_OWNER):
- if (gw_trans->gw_conf->got_show_repo_owner) {
- repo_owner = gw_html_escape(gw_get_repo_owner(gw_trans,
- gw_trans->repo_path));
- if ((asprintf(&repo_owner_h, summary_repo_owner,
- repo_owner)) == -1)
- return 0;
-
- if (repo_owner != NULL &&
- (strcmp(repo_owner, "") != 0)) {
- khttp_puts(gw_trans->gw_req, repo_owner_h);
- }
- free(repo_owner_h);
- }
break;
- case(TEMPL_REPO_AGE):
- if (gw_trans->gw_conf->got_show_repo_age) {
- repo_age = gw_get_repo_age(gw_trans,
- gw_trans->repo_path, "refs/heads", TM_LONG);
- if (repo_age != NULL) {
- if ((asprintf(&repo_age_h, summary_last_change,
- repo_age)) == -1)
- return 0;
- khttp_puts(gw_trans->gw_req, repo_age_h);
- free(repo_age);
- free(repo_age_h);
- }
- }
- break;
- case(TEMPL_CLONEURL):
- if (gw_trans->gw_conf->got_show_repo_cloneurl) {
- cloneurl = gw_html_escape(gw_get_clone_url(gw_trans,
- gw_trans->repo_path));
- if (cloneurl != NULL) {
- if ((asprintf(&cloneurl_h,
- summary_cloneurl, cloneurl)) == -1)
- return 0;
-
- khttp_puts(gw_trans->gw_req, cloneurl_h);
- free(cloneurl);
- free(cloneurl_h);
- }
-
- }
- break;
default:
return 0;
break;
break;
}
-noref:
+/* noref: */
got_ref_list_free(&refs);
free(id);
return repo_age;
goto err;
}
+ if (pledge("stdio rpath proc exec sendfd unveil", NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ goto err;
+ }
+
TAILQ_INIT(&gw_trans->gw_dirs);
gw_trans->page = 0;
blob - a058b737cb68fb43826c8186cc91f652fbd6e046
blob + 9628eafaeef5509996b07e89b3e5318b2dafcf1c
--- gotweb/gotweb_ui.h
+++ gotweb/gotweb_ui.h
char *nav_prev =
"<a href='?page=%d'>Previous<a/>";
+char *description =
+ "<div id='description_title'>Description: </div>" \
+ "<div id='description'>%s</div>";
+
+char *repo_owner =
+ "<div id='repo_owner_title'>Owner: </div>" \
+ "<div id='repo_owner'>%s</div>";
+
+char *last_change =
+ "<div id='last_change_title'>Last Change: </div>" \
+ "<div id='last_change'>%s</div>";
+
+char *cloneurl =
+ "<div id='cloneurl_title'>Clone URL: </div>" \
+ "<div id='cloneurl'>%s</div>";
+
/* index.tmpl */
char *index_projects_header =
/* summary.tmpl */
-char *summary_description =
- "<div id='summary_description_title'>Description: </div>" \
- "<div id='summary_description'>%s</div>";
+char *summary_wrapper =
+ "<div id='summary_wrapper'>";
-char *summary_repo_owner =
- "<div id='summary_repo_owner_title'>Owner: </div>" \
- "<div id='summary_repo_owner'>%s</div>";
-
-char *summary_last_change =
- "<div id='summary_last_change_title'>Last Change: </div>" \
- "<div id='summary_last_change'>%s</div>";
-
-char *summary_cloneurl =
- "<div id='summary_cloneurl_title'>Clone URL: </div>" \
- "<div id='summary_cloneurl'>%s</div>";
-
char *summary_shortlog =
"<div id='summary_shortlog_title_wrapper'>" \
"<div id='summary_shortlog_title'>Shortlog</div></div>" \