diff options
author | Lars Hjemli <hjemli@gmail.com> | 2006-12-28 10:01:49 (JST) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2006-12-28 10:01:49 (JST) |
commit | e39d738c39d37cdef115c145027f3eec85a62272 (patch) | |
tree | be60a07674a0d118d42f572a35b62ada9529a6bd /ui-shared.c | |
parent | 27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6 (diff) | |
download | cgit-e39d738c39d37cdef115c145027f3eec85a62272.zip cgit-e39d738c39d37cdef115c145027f3eec85a62272.tar.gz |
Add generic support for search box in page header
This adds the ability to show a search box in any pageheader with correct href and
hidden form data, but does not enable the box on any pages.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index 9ec4be8..b9c1243 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -60,6 +60,18 @@ char *cgit_pageurl(const char *reponame, const char *pagename, | |||
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | char *cgit_currurl() | ||
64 | { | ||
65 | if (!cgit_virtual_root) | ||
66 | return "./cgit.cgi"; | ||
67 | else if (cgit_query_page) | ||
68 | return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page); | ||
69 | else if (cgit_query_repo) | ||
70 | return fmt("%s/%s/", cgit_virtual_root, cgit_query_repo); | ||
71 | else | ||
72 | return fmt("%s/", cgit_virtual_root); | ||
73 | } | ||
74 | |||
63 | 75 | ||
64 | void cgit_print_date(unsigned long secs) | 76 | void cgit_print_date(unsigned long secs) |
65 | { | 77 | { |
@@ -98,12 +110,26 @@ void cgit_print_docend() | |||
98 | html("</body>\n</html>\n"); | 110 | html("</body>\n</html>\n"); |
99 | } | 111 | } |
100 | 112 | ||
101 | void cgit_print_pageheader(char *title) | 113 | void cgit_print_pageheader(char *title, int show_search) |
102 | { | 114 | { |
103 | html("<div id='header'>"); | 115 | html("<div id='header'>"); |
104 | htmlf("<a href='%s'>", cgit_logo_link); | 116 | htmlf("<a href='%s'>", cgit_logo_link); |
105 | htmlf("<img id='logo' src='%s'/>\n", cgit_logo); | 117 | htmlf("<img id='logo' src='%s'/>\n", cgit_logo); |
106 | htmlf("</a>"); | 118 | htmlf("</a>"); |
119 | if (show_search) { | ||
120 | html("<form method='get' href='"); | ||
121 | html_attr(cgit_currurl()); | ||
122 | html("'>"); | ||
123 | if (cgit_query_head) | ||
124 | html_hidden("h", cgit_query_head); | ||
125 | if (cgit_query_sha1) | ||
126 | html_hidden("id", cgit_query_sha1); | ||
127 | if (cgit_query_sha2) | ||
128 | html_hidden("id2", cgit_query_sha2); | ||
129 | html("<input type='text' name='q' value='"); | ||
130 | html_attr(cgit_query_search); | ||
131 | html("'/></form>"); | ||
132 | } | ||
107 | if (cgit_query_repo) | 133 | if (cgit_query_repo) |
108 | htmlf("<a href='%s'>", cgit_repourl(cgit_query_repo)); | 134 | htmlf("<a href='%s'>", cgit_repourl(cgit_query_repo)); |
109 | html_txt(title); | 135 | html_txt(title); |