author | Lars Hjemli <hjemli@gmail.com> | 2007-11-03 13:05:12 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-11-03 13:05:12 (UTC) |
commit | 601c76eb15a298ac9529f4dded5dd4297b9c3768 (patch) (side-by-side diff) | |
tree | cb81350b624cb7ef0cdf9cdd23804cc674b8b5d5 | |
parent | e36365c6841703e569fcaf20bfc415ee0489c76f (diff) | |
download | cgit-601c76eb15a298ac9529f4dded5dd4297b9c3768.zip cgit-601c76eb15a298ac9529f4dded5dd4297b9c3768.tar.gz cgit-601c76eb15a298ac9529f4dded5dd4297b9c3768.tar.bz2 |
Do not require javascript-enabled clients
A simple submit-button is all that's required to make the branch selector
drop-down work on any client, so lets add one.
Noticed-by: Olivier Ramonat <olivier@ramonat.fr>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.css | 12 | ||||
-rw-r--r-- | ui-shared.c | 4 |
2 files changed, 16 insertions, 0 deletions
@@ -1,328 +1,340 @@ body, table { padding: 0em; margin: 0em; } body { font-family: sans; font-size: 10pt; color: #333; background: white; padding-left: 4px; } table { border-collapse: collapse; } h2 { font-size: 120%; font-weight: bold; margin-top: 0em; margin-bottom: 0.25em; } h3 { margin-top: 0em; font-size: 100%; font-weight: normal; } h4 { margin-top: 1.5em; margin-bottom: 0.1em; font-size: 100%; font-weight: bold; } a { color: #600; text-decoration: none; } a:hover { background-color: #ddd; text-decoration: none; } table.list { border: none; border-collapse: collapse; } table.list tr { background: white; } table.list tr:hover { background: #f8f8f8; } table.list tr.nohover:hover { background: white; } table.list th { font-weight: bold; border-bottom: solid 1px #777; padding: 0.1em 0.5em 0.1em 0.5em; vertical-align: baseline; } table.list td { border: none; padding: 0.1em 0.5em 0.1em 0.5em; } img { border: none; } div#sidebar { vertical-align: top; width: 162px; padding: 0px 0px 0px 0px; margin: 4px; float: left; } div#logo { margin: 0px; padding: 4px 0px 4px 0px; text-align: center; background-color: #ccc; border-top: solid 1px #eee; border-left: solid 1px #eee; border-right: solid 1px #aaa; border-bottom: solid 1px #aaa; } div#sidebar div.infobox { margin: 0px 0px 0px 0px; padding: 0.5em; text-align: left; background-color: #ccc; border-top: solid 1px #eee; border-left: solid 1px #eee; border-right: solid 1px #aaa; border-bottom: solid 1px #aaa; } div#sidebar div.infobox h1 { font-size: 11pt; font-weight: bold; margin: 0px; } div#sidebar div.infobox a.menu { display: block; background-color: #ccc; padding: 0.1em 0.5em; text-decoration: none; } div#sidebar div.infobox a.menu:hover { background-color: #bbb; text-decoration: none; } div#sidebar div.infobox select { width: 100%; border: solid 1px #aaa; background-color: #bbb; margin: 2px 0px 0px 0px; padding: 0px; } +td#branch-dropdown-cell { + width: 99%; +} + +input#switch-btn { + width: 20px; + border: solid 1px #aaa; + background-color: #bbb; + margin: 2px 0px 0px 0px; + padding: 0px; +} + div#sidebar div.infobox input.txt { width: 100%; border: solid 1px #aaa; background-color: #bbb; margin: 2px 0px 0px 0px; padding: 0; } table#grid { margin: 0px; } td#content { vertical-align: top; padding: 1em 2em 1em 1em; border: none; } div#summary { vertical-align: top; margin-bottom: 1em; } table#downloads { float: right; border-collapse: collapse; border: solid 1px #777; margin-left: 0.5em; margin-bottom: 0.5em; } table#downloads th { background-color: #ccc; } div#blob { border: solid 1px black; } div.error { color: red; font-weight: bold; margin: 1em 2em; } a.ls-blob, a.ls-dir, a.ls-mod { font-family: monospace; } td.ls-size { text-align: right; } td.ls-size { font-family: monospace; } td.ls-mode { font-family: monospace; } table.blob { margin-top: 0.5em; border-top: solid 1px black; } table.blob td.no { border-right: solid 1px black; color: black; background-color: #eee; text-align: right; } table.blob td.no a { color: black; } table.blob td.no a:hover { color: black; text-decoration: none; } table.blob td.txt { white-space: pre; font-family: monospace; padding-left: 0.5em; } table.nowrap td { white-space: nowrap; } table.commit-info { border-collapse: collapse; margin-top: 1.5em; } table.commit-info th { text-align: left; font-weight: normal; padding: 0.1em 1em 0.1em 0.1em; vertical-align: top; } table.commit-info td { font-weight: normal; padding: 0.1em 1em 0.1em 0.1em; } div.commit-subject { font-weight: bold; font-size: 125%; margin: 1.5em 0em 0.5em 0em; padding: 0em; } div.commit-msg { white-space: pre; font-family: monospace; } div.diffstat-header { font-weight: bold; padding-top: 1.5em; } table.diffstat { border-collapse: collapse; border: solid 1px #aaa; background-color: #eee; } table.diffstat th { font-weight: normal; text-align: left; text-decoration: underline; padding: 0.1em 1em 0.1em 0.1em; font-size: 100%; } table.diffstat td { padding: 0.2em 0.2em 0.1em 0.1em; font-size: 100%; border: none; } table.diffstat td.mode { white-space: nowrap; } table.diffstat td span.modechange { padding-left: 1em; color: red; } table.diffstat td.add a { color: green; } table.diffstat td.del a { color: red; } table.diffstat td.upd a { color: blue; } table.diffstat td.graph { width: 500px; vertical-align: middle; } table.diffstat td.graph table { border: none; } table.diffstat td.graph td { padding: 0px; border: 0px; height: 7pt; } table.diffstat td.graph td.add { background-color: #5c5; } table.diffstat td.graph td.rem { background-color: #c55; } div.diffstat-summary { color: #888; diff --git a/ui-shared.c b/ui-shared.c index ca8dd3d..bd34cc3 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -298,236 +298,240 @@ void cgit_object_link(struct object *obj) sha1_to_hex(obj->sha1)); html_link_close(); } void cgit_print_date(time_t secs, char *format) { char buf[64]; struct tm *time; time = gmtime(&secs); strftime(buf, sizeof(buf)-1, format, time); html_txt(buf); } void cgit_print_age(time_t t, time_t max_relative, char *format) { time_t now, secs; time(&now); secs = now - t; if (secs > max_relative && max_relative >= 0) { cgit_print_date(t, format); return; } if (secs < TM_HOUR * 2) { htmlf("<span class='age-mins'>%.0f min.</span>", secs * 1.0 / TM_MIN); return; } if (secs < TM_DAY * 2) { htmlf("<span class='age-hours'>%.0f hours</span>", secs * 1.0 / TM_HOUR); return; } if (secs < TM_WEEK * 2) { htmlf("<span class='age-days'>%.0f days</span>", secs * 1.0 / TM_DAY); return; } if (secs < TM_MONTH * 2) { htmlf("<span class='age-weeks'>%.0f weeks</span>", secs * 1.0 / TM_WEEK); return; } if (secs < TM_YEAR * 2) { htmlf("<span class='age-months'>%.0f months</span>", secs * 1.0 / TM_MONTH); return; } htmlf("<span class='age-years'>%.0f years</span>", secs * 1.0 / TM_YEAR); } void cgit_print_docstart(char *title, struct cacheitem *item) { html("Content-Type: text/html; charset=utf-8\n"); htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); htmlf("Expires: %s\n", http_date(item->st.st_mtime + ttl_seconds(item->ttl))); html("\n"); html(cgit_doctype); html("<html>\n"); html("<head>\n"); html("<title>"); html_txt(title); html("</title>\n"); htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); html("<link rel='stylesheet' type='text/css' href='"); html_attr(cgit_css); html("'/>\n"); html("</head>\n"); html("<body>\n"); } void cgit_print_docend() { html("</td>\n</tr>\n<table>\n</body>\n</html>\n"); } int print_branch_option(const char *refname, const unsigned char *sha1, int flags, void *cb_data) { char *name = (char *)refname; html_option(name, name, cgit_query_head); return 0; } int print_archive_ref(const char *refname, const unsigned char *sha1, int flags, void *cb_data) { struct tag *tag; struct taginfo *info; struct object *obj; char buf[256], *url; unsigned char fileid[20]; int *header = (int *)cb_data; if (prefixcmp(refname, "refs/archives")) return 0; strncpy(buf, refname+14, sizeof(buf)); obj = parse_object(sha1); if (!obj) return 1; if (obj->type == OBJ_TAG) { tag = lookup_tag(sha1); if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) return 0; hashcpy(fileid, tag->tagged->sha1); } else if (obj->type != OBJ_BLOB) { return 0; } else { hashcpy(fileid, sha1); } if (!*header) { html("<p><h1>download</h1>"); *header = 1; } url = cgit_pageurl(cgit_query_repo, "blob", fmt("id=%s&path=%s", sha1_to_hex(fileid), buf)); html_link_open(url, NULL, "menu"); html_txt(strlpart(buf, 20)); html_link_close(); return 0; } void add_hidden_formfields(int incl_head, int incl_search, char *page) { char *url; if (!cgit_virtual_root) { url = fmt("%s/%s", cgit_query_repo, page); if (cgit_query_path) url = fmt("%s/%s", url, cgit_query_path); html_hidden("url", url); } if (incl_head && strcmp(cgit_query_head, cgit_repo->defbranch)) html_hidden("h", cgit_query_head); if (cgit_query_sha1) html_hidden("id", cgit_query_sha1); if (cgit_query_sha2) html_hidden("id2", cgit_query_sha2); 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; html("<div id='sidebar'>\n"); html("<a href='"); html_attr(cgit_rooturl()); htmlf("'><div id='logo'><img src='%s' alt='cgit'/></div></a>\n", cgit_logo); html("<div class='infobox'>"); if (cgit_query_repo) { html("<h1>"); html_txt(strrpart(cgit_repo->name, 20)); html("</h1>\n"); html_txt(cgit_repo->desc); if (cgit_repo->owner) { html("<p>\n<h1>owner</h1>\n"); html_txt(cgit_repo->owner); } html("<p>\n<h1>navigate</h1>\n"); reporevlink(NULL, "summary", NULL, "menu", cgit_query_head, 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); html("<p>\n<h1>branch</h1>\n"); html("<form method='get' action=''>\n"); add_hidden_formfields(0, 1, cgit_query_page); + html("<table 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("<input type='submit' id='switch-btn' value='..'>\n"); + html("</td></tr></table>"); html("</form>\n"); html("<p>\n<h1>search</h1>\n"); html("<form method='get' action='"); if (cgit_virtual_root) html_attr(cgit_fileurl(cgit_query_repo, "log", cgit_query_path, NULL)); html("'>\n"); add_hidden_formfields(1, 0, "log"); html("<select name='qt'>\n"); html_option("grep", "log msg", cgit_query_grep); html_option("author", "author", cgit_query_grep); html_option("committer", "committer", cgit_query_grep); html("</select>\n"); html("<input class='txt' type='text' name='q' value='"); html_attr(cgit_query_search); html("'/>\n"); html("</form>\n"); } else { if (!cgit_index_info || html_include(cgit_index_info)) html(default_info); } html("</div>\n"); html("</div>\n<table class='grid'><tr><td id='content'>\n"); } void cgit_print_snapshot_start(const char *mimetype, const char *filename, struct cacheitem *item) { htmlf("Content-Type: %s\n", mimetype); htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); htmlf("Expires: %s\n", http_date(item->st.st_mtime + ttl_seconds(item->ttl))); html("\n"); } /* vim:set sw=8: */ |