neocgit

a more 'modern' version of cgit
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/neocgit

commit 226030fe872d7f143a1d16fd2d4e86d8c4ab9102
parent b47a0f4f50a717877214d3448c59e0e5ef8d8ff9
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon,  9 Jul 2018 17:57:37 +0200

WORK: Some stuff on commit lists, non-tested

Signed-off-by: Ne02ptzero <louis@ne02ptzero.me>

Diffstat:
Mcgit.css | 29++++++++++++++---------------
Mui-log.c | 358++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mui-shared.c | 2+-
3 files changed, 213 insertions(+), 176 deletions(-)

diff --git a/cgit.css b/cgit.css @@ -409,26 +409,26 @@ option:not(:checked) { padding: 16px; } -.last-commit ul { +.commit ul { display: inline-block; width: 100%; padding: 0; margin: 0; } -.last-commit ul li { +.commit ul li { display: inline-grid; vertical-align: middle; margin: 0; padding: 0; } -.last-commit .avatar { +.commit .avatar { width: 5%; text-align: center; } -.last-commit .avatar img { +.commit .avatar img { width: 100%; height: auto; max-width: 40px; @@ -436,33 +436,33 @@ option:not(:checked) { margin-right: auto; } -.last-commit ul .commit-info { +.commit ul .commit-info { width: calc(95% - 138px); padding: 0; margin: 0; } -.last-commit ul .commit-info ul { +.commit ul .commit-info ul { padding: 0; margin: 0; padding-left: 16px; } -.last-commit ul .commit-info ul li { +.commit ul .commit-info ul li { width: 100%; display: inline-block; } -.last-commit ul .commit-info ul .title a { +.commit ul .commit-info ul .title a { font-weight: bold; color: #333 !important; } -.last-commit .hash { +.commit .hash { width: 138px; } -.last-commit .hash ul { +.commit .hash ul { margin: 0; padding: 0; width: 100%; @@ -470,11 +470,11 @@ option:not(:checked) { display: inline-block; } -.last-commit .hash ul li { +.commit .hash ul li { display: inline; } -.last-commit .hash input { +.commit .hash input { width: calc(100% - 62px); background: transparent; border: 1px solid #eee; @@ -485,7 +485,7 @@ option:not(:checked) { font-size: 14px; } -.last-commit .copy { +.commit .copy { text-align: center; border: 1px solid #eee; border-radius: 3px; @@ -500,12 +500,11 @@ option:not(:checked) { margin-left: -1px; } -.last-commit .copy:hover { +.commit .copy:hover { background: #e6e3e3; cursor: pointer; } - .repository-tree { padding: 10px 15px; } diff --git a/ui-log.c b/ui-log.c @@ -183,140 +183,173 @@ static void print_commit(struct commit *commit, struct rev_info *revs) if (ctx.repo->enable_log_linecount) columns++; - if (revs->graph) { - /* Advance graph until current commit */ - while (!graph_next_line(revs->graph, &graphbuf)) { - /* Print graph segment in otherwise empty table row */ - html("<tr class='nohover'><td class='commitgraph'>"); - html(graphbuf.buf); - htmlf("</td><td colspan='%d' /></tr>\n", columns); - strbuf_setlen(&graphbuf, 0); - } - /* Current commit's graph segment is now ready in graphbuf */ - } + /* if (revs->graph) {*/ + /*[> Advance graph until current commit <]*/ + /*while (!graph_next_line(revs->graph, &graphbuf)) {*/ + /*[> Print graph segment in otherwise empty table row <]*/ + /*html("<tr class='nohover'><td class='commitgraph'>");*/ + /*html(graphbuf.buf);*/ + /*htmlf("</td><td colspan='%d' /></tr>\n", columns);*/ + /*strbuf_setlen(&graphbuf, 0);*/ + /*}*/ + /*[> Current commit's graph segment is now ready in graphbuf <]*/ + /*}*/ info = cgit_parse_commit(commit); - htmlf("<tr%s>", ctx.qry.showmsg ? " class='logheader'" : ""); - - if (revs->graph) { - /* Print graph segment for current commit */ - html("<td class='commitgraph'>"); - html(graphbuf.buf); - html("</td>"); - strbuf_setlen(&graphbuf, 0); - } - else { - html("<td>"); - cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); - html("</td>"); - } - - htmlf("<td%s>", ctx.qry.showmsg ? " class='logsubject'" : ""); - if (ctx.qry.showmsg) { - /* line-wrap long commit subjects instead of truncating them */ - size_t subject_len = strlen(info->subject); - - if (subject_len > ctx.cfg.max_msg_len && - ctx.cfg.max_msg_len >= 15) { - /* symbol for signaling line-wrap (in PAGE_ENCODING) */ - const char wrap_symbol[] = { ' ', 0xE2, 0x86, 0xB5, 0 }; - int i = ctx.cfg.max_msg_len - strlen(wrap_symbol); - - /* Rewind i to preceding space character */ - while (i > 0 && !isspace(info->subject[i])) - --i; - if (!i) /* Oops, zero spaces. Reset i */ - i = ctx.cfg.max_msg_len - strlen(wrap_symbol); - - /* add remainder starting at i to msgbuf */ - strbuf_add(&msgbuf, info->subject + i, subject_len - i); - strbuf_trim(&msgbuf); - strbuf_add(&msgbuf, "\n\n", 2); - - /* Place wrap_symbol at position i in info->subject */ - strcpy(info->subject + i, wrap_symbol); - } - } - cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, - oid_to_hex(&commit->object.oid), ctx.qry.vpath); - show_commit_decorations(commit); - html("</td><td>"); - - gravatar_img(info->author_email, 13); - html_txt(info->author); - - if (revs->graph) { - html("</td><td>"); - cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); - } - - if (!lines_counted && (ctx.repo->enable_log_filecount || - ctx.repo->enable_log_linecount)) { - files = 0; - add_lines = 0; - rem_lines = 0; - cgit_diff_commit(commit, inspect_files, ctx.qry.vpath); - } - - if (ctx.repo->enable_log_filecount) - htmlf("</td><td>%d", files); - if (ctx.repo->enable_log_linecount) - htmlf("</td><td><span class='deletions'>-%d</span>/" - "<span class='insertions'>+%d</span>", rem_lines, add_lines); - - html("</td></tr>\n"); - - if ((revs->graph && !graph_is_commit_finished(revs->graph)) - || ctx.qry.showmsg) { /* Print a second table row */ - html("<tr class='nohover-highlight'>"); - - if (ctx.qry.showmsg) { - /* Concatenate commit message + notes in msgbuf */ - if (info->msg && *(info->msg)) { - strbuf_addstr(&msgbuf, info->msg); - strbuf_addch(&msgbuf, '\n'); - } - format_display_notes(&commit->object.oid, - &msgbuf, PAGE_ENCODING, 0); - strbuf_addch(&msgbuf, '\n'); - strbuf_ltrim(&msgbuf); - } - if (revs->graph) { - int lines = 0; - - /* Calculate graph padding */ - if (ctx.qry.showmsg) { - /* Count #lines in commit message + notes */ - const char *p = msgbuf.buf; - lines = 1; - while ((p = strchr(p, '\n'))) { - p++; - lines++; - } - } - - /* Print graph padding */ - html("<td class='commitgraph'>"); - while (lines > 0 || !graph_is_commit_finished(revs->graph)) { - if (graphbuf.len) - html("\n"); - strbuf_setlen(&graphbuf, 0); - graph_next_line(revs->graph, &graphbuf); - html(graphbuf.buf); - lines--; - } - html("</td>\n"); - } - else - html("<td/>"); /* Empty 'Age' column */ - - /* Print msgbuf into remainder of table row */ - htmlf("<td colspan='%d'%s>\n", columns - (revs->graph ? 1 : 0), - ctx.qry.showmsg ? " class='logmsg'" : ""); - html_txt(msgbuf.buf); - html("</td></tr>\n"); - } + _html("<li class='commit'><ul>") { + _html("<li class='avatar'>") { + gravatar_img(info->committer_email, 13); + } _html("</li>"); + + _html("<li class='commit-info'><ul>") { + + _html("<li class='title'") { + htmlf("<a href='/%s/commit/>id=%s'>%s</a>", + ctx.repo->name, oid_to_hex(&commit->object.oid), + info->subject); + } _html("</li>"); + + _html("<li class='author'>") { + htmlf("%s authored ", info->author); + cgit_print_age(info->author_date, info->author_tz, -1); + } _html("</li>"); + } _html("</ul></li>"); + + _html("<li class='hash'><ul>") { + html("<li><input type='text' value='"); + html_txt(oid_to_hex(&commit->object.oid)); + html("' readonly id='last-commit-value' /></li>"); + html("<li><span class='copy' " + "onclick=\"document.getElementById('last-commit-value')" + ".select(); document.execCommand('copy')\">" + "<i class='fa fa-copy'></i></span></li>"); + } _html("</ul></li>"); + + } _html("</ul></li>"); + + + /* htmlf("<tr%s>", ctx.qry.showmsg ? " class='logheader'" : "");*/ + + /*if (revs->graph) {*/ + /*[> Print graph segment for current commit <]*/ + /*html("<td class='commitgraph'>");*/ + /*html(graphbuf.buf);*/ + /*html("</td>");*/ + /*strbuf_setlen(&graphbuf, 0);*/ + /*}*/ + /*else {*/ + /*html("<td>");*/ + /*cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2);*/ + /*html("</td>");*/ + /*}*/ + + /*htmlf("<td%s>", ctx.qry.showmsg ? " class='logsubject'" : "");*/ + /*if (ctx.qry.showmsg) {*/ + /*[> line-wrap long commit subjects instead of truncating them <]*/ + /*size_t subject_len = strlen(info->subject);*/ + + /*if (subject_len > ctx.cfg.max_msg_len &&*/ + /*ctx.cfg.max_msg_len >= 15) {*/ + /*[> symbol for signaling line-wrap (in PAGE_ENCODING) <]*/ + /*const char wrap_symbol[] = { ' ', 0xE2, 0x86, 0xB5, 0 };*/ + /*int i = ctx.cfg.max_msg_len - strlen(wrap_symbol);*/ + + /*[> Rewind i to preceding space character <]*/ + /*while (i > 0 && !isspace(info->subject[i]))*/ + /*--i;*/ + /*if (!i) [> Oops, zero spaces. Reset i <]*/ + /*i = ctx.cfg.max_msg_len - strlen(wrap_symbol);*/ + + /*[> add remainder starting at i to msgbuf <]*/ + /*strbuf_add(&msgbuf, info->subject + i, subject_len - i);*/ + /*strbuf_trim(&msgbuf);*/ + /*strbuf_add(&msgbuf, "\n\n", 2);*/ + + /*[> Place wrap_symbol at position i in info->subject <]*/ + /*strcpy(info->subject + i, wrap_symbol);*/ + /*}*/ + /*}*/ + /*cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,*/ + /*oid_to_hex(&commit->object.oid), ctx.qry.vpath);*/ + /*show_commit_decorations(commit);*/ + /*html("</td><td>");*/ + + /*gravatar_img(info->author_email, 13);*/ + /*html_txt(info->author);*/ + + /*if (revs->graph) {*/ + /*html("</td><td>");*/ + /*cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2);*/ + /*}*/ + + /*if (!lines_counted && (ctx.repo->enable_log_filecount ||*/ + /*ctx.repo->enable_log_linecount)) {*/ + /*files = 0;*/ + /*add_lines = 0;*/ + /*rem_lines = 0;*/ + /*cgit_diff_commit(commit, inspect_files, ctx.qry.vpath);*/ + /*}*/ + + /*if (ctx.repo->enable_log_filecount)*/ + /*htmlf("</td><td>%d", files);*/ + /*if (ctx.repo->enable_log_linecount)*/ + /*htmlf("</td><td><span class='deletions'>-%d</span>/"*/ + /*"<span class='insertions'>+%d</span>", rem_lines, add_lines);*/ + + /*html("</td></tr>\n");*/ + + /*if ((revs->graph && !graph_is_commit_finished(revs->graph))*/ + /*|| ctx.qry.showmsg) { [> Print a second table row <]*/ + /*html("<tr class='nohover-highlight'>");*/ + + /*if (ctx.qry.showmsg) {*/ + /*[> Concatenate commit message + notes in msgbuf <]*/ + /*if (info->msg && *(info->msg)) {*/ + /*strbuf_addstr(&msgbuf, info->msg);*/ + /*strbuf_addch(&msgbuf, '\n');*/ + /*}*/ + /*format_display_notes(&commit->object.oid,*/ + /*&msgbuf, PAGE_ENCODING, 0);*/ + /*strbuf_addch(&msgbuf, '\n');*/ + /*strbuf_ltrim(&msgbuf);*/ + /*}*/ + + /*if (revs->graph) {*/ + /*int lines = 0;*/ + + /*[> Calculate graph padding <]*/ + /*if (ctx.qry.showmsg) {*/ + /*[> Count #lines in commit message + notes <]*/ + /*const char *p = msgbuf.buf;*/ + /*lines = 1;*/ + /*while ((p = strchr(p, '\n'))) {*/ + /*p++;*/ + /*lines++;*/ + /*}*/ + /*}*/ + + /*[> Print graph padding <]*/ + /*html("<td class='commitgraph'>");*/ + /*while (lines > 0 || !graph_is_commit_finished(revs->graph)) {*/ + /*if (graphbuf.len)*/ + /*html("\n");*/ + /*strbuf_setlen(&graphbuf, 0);*/ + /*graph_next_line(revs->graph, &graphbuf);*/ + /*html(graphbuf.buf);*/ + /*lines--;*/ + /*}*/ + /*html("</td>\n");*/ + /*}*/ + /*else*/ + /*html("<td/>"); [> Empty 'Age' column <]*/ + + /*[> Print msgbuf into remainder of table row <]*/ + /*htmlf("<td colspan='%d'%s>\n", columns - (revs->graph ? 1 : 0),*/ + /*ctx.qry.showmsg ? " class='logmsg'" : "");*/ + /*html_txt(msgbuf.buf);*/ + /*html("</td></tr>\n");*/ + /*}*/ strbuf_release(&msgbuf); strbuf_release(&graphbuf); @@ -436,7 +469,6 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern if (pager) { cgit_print_layout_start(); - html("<table class='list nowrap'>"); } /* rev_argv.argv[0] will be ignored by setup_revisions */ @@ -519,33 +551,36 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern prepare_revision_walk(&rev); reset_revision_walk(); - html("<tr class='nohover'>"); - if (commit_graph) - html("<th></th>"); - else - html("<th class='left'>Age</th>"); - html("<th class='left'>Commit message"); - if (pager) { - html(" ("); - cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL, - NULL, ctx.qry.head, ctx.qry.sha1, - ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep, - ctx.qry.search, ctx.qry.showmsg ? 0 : 1, - ctx.qry.follow); - html(")"); - } - html("</th><th class='left'>Author</th>"); - if (rev.graph) - html("<th class='left'>Age</th>"); - if (ctx.repo->enable_log_filecount) { - html("<th class='left'>Files</th>"); - columns++; - } - if (ctx.repo->enable_log_linecount) { - html("<th class='left'>Lines</th>"); - columns++; - } - html("</tr>\n"); + html("<div class='commit-list-container'"); + html("<ul class='commit-list'"); + + /* html("<tr class='nohover'>");*/ + /*if (commit_graph)*/ + /*html("<th></th>");*/ + /*else*/ + /*html("<th class='left'>Age</th>");*/ + /*html("<th class='left'>Commit message");*/ + /*if (pager) {*/ + /*html(" (");*/ + /*cgit_log_link(ctx.qry.showmsg ? "Collapse" : "Expand", NULL,*/ + /*NULL, ctx.qry.head, ctx.qry.sha1,*/ + /*ctx.qry.vpath, ctx.qry.ofs, ctx.qry.grep,*/ + /*ctx.qry.search, ctx.qry.showmsg ? 0 : 1,*/ + /*ctx.qry.follow);*/ + /*html(")");*/ + /*}*/ + /*html("</th><th class='left'>Author</th>");*/ + /*if (rev.graph)*/ + /*html("<th class='left'>Age</th>");*/ + /*if (ctx.repo->enable_log_filecount) {*/ + /*html("<th class='left'>Files</th>");*/ + /*columns++;*/ + /*}*/ + /*if (ctx.repo->enable_log_linecount) {*/ + /*html("<th class='left'>Lines</th>");*/ + /*columns++;*/ + /*}*/ + /*html("</tr>\n");*/ if (ofs<0) ofs = 0; @@ -579,8 +614,9 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern free_commit_list(commit->parents); commit->parents = NULL; } + html("</ul>"); if (pager) { - html("</table><ul class='pager'>"); + html("<ul class='pager'>"); if (ofs > 0) { html("<li>"); cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, @@ -609,6 +645,8 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern html("</td></tr>\n"); } + html("</div>"); + /* If we allocated tip then it is safe to cast away const. */ if (must_free_tip) free((char*) tip); diff --git a/ui-shared.c b/ui-shared.c @@ -1121,7 +1121,7 @@ void cgit_print_pageheader(void) } _html("</div>"); _html("<div class='summary-last-commit'>") { - _html("<div class='last-commit'>") { + _html("<div class='last-commit commit'>") { struct commit *commit; struct commitinfo *info; struct object_id oid;