about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2008-05-03 10:37:02 +0200
committerLars Hjemli <hjemli@gmail.com>2008-05-03 10:37:02 +0200
commit141f1c3eb657470e81bbf998f44f9723f9009def (patch)
treea591e720b4a532fc7f53e74d611bb63629c8c5dc
parentMerge branch 'lh/cache' (diff)
downloadcgit-pink-141f1c3eb657470e81bbf998f44f9723f9009def.tar.gz
cgit-pink-141f1c3eb657470e81bbf998f44f9723f9009def.zip
Add cgit_index_link() function with support for offset
This function will be used to build a pager in ui-repolist.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to '')
-rw-r--r--ui-shared.c22
-rw-r--r--ui-shared.h2
2 files changed, 19 insertions, 5 deletions
diff --git a/ui-shared.c b/ui-shared.c
index d08ede9..f366354 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -114,7 +114,7 @@ char *cgit_currurl()
 		return fmt("%s/", ctx.cfg.virtual_root);
 }
 
-static void site_url(char *page, char *search)
+static void site_url(char *page, char *search, int ofs)
 {
 	char *delim = "?";
 
@@ -133,11 +133,16 @@ static void site_url(char *page, char *search)
 		html(delim);
 		html("q=");
 		html_attr(search);
+		delim = "&";
+	}
+	if (ofs) {
+		html(delim);
+		htmlf("ofs=%d", ofs);
 	}
 }
 
 static void site_link(char *page, char *name, char *title, char *class,
-		       char *search)
+		      char *search, int ofs)
 {
 	html("<a");
 	if (title) {
@@ -151,12 +156,18 @@ static void site_link(char *page, char *name, char *title, char *class,
 		html("'");
 	}
 	html(" href='");
-	site_url(page, search);
+	site_url(page, search, ofs);
 	html("'>");
 	html_txt(name);
 	html("</a>");
 }
 
+void cgit_index_link(char *name, char *title, char *class, char *pattern,
+		     int ofs)
+{
+	site_link(NULL, name, title, class, pattern, ofs);
+}
+
 static char *repolink(char *title, char *class, char *page, char *head,
 		      char *path)
 {
@@ -596,9 +607,10 @@ void cgit_print_pageheader(struct cgit_context *ctx)
 		html("<input type='submit' value='search'/>\n");
 		html("</form>\n");
 	} else {
-		site_link(NULL, "index", NULL, hc(cmd, "repolist"), NULL);
+		site_link(NULL, "index", NULL, hc(cmd, "repolist"), NULL, 0);
 		if (ctx->cfg.root_readme)
-			site_link("about", "about", NULL, hc(cmd, "about"), NULL);
+			site_link("about", "about", NULL, hc(cmd, "about"),
+				  NULL, 0);
 		html("</td><td class='form'>");
 		html("<form method='get' action='");
 		html_attr(cgit_rooturl());
diff --git a/ui-shared.h b/ui-shared.h
index 76c2b1f..3005d30 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -7,6 +7,8 @@ extern char *cgit_fileurl(const char *reponame, const char *pagename,
 extern char *cgit_pageurl(const char *reponame, const char *pagename,
 			  const char *query);
 
+extern void cgit_index_link(char *name, char *title, char *class,
+			    char *pattern, int ofs);
 extern void cgit_tree_link(char *name, char *title, char *class, char *head,
 			   char *rev, char *path);
 extern void cgit_log_link(char *name, char *title, char *class, char *head,
td> 2021-01-12Remove hacky tagging from hilexJune McEnroe God that makes the lexers so much simpler. 2021-01-12Add htagml -iJune McEnroe 2021-01-12Render tag index in HTMLJune McEnroe 2021-01-12Add htagml -xJune McEnroe 2021-01-12Prevent matching the same tag twiceJune McEnroe 2021-01-12Process htagml file line by lineJune McEnroe This simplifies some things, adds support for line number tag definitions, and should enable combining htagml with other preprocessors in the future. 2021-01-12Split fields by tab onlyJune McEnroe Also don't fail hard on non-forward-search definitions. 2021-01-12List both Makefile and html.sh under README.7June McEnroe 2021-01-12Add htagml exampleJune McEnroe 2021-01-12Use mandoc and htagml for bin htmlJune McEnroe 2021-01-12Add htagmlJune McEnroe 2021-01-12Replace causal.agency with a simple mdoc pageJune McEnroe 2021-01-11Publish "Using vi"June McEnroe 2021-01-11Enable diff.colorMovedJune McEnroe 2021-01-10Set less search case-insensitiveJune McEnroe 2021-01-10Set EXINITJune McEnroe neovim is laggy as hell in my OpenBSD VM, so I switched to vi so I could type without getting frustrated. 2021-01-09Add c -t flag to print expression typeJune McEnroe Also add missing float case. 2021-01-05Update taglineJune McEnroe