Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Open and close each page through the layout calls
Diffstat (limited to 'source')
-rw-r--r--source/cgit.c12
-rw-r--r--source/ui-repolist.c6
-rw-r--r--source/ui-shared.c67
-rw-r--r--source/ui-shared.h3
4 files changed, 37 insertions, 51 deletions
diff --git a/source/cgit.c b/source/cgit.c
index da86943..ed9b62b 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -1076,11 +1076,9 @@ static int prepare_repo_cmd(int nongit, int err, int clone)
// <link rel='vcs-git'> and those clone urls expand macros such
// as $CGIT_REPO_URL out of this environment.
cgit_prepare_repo_env(ctx.repo);
- cgit_print_http_headers();
- cgit_print_docstart();
- cgit_print_pageheader();
+ cgit_print_layout_start();
cgit_print_empty_repo();
- cgit_print_docend();
+ cgit_print_layout_end();
return 1;
}
@@ -1115,12 +1113,10 @@ static void process_request(void)
// whatever page it asked for.
if (!ctx.env.authenticated) {
ctx.page.title = "Authentication Required";
- cgit_print_http_headers();
- cgit_print_docstart();
- cgit_print_pageheader();
+ cgit_print_layout_start();
open_auth_filter("body");
cgit_close_filter(ctx.cfg.auth_filter);
- cgit_print_docend();
+ cgit_print_layout_end();
return;
}
diff --git a/source/ui-repolist.c b/source/ui-repolist.c
index cd961bf..7e9c167 100644
--- a/source/ui-repolist.c
+++ b/source/ui-repolist.c
@@ -402,9 +402,7 @@ void cgit_print_repolist(void)
++columns;
ctx.page.title = ctx.cfg.root_title;
- cgit_print_http_headers();
- cgit_print_docstart();
- cgit_print_pageheader();
+ cgit_print_layout_start();
if (ctx.qry.sort)
column_sorted = sort_repolist(ctx.qry.sort);
@@ -446,7 +444,7 @@ void cgit_print_repolist(void)
if (hits > ctx.cfg.max_repo_count)
print_pager(hits, ctx.cfg.max_repo_count, ctx.qry.search, ctx.qry.sort);
free(currenturl);
- cgit_print_docend();
+ cgit_print_layout_end();
}
void cgit_print_site_readme(void)
diff --git a/source/ui-shared.c b/source/ui-shared.c
index 7c198ea..1d09c26 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -1375,7 +1375,7 @@ void cgit_redirect(const char *url, const char *query, bool permanent)
html("\n\n");
}
-void cgit_print_docstart(void)
+static void print_docstart(void)
{
const struct object_id *pinned;
struct string_list_item *item;
@@ -1462,28 +1462,6 @@ void cgit_print_docstart(void)
html_include(ctx.cfg.header);
}
-void cgit_print_docend(void)
-{
- html("</main>\n");
- if (ctx.cfg.embedded) {
- html("</div>\n");
- if (ctx.cfg.footer)
- html_include(ctx.cfg.footer);
- return;
- }
- if (ctx.cfg.footer)
- html_include(ctx.cfg.footer);
- else if (ctx.cfg.enable_version_info)
- htmlf("<footer class='footer'>generated by "
- "<a href='https://github.com/brycekwon/cgit'>cgit %s</a> "
- "(<a href='https://git-scm.com/'>git %s</a>)</footer>\n",
- cgit_version, git_version_string);
- else
- html("<footer class='footer'>generated by <a href='https://github.com/brycekwon/cgit'>cgit</a></footer>\n");
- html("</div>\n");
- html("</body>\n</html>\n");
-}
-
void cgit_print_error_page(int code, const char *msg, const char *fmt, ...)
{
va_list ap;
@@ -1521,18 +1499,6 @@ void cgit_print_blob_too_large(size_t size)
size / 1024, ctx.cfg.max_blob_size);
}
-void cgit_print_layout_start(void)
-{
- cgit_print_http_headers();
- cgit_print_docstart();
- cgit_print_pageheader();
-}
-
-void cgit_print_layout_end(void)
-{
- cgit_print_docend();
-}
-
static void add_clone_urls(void (*fn)(const char *), char *urls, char *suffix)
{
struct strbuf **url_list = strbuf_split_str(urls, ' ', 0);
@@ -1624,7 +1590,7 @@ void cgit_add_hidden_formfields(int incl_head, int incl_search, const char *page
}
}
-void cgit_print_pageheader(void)
+static void print_pageheader(void)
{
const struct object_id *pinned;
@@ -1711,6 +1677,35 @@ void cgit_print_pageheader(void)
html("<main class='content'>\n");
}
+void cgit_print_layout_start(void)
+{
+ cgit_print_http_headers();
+ print_docstart();
+ print_pageheader();
+}
+
+void cgit_print_layout_end(void)
+{
+ html("</main>\n");
+ if (ctx.cfg.embedded) {
+ html("</div>\n");
+ if (ctx.cfg.footer)
+ html_include(ctx.cfg.footer);
+ return;
+ }
+ if (ctx.cfg.footer)
+ html_include(ctx.cfg.footer);
+ else if (ctx.cfg.enable_version_info)
+ htmlf("<footer class='footer'>generated by "
+ "<a href='https://github.com/brycekwon/cgit'>cgit %s</a> "
+ "(<a href='https://git-scm.com/'>git %s</a>)</footer>\n",
+ cgit_version, git_version_string);
+ else
+ html("<footer class='footer'>generated by <a href='https://github.com/brycekwon/cgit'>cgit</a></footer>\n");
+ html("</div>\n");
+ html("</body>\n</html>\n");
+}
+
static void print_fileperm(unsigned short mode)
{
htmlf("%c%c%c", (mode & 4 ? 'r' : '-'), (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-'));
diff --git a/source/ui-shared.h b/source/ui-shared.h
index a40200e..fb02d7b 100644
--- a/source/ui-shared.h
+++ b/source/ui-shared.h
@@ -114,8 +114,6 @@ 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, ...);
@@ -123,7 +121,6 @@ extern void cgit_print_error_page(int code, const char *msg, const char *fmt, ..
* 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);
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);