aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cgit.c5
-rw-r--r--cgit.h1
-rw-r--r--cmd.c5
-rw-r--r--configfile.c3
-rw-r--r--ui-plain.c2
-rw-r--r--ui-plain.h2
-rw-r--r--ui-repolist.c9
-rw-r--r--ui-shared.c15
-rw-r--r--ui-shared.h5
-rw-r--r--ui-summary.c85
-rw-r--r--ui-tree.c11
11 files changed, 104 insertions, 39 deletions
diff --git a/cgit.c b/cgit.c
index 2efa962..d256b14 100644
--- a/cgit.c
+++ b/cgit.c
@@ -153,6 +153,8 @@ static void config_cb(const char *name, const char *value)
ctx.cfg.footer = xstrdup(value);
else if (!strcmp(name, "head-include"))
ctx.cfg.head_include = xstrdup(value);
+ else if (!strcmp(name, "default-index"))
+ ctx.cfg.default_index = xstrdup(value);
else if (!strcmp(name, "header"))
ctx.cfg.header = xstrdup(value);
else if (!strcmp(name, "logo"))
@@ -412,6 +414,7 @@ static void prepare_context(void)
ctx.cfg.summary_tags = 10;
ctx.cfg.max_atom_items = 10;
ctx.cfg.difftype = DIFF_UNIFIED;
+ ctx.cfg.default_index = "summary";
ctx.env.cgit_config = getenv("CGIT_CONFIG");
ctx.env.http_host = getenv("HTTP_HOST");
ctx.env.https = getenv("HTTPS");
@@ -1065,8 +1068,8 @@ int cmd_main(int argc, const char **argv)
prepare_context();
cgit_repolist.length = 0;
- cgit_repolist.count = 0;
cgit_repolist.repos = NULL;
+ cgit_repolist.count = 0;
cgit_parse_args(argc, argv);
parse_configfile(expand_macros(ctx.env.cgit_config), config_cb);
diff --git a/cgit.h b/cgit.h
index e0d286d..6c7f056 100644
--- a/cgit.h
+++ b/cgit.h
@@ -200,6 +200,7 @@ struct cgit_config {
char *cache_root;
char *clone_prefix;
char *clone_url;
+ char *default_index;
char *favicon;
char *footer;
char *head_include;
diff --git a/cmd.c b/cmd.c
index 0eb75b1..dd1acd1 100644
--- a/cmd.c
+++ b/cmd.c
@@ -193,14 +193,13 @@ struct cgit_cmd *cgit_get_cmd(void)
def_cmd(tree, 1, 1, 0),
};
int i;
-
if (ctx.qry.page == NULL) {
if (ctx.repo)
- ctx.qry.page = "summary";
+ ctx.qry.page = ctx.cfg.default_index;
else
ctx.qry.page = "repolist";
}
-
+
for (i = 0; i < sizeof(cmds)/sizeof(*cmds); i++)
if (!strcmp(ctx.qry.page, cmds[i].name))
return &cmds[i];
diff --git a/configfile.c b/configfile.c
index e039109..56b5f5b 100644
--- a/configfile.c
+++ b/configfile.c
@@ -79,8 +79,9 @@ int parse_configfile(const char *filename, configfile_value_fn fn)
if (!(f = fopen(filename, "r")))
return -1;
nesting++;
- while (read_config_line(f, &name, &value))
+ while (read_config_line(f, &name, &value)) {
fn(name.buf, value.buf);
+ }
nesting--;
fclose(f);
strbuf_release(&name);
diff --git a/ui-plain.c b/ui-plain.c
index 4d69607..d95fb22 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -18,7 +18,7 @@ struct walk_tree_context {
int match;
};
-static int print_object(const struct object_id *oid, const char *path)
+int print_object(const struct object_id *oid, const char *path)
{
enum object_type type;
char *buf, *mimetype;
diff --git a/ui-plain.h b/ui-plain.h
index 5bff07b..648206a 100644
--- a/ui-plain.h
+++ b/ui-plain.h
@@ -2,5 +2,5 @@
#define UI_PLAIN_H
extern void cgit_print_plain(void);
-
+extern int print_object(const struct object_id *oid, const char *path);
#endif /* UI_PLAIN_H */
diff --git a/ui-repolist.c b/ui-repolist.c
index d12e3dd..54c6f6a 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -274,7 +274,7 @@ void cgit_print_repolist(void)
int sorted = 0;
if (!any_repos_visible()) {
- cgit_print_error_page(404, "Not found", "No repositories found");
+ cgit_print_error_page(404, "Not found", "No repositories found :(");
return;
}
@@ -321,7 +321,12 @@ void cgit_print_repolist(void)
}
htmlf("<tr><td class='%s'>",
!sorted && section ? "sublevel-repo" : "toplevel-repo");
- cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
+ /* TODO: ctx.repo->readme.nr is always equal to 6, but it should not be.
+ * The check does not work for now */
+ if (!ctx.repo->readme.nr && !strcmp(ctx.cfg.default_index, "about"))
+ cgit_summary_link(ctx.repo->name, NULL, NULL, NULL);
+ else
+ cgit_reporevlink(ctx.cfg.default_index, ctx.repo->name, NULL, NULL, NULL, NULL, NULL);
html("</td><td>");
repourl = cgit_repourl(ctx.repo->url);
html_link_open(repourl, NULL, NULL);
diff --git a/ui-shared.c b/ui-shared.c
index 6fae72d..82c6ca3 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -330,10 +330,23 @@ static void reporevlink(const char *page, const char *name, const char *title,
html("</a>");
}
+void cgit_reporevlink(const char *page, const char *name, const char *title,
+ const char *class, const char *head, const char *rev,
+ const char *path)
+{
+ reporevlink(page, name, title, class, head, rev, path);
+}
+
+void cgit_about_link(const char *name, const char *title, const char *class,
+ const char *head)
+{
+ reporevlink("about", name, title, class, head, NULL, NULL);
+}
+
void cgit_summary_link(const char *name, const char *title, const char *class,
const char *head)
{
- reporevlink(NULL, name, title, class, head, NULL, NULL);
+ reporevlink("summary", name, title, class, head, NULL, NULL);
}
void cgit_tag_link(const char *name, const char *title, const char *class,
diff --git a/ui-shared.h b/ui-shared.h
index f12fa99..f332581 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -15,8 +15,13 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename,
extern void cgit_add_clone_urls(void (*fn)(const char *));
+extern void cgit_reporevlink(const char *page, const char *name, const char *title,
+ const char *class, const char *head, const char *rev,
+ const char *path);
extern void cgit_index_link(const char *name, const char *title,
const char *class, const char *pattern, const char *sort, int ofs, int always_root);
+void cgit_about_link(const char *name, const char *title, const char *class,
+ const char *head);
extern void cgit_summary_link(const char *name, const char *title,
const char *class, const char *head);
extern void cgit_tag_link(const char *name, const char *title,
diff --git a/ui-summary.c b/ui-summary.c
index 947812a..dcf39af 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -40,31 +40,6 @@ static void print_url(const char *url)
html("</a></td></tr>\n");
}
-void cgit_print_summary(void)
-{
- int columns = 3;
-
- if (ctx.repo->enable_log_filecount)
- columns++;
- if (ctx.repo->enable_log_linecount)
- columns++;
-
- cgit_print_layout_start();
- html("<table summary='repository info' class='list nowrap'>");
- cgit_print_branches(ctx.cfg.summary_branches);
- htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
- cgit_print_tags(ctx.cfg.summary_tags);
- if (ctx.cfg.summary_log > 0) {
- htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
- cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
- NULL, NULL, 0, 0, 0);
- }
- urls = 0;
- cgit_add_clone_urls(print_url);
- html("</table>");
- cgit_print_layout_end();
-}
-
/* The caller must free the return value. */
static char* append_readme_path(const char *filename, const char *ref, const char *path)
{
@@ -98,6 +73,64 @@ static char* append_readme_path(const char *filename, const char *ref, const cha
return full_path;
}
+/*
+static void cgit_print_readme_into_summary(const char *path) {
+ char *filename, *ref;
+ int free_filename = 0;
+
+ if (ctx.repo->readme.nr == 0)
+ return;
+
+ filename = ctx.repo->readme.items[0].string;
+ ref = ctx.repo->readme.items[0].util;
+
+ if (path) {
+ free_filename = 1;
+ filename = append_readme_path(filename, ref, path);
+ if (!filename)
+ return;
+ }
+
+ cgit_open_filter(ctx.repo->about_filter, filename);
+ if (ref)
+ cgit_print_file(filename, ref, 1);
+ else
+ html_include(filename);
+ cgit_close_filter(ctx.repo->about_filter);
+
+ html("</div>");
+ if (free_filename)
+ free(filename);
+}
+*/
+
+void cgit_print_summary(void)
+{
+ int columns = 3;
+
+ if (ctx.repo->enable_log_filecount)
+ columns++;
+ if (ctx.repo->enable_log_linecount)
+ columns++;
+
+ cgit_print_layout_start();
+ html("<table summary='repository info' class='list nowrap'>");
+ cgit_print_branches(ctx.cfg.summary_branches);
+ htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
+ cgit_print_tags(ctx.cfg.summary_tags);
+ if (ctx.cfg.summary_log > 0) {
+ htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
+ cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
+ NULL, NULL, 0, 0, 0);
+ }
+ urls = 0;
+ cgit_add_clone_urls(print_url);
+ html("</table>");
+ //html("<b>Down here should be readme:</b>");
+ //if (ctx.repo->readme.nr)
+ // cgit_print_readme_into_summary(ctx.qry.path);
+ cgit_print_layout_end();
+}
void cgit_print_repo_readme(const char *path)
{
@@ -128,7 +161,7 @@ void cgit_print_repo_readme(const char *path)
goto done;
}
- /* Print the calculated readme, either from the git repo or from the
+ /* print the calculated readme, either from the git repo or from the
* filesystem, while applying the about-filter.
*/
html("<div id='summary'>");
diff --git a/ui-tree.c b/ui-tree.c
index 3d8a2eb..9fa265b 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -10,6 +10,7 @@
#include "cgit.h"
#include "ui-tree.h"
+// #include "ui-plain.h"
#include "html.h"
#include "ui-shared.h"
@@ -127,10 +128,14 @@ static void print_object(const struct object_id *oid, const char *path, const ch
return;
}
- if (is_binary)
- print_binary_buffer(buf, size);
- else
+ if (is_binary) {
+ //int print_object(const struct object_id *oid, const char *path)
+ //if (1) print_object();
+ /*else*/ print_binary_buffer(buf, size);
+ }
+ else {
print_text_buffer(basename, buf, size);
+ }
free(buf);
}