");
- if (cgit_query_repo) {
- html_txt(cgit_repo->name);
- html(" (");
- html_txt(cgit_query_head);
- html(") : ");
- reporevlink(NULL, "summary", NULL, NULL, cgit_query_head,
- NULL, NULL);
- html(" ");
- cgit_log_link("log", NULL, NULL, cgit_query_head,
- cgit_query_sha1, cgit_query_path, 0);
- html(" ");
- cgit_tree_link("tree", NULL, NULL, cgit_query_head,
- cgit_query_sha1, NULL);
- html(" ");
- cgit_commit_link("commit", NULL, NULL, cgit_query_head,
- cgit_query_sha1);
- html(" ");
- cgit_diff_link("diff", NULL, NULL, cgit_query_head,
- cgit_query_sha1, cgit_query_sha2,
- cgit_query_path);
+ char *name = (char *)refname;
+ html_option(name, name, ctx.qry.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("download\n");
+ *header = 1;
+ }
+ url = cgit_pageurl(ctx.qry.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 cgit_add_hidden_formfields(int incl_head, int incl_search,
+ const char *page)
+{
+ char *url;
+
+ if (!ctx.cfg.virtual_root) {
+ url = fmt("%s/%s", ctx.qry.repo, page);
+ if (ctx.qry.vpath)
+ url = fmt("%s/%s", url, ctx.qry.vpath);
+ html_hidden("url", url);
+ }
+
+ if (incl_head && ctx.qry.head && ctx.repo->defbranch &&
+ 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 (ctx.qry.showmsg)
+ html_hidden("showmsg", "1");
+
+ if (incl_search) {
+ if (ctx.qry.grep)
+ html_hidden("qt", ctx.qry.grep);
+ if (ctx.qry.search)
+ html_hidden("q", ctx.qry.search);
+ }
+}
+
+static const char *hc(struct cgit_context *ctx, const char *page)
+{
+ return strcmp(ctx->qry.page, page) ? NULL : "active";
+}
+
+static void cgit_print_path_crumbs(struct cgit_context *ctx, char *path)
+{
+ char *old_path = ctx->qry.path;
+ char *p = path, *q, *end = path + strlen(path);
+
+ ctx->qry.path = NULL;
+ cgit_self_link("root", NULL, NULL, ctx);
+ ctx->qry.path = p = path;
+ while (p < end) {
+ if (!(q = strchr(p, '/')))
+ q = end;
+ *q = '\0';
+ html_txt("/");
+ cgit_self_link(p, NULL, NULL, ctx);
+ if (q < end)
+ *q = '/';
+ p = q + 1;
+ }
+ ctx->qry.path = old_path;
+}
+
+static void print_header(struct cgit_context *ctx)
+{
+ char *logo = NULL, *logo_link = NULL;
+
+ html("\n");
+}
+
+void cgit_print_pageheader(struct cgit_context *ctx)
+{
+ html("");
+ if (!ctx->cfg.noheader)
+ print_header(ctx);
+
+ html(" | \n");
+ if (ctx->repo) {
+ cgit_summary_link("summary", NULL, hc(ctx, "summary"),
+ ctx->qry.head);
+ cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head,
+ ctx->qry.sha1, NULL);
+ cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head,
+ NULL, ctx->qry.vpath, 0, NULL, NULL,
+ ctx->qry.showmsg);
+ cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head,
+ ctx->qry.sha1, ctx->qry.vpath);
+ cgit_commit_link("commit", NULL, hc(ctx, "commit"),
+ ctx->qry.head, ctx->qry.sha1, ctx->qry.vpath, 0);
+ cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head,
+ ctx->qry.sha1, ctx->qry.sha2, ctx->qry.vpath, 0);
+ if (ctx->repo->max_stats)
+ cgit_stats_link("stats", NULL, hc(ctx, "stats"),
+ ctx->qry.head, ctx->qry.vpath);
+ if (ctx->repo->readme)
+ reporevlink("about", "about", NULL,
+ hc(ctx, "about"), ctx->qry.head, NULL,
+ NULL);
+ html(" | ");
+ html("\n");
+ } else {
+ site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, 0);
+ if (ctx->cfg.root_readme)
+ site_link("about", "about", NULL, hc(ctx, "about"),
+ NULL, 0);
+ html(" | ");
html("");
- }
- html(" | ");
- html("| ");
-}
-
-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");
+ html_attr(cgit_rooturl());
+ html("'>\n");
+ html("\n");
+ html("\n");
+ html("");
+ }
+ html(" |
\n");
+ if (ctx->qry.vpath) {
+ html(" ");
+ html("path: ");
+ cgit_print_path_crumbs(ctx, ctx->qry.vpath);
+ html(" ");
+ }
+ html(" ");
}
-/* vim:set sw=8: */
+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);
+}
+
+void cgit_print_snapshot_links(const char *repo, const char *head,
+ const char *hex, int snapshots)
+{
+ const struct cgit_snapshot_format* f;
+ char *prefix;
+ char *filename;
+ unsigned char sha1[20];
+
+ if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&
+ (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1]))
+ hex++;
+ prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex));
+ for (f = cgit_snapshot_formats; f->suffix; f++) {
+ if (!(snapshots & f->bit))
+ continue;
+ filename = fmt("%s%s", prefix, f->suffix);
+ cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);
+ html(" ");
+ }
+}
|