author | Lars Hjemli <hjemli@gmail.com> | 2006-12-28 01:01:49 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2006-12-28 01:01:49 (UTC) |
commit | e39d738c39d37cdef115c145027f3eec85a62272 (patch) (unidiff) | |
tree | be60a07674a0d118d42f572a35b62ada9529a6bd /html.c | |
parent | 27cd3b2a700e1cc46cd0393ddea48c07b62ee3a6 (diff) | |
download | cgit-e39d738c39d37cdef115c145027f3eec85a62272.zip cgit-e39d738c39d37cdef115c145027f3eec85a62272.tar.gz cgit-e39d738c39d37cdef115c145027f3eec85a62272.tar.bz2 |
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>
-rw-r--r-- | html.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -88,70 +88,80 @@ void html_ntxt(int len, char *txt) | |||
88 | char c = *t; | 88 | char c = *t; |
89 | *t = '\0'; | 89 | *t = '\0'; |
90 | html(txt); | 90 | html(txt); |
91 | *t = c; | 91 | *t = c; |
92 | } | 92 | } |
93 | if (len<0) | 93 | if (len<0) |
94 | html("..."); | 94 | html("..."); |
95 | } | 95 | } |
96 | 96 | ||
97 | void html_attr(char *txt) | 97 | void html_attr(char *txt) |
98 | { | 98 | { |
99 | char *t = txt; | 99 | char *t = txt; |
100 | while(t && *t){ | 100 | while(t && *t){ |
101 | int c = *t; | 101 | int c = *t; |
102 | if (c=='<' || c=='>' || c=='\'') { | 102 | if (c=='<' || c=='>' || c=='\'') { |
103 | *t = '\0'; | 103 | *t = '\0'; |
104 | html(txt); | 104 | html(txt); |
105 | *t = c; | 105 | *t = c; |
106 | if (c=='>') | 106 | if (c=='>') |
107 | html(">"); | 107 | html(">"); |
108 | else if (c=='<') | 108 | else if (c=='<') |
109 | html("<"); | 109 | html("<"); |
110 | else if (c=='\'') | 110 | else if (c=='\'') |
111 | html(""e;"); | 111 | html(""e;"); |
112 | txt = t+1; | 112 | txt = t+1; |
113 | } | 113 | } |
114 | t++; | 114 | t++; |
115 | } | 115 | } |
116 | if (t!=txt) | 116 | if (t!=txt) |
117 | html(txt); | 117 | html(txt); |
118 | } | 118 | } |
119 | 119 | ||
120 | void html_hidden(char *name, char *value) | ||
121 | { | ||
122 | html("<input type='hidden' name='"); | ||
123 | html_attr(name); | ||
124 | html("' value='"); | ||
125 | html_attr(value); | ||
126 | html("'/>"); | ||
127 | } | ||
128 | |||
120 | void html_link_open(char *url, char *title, char *class) | 129 | void html_link_open(char *url, char *title, char *class) |
121 | { | 130 | { |
122 | html("<a href='"); | 131 | html("<a href='"); |
123 | html_attr(url); | 132 | html_attr(url); |
124 | if (title) { | 133 | if (title) { |
125 | html("' title='"); | 134 | html("' title='"); |
126 | html_attr(title); | 135 | html_attr(title); |
127 | } | 136 | } |
128 | if (class) { | 137 | if (class) { |
129 | html("' class='"); | 138 | html("' class='"); |
130 | html_attr(class); | 139 | html_attr(class); |
131 | } | 140 | } |
132 | html("'>"); | 141 | html("'>"); |
133 | } | 142 | } |
134 | 143 | ||
135 | void html_link_close(void) | 144 | void html_link_close(void) |
136 | { | 145 | { |
137 | html("</a>"); | 146 | html("</a>"); |
138 | } | 147 | } |
139 | 148 | ||
140 | void html_fileperm(unsigned short mode) | 149 | void html_fileperm(unsigned short mode) |
141 | { | 150 | { |
142 | htmlf("%c%c%c", (mode & 4 ? 'r' : '-'), | 151 | htmlf("%c%c%c", (mode & 4 ? 'r' : '-'), |
143 | (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-')); | 152 | (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-')); |
144 | } | 153 | } |
145 | 154 | ||
146 | void html_filemode(unsigned short mode) | 155 | void html_filemode(unsigned short mode) |
147 | { | 156 | { |
148 | if (S_ISDIR(mode)) | 157 | if (S_ISDIR(mode)) |
149 | html("d"); | 158 | html("d"); |
150 | else if (S_ISLNK(mode)) | 159 | else if (S_ISLNK(mode)) |
151 | html("l"); | 160 | html("l"); |
152 | else | 161 | else |
153 | html("-"); | 162 | html("-"); |
154 | html_fileperm(mode >> 6); | 163 | html_fileperm(mode >> 6); |
155 | html_fileperm(mode >> 3); | 164 | html_fileperm(mode >> 3); |
156 | html_fileperm(mode); | 165 | html_fileperm(mode); |
157 | } | 166 | } |
167 | |||