Diff options
Diffstat (limited to '')
| -rw-r--r-- | source/ui-shared.h | 77 |
1 file changed, 67 insertions, 10 deletions
diff --git a/source/ui-shared.h b/source/ui-shared.h index da1b889..cd937a3 100644 --- a/source/ui-shared.h +++ b/source/ui-shared.h @@ -3,15 +3,14 @@ * 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. + * 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); @@ -33,7 +32,6 @@ extern const char *cgit_loginurl(void); * result still needs escaping for wherever it lands. */ extern char *cgit_repourl(const char *reponame); -extern void cgit_print_clone_row(const char *url, int colspan); 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); @@ -52,6 +50,14 @@ extern void cgit_tree_url(const char *head, struct strbuf *base, struct strbuf * 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. @@ -101,6 +107,26 @@ extern struct date_mode cgit_date_mode(enum date_mode_type type); * 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 <time> element, readable on the page and exact in its + * datetime attribute. + */ +extern void cgit_print_date(timestamp_t date, int tz); + +/* + * Print the anchor of every line from first to last, each linking to itself. + * The anchors are handed over in batches rather than a write per line, and + * never built whole, which would come to several times the blob's size. + */ +extern void cgit_print_line_anchors(size_t first, size_t last); + +/* + * Print name through the email filter, followed by the address when + * show_email is set and enable-plain-email is on. A missing address reaches + * the filter as an empty string, since a filter must not be handed NULL. + */ +extern void cgit_print_person(const char *name, const char *email, const char *origin, int show_email); extern void cgit_print_http_headers(void); /* * Answer with a redirect to url, followed by query when one is given. Both @@ -108,24 +134,49 @@ extern void cgit_print_http_headers(void); * builds it, and only a byte a header line cannot carry is encoded here. */ extern void cgit_redirect(const char *url, const char *query, 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); /* * Answer with the error page for a blob of size bytes past max-blob-size. */ extern void cgit_print_blob_too_large(size_t size); -extern void cgit_print_pageheader(void); + +/* + * Resolve rev to the parsed commit it names, peeling a tag, with oid set to + * what rev itself names. Returns NULL once the 404 page naming rev is out. + */ +extern struct commit *cgit_get_commit(const char *rev, struct object_id *oid); + +/* + * Fill oid with the older end of a comparison with commit, which is what + * old_rev names when it is given, else commit's first parent, else the null + * id for a root commit. Returns -1 once the 404 page for old_rev is out. + */ +extern int cgit_get_old_oid(const char *old_rev, const struct commit *commit, struct object_id *oid); + +/* + * Start rev's walk, or print the error page and return non-zero when git + * cannot. A failed setup leaves the walk holding freed commits, so the caller + * must then neither read from it nor hand it to release_revisions. + */ +extern int cgit_prepare_walk(struct rev_info *rev); + +/* + * Refuse a path with a leading colon, printing the 400 page. git reads such a + * path as a pathspec with magic, which can end the request inside git. + * Returns non-zero when the path was refused. + */ +extern int cgit_refuse_pathspec_magic(const char *path); + 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. + * configured prefix or the last component of the repository URL. A name taken + * from the URL is only good until the next call. */ extern const char *cgit_snapshot_prefix(const struct cgit_repo *repo); @@ -135,11 +186,17 @@ extern const char *cgit_snapshot_prefix(const struct cgit_repo *repo); * 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); +extern void cgit_add_hidden_formfields(int incl_head, int incl_search); /* * Put path in front of the page title, its last component first. */ extern void cgit_set_title_from_path(const char *path); + +/* + * Names the page ahead of the repository and the site, so that the pages of one + * repository can be told apart in tabs, history and search results. + */ extern void cgit_prefix_title(const char *name); + #endif // CGIT_UI_SHARED_H |
