neocgit

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

commit ec5e64da4240995f589f7de91b77bf7a1b2914a8
parent b11fde70a236802ba4bb27507dab82870e3129c8
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon,  2 Jul 2018 19:52:50 +0200

FIX: Proper commit copy and search is working

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

Diffstat:
Mcgit.css | 62++++++++++++++++++++++++++++++++++++++++++++++++++------------
Mui-shared.c | 32+++++++++++++++++++++++---------
Mui-tree.c | 4++--
3 files changed, 75 insertions(+), 23 deletions(-)

diff --git a/cgit.css b/cgit.css @@ -280,11 +280,10 @@ div#cgit table { text-align: center; border: 1px solid #e5e5e5; border-radius: 3px; - padding: 5px 15px; + padding: 5px 15px 5px; border-bottom-left-radius: 0; border-top-left-radius: 0; color: #7e7c7c !important; - height: 100%; margin: 0; margin-left: -5px; transition-duration: 0.3s; @@ -403,24 +402,27 @@ div#cgit table { } .last-commit ul li { - display: inline-block; + display: inline-grid; vertical-align: middle; margin: 0; padding: 0; } .last-commit .avatar { - width: 6%; - max-width: 40px; + width: 5%; + text-align: center; } .last-commit .avatar img { - width: 90%; + width: 100%; height: auto; + max-width: 40px; + margin-left: auto; + margin-right: auto; } .last-commit ul .commit-info { - width: 84%; + width: calc(95% - 138px); padding: 0; margin: 0; } @@ -428,10 +430,12 @@ div#cgit table { .last-commit ul .commit-info ul { padding: 0; margin: 0; + padding-left: 16px; } .last-commit ul .commit-info ul li { width: 100%; + display: inline-block; } .last-commit ul .commit-info ul .title a { @@ -440,20 +444,53 @@ div#cgit table { } .last-commit .hash { - width: calc(10% - 8px); - float: right; + width: 138px; } -.last-commit .hash input { +.last-commit .hash ul { + margin: 0; + padding: 0; width: 100%; + list-style: none; + display: inline-block; +} + +.last-commit .hash ul li { + display: inline; +} + +.last-commit .hash input { + width: calc(100% - 62px); background: transparent; border: 1px solid #eee; padding: 5px 5px; border-radius: 3px; - margin-left: -10px; - margin-top: 5px; + border-bottom-right-radius: 0; + border-top-right-radius: 0; + font-size: 14px; +} + +.last-commit .copy { + text-align: center; + border: 1px solid #eee; + border-radius: 3px; + padding: 5px 15px 5px; + border-bottom-left-radius: 0; + border-top-left-radius: 0; + color: #7e7c7c !important; + transition-duration: 0.3s; + transition-property: all; + font-size: 14px; + width: 30px; + margin-left: -1px; +} + +.last-commit .copy:hover { + background: #e6e3e3; + cursor: pointer; } + .repository-tree { padding: 10px 15px; } @@ -468,6 +505,7 @@ div#cgit table { border-top: 1px solid #f0f0f0; } + .repo-tree table .tree-entry:hover { cursor: pointer; background: #fafafa; diff --git a/ui-shared.c b/ui-shared.c @@ -997,9 +997,17 @@ static void print_header(void) char *current_url = cgit_currenturl(); html("<li class='search'>"); html("<form method='get' action='"); - html_attr(current_url); - html("'>"); - html("<input type='text' name='q' placeholder='Search' />"); + if (ctx.repo) + { + htmlf("/%s/log/'>", ctx.repo->name); + htmlf("<input type='hidden' name='qt' value='grep' />"); + } + else + { + html_attr(current_url); + html("'>"); + } + html("<input type='text' name='q' placeholder='Search ..' />"); html("</form>"); html("</li>"); @@ -1131,7 +1139,7 @@ void cgit_print_pageheader(void) cgit_open_filter(ctx.repo->email_filter, info->committer_email, "commit"); html_txt(info->committer); cgit_close_filter(ctx.repo->email_filter); - } _html("</li>"); + } html("</li>"); _html("<li class='commit-info'><ul>") { htmlf("<li class='title'><a href='/%s/commit/?id=%s'>%s</a></li>", @@ -1139,13 +1147,19 @@ void cgit_print_pageheader(void) htmlf("<li class='author'>%s authored ", info->author); cgit_print_age(info->author_date, info->author_tz, -1); html(" ago</li>"); - } _html("</ul></li>"); + } html("</ul></li>"); - _html("<li class='hash'>") { - html("<input type='text' value='"); + _html("<li class='hash'><ul>") { + html("<li><input type='text' value='"); html_txt(oid_to_hex(&commit->object.oid)); - html("' readonly />"); - } _html("</li>"); + 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>"); } _html("</div>"); diff --git a/ui-tree.c b/ui-tree.c @@ -452,7 +452,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co if (ctx.qry.path) { htmlf("<tr onclick=\"location.href='/%s/tree/%s/../?h=%s'\" class='tree-entry'>" - "<td><span>..</span></td><td></td><td</td></tr>", + "<td><span>..</span></td><td></td><td></td></tr>", ctx.repo->name, ctx.qry.path, ctx.qry.head); } @@ -561,7 +561,7 @@ void cgit_print_tree(const char *rev, char *path, bool layout) if (ctx.qry.path) { htmlf("<tr onclick=\"location.href='/%s/tree/%s/../?h=%s'\" class='tree-entry'>" - "<td><span>..</span></td><td></td><td</td></tr>", + "<td><span>..</span></td><td></td><td></td></tr>", ctx.repo->name, ctx.qry.path, ctx.qry.head); }