");
- 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 {
- html_txt("Index of repositories");
+ hashcpy(fileid, sha1);
}
- html(" | ");
- html("");
- if (show_search) {
+ 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, char *page)
+{
+ char *url;
+
+ if (!ctx.cfg.virtual_root) {
+ url = fmt("%s/%s", ctx.qry.repo, page);
+ if (ctx.qry.path)
+ url = fmt("%s/%s", url, ctx.qry.path);
+ 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);
+ }
+}
+
+const char *fallback_cmd = "repolist";
+
+char *hc(struct cgit_cmd *cmd, const char *page)
+{
+ return (strcmp(cmd ? cmd->name : fallback_cmd, page) ? NULL : "active");
+}
+
+static void print_header(struct cgit_context *ctx)
+{
+ html("\n");
+}
+
+void cgit_print_pageheader(struct cgit_context *ctx)
+{
+ struct cgit_cmd *cmd = cgit_get_cmd(ctx);
+
+ if (!cmd && ctx->repo)
+ fallback_cmd = "summary";
+
+ html("");
+ if (!ctx->cfg.noheader)
+ print_header(ctx);
+
+ html(" \n");
+ if (ctx->repo) {
+ cgit_summary_link("summary", NULL, hc(cmd, "summary"),
+ ctx->qry.head);
+ cgit_refs_link("refs", NULL, hc(cmd, "refs"), ctx->qry.head,
+ ctx->qry.sha1, NULL);
+ cgit_log_link("log", NULL, hc(cmd, "log"), ctx->qry.head,
+ NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
+ cgit_tree_link("tree", NULL, hc(cmd, "tree"), ctx->qry.head,
+ ctx->qry.sha1, NULL);
+ cgit_commit_link("commit", NULL, hc(cmd, "commit"),
+ ctx->qry.head, ctx->qry.sha1);
+ cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head,
+ ctx->qry.sha1, ctx->qry.sha2, NULL);
+ if (ctx->repo->max_stats)
+ cgit_stats_link("stats", NULL, hc(cmd, "stats"),
+ ctx->qry.head, NULL);
+ if (ctx->repo->readme)
+ reporevlink("about", "about", NULL,
+ hc(cmd, "about"), ctx->qry.head, NULL,
+ NULL);
+ html(" | ");
+ html("\n");
+ } else {
+ site_link(NULL, "index", NULL, hc(cmd, "repolist"), NULL, 0);
+ if (ctx->cfg.root_readme)
+ site_link("about", "about", NULL, hc(cmd, "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");
+ html(" ");
+}
+
+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, NULL, NULL, filename);
+ html(" ");
+ }
+}
|