summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2007-06-18 22:56:40 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-06-18 22:56:40 (UTC)
commit0d05bca502f4a5347fa629045aca97ba9b404acc (patch) (side-by-side diff)
treee11b6a3e183aab02824f83c51759b5d426a64a67
parenta215bf4620113fcefb8dd3442bf3501bd648c463 (diff)
downloadcgit-0d05bca502f4a5347fa629045aca97ba9b404acc.zip
cgit-0d05bca502f4a5347fa629045aca97ba9b404acc.tar.gz
cgit-0d05bca502f4a5347fa629045aca97ba9b404acc.tar.bz2
Add setting to enable/disable extra links on index page
The summary/log/tree links displayed for each repository on the index page lost some of their purpose when the header menu was added, so this commit introduces the parameter 'enable-index-links' which must be set to 1 to enable these links. Suggested-by: Kristian Høgsberg <krh@bitplanet.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.h1
-rw-r--r--cgitrc4
-rw-r--r--shared.c3
-rw-r--r--ui-repolist.c25
4 files changed, 26 insertions, 7 deletions
diff --git a/cgit.h b/cgit.h
index bd2dd0d..81c819d 100644
--- a/cgit.h
+++ b/cgit.h
@@ -97,48 +97,49 @@ struct taginfo {
int tagger_date;
char *msg;
};
extern const char cgit_version[];
extern struct repolist cgit_repolist;
extern struct repoinfo *cgit_repo;
extern int cgit_cmd;
extern char *cgit_root_title;
extern char *cgit_css;
extern char *cgit_logo;
extern char *cgit_index_header;
extern char *cgit_logo_link;
extern char *cgit_module_link;
extern char *cgit_agefile;
extern char *cgit_virtual_root;
extern char *cgit_script_name;
extern char *cgit_cache_root;
extern char *cgit_repo_group;
extern int cgit_nocache;
extern int cgit_snapshots;
+extern int cgit_enable_index_links;
extern int cgit_enable_log_filecount;
extern int cgit_enable_log_linecount;
extern int cgit_max_lock_attempts;
extern int cgit_cache_root_ttl;
extern int cgit_cache_repo_ttl;
extern int cgit_cache_dynamic_ttl;
extern int cgit_cache_static_ttl;
extern int cgit_cache_max_create_time;
extern int cgit_summary_log;
extern int cgit_max_msg_len;
extern int cgit_max_repodesc_len;
extern int cgit_max_commit_count;
extern int cgit_query_has_symref;
extern int cgit_query_has_sha1;
extern char *cgit_querystring;
extern char *cgit_query_repo;
extern char *cgit_query_page;
extern char *cgit_query_search;
extern char *cgit_query_head;
extern char *cgit_query_sha1;
extern char *cgit_query_sha2;
diff --git a/cgitrc b/cgitrc
index 0f602e4..40877f8 100644
--- a/cgitrc
+++ b/cgitrc
@@ -1,38 +1,42 @@
##
## cgitrc: template for /etc/cgitrc
##
## Uncomment and set to 1 to deactivate caching of generated pages. Mostly
## usefull for testing.
#nocache=0
## Enable/disable snapshots by default. This can be overridden per repo
#snapshots=0
+## Enable/disable extra links to summary/log/tree per repo on index page
+#enable-index-links=0
+
+
## Enable/disable display of 'number of files changed' in log view
#enable-log-filecount=0
## Enable/disable display of 'number of lines changed' in log view
#enable-log-linecount=0
## Enable/disable display of HEAD shortlog in summary view. Set it to maximum
## number of commits that should be displayed
#summary-log=0
## Specify a root for virtual urls. This makes cgit generate urls like
##
## http://localhost/git/repo/log/?id=master
##
## instead of
##
## http://localhost/cgit/cgit.cgi?r=repo&p=log&id=master
##
## For this to work with apache, rewrite rules must be added to httpd.conf,
## possibly looking something like this:
##
diff --git a/shared.c b/shared.c
index f20fb5c..ab00bc9 100644
--- a/shared.c
+++ b/shared.c
@@ -5,48 +5,49 @@
* Licensed under GNU General Public License v2
* (see COPYING for full license text)
*/
#include "cgit.h"
struct repolist cgit_repolist;
struct repoinfo *cgit_repo;
int cgit_cmd;
char *cgit_root_title = "Git repository browser";
char *cgit_css = "/cgit.css";
char *cgit_logo = "/git-logo.png";
char *cgit_index_header = NULL;
char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
char *cgit_agefile = "info/web/last-modified";
char *cgit_virtual_root = NULL;
char *cgit_script_name = CGIT_SCRIPT_NAME;
char *cgit_cache_root = "/var/cache/cgit";
char *cgit_repo_group = NULL;
int cgit_nocache = 0;
int cgit_snapshots = 0;
+int cgit_enable_index_links = 0;
int cgit_enable_log_filecount = 0;
int cgit_enable_log_linecount = 0;
int cgit_max_lock_attempts = 5;
int cgit_cache_root_ttl = 5;
int cgit_cache_repo_ttl = 5;
int cgit_cache_dynamic_ttl = 5;
int cgit_cache_static_ttl = -1;
int cgit_cache_max_create_time = 5;
int cgit_summary_log = 0;
int cgit_max_msg_len = 60;
int cgit_max_repodesc_len = 60;
int cgit_max_commit_count = 50;
int cgit_query_has_symref = 0;
int cgit_query_has_sha1 = 0;
char *cgit_querystring = NULL;
char *cgit_query_repo = NULL;
char *cgit_query_page = NULL;
char *cgit_query_head = NULL;
char *cgit_query_search = NULL;
char *cgit_query_sha1 = NULL;
char *cgit_query_sha2 = NULL;
@@ -125,48 +126,50 @@ struct repoinfo *cgit_get_repoinfo(const char *url)
}
return NULL;
}
void cgit_global_config_cb(const char *name, const char *value)
{
if (!strcmp(name, "root-title"))
cgit_root_title = xstrdup(value);
else if (!strcmp(name, "css"))
cgit_css = xstrdup(value);
else if (!strcmp(name, "logo"))
cgit_logo = xstrdup(value);
else if (!strcmp(name, "index-header"))
cgit_index_header = xstrdup(value);
else if (!strcmp(name, "logo-link"))
cgit_logo_link = xstrdup(value);
else if (!strcmp(name, "module-link"))
cgit_module_link = xstrdup(value);
else if (!strcmp(name, "virtual-root"))
cgit_virtual_root = xstrdup(value);
else if (!strcmp(name, "nocache"))
cgit_nocache = atoi(value);
else if (!strcmp(name, "snapshots"))
cgit_snapshots = atoi(value);
+ else if (!strcmp(name, "enable-index-links"))
+ cgit_enable_index_links = atoi(value);
else if (!strcmp(name, "enable-log-filecount"))
cgit_enable_log_filecount = atoi(value);
else if (!strcmp(name, "enable-log-linecount"))
cgit_enable_log_linecount = atoi(value);
else if (!strcmp(name, "cache-root"))
cgit_cache_root = xstrdup(value);
else if (!strcmp(name, "cache-root-ttl"))
cgit_cache_root_ttl = atoi(value);
else if (!strcmp(name, "cache-repo-ttl"))
cgit_cache_repo_ttl = atoi(value);
else if (!strcmp(name, "cache-static-ttl"))
cgit_cache_static_ttl = atoi(value);
else if (!strcmp(name, "cache-dynamic-ttl"))
cgit_cache_dynamic_ttl = atoi(value);
else if (!strcmp(name, "max-message-length"))
cgit_max_msg_len = atoi(value);
else if (!strcmp(name, "max-repodesc-length"))
cgit_max_repodesc_len = atoi(value);
else if (!strcmp(name, "max-commit-count"))
cgit_max_commit_count = atoi(value);
else if (!strcmp(name, "summary-log"))
cgit_summary_log = atoi(value);
else if (!strcmp(name, "agefile"))
cgit_agefile = xstrdup(value);
diff --git a/ui-repolist.c b/ui-repolist.c
index 4f820a8..c735368 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -23,76 +23,87 @@ time_t read_agefile(char *path)
return strtoul(buf2, NULL, 10);
else
return 0;
}
static void print_modtime(struct repoinfo *repo)
{
char *path;
struct stat s;
path = fmt("%s/%s", repo->path, cgit_agefile);
if (stat(path, &s) == 0) {
cgit_print_age(read_agefile(path), -1, NULL);
return;
}
path = fmt("%s/refs/heads/%s", repo->path, repo->defbranch);
if (stat(path, &s) != 0)
return;
cgit_print_age(s.st_mtime, -1, NULL);
}
void cgit_print_repolist(struct cacheitem *item)
{
- int i;
+ int i, columns = 4;
char *last_group = NULL;
+ if (cgit_enable_index_links)
+ columns++;
+
cgit_print_docstart(cgit_root_title, item);
cgit_print_pageheader(cgit_root_title, 0);
html("<table class='list nowrap'>");
if (cgit_index_header) {
- html("<tr class='nohover'><td colspan='5' class='include-block'>");
+ htmlf("<tr class='nohover'><td colspan='%d' class='include-block'>",
+ columns);
html_include(cgit_index_header);
html("</td></tr>");
}
html("<tr class='nohover'>"
"<th class='left'>Name</th>"
"<th class='left'>Description</th>"
"<th class='left'>Owner</th>"
- "<th class='left'>Idle</th>"
- "<th>Links</th></tr>\n");
+ "<th class='left'>Idle</th>");
+ if (cgit_enable_index_links)
+ html("<th>Links</th>");
+ html("</tr>\n");
for (i=0; i<cgit_repolist.count; i++) {
cgit_repo = &cgit_repolist.repos[i];
if ((last_group == NULL && cgit_repo->group != NULL) ||
(last_group != NULL && cgit_repo->group == NULL) ||
(last_group != NULL && cgit_repo->group != NULL &&
strcmp(cgit_repo->group, last_group))) {
- html("<tr class='nohover'><td colspan='4' class='repogroup'>");
+ htmlf("<tr class='nohover'><td colspan='%d' class='repogroup'>",
+ columns);
html_txt(cgit_repo->group);
html("</td></tr>");
last_group = cgit_repo->group;
}
htmlf("<tr><td class='%s'>",
cgit_repo->group ? "sublevel-repo" : "toplevel-repo");
html_link_open(cgit_repourl(cgit_repo->url), NULL, NULL);
html_txt(cgit_repo->name);
html_link_close();
html("</td><td>");
html_ntxt(cgit_max_repodesc_len, cgit_repo->desc);
html("</td><td>");
html_txt(cgit_repo->owner);
html("</td><td>");
print_modtime(cgit_repo);
- html("</td><td>");
+ html("</td>");
+ if (cgit_enable_index_links) {
+ html("<td>");
html_link_open(cgit_repourl(cgit_repo->url),
NULL, "button");
html("summary</a>");
cgit_log_link("log", NULL, "button", NULL, NULL, NULL);
cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
- html("</td></tr>\n");
+ html("</td>");
+ }
+ html("</tr>\n");
}
html("</table>");
cgit_print_docend();
}