summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h2
-rw-r--r--cgitrc7
-rw-r--r--shared.c5
-rw-r--r--ui-shared.c17
4 files changed, 31 insertions, 0 deletions
diff --git a/cgit.h b/cgit.h
index ab0efeb..f223dbc 100644
--- a/cgit.h
+++ b/cgit.h
@@ -66,24 +66,25 @@ struct cacheitem {
};
struct repoinfo {
char *url;
char *name;
char *path;
char *desc;
char *owner;
char *defbranch;
char *group;
char *module_link;
char *readme;
+ char *clone_url;
int snapshots;
int enable_log_filecount;
int enable_log_linecount;
};
struct repolist {
int length;
int count;
struct repoinfo *repos;
};
struct commitinfo {
@@ -131,24 +132,25 @@ extern char *cgit_root_title;
extern char *cgit_css;
extern char *cgit_logo;
extern char *cgit_index_header;
extern char *cgit_index_info;
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 char *cgit_robots;
+extern char *cgit_clone_prefix;
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;
diff --git a/cgitrc b/cgitrc
index 8c616e0..ce0c01b 100644
--- a/cgitrc
+++ b/cgitrc
@@ -107,24 +107,29 @@
## Link to logo file
#logo=/cgit/git-logo.png
## Url loaded when clicking the logo
#logo-link=http://www.kernel.org/pub/software/scm/git/docs/
## Url loaded when clicking a submodule link
#module-link=./?repo=%s&page=commit&id=%s
+## Shared prefix which, when combined with repo url, becomes the url used
+## to clone the repo
+#clone-prefix=
+
+
## Number of chars shown of repo description (in repolist view)
#max-repodesc-length=60
## Number of chars shown of commit subject message (in log view)
#max-message-length=60
## Number of commits per page in log view
#max-commit-count=50
@@ -158,30 +163,32 @@
## repository section must start with repo.url).
#repo.url=cgit
#repo.name=cgit
#repo.desc=the caching cgi for git
#repo.path=/pub/git/cgit ## this is the path to $GIT_DIR
#repo.owner=Lars Hjemli
#repo.defbranch=master ## define a default branch
#repo.snapshots=tar.bz2 ## override a sitewide snapshot-setting
#repo.enable-log-filecount=0 ## override the default filecount setting
#repo.enable-log-linecount=0 ## override the default linecount setting
#repo.module-link=/git/%s/commit/?id=%s ## override the standard module-link
#repo.readme=info/web/readme ## specify a file to include on summary page
+#repo.clone-url=git://hjemli.net/pub/git/cgit
## Additional repositories grouped under "mirrors"
#repo.group=mirrors
#repo.url=git
#repo.path=/pub/git/git
+#repo.clone-url=git://hjemli.net/pub/git/git
#
#repo.url=linux
#repo.path=/pub/git/linux
## A group of private repositories (with a working directory)
#repo.group=private
#repo.url=larsh/cgit
#repo.path=/home/larsh/src/cgit/.git
#repo.url=larsh/git
#repo.path=/home/larsh/src/git/.git
diff --git a/shared.c b/shared.c
index fd8b1e3..2c309f5 100644
--- a/shared.c
+++ b/shared.c
@@ -18,24 +18,25 @@ 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_index_info = 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 = CGIT_CACHE_ROOT;
char *cgit_repo_group = NULL;
char *cgit_robots = "index, nofollow";
+char *cgit_clone_prefix = 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;
@@ -191,32 +192,36 @@ void cgit_global_config_cb(const char *name, const char *value)
else if (!strcmp(name, "summary-log"))
cgit_summary_log = atoi(value);
else if (!strcmp(name, "summary-branches"))
cgit_summary_branches = atoi(value);
else if (!strcmp(name, "summary-tags"))
cgit_summary_tags = atoi(value);
else if (!strcmp(name, "agefile"))
cgit_agefile = xstrdup(value);
else if (!strcmp(name, "renamelimit"))
cgit_renamelimit = atoi(value);
else if (!strcmp(name, "robots"))
cgit_robots = xstrdup(value);
+ else if (!strcmp(name, "clone-prefix"))
+ cgit_clone_prefix = xstrdup(value);
else if (!strcmp(name, "repo.group"))
cgit_repo_group = xstrdup(value);
else if (!strcmp(name, "repo.url"))
cgit_repo = add_repo(value);
else if (!strcmp(name, "repo.name"))
cgit_repo->name = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.path"))
cgit_repo->path = trim_end(value, '/');
+ else if (cgit_repo && !strcmp(name, "repo.clone-url"))
+ cgit_repo->clone_url = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.desc"))
cgit_repo->desc = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.owner"))
cgit_repo->owner = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.defbranch"))
cgit_repo->defbranch = xstrdup(value);
else if (cgit_repo && !strcmp(name, "repo.snapshots"))
cgit_repo->snapshots = cgit_snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */
else if (cgit_repo && !strcmp(name, "repo.enable-log-filecount"))
cgit_repo->enable_log_filecount = cgit_enable_log_filecount * atoi(value);
else if (cgit_repo && !strcmp(name, "repo.enable-log-linecount"))
cgit_repo->enable_log_linecount = cgit_enable_log_linecount * atoi(value);
diff --git a/ui-shared.c b/ui-shared.c
index 3e13c86..ece041c 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -451,24 +451,25 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
if (incl_search) {
if (cgit_query_grep)
html_hidden("qt", cgit_query_grep);
if (cgit_query_search)
html_hidden("q", cgit_query_search);
}
}
void cgit_print_pageheader(char *title, int show_search)
{
static const char *default_info = "This is cgit, a fast webinterface for git repositories";
int header = 0;
+ char *url;
html("<table id='layout' summary=''>\n");
html("<tr><td id='sidebar'>\n");
html("<table class='sidebar' cellspacing='0' summary=''>\n");
html("<tr><td class='sidebar'>\n<a href='");
html_attr(cgit_rooturl());
htmlf("'><img src='%s' alt='cgit'/></a>\n",
cgit_logo);
html("</td></tr>\n<tr><td class='sidebar'>\n");
if (cgit_query_repo) {
html("<h1 class='first'>");
html_txt(strrpart(cgit_repo->name, 20));
@@ -483,24 +484,40 @@ void cgit_print_pageheader(char *title, int show_search)
NULL, NULL);
cgit_log_link("log", NULL, "menu", cgit_query_head, NULL, NULL,
0, NULL, NULL);
cgit_tree_link("tree", NULL, "menu", cgit_query_head,
cgit_query_sha1, NULL);
cgit_commit_link("commit", NULL, "menu", cgit_query_head,
cgit_query_sha1);
cgit_diff_link("diff", NULL, "menu", cgit_query_head,
cgit_query_sha1, cgit_query_sha2, NULL);
for_each_ref(print_archive_ref, &header);
+ if (cgit_repo->clone_url || cgit_clone_prefix) {
+ html("<h1>clone</h1>\n");
+ if (cgit_repo->clone_url)
+ url = cgit_repo->clone_url;
+ else
+ url = fmt("%s%s", cgit_clone_prefix,
+ cgit_repo->url);
+ html("<a class='menu' href='");
+ html_attr(url);
+ html("' title='");
+ html_attr(url);
+ html("'>\n");
+ html_txt(strrpart(url, 20));
+ html("</a>\n");
+ }
+
html("<h1>branch</h1>\n");
html("<form method='get' action=''>\n");
add_hidden_formfields(0, 1, cgit_query_page);
// html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>");
html("<select name='h' onchange='this.form.submit();'>\n");
for_each_branch_ref(print_branch_option, cgit_query_head);
html("</select>\n");
// html("</td><td>");
html("<noscript><input type='submit' id='switch-btn' value='switch'/></noscript>\n");
// html("</td></tr></table>");
html("</form>\n");