/* * The page furniture and the link builders every renderer shares. A page * handler renders its own body and calls in here for all that surrounds it, * which is the HTTP headers, the document head and footer, the header block * with its tabs and search form, the error page, and an anchor to any other * cgit page. */ #ifndef CGIT_UI_SHARED_H #define CGIT_UI_SHARED_H #include "cgit.h" extern const char *cgit_httpscheme(void); extern char *cgit_hosturl(void); /* * The URL of the request being answered, which cgit_currentfullurl gives with * the query string on the end as well, minus the url argument that the path * was taken from. cgit_currentquery is that query string alone, led by its * question mark, or an empty string when nothing is left of it. */ extern char *cgit_currenturl(void); extern char *cgit_currentfullurl(void); extern char *cgit_currentquery(void); extern const char *cgit_loginurl(void); /* * The urls of a repository and of its pages. The repository url is encoded * here, since it is configuration or a scanned path and may hold any byte, * while a page name, file name or query must arrive encoded already. The * result still needs escaping for wherever it lands. */ extern char *cgit_repourl(const char *reponame); extern char *cgit_fileurl(const char *reponame, const char *pagename, const char *filename, const char *query); extern char *cgit_pageurl(const char *reponame, const char *pagename, const char *query); /* * The url of the current repository's tree page at head, split where a path * in the tree goes, for a filter to build links of its own from. Both parts * are escaped for a url but not for HTML, and query stays empty for the * default branch. */ extern void cgit_tree_url(const char *head, struct strbuf *base, struct strbuf *query); /* * Call fn once for every URL this repository can be cloned from. */ extern void cgit_add_clone_urls(void (*fn)(const char *)); /* * One row of the clone table. Every row is a link, but a browser cannot * follow the ssh, scp or git forms, so those rows point at the first http * url in the clone list, or at the repository's own page when the list has * none. A colspan of zero leaves the attribute out. */ extern void cgit_print_clone_row(const char *url, int colspan); /* * Each of these writes one anchor to the page and nothing around it, with name * as the text a reader sees. A NULL title or class leaves that attribute out, * and what follows them is the state the target page should open in. */ extern void cgit_index_link(const char *name, const char *title, const char *class, const char *pattern, const char *sort, int ofs, int always_root); extern void cgit_summary_link(const char *name, const char *title, const char *class, const char *head); extern void cgit_tag_link(const char *name, const char *title, const char *class, const char *tag); extern void cgit_tree_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path); extern void cgit_plain_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path); extern void cgit_blame_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path); extern void cgit_log_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path, int ofs, const char *grep, const char *pattern, int showmsg, int follow); extern void cgit_commit_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path); extern void cgit_patch_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path); extern void cgit_refs_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path); extern void cgit_diff_link(const char *name, const char *title, const char *class, const char *head, const char *new_rev, const char *old_rev, const char *path); extern void cgit_stats_link(const char *name, const char *title, const char *class, const char *head, const char *path); /* * Names the object by type and id, abbreviated unless full is set. */ extern void cgit_object_link(struct object *obj, int full); extern void cgit_submodule_link(const char *class, char *path, const char *rev); extern void cgit_print_layout_start(void); extern void cgit_print_layout_end(void); __attribute__((format (printf,1,2))) extern void cgit_print_error(const char *fmt, ...); extern struct date_mode cgit_date_mode(enum date_mode_type type); /* * Print the time t, which was recorded in the timezone tz, as an age. An age * further back than max_relative is given as a calendar date instead, and a * negative max_relative stays relative however old it is. A site that turns * relative dates off gets the date either way. */ extern void cgit_print_age(time_t t, int tz, time_t max_relative); /* * Print date as a