From d14d77fe95c3b6224b40df9b101dded0deea913c Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 16 Feb 2008 11:53:40 +0100 Subject: Introduce struct cgit_context This struct will hold all the cgit runtime information currently found in a multitude of global variables. The first cleanup removes all querystring-related variables. Signed-off-by: Lars Hjemli --- ui-summary.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ui-summary.c') diff --git a/ui-summary.c b/ui-summary.c index b96414e..bbd4464 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -94,7 +94,7 @@ static int print_tag(struct refinfo *ref) if (!tag || !info) return 1; html(""); - url = cgit_pageurl(cgit_query_repo, "tag", + url = cgit_pageurl(ctx.qry.repo, "tag", fmt("id=%s", name)); html_link_open(url, NULL, NULL); html_txt(name); @@ -123,7 +123,7 @@ static int print_tag(struct refinfo *ref) static void print_refs_link(char *path) { html(""); - cgit_refs_link("[...]", NULL, NULL, cgit_query_head, NULL, path); + cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); html(""); } @@ -188,7 +188,7 @@ void cgit_print_summary() html(""); } if (cgit_summary_log > 0) - cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, + cgit_print_log(ctx.qry.head, 0, cgit_summary_log, NULL, NULL, NULL, 0); html(""); if (cgit_summary_log > 0) -- cgit v1.2.3 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-summary.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ui-summary.c') diff --git a/ui-summary.c b/ui-summary.c index bbd4464..0a44994 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -187,14 +187,14 @@ void cgit_print_summary() html_include(cgit_repo->readme); html(""); } - if (cgit_summary_log > 0) - cgit_print_log(ctx.qry.head, 0, cgit_summary_log, NULL, + if (ctx.cfg.summary_log > 0) + cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, NULL, NULL, 0); html("
"); - if (cgit_summary_log > 0) + if (ctx.cfg.summary_log > 0) html(""); - cgit_print_branches(cgit_summary_branches); + cgit_print_branches(ctx.cfg.summary_branches); html(""); - cgit_print_tags(cgit_summary_tags); + cgit_print_tags(ctx.cfg.summary_tags); html("
 
 
"); } -- cgit v1.2.3 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-summary.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui-summary.c') diff --git a/ui-summary.c b/ui-summary.c index 0a44994..3baac08 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -182,9 +182,9 @@ void cgit_print_tags(int maxcount) void cgit_print_summary() { - if (cgit_repo->readme) { + if (ctx.repo->readme) { html("
"); - html_include(cgit_repo->readme); + html_include(ctx.repo->readme); html("
"); } if (ctx.cfg.summary_log > 0) -- cgit v1.2.3 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-summary.c | 1 + 1 file changed, 1 insertion(+) (limited to 'ui-summary.c') diff --git a/ui-summary.c b/ui-summary.c index 3baac08..0afa0a3 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -7,6 +7,7 @@ */ #include "cgit.h" +#include "html.h" static int header; -- cgit v1.2.3 From c5984a9896b39748e61daf6e620483749654b102 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 24 Mar 2008 16:38:47 +0100 Subject: Add separate header-files for each page/view Yet another step towards removing cgit.h. Signed-off-by: Lars Hjemli --- ui-summary.c | 174 +---------------------------------------------------------- 1 file changed, 2 insertions(+), 172 deletions(-) (limited to 'ui-summary.c') diff --git a/ui-summary.c b/ui-summary.c index 0afa0a3..0b66b52 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -8,178 +8,8 @@ #include "cgit.h" #include "html.h" - -static int header; - -static int cmp_age(int age1, int age2) -{ - if (age1 != 0 && age2 != 0) - return age2 - age1; - - if (age1 == 0 && age2 == 0) - return 0; - - if (age1 == 0) - return +1; - - return -1; -} - -static int cmp_ref_name(const void *a, const void *b) -{ - struct refinfo *r1 = *(struct refinfo **)a; - struct refinfo *r2 = *(struct refinfo **)b; - - return strcmp(r1->refname, r2->refname); -} - -static int cmp_branch_age(const void *a, const void *b) -{ - struct refinfo *r1 = *(struct refinfo **)a; - struct refinfo *r2 = *(struct refinfo **)b; - - return cmp_age(r1->commit->committer_date, r2->commit->committer_date); -} - -static int cmp_tag_age(const void *a, const void *b) -{ - struct refinfo *r1 = *(struct refinfo **)a; - struct refinfo *r2 = *(struct refinfo **)b; - - return cmp_age(r1->tag->tagger_date, r2->tag->tagger_date); -} - -static int print_branch(struct refinfo *ref) -{ - struct commitinfo *info = ref->commit; - char *name = (char *)ref->refname; - - if (!info) - return 1; - html(""); - cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL); - html(""); - - if (ref->object->type == OBJ_COMMIT) { - cgit_print_age(info->commit->date, -1, NULL); - html(""); - html_txt(info->author); - html(""); - cgit_commit_link(info->subject, NULL, NULL, name, NULL); - } else { - html(""); - cgit_object_link(ref->object); - } - html("\n"); - return 0; -} - -static void print_tag_header() -{ - html("Tag" - "Age" - "Author" - "Reference\n"); - header = 1; -} - -static int print_tag(struct refinfo *ref) -{ - struct tag *tag; - struct taginfo *info; - char *url, *name = (char *)ref->refname; - - if (ref->object->type == OBJ_TAG) { - tag = (struct tag *)ref->object; - info = ref->tag; - if (!tag || !info) - return 1; - html(""); - url = cgit_pageurl(ctx.qry.repo, "tag", - fmt("id=%s", name)); - html_link_open(url, NULL, NULL); - html_txt(name); - html_link_close(); - html(""); - if (info->tagger_date > 0) - cgit_print_age(info->tagger_date, -1, NULL); - html(""); - if (info->tagger) - html(info->tagger); - html(""); - cgit_object_link(tag->tagged); - html("\n"); - } else { - if (!header) - print_tag_header(); - html(""); - html_txt(name); - html(""); - cgit_object_link(ref->object); - html("\n"); - } - return 0; -} - -static void print_refs_link(char *path) -{ - html(""); - cgit_refs_link("[...]", NULL, NULL, ctx.qry.head, NULL, path); - html(""); -} - -void cgit_print_branches(int maxcount) -{ - struct reflist list; - int i; - - html("Branch" - "Idle" - "Author" - "Head commit\n"); - - list.refs = NULL; - list.alloc = list.count = 0; - for_each_branch_ref(cgit_refs_cb, &list); - - if (maxcount == 0 || maxcount > list.count) - maxcount = list.count; - - if (maxcount < list.count) { - qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); - qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); - } - - for(i=0; i list.count) - maxcount = list.count; - print_tag_header(); - for(i=0; i