author | Lars Hjemli <hjemli@gmail.com> | 2008-03-24 15:00:27 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-03-24 15:00:27 (UTC) |
commit | f34478cbe0214a201e7ecef3e79ed6c957b7beee (patch) (side-by-side diff) | |
tree | 1ee05da742488cab51a06e083d26b7b58d829b43 /ui-shared.c | |
parent | e0e4478e7b4812f822d60a13a33525f8e529e1e8 (diff) | |
download | cgit-f34478cbe0214a201e7ecef3e79ed6c957b7beee.zip cgit-f34478cbe0214a201e7ecef3e79ed6c957b7beee.tar.gz cgit-f34478cbe0214a201e7ecef3e79ed6c957b7beee.tar.bz2 |
Refactor snapshot support
The snapshot support needs to be split between output- and config-related
functions to get the layering between shared.c and ui-*.c right. There
is also some codestyle-issues which needs fixing to make the snapshot
functions more similar to the rest of the cgit code.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index 2596023..aa65988 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -448,129 +448,144 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page) url = fmt("%s/%s", url, ctx.qry.path); html_hidden("url", url); } if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch)) html_hidden("h", ctx.qry.head); if (ctx.qry.sha1) html_hidden("id", ctx.qry.sha1); if (ctx.qry.sha2) html_hidden("id2", ctx.qry.sha2); if (incl_search) { if (ctx.qry.grep) html_hidden("qt", ctx.qry.grep); if (ctx.qry.search) html_hidden("q", ctx.qry.search); } } void cgit_print_pageheader(struct cgit_context *ctx) { 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", ctx->cfg.logo); html("</td></tr>\n<tr><td class='sidebar'>\n"); if (ctx->repo) { html("<h1 class='first'>"); html_txt(strrpart(ctx->repo->name, 20)); html("</h1>\n"); html_txt(ctx->repo->desc); if (ctx->repo->owner) { html("<h1>owner</h1>\n"); html_txt(ctx->repo->owner); } html("<h1>navigate</h1>\n"); reporevlink(NULL, "summary", NULL, "menu", ctx->qry.head, NULL, NULL); cgit_log_link("log", NULL, "menu", ctx->qry.head, NULL, NULL, 0, NULL, NULL); cgit_tree_link("tree", NULL, "menu", ctx->qry.head, ctx->qry.sha1, NULL); cgit_commit_link("commit", NULL, "menu", ctx->qry.head, ctx->qry.sha1); cgit_diff_link("diff", NULL, "menu", ctx->qry.head, ctx->qry.sha1, ctx->qry.sha2, NULL); cgit_patch_link("patch", NULL, "menu", ctx->qry.head, ctx->qry.sha1); for_each_ref(print_archive_ref, &header); if (ctx->repo->clone_url || ctx->cfg.clone_prefix) { html("<h1>clone</h1>\n"); if (ctx->repo->clone_url) url = ctx->repo->clone_url; else url = fmt("%s%s", ctx->cfg.clone_prefix, ctx->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, ctx->qry.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, ctx->qry.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"); html("<h1>search</h1>\n"); html("<form method='get' action='"); if (ctx->cfg.virtual_root) html_attr(cgit_fileurl(ctx->qry.repo, "log", ctx->qry.path, NULL)); html("'>\n"); add_hidden_formfields(1, 0, "log"); html("<select name='qt'>\n"); html_option("grep", "log msg", ctx->qry.grep); html_option("author", "author", ctx->qry.grep); html_option("committer", "committer", ctx->qry.grep); html("</select>\n"); html("<input class='txt' type='text' name='q' value='"); html_attr(ctx->qry.search); html("'/>\n"); html("</form>\n"); } else { if (!ctx->cfg.index_info || html_include(ctx->cfg.index_info)) html(default_info); } html("</td></tr></table></td>\n"); html("<td id='content'>\n"); } void cgit_print_filemode(unsigned short mode) { if (S_ISDIR(mode)) html("d"); else if (S_ISLNK(mode)) html("l"); else if (S_ISGITLINK(mode)) html("m"); else html("-"); html_fileperm(mode >> 6); html_fileperm(mode >> 3); html_fileperm(mode); } -/* vim:set sw=8: */ +void cgit_print_snapshot_links(const char *repo, const char *head, + const char *hex, int snapshots) +{ + const struct cgit_snapshot_format* f; + char *filename; + + for (f = cgit_snapshot_formats; f->suffix; f++) { + if (!(snapshots & f->bit)) + continue; + filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, + f->suffix); + cgit_snapshot_link(filename, NULL, NULL, (char *)head, + (char *)hex, filename); + html("<br/>"); + } +} |