From eae408c064497a222cf6f5f89f2719d3ecdf18f0 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Fri, 27 Jul 2018 17:33:03 +0100 Subject: repolist working -- towards a proper summary --- ui_70-shared.c | 157 +++++++++++++++++++-------------------------------------- 1 file changed, 53 insertions(+), 104 deletions(-) (limited to 'ui_70-shared.c') diff --git a/ui_70-shared.c b/ui_70-shared.c index 990143c..30a1eaf 100644 --- a/ui_70-shared.c +++ b/ui_70-shared.c @@ -56,6 +56,10 @@ void cgit_gopher_text(const char *txt){ printf("%s", txt); } +void cgit_gopher_tab(){ + printf("\t"); +} + void gopher_vtxtf(const char *format, va_list ap) { @@ -207,18 +211,18 @@ char *cgit_currenturl(void) size_t len = strlen(root); if (!ctx.qry.url) - return xstrdup(root); + return fmtalloc("/%s", root); if (len && root[len - 1] == '/') - return fmtalloc("%s%s", root, ctx.qry.url); - return fmtalloc("%s/%s", root, ctx.qry.url); + return fmtalloc("/%s%s", root, ctx.qry.url); + return fmtalloc("/%s/%s", root, ctx.qry.url); } const char *cgit_rooturl(void) { if (ctx.cfg.virtual_root) - return ctx.cfg.virtual_root; + return fmtalloc("/%s", ctx.cfg.virtual_root); else - return ctx.cfg.script_name; + return fmtalloc("/%s", ctx.cfg.script_name); } const char *cgit_loginurl(void) @@ -305,55 +309,47 @@ static void site_url(const char *page, const char *search, const char *sort, int { char *delim = "?"; - if (always_root || page) - html_attr(cgit_rooturl()); + if (always_root || page){ + + cgit_gopher_text(cgit_rooturl()); + } else { char *currenturl = cgit_currenturl(); - html_attr(currenturl); + cgit_gopher_text(currenturl); free(currenturl); } if (page) { - htmlf("?p=%s", page); - delim = "&"; + cgit_gopher_textf("?p=%s", page); + delim = "&"; } if (search) { - html(delim); - html("q="); - html_attr(search); - delim = "&"; + cgit_gopher_text(delim); + cgit_gopher_text("q="); + cgit_gopher_text(search); + delim = "&"; } if (sort) { - html(delim); - html("s="); - html_attr(sort); - delim = "&"; + cgit_gopher_text(delim); + cgit_gopher_text("s="); + cgit_gopher_text(sort); + delim = "&"; } if (ofs) { - html(delim); - htmlf("ofs=%d", ofs); + cgit_gopher_text(delim); + cgit_gopher_textf("ofs=%d", ofs); } } static void site_link(const char *page, const char *name, const char *title, const char *class, const char *search, const char *sort, int ofs, int always_root) { - html(""); - html_txt(name); - html(""); + cgit_gopher_tab(); + cgit_gopher_end_selector(); } void cgit_index_link(const char *name, const char *title, const char *class, @@ -458,13 +454,18 @@ static void reporevlink(const char *page, const char *name, const char *title, cgit_gopher_text("id="); cgit_gopher_text(rev); } - cgit_gopher_text("\t"); + cgit_gopher_tab(); } void cgit_summary_link(const char *name, const char *title, const char *class, const char *head) { + + cgit_gopher_start_selector(GOPHER_MENU); + cgit_gopher_text(name); + cgit_gopher_tab(); reporevlink(NULL, name, title, class, head, NULL, NULL); + cgit_gopher_end_selector(); } void cgit_tag_link(const char *name, const char *title, const char *class, @@ -578,7 +579,11 @@ void cgit_commit_link(const char *name, const char *title, const char *class, void cgit_refs_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path) { + cgit_gopher_start_selector(GOPHER_MENU); + cgit_gopher_text(name); + cgit_gopher_tab(); reporevlink("refs", name, title, class, head, rev, path); + cgit_gopher_end_selector(); } void cgit_snapshot_link(const char *name, const char *title, const char *class, @@ -950,8 +955,8 @@ void cgit_print_error_page(int code, const char *msg, const char *fmt, ...) void cgit_print_layout_start(void) { - cgit_print_http_headers(); - cgit_print_docstart(); + /*cgit_print_http_headers(); + cgit_print_docstart();*/ cgit_print_pageheader(); } @@ -1054,73 +1059,32 @@ static void cgit_print_path_crumbs(char *path) ctx.qry.path = old_path; } -static void print_header(void) -{ - char *logo = NULL, *logo_link = NULL; - html("\n"); - html("\n"); - if (ctx.repo && ctx.repo->logo && *ctx.repo->logo) - logo = ctx.repo->logo; - else - logo = ctx.cfg.logo; - if (ctx.repo && ctx.repo->logo_link && *ctx.repo->logo_link) - logo_link = ctx.repo->logo_link; - else - logo_link = ctx.cfg.logo_link; - if (logo && *logo) { - html("\n"); - } - html("\n"); - - html("\n"); } void cgit_print_pageheader(void) { - html("
"); if (!ctx.env.authenticated || !ctx.cfg.noheader) print_header(); - html("
\n"); - if (ctx.env.authenticated && ctx.repo) { + if (ctx.repo) { if (ctx.repo->readme.nr) reporevlink("about", "about", NULL, hc("about"), ctx.qry.head, NULL, @@ -1158,19 +1122,6 @@ void cgit_print_pageheader(void) html_url_path(fileurl); free(fileurl); } - html("'>\n"); - cgit_add_hidden_formfields(1, 0, "log"); - html("\n"); - html("\n"); - html("\n"); - html("\n"); } else if (ctx.env.authenticated) { char *currenturl = cgit_currenturl(); site_link(NULL, "index", NULL, hc("repolist"), NULL, NULL, 0, 1); @@ -1188,7 +1139,6 @@ void cgit_print_pageheader(void) html(""); free(currenturl); } - html("
\n"); if (ctx.env.authenticated && ctx.repo && ctx.qry.vpath) { html("
"); html("path: "); @@ -1203,7 +1153,6 @@ void cgit_print_pageheader(void) } html("
"); } - html("
"); } void cgit_print_filemode(unsigned short mode) -- cgit v1.2.3