author | Lars Hjemli <hjemli@gmail.com> | 2008-02-23 21:45:33 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-03-18 07:13:10 (UTC) |
commit | b1f9b9c1459cb9a30ebf80721aff6ef788d1f891 (patch) (side-by-side diff) | |
tree | 05796a741faef90c12aadd3a5c92b702ec870c48 /ui-shared.c | |
parent | b88fb016d0209f7041ac7d3b4d2c077318407a4d (diff) | |
download | cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.zip cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.tar.gz cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.tar.bz2 |
Introduce html.h
All html-functions can be quite easily separated from the rest of cgit, so
lets do it; the only issue was html_filemode which uses some git-defined
macros so the function is moved into ui-shared.c::cgit_print_filemode().
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index cc1ab8b..2eff79d 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1,41 +1,42 @@ /* ui-shared.c: common web output functions * * Copyright (C) 2006 Lars Hjemli * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ #include "cgit.h" +#include "html.h" const char cgit_doctype[] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; static char *http_date(time_t t) { static char day[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; static char month[][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Now", "Dec"}; struct tm *tm = gmtime(&t); return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec); } static long ttl_seconds(long ttl) { if (ttl<0) return 60 * 60 * 24 * 365; else return ttl * 60; } void cgit_print_error(char *msg) { html("<div class='error'>"); html_txt(msg); html("</div>\n"); } @@ -538,33 +539,48 @@ void cgit_print_pageheader(char *title, int show_search) add_hidden_formfields(1, 0, "log"); html("<select name='qt'>\n"); html_option("grep", "log msg", ctx.qry.grep); html_option("author", "author", ctx.qry.grep); html_option("committer", "committer", ctx.qry.grep); html("</select>\n"); html("<input class='txt' type='text' name='q' value='"); html_attr(ctx.qry.search); html("'/>\n"); html("</form>\n"); } else { if (!ctx.cfg.index_info || html_include(ctx.cfg.index_info)) html(default_info); } html("</td></tr></table></td>\n"); html("<td id='content'>\n"); } void cgit_print_snapshot_start(const char *mimetype, const char *filename, struct cacheitem *item) { htmlf("Content-Type: %s\n", mimetype); htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); htmlf("Expires: %s\n", http_date(item->st.st_mtime + ttl_seconds(item->ttl))); html("\n"); } +void cgit_print_filemode(unsigned short mode) +{ + if (S_ISDIR(mode)) + html("d"); + else if (S_ISLNK(mode)) + html("l"); + else if (S_ISGITLINK(mode)) + html("m"); + else + html("-"); + html_fileperm(mode >> 6); + html_fileperm(mode >> 3); + html_fileperm(mode); +} + /* vim:set sw=8: */ |