commit 4ceb8155ccb971807ae8c7e32ed1357ac23685a2 from: Tracey Emery date: Wed Jan 15 22:10:30 2020 UTC create full logs page commit - 9d84e7dd9e16bfa028f8607ebeae226c7ea4c0ed commit + 4ceb8155ccb971807ae8c7e32ed1357ac23685a2 blob - 106ff970598595629b38dd4456b7d32c91379c50 blob + 8f9b2cf6f568f007f0e1d1cce187828cc667f290 --- Makefile.inc +++ Makefile.inc @@ -1,5 +1,5 @@ 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 - c1ca944f5834b9a6f65edf7f890a8968edafdf78 blob + a55dfa209eaad11211cb2f51ad6f29220cb4ce97 --- gotweb/TODO +++ gotweb/TODO @@ -2,6 +2,15 @@ Complete templates. Complete stylesheets. Complete gw_funcs ---- -Remember items - description - cloneurl + +- Add Prev/Next to shortlogs/logs that have more entries than + got_max_commits_display + +- Alter gw_get_repo_log full_log int to type more logs output for other options, + such as header displays for commit, commit_diff, etc. + +- Discuss how much of the gitweb functionality we really need or want. A user + can really go down an endless rabbit hole. Is it all worthwhile? + +- Redo index header, so columns are removed when content is set to not display + in gotweb.conf. blob - 6593c76079499fdfdc518d7224d06e2fa34b16dd blob + 3ea47833b3f3410756fa80dd2f323be2bc2b3b29 --- gotweb/files/htdocs/gotweb/gotweb.css +++ gotweb/files/htdocs/gotweb/gotweb.css @@ -190,12 +190,12 @@ body { padding-bottom: 5px; overflow: auto; } -#shortlog_wrapper { +#logbriefs_wrapper { clear: left; float: left; width: 100%; } -#shortlog_age { +#logbriefs_age { padding-left: 10px; padding-top: 5px; padding-bottom: 5px; @@ -203,7 +203,7 @@ body { width: 7.5em; overflow: auto; } -#shortlog_author { +#logbriefs_author { float: left; padding-top: 5px; padding-bottom: 5px; @@ -211,8 +211,9 @@ body { font-style: italic; overflow: auto; } -#shortlog_log { +#logbriefs_log { float: left; + padding-left: 10px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px; @@ -353,6 +354,66 @@ body { text-decoration: none; } +/* logs.tmpl */ + +#logs_wrapper { + clear: left; + float: left; + width: 100%; +} +#logs_title_wrapper { + clear: left; + float: left; + width: 100%; + background-color: LightSlateGray; + color: #ffffff; +} +#logs_title { + padding-left: 10px; + padding-top: 5px; + padding-bottom: 5px; +} +#logs_content { + clear: left; + float: left; + width: 100%; +} +#logs_row_wrapper { + clear: left; + float: left; + background-color: #f5fcfb; + width: 100%; +} +#logs_commit { + clear: left; + float: left; + padding-left: 10px; + padding-top: 5px; + padding-bottom: 2px; +} +#logs_author { + clear: left; + float: left; + padding-left: 10px; + padding-top: 2px; + padding-bottom: 2px; +} +#logs_age { + clear: left; + float: left; + padding-left: 10px; + padding-top: 2px; + padding-bottom: 5px; +} + +#log { + clear: left; + float: left; + padding-left: 20px; + padding-top: 2px; + padding-bottom: 20px; +} + /* summary.tmpl */ #summary_wrapper { @@ -361,19 +422,19 @@ body { width: 100%; background-color: Khaki; } -#summary_shortlog_title_wrapper { +#summary_logbriefs_title_wrapper { clear: left; float: left; width: 100%; background-color: LightSlateGray; color: #ffffff; } -#summary_shortlog_title { +#summary_logbriefs_title { padding-left: 10px; padding-top: 5px; padding-bottom: 5px; } -#summary_shortlog_content { +#summary_logbriefs_content { clear: left; float: left; width: 100%; blob - 69b21bc7c6576a212fa584990ba15f078a2e2883 blob + debc3faf3bd9431c7b47c2827fed1d20c6d3db67 --- gotweb/gotweb.c +++ gotweb/gotweb.c @@ -141,8 +141,8 @@ static char *gw_get_repo_owner(struct trans *, static char *gw_get_time_str(time_t, int); static char *gw_get_repo_age(struct trans *, char *, char *, int); -static char *gw_get_repo_shortlog(struct trans *, - const char *, int); +static char *gw_get_repo_log(struct trans *, const char *, + char *, int, int); static char *gw_get_repo_tags(struct trans *); static char *gw_get_repo_heads(struct trans *); static char *gw_get_clone_url(struct trans *, char *); @@ -174,7 +174,7 @@ static const struct got_error* gw_history(struct tran static const struct got_error* gw_index(struct trans *); static const struct got_error* gw_log(struct trans *); static const struct got_error* gw_raw(struct trans *); -static const struct got_error* gw_shortlog(struct trans *); +static const struct got_error* gw_logbriefs(struct trans *); static const struct got_error* gw_snapshot(struct trans *); static const struct got_error* gw_summary(struct trans *); static const struct got_error* gw_tree(struct trans *); @@ -197,7 +197,7 @@ enum gw_query_actions { GW_INDEX, GW_LOG, GW_RAW, - GW_SHORTLOG, + GW_LOGBRIEFS, GW_SNAPSHOT, GW_SUMMARY, GW_TREE @@ -214,7 +214,7 @@ static struct gw_query_action gw_query_funcs[] = { { GW_INDEX, "index", gw_index, "gw_tmpl/index.tmpl" }, { GW_LOG, "log", gw_log, "gw_tmpl/index.tmpl" }, { GW_RAW, "raw", gw_raw, "gw_tmpl/index.tmpl" }, - { GW_SHORTLOG, "shortlog", gw_shortlog, "gw_tmpl/index.tmpl" }, + { GW_LOGBRIEFS, "logbriefs", gw_logbriefs, "gw_tmpl/index.tmpl" }, { GW_SNAPSHOT, "snapshot", gw_snapshot, "gw_tmpl/index.tmpl" }, { GW_SUMMARY, "summary", gw_summary, "gw_tmpl/index.tmpl" }, { GW_TREE, "tree", gw_tree, "gw_tmpl/index.tmpl" }, @@ -393,7 +393,18 @@ static const struct got_error * gw_log(struct trans *gw_trans) { const struct got_error *error = NULL; + char *log, *log_html; + log = gw_get_repo_log(gw_trans, NULL, NULL, + gw_trans->gw_conf->got_max_commits_display, 1); + + if (log != NULL && strcmp(log, "") != 0) { + if ((asprintf(&log_html, logs, log)) == -1) + return got_error_from_errno("asprintf"); + khttp_puts(gw_trans->gw_req, log_html); + free(log_html); + free(log); + } return error; } @@ -406,23 +417,22 @@ gw_raw(struct trans *gw_trans) } static const struct got_error * -gw_shortlog(struct trans *gw_trans) +gw_logbriefs(struct trans *gw_trans) { const struct got_error *error = NULL; - char *shortlog, *shortlog_html; + char *logbriefs, *logbriefs_html; - shortlog = gw_get_repo_shortlog(gw_trans, NULL, - gw_trans->gw_conf->got_max_commits_display); + logbriefs = gw_get_repo_log(gw_trans, NULL, NULL, + gw_trans->gw_conf->got_max_commits_display, 0); - if (shortlog != NULL && strcmp(shortlog, "") != 0) { - if ((asprintf(&shortlog_html, summary_shortlog, - shortlog)) == -1) + if (logbriefs != NULL && strcmp(logbriefs, "") != 0) { + if ((asprintf(&logbriefs_html, summary_logbriefs, + logbriefs)) == -1) return got_error_from_errno("asprintf"); - khttp_puts(gw_trans->gw_req, shortlog_html); - free(shortlog_html); - free(shortlog); + khttp_puts(gw_trans->gw_req, logbriefs_html); + free(logbriefs_html); + free(logbriefs); } - return error; } @@ -439,7 +449,7 @@ gw_summary(struct trans *gw_trans) { const struct got_error *error = NULL; char *description_html, *repo_owner_html, *repo_age_html, - *cloneurl_html, *shortlog, *tags, *heads, *shortlog_html, + *cloneurl_html, *logbriefs, *tags, *heads, *logbriefs_html, *tags_html, *heads_html, *age; error = apply_unveil(gw_trans->gw_dir->path, NULL); @@ -497,17 +507,17 @@ gw_summary(struct trans *gw_trans) } khttp_puts(gw_trans->gw_req, div_end); - shortlog = gw_get_repo_shortlog(gw_trans, NULL, D_MAXSLCOMMDISP); + logbriefs = gw_get_repo_log(gw_trans, NULL, NULL, D_MAXSLCOMMDISP, 0); tags = gw_get_repo_tags(gw_trans); heads = gw_get_repo_heads(gw_trans); - if (shortlog != NULL && strcmp(shortlog, "") != 0) { - if ((asprintf(&shortlog_html, summary_shortlog, - shortlog)) == -1) + if (logbriefs != NULL && strcmp(logbriefs, "") != 0) { + if ((asprintf(&logbriefs_html, summary_logbriefs, + logbriefs)) == -1) return got_error_from_errno("asprintf"); - khttp_puts(gw_trans->gw_req, shortlog_html); - free(shortlog_html); - free(shortlog); + khttp_puts(gw_trans->gw_req, logbriefs_html); + free(logbriefs_html); + free(logbriefs); } if (tags != NULL && strcmp(tags, "") != 0) { @@ -545,7 +555,7 @@ gw_load_got_path(struct trans *gw_trans, struct gw_dir const struct got_error *error = NULL; DIR *dt; char *dir_test; - bool opened = false; + int opened = 0; if ((asprintf(&dir_test, "%s/%s/%s", gw_trans->gw_conf->got_repos_path, gw_dir->name, @@ -557,7 +567,7 @@ gw_load_got_path(struct trans *gw_trans, struct gw_dir free(dir_test); } else { gw_dir->path = strdup(dir_test); - opened = true; + opened = 1; goto done; } @@ -570,7 +580,7 @@ gw_load_got_path(struct trans *gw_trans, struct gw_dir if (dt == NULL) free(dir_test); else { - opened = true; + opened = 1; error = got_error(GOT_ERR_NOT_GIT_REPO); goto errored; } @@ -1111,8 +1121,8 @@ gw_get_clone_url(struct trans *gw_trans, char *dir) } static char * -gw_get_repo_shortlog(struct trans *gw_trans, const char *search_pattern, - int limit) +gw_get_repo_log(struct trans *gw_trans, const char *search_pattern, + char *start_commit, int limit, int full_log) { const struct got_error *error; struct got_repository *repo = NULL; @@ -1121,10 +1131,10 @@ gw_get_repo_shortlog(struct trans *gw_trans, const cha struct got_commit_object *commit = NULL; struct got_object_id *id = NULL; struct got_commit_graph *graph = NULL; - char *start_commit = NULL, *shortlog = NULL, *id_str = NULL, - *path = NULL, *in_repo_path = NULL, *commit_row = NULL, - *commit_age = NULL, *commit_author = NULL, *commit_log = NULL, - *commit_log0, *newline, *shortlog_navs_html = NULL; + char *logbriefs = NULL, *id_str = NULL, *path = NULL, + *in_repo_path = NULL, *commit_row = NULL, *commit_age = NULL, + *commit_author = NULL, *commit_log = NULL, *commit_log0, *newline, + *logbriefs_navs_html = NULL; regex_t regex; int have_match; size_t newsize; @@ -1313,39 +1323,65 @@ gw_get_repo_shortlog(struct trans *gw_trans, const cha committer_time = got_object_commit_get_committer_time(commit_disp); - asprintf(&commit_age, "%s", gw_get_time_str(committer_time, - TM_DIFF)); - asprintf(&commit_author, "%s", - got_object_commit_get_author(commit_disp)); - error = got_object_commit_get_logmsg(&commit_log0, commit_disp); - if (error) - commit_log = strdup(""); - else { - commit_log = commit_log0; - while (*commit_log == '\n') - commit_log++; - newline = strchr(commit_log, '\n'); - if (newline) - *newline = '\0'; + + if (full_log) { + + asprintf(&commit_age, "%s", + gw_get_time_str(committer_time, TM_LONG)); + asprintf(&commit_author, "%s", + got_object_commit_get_author(commit_disp)); + error = got_object_commit_get_logmsg(&commit_log0, + commit_disp); + if (error) + commit_log = strdup(""); + else + commit_log = gw_html_escape(commit_log0); + asprintf(&logbriefs_navs_html, logbriefs_navs, + gw_trans->repo_name, id_str, gw_trans->repo_name, + id_str, gw_trans->repo_name, id_str, + gw_trans->repo_name, id_str); + asprintf(&commit_row, logs_row, id_str, + gw_html_escape(commit_author), commit_age, + commit_log, logbriefs_navs_html); + error = buf_append(&newsize, diffbuf, commit_row, + strlen(commit_row)); + } else { + asprintf(&commit_age, "%s", + gw_get_time_str(committer_time, TM_DIFF)); + asprintf(&commit_author, "%s", + got_object_commit_get_author(commit_disp)); + error = got_object_commit_get_logmsg(&commit_log0, + commit_disp); + if (error) + commit_log = strdup(""); + else { + commit_log = commit_log0; + while (*commit_log == '\n') + commit_log++; + newline = strchr(commit_log, '\n'); + if (newline) + *newline = '\0'; + } + asprintf(&logbriefs_navs_html, logbriefs_navs, + gw_trans->repo_name, id_str, gw_trans->repo_name, + id_str, gw_trans->repo_name, id_str, + gw_trans->repo_name, id_str); + asprintf(&commit_row, logbriefs_row, commit_age, + commit_author, commit_log, logbriefs_navs_html); + error = buf_append(&newsize, diffbuf, commit_row, + strlen(commit_row)); } - asprintf(&shortlog_navs_html, shortlog_navs, - gw_trans->repo_name, id_str, gw_trans->repo_name, id_str, - gw_trans->repo_name, id_str, gw_trans->repo_name, id_str); - asprintf(&commit_row, shortlog_row, commit_age, commit_author, - commit_log, shortlog_navs_html); - error = buf_append(&newsize, diffbuf, commit_row, - strlen(commit_row)); free(commit_age); free(commit_author); free(commit_log0); - free(shortlog_navs_html); + free(logbriefs_navs_html); free(commit_row); free(id_str); commit_age = NULL; commit_author = NULL; commit_log = NULL; - shortlog_navs_html = NULL; + logbriefs_navs_html = NULL; commit_row = NULL; id_str = NULL; @@ -1353,7 +1389,7 @@ gw_get_repo_shortlog(struct trans *gw_trans, const cha if (error || (limit && --limit == 0)) break; } - shortlog = strdup(diffbuf->cb_buf); + logbriefs = strdup(diffbuf->cb_buf); got_object_commit_close(commit); free(path); @@ -1368,7 +1404,7 @@ gw_get_repo_shortlog(struct trans *gw_trans, const cha if (search_pattern) regfree(®ex); - return shortlog; + return logbriefs; done: if (repo) got_repo_close(repo); @@ -1385,7 +1421,8 @@ gw_get_repo_tags(struct trans *gw_trans) { char *tags = NULL; - asprintf(&tags, tags_row, "30 min ago", "1.0.0", "tag 1.0.0", tags_navs); + asprintf(&tags, tags_row, "30 min ago", "1.0.0", "tag 1.0.0", + tags_navs); return tags; } @@ -1488,7 +1525,7 @@ main() struct trans *gw_trans; struct gw_dir *dir = NULL, *tdir; const char *page = "index"; - bool gw_malloc = true; + int gw_malloc = 1; if ((gw_trans = malloc(sizeof(struct trans))) == NULL) errx(1, "malloc"); @@ -1508,7 +1545,7 @@ main() if ((gw_trans->gw_conf = malloc(sizeof(struct gotweb_conf))) == NULL) { - gw_malloc = false; + gw_malloc = 0; error = got_error_from_errno("malloc"); goto err; } blob - 4a710632da6fbf66ec0bc3850aa85db8e8b242bc blob + 2d578f1acd4baa157bf621af57a3f6653c663d29 --- gotweb/gotweb_ui.h +++ gotweb/gotweb_ui.h @@ -14,31 +14,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* - * header nav - * - * ***index - * search - * Projects - * Project|Description|Owner|Last Commit - * DIV (summary|shortlog|log|tree) - * ***summary - * repo navs | search - * repo description - * description - * owner - * last commit - * URL - * shortlog - * Date|committer|commit description (commit|commitdiff|tree|snapshot) - * heads - * create date | head (shortlog|log|tree) - * - * - * - * footer - */ - #ifndef GOTWEB_UI_H #define GOTWEB_UI_H @@ -114,11 +89,11 @@ char *cloneurl = "
Clone URL:
" \ "
%s
"; -char *shortlog_row = - "
" \ - "
%s
" \ - "
%s
" \ - "
%s
" \ +char *logbriefs_row = + "
" \ + "
%s
" \ + "
%s
" \ + "
%s
" \ "
" \ "" \ "
"; -char *shortlog_navs = +char *logbriefs_navs = "commit | " \ "diff | " \ "tree | " \ @@ -147,7 +122,7 @@ char *tags_row = char *tags_navs = "tag | " \ "commit | " \ - "shortlog | " \ + "Log Briefs | " \ "log"; char *heads_row = @@ -162,10 +137,40 @@ char *heads_row = "
"; char *heads_navs = - "shortlog | " \ + "Log Briefs | " \ "log | " \ "commit"; +/* log.tmpl */ + +char *logs_wrapper = + "
"; + +char *logs = + "
" \ + "
Commits
" \ + "
%s
"; + +char *logs_row = + "
" \ + "
Commit: %s
" \ + "
From: %s
" \ + "
Date: %s
" \ + "
" \ + "
" \ + "
%s
" \ + "" \ + "
" \ + "
"; + +char *logs_navs = + "commit | " \ + "diff | " \ + "tree | " \ + "snapshot"; + /* index.tmpl */ char *index_projects_header = @@ -192,7 +197,7 @@ char *index_projects = char *index_navs = "summary | " \ - "shortlog | " \ + "log briefs | " \ "log | " \ "tree"; @@ -201,10 +206,10 @@ char *index_navs = char *summary_wrapper = "
"; -char *summary_shortlog = - "
" \ - "
Shortlog
" \ - "
%s
"; +char *summary_logbriefs = + "
" \ + "
Log Briefs
" \ + "
%s
"; char *summary_tags = "
" \