From b228d4ff82a65fdcd4a7364759fe36a0bdda5978 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 16 Feb 2008 13:07:13 +0100 Subject: Add all config variables into struct cgit_context This removes another big set of global variables, and introduces the cgit_prepare_context() function which populates a context-variable with compile-time default values. Signed-off-by: Lars Hjemli --- ui-repolist.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index 3e97ca9..a6cc2cc 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -30,7 +30,7 @@ static void print_modtime(struct repoinfo *repo) char *path; struct stat s; - path = fmt("%s/%s", repo->path, cgit_agefile); + path = fmt("%s/%s", repo->path, ctx.cfg.agefile); if (stat(path, &s) == 0) { cgit_print_age(read_agefile(path), -1, NULL); return; @@ -47,17 +47,17 @@ void cgit_print_repolist(struct cacheitem *item) int i, columns = 4; char *last_group = NULL; - if (cgit_enable_index_links) + if (ctx.cfg.enable_index_links) columns++; - cgit_print_docstart(cgit_root_title, item); - cgit_print_pageheader(cgit_root_title, 0); + cgit_print_docstart(ctx.cfg.root_title, item); + cgit_print_pageheader(ctx.cfg.root_title, 0); html(""); - if (cgit_index_header) { + if (ctx.cfg.index_header) { htmlf(""); } html("" @@ -65,7 +65,7 @@ void cgit_print_repolist(struct cacheitem *item) "" "" ""); - if (cgit_enable_index_links) + if (ctx.cfg.enable_index_links) html(""); html("\n"); @@ -87,13 +87,13 @@ void cgit_print_repolist(struct cacheitem *item) html_txt(cgit_repo->name); html_link_close(); html(""); - if (cgit_enable_index_links) { + if (ctx.cfg.enable_index_links) { html("\n"); for (i=0; igroup != NULL) || - (last_group != NULL && cgit_repo->group == NULL) || - (last_group != NULL && cgit_repo->group != NULL && - strcmp(cgit_repo->group, last_group))) { + ctx.repo = &cgit_repolist.repos[i]; + if ((last_group == NULL && ctx.repo->group != NULL) || + (last_group != NULL && ctx.repo->group == NULL) || + (last_group != NULL && ctx.repo->group != NULL && + strcmp(ctx.repo->group, last_group))) { htmlf(""); - last_group = cgit_repo->group; + last_group = ctx.repo->group; } htmlf(""); if (ctx.cfg.enable_index_links) { html("
", columns); - html_include(cgit_index_header); + html_include(ctx.cfg.index_header); html("
DescriptionOwnerIdleLinks
"); - html_ntxt(cgit_max_repodesc_len, cgit_repo->desc); + html_ntxt(ctx.cfg.max_repodesc_len, cgit_repo->desc); html(""); html_txt(cgit_repo->owner); html(""); print_modtime(cgit_repo); html(""); html_link_open(cgit_repourl(cgit_repo->url), NULL, "button"); -- cgit v1.2.1 From d1f3bbe9d22029f45a77bb938c176ccc0c827d46 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 16 Feb 2008 13:56:09 +0100 Subject: Move cgit_repo into cgit_context This removes the global variable which is used to keep track of the currently selected repository, and adds a new variable in the cgit_context structure. Signed-off-by: Lars Hjemli --- ui-repolist.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index a6cc2cc..5fde174 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -25,7 +25,7 @@ time_t read_agefile(char *path) return 0; } -static void print_modtime(struct repoinfo *repo) +static void print_modtime(struct cgit_repo *repo) { char *path; struct stat s; @@ -70,32 +70,32 @@ void cgit_print_repolist(struct cacheitem *item) html("
", columns); - html_txt(cgit_repo->group); + html_txt(ctx.repo->group); html("
", - cgit_repo->group ? "sublevel-repo" : "toplevel-repo"); - html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL); - html_txt(cgit_repo->name); + ctx.repo->group ? "sublevel-repo" : "toplevel-repo"); + html_link_open(cgit_repourl(ctx.repo->url), NULL, NULL); + html_txt(ctx.repo->name); html_link_close(); html(""); - html_ntxt(ctx.cfg.max_repodesc_len, cgit_repo->desc); + html_ntxt(ctx.cfg.max_repodesc_len, ctx.repo->desc); html(""); - html_txt(cgit_repo->owner); + html_txt(ctx.repo->owner); html(""); - print_modtime(cgit_repo); + print_modtime(ctx.repo); html(""); - html_link_open(cgit_repourl(cgit_repo->url), + html_link_open(cgit_repourl(ctx.repo->url), NULL, "button"); html("summary"); cgit_log_link("log", NULL, "button", NULL, NULL, NULL, -- cgit v1.2.1 From b1f9b9c1459cb9a30ebf80721aff6ef788d1f891 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 23 Feb 2008 22:45:33 +0100 Subject: Introduce html.h All html-functions can be quite easily separated from the rest of cgit, so lets do it; the only issue was html_filemode which uses some git-defined macros so the function is moved into ui-shared.c::cgit_print_filemode(). Signed-off-by: Lars Hjemli --- ui-repolist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index 5fde174..cd4e41d 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -6,9 +6,10 @@ * (see COPYING for full license text) */ -#include "cgit.h" #include +#include "cgit.h" +#include "html.h" time_t read_agefile(char *path) { -- cgit v1.2.1 From f3c1a187fe2bc33f8423cd535d5045899699995b Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Mar 2008 00:51:19 +0100 Subject: Add struct cgit_page to cgit_context This struct is used when generating http headers, and as such is another small step towards the goal of the whole cleanup series; to invoke each page/view function with a function pointer. Signed-off-by: Lars Hjemli --- ui-repolist.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index cd4e41d..e663585 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -51,8 +51,10 @@ void cgit_print_repolist(struct cacheitem *item) if (ctx.cfg.enable_index_links) columns++; - cgit_print_docstart(ctx.cfg.root_title, item); - cgit_print_pageheader(ctx.cfg.root_title, 0); + ctx.page.title = ctx.cfg.root_title; + cgit_print_http_headers(&ctx); + cgit_print_docstart(&ctx); + cgit_print_pageheader(&ctx); html(""); if (ctx.cfg.index_header) { -- cgit v1.2.1 From b608e88adb6f77328288afb6dd0eddf674fc9b5b Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Mar 2008 01:00:36 +0100 Subject: Remove obsolete cacheitem parameter to ui-functions This parameter hasn't been used for a very long time... Signed-off-by: Lars Hjemli --- ui-repolist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index e663585..ad9b1bc 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -43,7 +43,7 @@ static void print_modtime(struct cgit_repo *repo) cgit_print_age(s.st_mtime, -1, NULL); } -void cgit_print_repolist(struct cacheitem *item) +void cgit_print_repolist() { int i, columns = 4; char *last_group = NULL; -- cgit v1.2.1 From a4d1ca1dc6ff8171694d9e2280b6075a1beced0c Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Mar 2008 16:50:57 +0100 Subject: Add ui-shared.h This is finally a proper headerfile for the shared ui-functions which used to reside in cgit.h Signed-off-by: Lars Hjemli --- ui-repolist.c | 1 + 1 file changed, 1 insertion(+) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index ad9b1bc..eeeaf3d 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -10,6 +10,7 @@ #include "cgit.h" #include "html.h" +#include "ui-shared.h" time_t read_agefile(char *path) { -- cgit v1.2.1