summaryrefslogtreecommitdiff
path: root/ui_70-shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui_70-shared.c')
-rw-r--r--ui_70-shared.c157
1 files changed, 53 insertions, 104 deletions
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("<a");
- if (title) {
- html(" title='");
- html_attr(title);
- html("'");
- }
- if (class) {
- html(" class='");
- html_attr(class);
- html("'");
- }
- html(" href='");
+ cgit_gopher_start_selector(GOPHER_MENU);
+ cgit_gopher_text(name);
+ cgit_gopher_tab();
site_url(page, search, sort, ofs, always_root);
- html("'>");
- html_txt(name);
- html("</a>");
+ 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("<table id='header'>\n");
- html("<tr>\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("<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_attr(logo);
- html("' alt='cgit logo'/></a></td>\n");
- }
- html("<td class='main'>");
+static void print_header(void)
+{
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'>");
+ cgit_gopher_info(ctx.cfg.root_title);
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);
+ cgit_gopher_start_selector(GOPHER_MENU);
+ cgit_gopher_text("Owner: ");
+ cgit_gopher_text(ctx.repo->owner);
+ cgit_gopher_tab();
+ cgit_gopher_selector_link("Err");
+ cgit_gopher_end_selector();
}
- html("</td></tr></table>\n");
}
void cgit_print_pageheader(void)
{
- html("<div id='cgit'>");
if (!ctx.env.authenticated || !ctx.cfg.noheader)
print_header();
- html("<table class='tabs'><tr><td>\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("<select name='qt'>\n");
- html_option("grep", "log msg", ctx.qry.grep);
- html_option("author", "author", ctx.qry.grep);
- html_option("committer", "committer", ctx.qry.grep);
- html_option("range", "range", ctx.qry.grep);
- html("</select>\n");
- html("<input class='txt' type='search' size='10' name='q' value='");
- html_attr(ctx.qry.search);
- 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);
@@ -1188,7 +1139,6 @@ void cgit_print_pageheader(void)
html("</form>");
free(currenturl);
}
- html("</td></tr></table>\n");
if (ctx.env.authenticated && ctx.repo && ctx.qry.vpath) {
html("<div class='path'>");
html("path: ");
@@ -1203,7 +1153,6 @@ void cgit_print_pageheader(void)
}
html("</div>");
}
- html("<div class='content'>");
}
void cgit_print_filemode(unsigned short mode)