aboutsummaryrefslogtreecommitdiffstats
path: root/ui-summary.c
diff options
context:
space:
mode:
authorLars Hjemli2007-10-30 10:47:38 +0100
committerLars Hjemli2007-10-30 13:38:34 +0100
commit0c8e184e9cbf4d3a1e907de9125f6d8210c169d6 (patch)
tree2e82baf582b7ba0b34f498e1e7494800070067f9 /ui-summary.c
parent10ac7ad1f30f914dc5ff36ba3651ef6dca11aaf7 (diff)
downloadcgit-0c8e184e9cbf4d3a1e907de9125f6d8210c169d6.tar.gz
cgit-0c8e184e9cbf4d3a1e907de9125f6d8210c169d6.tar.bz2
cgit-0c8e184e9cbf4d3a1e907de9125f6d8210c169d6.zip
Change the cgit layout
This modifies and hopefully improves the layout of all cgit pages: * Remove the header from all pages and replace it with a sidebar; most pages have sufficient width but many needs more height. * Add a dropdown-box to switch between branches, using a one-liner javascript to reload the current page in context of the selected branch. * Include refs found below refs/archives in the sidebar, appearing as a set of menuitems below a 'download' heading. * Include the brand new cgit logo Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-summary.c')
-rw-r--r--ui-summary.c65
1 files changed, 6 insertions, 59 deletions
diff --git a/ui-summary.c b/ui-summary.c
index ba90510..39fe330 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -120,47 +120,6 @@ static int print_tag(struct refinfo *ref)
120 return 0; 120 return 0;
121} 121}
122 122
123static int cgit_print_archive_cb(const char *refname, const unsigned char *sha1,
124 int flags, void *cb_data)
125{
126 struct tag *tag;
127 struct taginfo *info;
128 struct object *obj;
129 char buf[256], *url;
130 unsigned char fileid[20];
131
132 if (prefixcmp(refname, "refs/archives"))
133 return 0;
134 strncpy(buf, refname+14, sizeof(buf));
135 obj = parse_object(sha1);
136 if (!obj)
137 return 1;
138 if (obj->type == OBJ_TAG) {
139 tag = lookup_tag(sha1);
140 if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
141 return 0;
142 hashcpy(fileid, tag->tagged->sha1);
143 } else if (obj->type != OBJ_BLOB) {
144 return 0;
145 } else {
146 hashcpy(fileid, sha1);
147 }
148 if (!header) {
149 html("<table id='downloads'>");
150 html("<tr><th>Downloads</th></tr>");
151 header = 1;
152 }
153 html("<tr><td>");
154 url = cgit_pageurl(cgit_query_repo, "blob",
155 fmt("id=%s&amp;path=%s", sha1_to_hex(fileid),
156 buf));
157 html_link_open(url, NULL, NULL);
158 html_txt(buf);
159 html_link_close();
160 html("</td></tr>");
161 return 0;
162}
163
164static void print_refs_link(char *path) 123static void print_refs_link(char *path)
165{ 124{
166 html("<tr class='nohover'><td colspan='4'>"); 125 html("<tr class='nohover'><td colspan='4'>");
@@ -221,28 +180,16 @@ void cgit_print_tags(int maxcount)
221 print_refs_link("tags"); 180 print_refs_link("tags");
222} 181}
223 182
224static void cgit_print_archives()
225{
226 header = 0;
227 for_each_ref(cgit_print_archive_cb, NULL);
228 if (header)
229 html("</table>");
230}
231
232void cgit_print_summary() 183void cgit_print_summary()
233{ 184{
234 html("<div id='summary'>"); 185 if (cgit_repo->readme) {
235 cgit_print_archives(); 186 html("<div id='summary'>");
236 html("<h2>");
237 html_txt(cgit_repo->name);
238 html(" - ");
239 html_txt(cgit_repo->desc);
240 html("</h2>");
241 if (cgit_repo->readme)
242 html_include(cgit_repo->readme); 187 html_include(cgit_repo->readme);
243 html("</div>"); 188 html("</div>");
189 }
244 if (cgit_summary_log > 0) 190 if (cgit_summary_log > 0)
245 cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL, NULL, NULL, 0); 191 cgit_print_log(cgit_query_head, 0, cgit_summary_log, NULL,
192 NULL, NULL, 0);
246 html("<table class='list nowrap'>"); 193 html("<table class='list nowrap'>");
247 if (cgit_summary_log > 0) 194 if (cgit_summary_log > 0)
248 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>"); 195 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");