/* * 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. Whether a site addresses a request as a path below a virtual root * or as a query string is settled behind these calls, so that nothing else has * to know which of the two it is looking at. */ #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. */ extern char *cgit_currenturl(void); extern char *cgit_currentfullurl(void); extern const char *cgit_loginurl(void); 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); // Call fn once for every URL this repository can be cloned from. extern void cgit_add_clone_urls(void (*fn)(const char *)); /* * 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); extern void cgit_object_link(struct object *obj); 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); extern void cgit_print_http_headers(void); extern void cgit_redirect(const char *url, bool permanent); extern void cgit_print_docstart(void); extern void cgit_print_docend(void); __attribute__((format (printf,3,4))) extern void cgit_print_error_page(int code, const char *msg, const char *fmt, ...); extern void cgit_vprint_error_page(int code, const char *msg, const char *fmt, va_list ap); extern void cgit_print_pageheader(void); extern void cgit_print_filemode(unsigned short mode); extern void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, const char *separator); // The name a snapshot of this repository is downloaded under, which is the // configured prefix or the last component of the repository URL. extern const char *cgit_snapshot_prefix(const struct cgit_repo *repo); /* * Carry the current request into a form as hidden inputs, so that submitting * it changes only what the form itself asks about. The branch and the search * terms are carried only when the caller asks for them, since a form with a * field of its own for either would otherwise submit that name twice. */ extern void cgit_add_hidden_formfields(int incl_head, int incl_search, const char *page); // Put path in front of the page title, its last component first. extern void cgit_set_title_from_path(const char *path); #endif // CGIT_UI_SHARED_H