neocgit

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

commit f781631f9e07a84b94834a3a7e8b523c76998cf4
parent a1721d480bfc5210cbd3619ad5c255e65b151047
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Thu, 28 Jun 2018 16:21:36 +0200

NEW: Menu and repo list reworked

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

Diffstat:
Mcgit.css | 182+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Mcgit.png | 0
Mhtml.h | 1+
Mui-repolist.c | 137++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mui-shared.c | 125++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
5 files changed, 289 insertions(+), 156 deletions(-)

diff --git a/cgit.css b/cgit.css @@ -11,7 +11,7 @@ div#cgit { font-family: sans-serif; font-size: 10pt; color: #333; - background: white; + background: #FFFFFF; } div#cgit a { @@ -27,51 +27,169 @@ div#cgit table { border-collapse: collapse; } -div#cgit table#header { - width: 100%; - margin-bottom: 1em; - background: black; +#header { + width: 100%; + background: #2C3E50; + color: #D7DADB; + padding: 0; } -div#cgit table#header td.logo { - width: 96px; - vertical-align: top; +#header ul { + display: inline-block; + list-style: none; + width: 100%; + padding: 4px; + margin: 0; } -div#cgit table#header td.main { - font-size: 250%; - padding-left: 10px; - white-space: nowrap; +#header ul li { + display: inline-block; + vertical-align: middle; } -div#cgit table#header td.main a { - color: #000; +#header ul img { + width: 30px; + height: auto; + padding-top: 2px; + float: left; } -div#cgit table#header td.form { - text-align: right; - vertical-align: bottom; - padding-right: 1em; - padding-bottom: 2px; - white-space: nowrap; +#header ul .root-title { + font-size: 1.3em; + margin-right: 15px; + border-radius: 5px; + padding: 2px 8px; } -div#cgit table#header td.form form, -div#cgit table#header td.form input, -div#cgit table#header td.form select { - font-size: 90%; +#header ul .root-title span { + display: inline-block; + float: left; + margin-top: 7px; + margin-left: 4px; + color: white; + font-weight: 600; } -div#cgit table#header td.sub { - color: #777; - border-top: solid 1px #ccc; - padding-left: 10px; +#header ul .menu-button { + margin-left: 5px; + padding: 7px 8px; + border-radius: 5px; + font-weight: 600; + transition-duration: 0.3s; + transition-property: all; +} + +#header ul .menu-button:not(.active):hover, #header ul .root-title:hover { + background: #D7DADB33; + cursor: pointer; +} + +#header ul .active { + background: #D7DADB; + color: #2C3E50; + transition-property: color; +} + +#header ul .search { + float: right; + margin-top: 2px; + margin-right: 10px; +} + +#header ul .search input { + width: 200px; + height: 30px; + border: 0; + border-radius: 5px; + padding-left: 5px; + background: #D7DADB4D; + color: white; + transition-duration: 0.3s; + transition-property: all; +} + +#header ul .search input:hover { + background: #D7DADB66; +} + +#header ul .search input:focus { + background: white; + color: #2C3E50; +} + +.sub-title { + text-align: center; + margin-top: 40px; + margin-bottom: 40px; +} + +.repo-list { + list-style: none; + padding: 0 15px; + margin: 0; +} + +.repo-list h5 { + margin-bottom: 0; + font-weight: 600; +} + +.repo-list ul { + list-style: none; + margin: 0; + padding: 0; +} + +.repo-entry { + border-bottom: 1px solid #eee; + padding: 7px 0; +} + +.repo-pad { + width: 100%; + display: inline-block; +} + +.repo-desc a { + color: black !important; +} + +.repo-pad li { + display: inline-block; +} + +.repo-title { + width: 100%; + padding-bottom: 5px; +} + +.repo-title a { + color: black !important; + font-weight: 600; +} + +.repo-infos { + width: 60%; +} + +.repo-details { + width: 40%; + text-align: right; + display: inline-block; +} + +.repo-links { + display: inline; + width: 100%; + padding-bottom: 5px; +} + +.repo-links li { + display: inline-block; } div#cgit table.tabs { - border-bottom: solid 3px #ccc; border-collapse: collapse; - margin-top: 2em; margin-bottom: 0px; width: 100%; } @@ -122,8 +240,8 @@ div#cgit div.path { div#cgit div.content { margin: 0px; - padding: 2em; - border-bottom: solid 3px #ccc; + /*padding: 2em;*/ + /*border-bottom: solid 3px #ccc;*/ } diff --git a/cgit.png b/cgit.png Binary files differ. diff --git a/html.h b/html.h @@ -4,6 +4,7 @@ #include "cgit.h" extern void html_raw(const char *txt, size_t size); +#define _html(txt) html(txt "\n"); extern void html(const char *txt); __attribute__((format (printf,1,2))) diff --git a/ui-repolist.c b/ui-repolist.c @@ -293,75 +293,76 @@ void cgit_print_repolist(void) else if (ctx.cfg.section_sort) sort_repolist("section"); - html("<h1>Hello!</h1>"); - html("<table summary='repository list' class='list nowrap'>"); + html("<h1 class='sub-title'>"); + html_txt(ctx.cfg.root_desc); + html("</h1>"); + html("<ul class='repo-list'>"); for (i = 0; i < cgit_repolist.count; i++) { - ctx.repo = &cgit_repolist.repos[i]; - if (!is_visible(ctx.repo)) - continue; - hits++; - if (hits <= ctx.qry.ofs) - continue; - if (hits > ctx.qry.ofs + ctx.cfg.max_repo_count) - continue; - if (!header++) - print_header(); - section = ctx.repo->section; - if (section && !strcmp(section, "")) - section = NULL; - if (!sorted && - ((last_section == NULL && section != NULL) || - (last_section != NULL && section == NULL) || - (last_section != NULL && section != NULL && - strcmp(section, last_section)))) { - htmlf("<tr class='nohover-highlight'><td colspan='%d' class='reposection'>", - columns); - html_txt(section); - html("</td></tr>"); - last_section = section; - } - htmlf("<tr><td class='%s'>", - !sorted && section ? "sublevel-repo" : "toplevel-repo"); - cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); - html("</td><td>"); - repourl = cgit_repourl(ctx.repo->url); - html_link_open(repourl, NULL, NULL); - free(repourl); - if (html_ntxt(ctx.repo->desc, ctx.cfg.max_repodesc_len) < 0) - html("..."); - html_link_close(); - html("</td><td>"); - if (ctx.cfg.enable_index_owner) { - if (ctx.repo->owner_filter) { - cgit_open_filter(ctx.repo->owner_filter); - html_txt(ctx.repo->owner); - cgit_close_filter(ctx.repo->owner_filter); - } else { - char *currenturl = cgit_currenturl(); - html("<a href='"); - html_attr(currenturl); - html("?q="); - html_url_arg(ctx.repo->owner); - html("'>"); - html_txt(ctx.repo->owner); - html("</a>"); - free(currenturl); - } - html("</td><td>"); - } - print_modtime(ctx.repo); - html("</td>"); - if (ctx.cfg.enable_index_links) { - html("<td>"); - cgit_summary_link("summary", NULL, "button", NULL); - cgit_log_link("log", NULL, "button", NULL, NULL, NULL, - 0, NULL, NULL, ctx.qry.showmsg, 0); - cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); - html("</td>"); - } - html("</tr>\n"); - } - html("</table>"); + ctx.repo = &cgit_repolist.repos[i]; + html("<li class='repo-entry'>"); + if (!is_visible(ctx.repo)) + continue; + hits++; + if (hits <= ctx.qry.ofs) + continue; + if (hits > ctx.qry.ofs + ctx.cfg.max_repo_count) + continue; + section = ctx.repo->section; + if (section && !strcmp(section, "")) + section = NULL; + if (!sorted && + ((last_section == NULL && section != NULL) || + (last_section != NULL && section == NULL) || + (last_section != NULL && section != NULL && + strcmp(section, last_section)))) + { + htmlf("<h5>%s</h5></li><li class='repo-entry'>", section); + last_section = section; + } + + _html("<ul class='repo-pad'>") { + + _html("<li class='repo-infos'><ul>") { + _html("<li class='repo-title'>") { + htmlf("<a href='/%s'>%s</a>", ctx.repo->name, ctx.repo->name); + } html("</li>"); + + _html("<li class='repo-desc'>") { + htmlf("<a href='/%s'>", ctx.repo->name, ctx.repo->name); + if (html_ntxt(ctx.repo->desc, ctx.cfg.max_repodesc_len) < 0) + html("..."); + html("</a>"); + } html("</li>"); + } html("</ul></li>"); + + _html("<li class='repo-details'><ul>") { + html("<li class='repo-links'><ul>"); { + _html("<li>") { + cgit_summary_link("summary", NULL, "button", NULL); + } html("</li>"); + + _html("<li>") { + cgit_log_link("log", NULL, "button", NULL, NULL, NULL, + 0, NULL, NULL, ctx.qry.showmsg, 0); + } html("</li>"); + + _html("<li>") { + cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); + } html("</li>"); + }; html("</ul></li>"); + + _html("<li>") { + html("updated "); + print_modtime(ctx.repo); + html(" ago"); + } html("</li>"); + } html("</ul></li>"); + + } html("</ul>"); + + html("</li>\n"); + } + html("</ul>"); if (hits > ctx.cfg.max_repo_count) print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search, ctx.qry.sort); cgit_print_docend(); diff --git a/ui-shared.c b/ui-shared.c @@ -794,7 +794,7 @@ void cgit_print_docend(void) if (ctx.cfg.footer) html_include(ctx.cfg.footer); else { - htmlf("<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit %s</a> " + htmlf("<div class='footer'>generated by <a href='https://git.ne02ptzero.me/neocgit/'>neocgit %s</a> " "(<a href='https://git-scm.com/'>git %s</a>) at ", cgit_version, git_version_string); html_txt(show_date(time(NULL), 0, cgit_date_mode(DATE_ISO8601))); html("</div>\n"); @@ -926,8 +926,13 @@ static void print_header(void) { char *logo = NULL, *logo_link = NULL; - html("<table id='header'>\n"); - html("<tr>\n"); + html("<div id='header'>"); + html("<ul>"); + + html("<li class='root-title'>"); + html("<a href='"); + html_attr(cgit_rooturl()); + html("'>"); if (ctx.repo && ctx.repo->logo && *ctx.repo->logo) logo = ctx.repo->logo; @@ -938,47 +943,71 @@ static void print_header(void) else logo_link = ctx.cfg.logo_link; if (logo && *logo) { - html("<td class='logo' rowspan='2'><a href='"); - if (logo_link && *logo_link) - html_attr(logo_link); - else - html_attr(cgit_rooturl()); - html("'><img src='"); + html("<img src='"); html_attr(logo); - html("' alt='cgit logo'/></a></td>\n"); + html("' alt='cgit logo'/>\n"); } - html("<td class='main'>"); - if (ctx.repo) { - cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1); - html(" : "); - cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL); - if (ctx.env.authenticated) { - html("</td><td class='form'>"); - html("<form method='get'>\n"); - cgit_add_hidden_formfields(0, 1, ctx.qry.page); - html("<select name='h' onchange='this.form.submit();'>\n"); - for_each_branch_ref(print_branch_option, ctx.qry.head); - if (ctx.repo->enable_remote_branches) - for_each_remote_ref(print_branch_option, ctx.qry.head); - html("</select> "); - html("<input type='submit' value='switch'/>"); - html("</form>"); - } - } else - html_txt(ctx.cfg.root_title); - html("</td></tr>\n"); - - html("<tr><td class='sub'>"); - if (ctx.repo) { - html_txt(ctx.repo->desc); - html("</td><td class='sub right'>"); - html_txt(ctx.repo->owner); - } else { - /*if (ctx.cfg.root_desc)*/ - /*html_txt(ctx.cfg.root_desc);*/ + html("<span>"); + html_txt(ctx.cfg.root_title); + html("</span></a></li>"); + + html("<li class='menu-button active'>"); + html("Projects"); + html("</li>"); + + html("<li class='menu-button'>"); + html("Contribute"); + html("</li>"); + + if (ctx.repo != NULL) + { + // XXX: repo } - html("</td></tr></table>\n"); + + 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' />"); + html("</form>"); + html("</li>"); + + html("</ul>"); + html("</div>"); + + /* html("<td class='main'>");*/ + /*if (ctx.repo) {*/ + /*cgit_index_link("index", NULL, NULL, NULL, NULL, 0, 1);*/ + /*html(" : ");*/ + /*cgit_summary_link(ctx.repo->name, ctx.repo->name, NULL, NULL);*/ + /*if (ctx.env.authenticated) {*/ + /*html("</td><td class='form'>");*/ + /*html("<form method='get'>\n");*/ + /*cgit_add_hidden_formfields(0, 1, ctx.qry.page);*/ + /*html("<select name='h' onchange='this.form.submit();'>\n");*/ + /*for_each_branch_ref(print_branch_option, ctx.qry.head);*/ + /*if (ctx.repo->enable_remote_branches)*/ + /*for_each_remote_ref(print_branch_option, ctx.qry.head);*/ + /*html("</select> ");*/ + /*html("<input type='submit' value='switch'/>");*/ + /*html("</form>");*/ + /*}*/ + /*} else*/ + /*html_txt(ctx.cfg.root_title);*/ + /*html("</td></tr>\n");*/ + + /*html("<tr><td class='sub'>");*/ + /*if (ctx.repo) {*/ + /*html_txt(ctx.repo->desc);*/ + /*html("</td><td class='sub right'>");*/ + /*html_txt(ctx.repo->owner);*/ + /*} else {*/ + /*[>if (ctx.cfg.root_desc)<]*/ + /*[>html_txt(ctx.cfg.root_desc);<]*/ + /*}*/ + /*html("</td></tr></table>\n");*/ } void cgit_print_pageheader(void) @@ -1039,22 +1068,6 @@ void cgit_print_pageheader(void) html("'/>\n"); html("<input type='submit' value='search'/>\n"); html("</form>\n"); - } else if (ctx.env.authenticated) { - char *currenturl = cgit_currenturl(); - site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1); - if (ctx.cfg.root_readme) - site_link("about", "about", NULL, hc("about"), - NULL, NULL, 0, 1); - html("</td><td class='form'>"); - html("<form method='get' action='"); - html_attr(currenturl); - html("'>\n"); - html("<input type='search' name='q' size='10' value='"); - html_attr(ctx.qry.search); - html("'/>\n"); - html("<input type='submit' value='search'/>\n"); - html("</form>"); - free(currenturl); } html("</td></tr></table>\n"); if (ctx.env.authenticated && ctx.repo && ctx.qry.vpath) {