author | Lars Hjemli <hjemli@gmail.com> | 2007-12-03 00:49:38 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-12-03 00:49:38 (UTC) |
commit | afcdd083dab81afef744e261d81a452698188c30 (patch) (side-by-side diff) | |
tree | 0ca43a6b87567af70c802a25124702c7c7891c9a /ui-shared.c | |
parent | dabb34af760eff2a6ab8e14927fd173cafb77547 (diff) | |
download | cgit-afcdd083dab81afef744e261d81a452698188c30.zip cgit-afcdd083dab81afef744e261d81a452698188c30.tar.gz cgit-afcdd083dab81afef744e261d81a452698188c30.tar.bz2 |
Add support for automatic and custom clone urls
This adds support for two new parameters to cgitrc: clone-prefix and
repo.clone-url.
If clone-prefix is specified, all repos will get a clone url printed in the
sidebar; the url is generated by clone-prefix + repo.url.
Additionally, each repo can specify repo.clone-url which will override any
such auto-generated url.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 17 |
1 files changed, 17 insertions, 0 deletions
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"); |