neocgit

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

commit fd92830ce99e8556df78135d575c68646eaf7951
parent 35149806e0fac52f8e296673907eec0bff218a10
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Tue, 10 Jul 2018 11:27:30 +0200

NEW: Now displaying commit full message in log

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

Diffstat:
Mcgit.css | 22++++++++++++++++++++++
Mui-log.c | 273+++++++++++++++++++++++++------------------------------------------------------
2 files changed, 109 insertions(+), 186 deletions(-)

diff --git a/cgit.css b/cgit.css @@ -506,6 +506,28 @@ option:not(:checked) { cursor: pointer; } +.commit .title button { + border-radius: 2px; + border: 1px solid #eee; + background: #fff; + margin-left: 10px; + transition-duration: 0.3s; + transition-property: all; +} + +.commit pre { + margin-left: 25px; + border-left: 2px solid rgb(112, 112, 112);; + padding-left: 10px; + color: #00000080; +} + +.commit .title button:hover { + background: #e6e3e3; + cursor: pointer; +} + + .repository-tree { padding: 10px 15px; } diff --git a/ui-log.c b/ui-log.c @@ -173,199 +173,100 @@ static int show_commit(struct commit *commit, struct rev_info *revs) static void print_commit(struct commit *commit, struct rev_info *revs) { - struct commitinfo *info; - int columns = revs->graph ? 4 : 3; - struct strbuf graphbuf = STRBUF_INIT; - struct strbuf msgbuf = STRBUF_INIT; - - if (ctx.repo->enable_log_filecount) - columns++; - 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 <]*/ - /*}*/ - - info = cgit_parse_commit(commit); - - _html("<li class='commit'><ul>") { - _html("<li class='avatar'>") { - gravatar_img(info->committer_email, 13); + struct commitinfo *info; + struct strbuf msgbuf = STRBUF_INIT; + char *hex = oid_to_hex(&commit->object.oid); + + info = cgit_parse_commit(commit); + + 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); + } + + 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); + + _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, hex, + info->subject); + + if (msgbuf.len > 0) + { + htmlf("<button class='show-commit-msg' onclick='" + "document.getElementById(\"commit-msg-%s\").style.display = \"block\"" + "'>...</button>", hex); + } } _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(" ago"); - } _html("</li>"); - } _html("</ul></li>"); - - _html("<li class='hash'><ul>") { - html("<li>"); { - htmlf("<input type='text' value='%s' readonly id='commit-hash-%s' />", - oid_to_hex(&commit->object.oid), oid_to_hex(&commit->object.oid)); - } html("</li>"); - - html("<li>"); { - htmlf("<span class='copy' " - "onclick=\"document.getElementById('commit-hash-%s')" - ".select(); document.execCommand('copy')\">" - "<i class='fa fa-copy'></i></span>", - oid_to_hex(&commit->object.oid)); - } html("</li>"); - - html("<li>"); { - htmlf("<a href='/%s/tree/?id=%s' class='tree'>" - "<i class='fa fa-folder'></i></a>", - ctx.repo->name, oid_to_hex(&commit->object.oid)); - } html("</li>"); - } _html("</ul></li>"); - + _html("<li class='author'>") { + htmlf("%s authored ", info->author); + cgit_print_age(info->author_date, info->author_tz, -1); + html(" ago"); + } _html("</li>"); } _html("</ul></li>"); + _html("<li class='hash'><ul>") { + html("<li>"); { + htmlf("<input type='text' value='%s' readonly id='commit-hash-%s' />", + hex, hex); + } html("</li>"); + + html("<li>"); { + htmlf("<span class='copy' " + "onclick=\"document.getElementById('commit-hash-%s')" + ".select(); document.execCommand('copy')\">" + "<i class='fa fa-copy'></i></span>", + hex); + } html("</li>"); + + html("<li>"); { + htmlf("<a href='/%s/tree/?id=%s' class='tree'>" + "<i class='fa fa-folder'></i></a>", + ctx.repo->name, hex); + } html("</li>"); + } _html("</ul></li>"); + htmlf("<pre id='commit-msg-%s' style='display: none;'>%s</pre>", hex, msgbuf.buf); + } _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); - cgit_free_commitinfo(info); + strbuf_release(&msgbuf); + cgit_free_commitinfo(info); } static const char *disambiguate_ref(const char *ref, int *must_free_result)