mirror of
https://git.zx2c4.com/cgit
synced 2024-11-22 16:38:42 +00:00
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>
This commit is contained in:
parent
e19683bede
commit
141f1c3eb6
22
ui-shared.c
22
ui-shared.c
@ -114,7 +114,7 @@ char *cgit_currurl()
|
|||||||
return fmt("%s/", ctx.cfg.virtual_root);
|
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 = "?";
|
char *delim = "?";
|
||||||
|
|
||||||
@ -133,11 +133,16 @@ static void site_url(char *page, char *search)
|
|||||||
html(delim);
|
html(delim);
|
||||||
html("q=");
|
html("q=");
|
||||||
html_attr(search);
|
html_attr(search);
|
||||||
|
delim = "&";
|
||||||
|
}
|
||||||
|
if (ofs) {
|
||||||
|
html(delim);
|
||||||
|
htmlf("ofs=%d", ofs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void site_link(char *page, char *name, char *title, char *class,
|
static void site_link(char *page, char *name, char *title, char *class,
|
||||||
char *search)
|
char *search, int ofs)
|
||||||
{
|
{
|
||||||
html("<a");
|
html("<a");
|
||||||
if (title) {
|
if (title) {
|
||||||
@ -151,12 +156,18 @@ static void site_link(char *page, char *name, char *title, char *class,
|
|||||||
html("'");
|
html("'");
|
||||||
}
|
}
|
||||||
html(" href='");
|
html(" href='");
|
||||||
site_url(page, search);
|
site_url(page, search, ofs);
|
||||||
html("'>");
|
html("'>");
|
||||||
html_txt(name);
|
html_txt(name);
|
||||||
html("</a>");
|
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,
|
static char *repolink(char *title, char *class, char *page, char *head,
|
||||||
char *path)
|
char *path)
|
||||||
{
|
{
|
||||||
@ -596,9 +607,10 @@ void cgit_print_pageheader(struct cgit_context *ctx)
|
|||||||
html("<input type='submit' value='search'/>\n");
|
html("<input type='submit' value='search'/>\n");
|
||||||
html("</form>\n");
|
html("</form>\n");
|
||||||
} else {
|
} 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)
|
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("</td><td class='form'>");
|
||||||
html("<form method='get' action='");
|
html("<form method='get' action='");
|
||||||
html_attr(cgit_rooturl());
|
html_attr(cgit_rooturl());
|
||||||
|
@ -7,6 +7,8 @@ extern char *cgit_fileurl(const char *reponame, const char *pagename,
|
|||||||
extern char *cgit_pageurl(const char *reponame, const char *pagename,
|
extern char *cgit_pageurl(const char *reponame, const char *pagename,
|
||||||
const char *query);
|
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,
|
extern void cgit_tree_link(char *name, char *title, char *class, char *head,
|
||||||
char *rev, char *path);
|
char *rev, char *path);
|
||||||
extern void cgit_log_link(char *name, char *title, char *class, char *head,
|
extern void cgit_log_link(char *name, char *title, char *class, char *head,
|
||||||
|
Loading…
Reference in New Issue
Block a user