@ -7,6 +7,7 @@
*/
*/
# include "cgit.h"
# include "cgit.h"
# include "html.h"
const char cgit_doctype [ ] =
const char cgit_doctype [ ] =
" <!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN \" \n "
" <!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN \" \n "
@ -25,14 +26,6 @@ static char *http_date(time_t t)
tm - > tm_hour , tm - > tm_min , tm - > tm_sec ) ;
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 )
void cgit_print_error ( char * msg )
{
{
html ( " <div class='error'> " ) ;
html ( " <div class='error'> " ) ;
@ -42,16 +35,16 @@ void cgit_print_error(char *msg)
char * cgit_rooturl ( )
char * cgit_rooturl ( )
{
{
if ( c git_ virtual_root)
if ( c tx. cfg . virtual_root)
return fmt ( " %s/ " , c git_ virtual_root) ;
return fmt ( " %s/ " , c tx. cfg . virtual_root) ;
else
else
return c git_ script_name;
return c tx. cfg . script_name;
}
}
char * cgit_repourl ( const char * reponame )
char * cgit_repourl ( const char * reponame )
{
{
if ( c git_ virtual_root) {
if ( c tx. cfg . virtual_root) {
return fmt ( " %s/%s/ " , c git_ virtual_root, reponame ) ;
return fmt ( " %s/%s/ " , c tx. cfg . virtual_root, reponame ) ;
} else {
} else {
return fmt ( " ?r=%s " , reponame ) ;
return fmt ( " ?r=%s " , reponame ) ;
}
}
@ -63,8 +56,8 @@ char *cgit_fileurl(const char *reponame, const char *pagename,
char * tmp ;
char * tmp ;
char * delim ;
char * delim ;
if ( c git_ virtual_root) {
if ( c tx. cfg . virtual_root) {
tmp = fmt ( " %s/%s/%s/%s " , c git_ virtual_root, reponame ,
tmp = fmt ( " %s/%s/%s/%s " , c tx. cfg . virtual_root, reponame ,
pagename , ( filename ? filename : " " ) ) ;
pagename , ( filename ? filename : " " ) ) ;
delim = " ? " ;
delim = " ? " ;
} else {
} else {
@ -110,14 +103,14 @@ const char *cgit_repobasename(const char *reponame)
char * cgit_currurl ( )
char * cgit_currurl ( )
{
{
if ( ! c git_ virtual_root)
if ( ! c tx. cfg . virtual_root)
return c git_ script_name;
return c tx. cfg . script_name;
else if ( c git_query_ page)
else if ( c tx. qry . page)
return fmt ( " %s/%s/%s/ " , c git_virtual_root, cgit_query_repo , cgit_query_ page) ;
return fmt ( " %s/%s/%s/ " , c tx. cfg . virtual_root , ctx . qry . repo , ctx . qry . page) ;
else if ( c git_query_ repo)
else if ( c tx. qry . repo)
return fmt ( " %s/%s/ " , c git_virtual_root, cgit_query_ repo) ;
return fmt ( " %s/%s/ " , c tx. cfg . virtual_root , ctx . qry . repo) ;
else
else
return fmt ( " %s/ " , c git_ virtual_root) ;
return fmt ( " %s/ " , c tx. cfg . virtual_root) ;
}
}
static char * repolink ( char * title , char * class , char * page , char * head ,
static char * repolink ( char * title , char * class , char * page , char * head ,
@ -137,12 +130,12 @@ static char *repolink(char *title, char *class, char *page, char *head,
html ( " ' " ) ;
html ( " ' " ) ;
}
}
html ( " href=' " ) ;
html ( " href=' " ) ;
if ( c git_ virtual_root) {
if ( c tx. cfg . virtual_root) {
html_attr ( c git_ virtual_root) ;
html_attr ( c tx. cfg . virtual_root) ;
if ( c git_virtual_root[ strlen ( cgit_ virtual_root) - 1 ] ! = ' / ' )
if ( c tx. cfg . virtual_root [ strlen ( ctx . cfg . virtual_root) - 1 ] ! = ' / ' )
html ( " / " ) ;
html ( " / " ) ;
html_attr ( c git_ repo- > url ) ;
html_attr ( c tx. repo- > url ) ;
if ( c git_repo- > url [ strlen ( cgit_ repo- > url ) - 1 ] ! = ' / ' )
if ( c tx. repo - > url [ strlen ( ctx . repo- > url ) - 1 ] ! = ' / ' )
html ( " / " ) ;
html ( " / " ) ;
if ( page ) {
if ( page ) {
html ( page ) ;
html ( page ) ;
@ -151,10 +144,10 @@ static char *repolink(char *title, char *class, char *page, char *head,
html_attr ( path ) ;
html_attr ( path ) ;
}
}
} else {
} else {
html ( c git_ script_name) ;
html ( c tx. cfg . script_name) ;
html ( " ?url= " ) ;
html ( " ?url= " ) ;
html_attr ( c git_ repo- > url ) ;
html_attr ( c tx. repo- > url ) ;
if ( c git_repo- > url [ strlen ( cgit_ repo- > url ) - 1 ] ! = ' / ' )
if ( c tx. repo - > url [ strlen ( ctx . repo- > url ) - 1 ] ! = ' / ' )
html ( " / " ) ;
html ( " / " ) ;
if ( page ) {
if ( page ) {
html ( page ) ;
html ( page ) ;
@ -164,7 +157,7 @@ static char *repolink(char *title, char *class, char *page, char *head,
}
}
delim = " & " ;
delim = " & " ;
}
}
if ( head & & strcmp ( head , c git_ repo- > defbranch ) ) {
if ( head & & strcmp ( head , c tx. repo- > defbranch ) ) {
html ( delim ) ;
html ( delim ) ;
html ( " h= " ) ;
html ( " h= " ) ;
html_attr ( head ) ;
html_attr ( head ) ;
@ -179,7 +172,7 @@ static void reporevlink(char *page, char *name, char *title, char *class,
char * delim ;
char * delim ;
delim = repolink ( title , class , page , head , path ) ;
delim = repolink ( title , class , page , head , path ) ;
if ( rev & & strcmp ( rev , c git_query_ head) ) {
if ( rev & & strcmp ( rev , c tx. qry . head) ) {
html ( delim ) ;
html ( delim ) ;
html ( " id= " ) ;
html ( " id= " ) ;
html_attr ( rev ) ;
html_attr ( rev ) ;
@ -201,7 +194,7 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
char * delim ;
char * delim ;
delim = repolink ( title , class , " log " , head , path ) ;
delim = repolink ( title , class , " log " , head , path ) ;
if ( rev & & strcmp ( rev , c git_query_ head) ) {
if ( rev & & strcmp ( rev , c tx. qry . head) ) {
html ( delim ) ;
html ( delim ) ;
html ( " id= " ) ;
html ( " id= " ) ;
html_attr ( rev ) ;
html_attr ( rev ) ;
@ -229,11 +222,11 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
void cgit_commit_link ( char * name , char * title , char * class , char * head ,
void cgit_commit_link ( char * name , char * title , char * class , char * head ,
char * rev )
char * rev )
{
{
if ( strlen ( name ) > c git_max_msg_len & & cgit_ max_msg_len > = 15 ) {
if ( strlen ( name ) > c tx. cfg . max_msg_len & & ctx . cfg . max_msg_len > = 15 ) {
name [ c git_ max_msg_len] = ' \0 ' ;
name [ c tx. cfg . max_msg_len] = ' \0 ' ;
name [ c git_ max_msg_len - 1 ] = ' . ' ;
name [ c tx. cfg . max_msg_len - 1 ] = ' . ' ;
name [ c git_ max_msg_len - 2 ] = ' . ' ;
name [ c tx. cfg . max_msg_len - 2 ] = ' . ' ;
name [ c git_ max_msg_len - 3 ] = ' . ' ;
name [ c tx. cfg . max_msg_len - 3 ] = ' . ' ;
}
}
reporevlink ( " commit " , name , title , class , head , rev , NULL ) ;
reporevlink ( " commit " , name , title , class , head , rev , NULL ) ;
}
}
@ -256,7 +249,7 @@ void cgit_diff_link(char *name, char *title, char *class, char *head,
char * delim ;
char * delim ;
delim = repolink ( title , class , " diff " , head , path ) ;
delim = repolink ( title , class , " diff " , head , path ) ;
if ( new_rev & & strcmp ( new_rev , c git_query_ head) ) {
if ( new_rev & & strcmp ( new_rev , c tx. qry . head) ) {
html ( delim ) ;
html ( delim ) ;
html ( " id= " ) ;
html ( " id= " ) ;
html_attr ( new_rev ) ;
html_attr ( new_rev ) ;
@ -284,7 +277,7 @@ void cgit_object_link(struct object *obj)
if ( obj - > type = = OBJ_COMMIT ) {
if ( obj - > type = = OBJ_COMMIT ) {
cgit_commit_link ( fmt ( " commit %s " , sha1_to_hex ( obj - > sha1 ) ) , NULL , NULL ,
cgit_commit_link ( fmt ( " commit %s " , sha1_to_hex ( obj - > sha1 ) ) , NULL , NULL ,
c git_query_ head, sha1_to_hex ( obj - > sha1 ) ) ;
c tx. qry . head, sha1_to_hex ( obj - > sha1 ) ) ;
return ;
return ;
} else if ( obj - > type = = OBJ_TREE ) {
} else if ( obj - > type = = OBJ_TREE ) {
page = " tree " ;
page = " tree " ;
@ -297,7 +290,7 @@ void cgit_object_link(struct object *obj)
arg = " id " ;
arg = " id " ;
}
}
url = cgit_pageurl ( c git_query_ repo, page ,
url = cgit_pageurl ( c tx. qry . repo, page ,
fmt ( " %s=%s " , arg , sha1_to_hex ( obj - > sha1 ) ) ) ;
fmt ( " %s=%s " , arg , sha1_to_hex ( obj - > sha1 ) ) ) ;
html_link_open ( url , NULL , NULL ) ;
html_link_open ( url , NULL , NULL ) ;
htmlf ( " %s %s " , typename ( obj - > type ) ,
htmlf ( " %s %s " , typename ( obj - > type ) ,
@ -360,24 +353,34 @@ void cgit_print_age(time_t t, time_t max_relative, char *format)
secs * 1.0 / TM_YEAR ) ;
secs * 1.0 / TM_YEAR ) ;
}
}
void cgit_print_ docstart( char * title , struct cacheitem * item )
void cgit_print_ http_headers( struct cgit_context * ctx )
{
{
html ( " Content-Type: text/html; charset= " PAGE_ENCODING " \n " ) ;
if ( ctx - > page . mimetype & & ctx - > page . charset )
htmlf ( " Last-Modified: %s \n " , http_date ( item - > st . st_mtime ) ) ;
htmlf ( " Content-Type: %s; charset=%s \n " , ctx - > page . mimetype ,
htmlf ( " Expires: %s \n " , http_date ( item - > st . st_mtime +
ctx - > page . charset ) ;
ttl_seconds ( item - > ttl ) ) ) ;
else if ( ctx - > page . mimetype )
htmlf ( " Content-Type: %s \n " , ctx - > page . mimetype ) ;
if ( ctx - > page . filename )
htmlf ( " Content-Disposition: inline; filename= \" %s \" \n " ,
ctx - > page . filename ) ;
htmlf ( " Last-Modified: %s \n " , http_date ( ctx - > page . modified ) ) ;
htmlf ( " Expires: %s \n " , http_date ( ctx - > page . expires ) ) ;
html ( " \n " ) ;
html ( " \n " ) ;
}
void cgit_print_docstart ( struct cgit_context * ctx )
{
html ( cgit_doctype ) ;
html ( cgit_doctype ) ;
html ( " <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> \n " ) ;
html ( " <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> \n " ) ;
html ( " <head> \n " ) ;
html ( " <head> \n " ) ;
html ( " <title> " ) ;
html ( " <title> " ) ;
html_txt ( title ) ;
html_txt ( ctx- > page . title) ;
html ( " </title> \n " ) ;
html ( " </title> \n " ) ;
htmlf ( " <meta name='generator' content='cgit %s'/> \n " , cgit_version ) ;
htmlf ( " <meta name='generator' content='cgit %s'/> \n " , cgit_version ) ;
if ( c git_robots & & * cgit_ robots)
if ( c tx- > cfg . robots & & * ctx - > cfg . robots)
htmlf ( " <meta name='robots' content='%s'/> \n " , c git_ robots) ;
htmlf ( " <meta name='robots' content='%s'/> \n " , c tx- > cfg . robots) ;
html ( " <link rel='stylesheet' type='text/css' href=' " ) ;
html ( " <link rel='stylesheet' type='text/css' href=' " ) ;
html_attr ( c git_ css) ;
html_attr ( c tx- > cfg . css) ;
html ( " '/> \n " ) ;
html ( " '/> \n " ) ;
html ( " </head> \n " ) ;
html ( " </head> \n " ) ;
html ( " <body> \n " ) ;
html ( " <body> \n " ) ;
@ -392,7 +395,7 @@ int print_branch_option(const char *refname, const unsigned char *sha1,
int flags , void * cb_data )
int flags , void * cb_data )
{
{
char * name = ( char * ) refname ;
char * name = ( char * ) refname ;
html_option ( name , name , c git_query_ head) ;
html_option ( name , name , c tx. qry . head) ;
return 0 ;
return 0 ;
}
}
@ -426,7 +429,7 @@ int print_archive_ref(const char *refname, const unsigned char *sha1,
html ( " <h1>download</h1> \n " ) ;
html ( " <h1>download</h1> \n " ) ;
* header = 1 ;
* header = 1 ;
}
}
url = cgit_pageurl ( c git_query_ repo, " blob " ,
url = cgit_pageurl ( c tx. qry . repo, " blob " ,
fmt ( " id=%s&path=%s " , sha1_to_hex ( fileid ) ,
fmt ( " id=%s&path=%s " , sha1_to_hex ( fileid ) ,
buf ) ) ;
buf ) ) ;
html_link_open ( url , NULL , " menu " ) ;
html_link_open ( url , NULL , " menu " ) ;
@ -439,30 +442,30 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
{
{
char * url ;
char * url ;
if ( ! c git_ virtual_root) {
if ( ! c tx. cfg . virtual_root) {
url = fmt ( " %s/%s " , c git_query_ repo, page ) ;
url = fmt ( " %s/%s " , c tx. qry . repo, page ) ;
if ( c git_query_ path)
if ( c tx. qry . path)
url = fmt ( " %s/%s " , url , c git_query_ path) ;
url = fmt ( " %s/%s " , url , c tx. qry . path) ;
html_hidden ( " url " , url ) ;
html_hidden ( " url " , url ) ;
}
}
if ( incl_head & & strcmp ( c git_query_head, cgit_ repo- > defbranch ) )
if ( incl_head & & strcmp ( c tx. qry . head , ctx . repo- > defbranch ) )
html_hidden ( " h " , c git_query_ head) ;
html_hidden ( " h " , c tx. qry . head) ;
if ( c git_query_ sha1)
if ( c tx. qry . sha1)
html_hidden ( " id " , c git_query_ sha1) ;
html_hidden ( " id " , c tx. qry . sha1) ;
if ( c git_query_ sha2)
if ( c tx. qry . sha2)
html_hidden ( " id2 " , c git_query_ sha2) ;
html_hidden ( " id2 " , c tx. qry . sha2) ;
if ( incl_search ) {
if ( incl_search ) {
if ( c git_query_ grep)
if ( c tx. qry . grep)
html_hidden ( " qt " , c git_query_ grep) ;
html_hidden ( " qt " , c tx. qry . grep) ;
if ( c git_query_ search)
if ( c tx. qry . search)
html_hidden ( " q " , c git_query_ search) ;
html_hidden ( " q " , c tx. qry . search) ;
}
}
}
}
void cgit_print_pageheader ( char * title , int show_search )
void cgit_print_pageheader ( struct cgit_context * ctx )
{
{
static const char * default_info = " This is cgit, a fast webinterface for git repositories " ;
static const char * default_info = " This is cgit, a fast webinterface for git repositories " ;
int header = 0 ;
int header = 0 ;
@ -474,40 +477,40 @@ void cgit_print_pageheader(char *title, int show_search)
html ( " <tr><td class='sidebar'> \n <a href=' " ) ;
html ( " <tr><td class='sidebar'> \n <a href=' " ) ;
html_attr ( cgit_rooturl ( ) ) ;
html_attr ( cgit_rooturl ( ) ) ;
htmlf ( " '><img src='%s' alt='cgit'/></a> \n " ,
htmlf ( " '><img src='%s' alt='cgit'/></a> \n " ,
c git_ logo) ;
c tx- > cfg . logo) ;
html ( " </td></tr> \n <tr><td class='sidebar'> \n " ) ;
html ( " </td></tr> \n <tr><td class='sidebar'> \n " ) ;
if ( c git_query_ repo) {
if ( c tx- > repo) {
html ( " <h1 class='first'> " ) ;
html ( " <h1 class='first'> " ) ;
html_txt ( strrpart ( c git_ repo- > name , 20 ) ) ;
html_txt ( strrpart ( c tx- > repo- > name , 20 ) ) ;
html ( " </h1> \n " ) ;
html ( " </h1> \n " ) ;
html_txt ( c git_ repo- > desc ) ;
html_txt ( c tx- > repo- > desc ) ;
if ( c git_ repo- > owner ) {
if ( c tx- > repo- > owner ) {
html ( " <h1>owner</h1> \n " ) ;
html ( " <h1>owner</h1> \n " ) ;
html_txt ( c git_ repo- > owner ) ;
html_txt ( c tx- > repo- > owner ) ;
}
}
html ( " <h1>navigate</h1> \n " ) ;
html ( " <h1>navigate</h1> \n " ) ;
reporevlink ( NULL , " summary " , NULL , " menu " , c git_query_ head,
reporevlink ( NULL , " summary " , NULL , " menu " , c tx- > qry . head,
NULL , NULL ) ;
NULL , NULL ) ;
cgit_log_link ( " log " , NULL , " menu " , c git_query_ head, NULL , NULL ,
cgit_log_link ( " log " , NULL , " menu " , c tx- > qry . head, NULL , NULL ,
0 , NULL , NULL ) ;
0 , NULL , NULL ) ;
cgit_tree_link ( " tree " , NULL , " menu " , c git_query_ head,
cgit_tree_link ( " tree " , NULL , " menu " , c tx- > qry . head,
c git_query_ sha1, NULL ) ;
c tx- > qry . sha1, NULL ) ;
cgit_commit_link ( " commit " , NULL , " menu " , c git_query_ head,
cgit_commit_link ( " commit " , NULL , " menu " , c tx- > qry . head,
c git_query_ sha1) ;
c tx- > qry . sha1) ;
cgit_diff_link ( " diff " , NULL , " menu " , c git_query_ head,
cgit_diff_link ( " diff " , NULL , " menu " , c tx- > qry . head,
c git_query_sha1, cgit_query_ sha2, NULL ) ;
c tx- > qry . sha1 , ctx - > qry . sha2, NULL ) ;
cgit_patch_link ( " patch " , NULL , " menu " , c git_query_ head,
cgit_patch_link ( " patch " , NULL , " menu " , c tx- > qry . head,
c git_query_ sha1) ;
c tx- > qry . sha1) ;
for_each_ref ( print_archive_ref , & header ) ;
for_each_ref ( print_archive_ref , & header ) ;
if ( c git_repo- > clone_url | | cgit_ clone_prefix) {
if ( c tx- > repo - > clone_url | | ctx - > cfg . clone_prefix) {
html ( " <h1>clone</h1> \n " ) ;
html ( " <h1>clone</h1> \n " ) ;
if ( c git_ repo- > clone_url )
if ( c tx- > repo- > clone_url )
url = c git_ repo- > clone_url ;
url = c tx- > repo- > clone_url ;
else
else
url = fmt ( " %s%s " , c git_ clone_prefix,
url = fmt ( " %s%s " , c tx- > cfg . clone_prefix,
c git_ repo- > url ) ;
c tx- > repo- > url ) ;
html ( " <a class='menu' href=' " ) ;
html ( " <a class='menu' href=' " ) ;
html_attr ( url ) ;
html_attr ( url ) ;
html ( " ' title=' " ) ;
html ( " ' title=' " ) ;
@ -519,10 +522,10 @@ void cgit_print_pageheader(char *title, int show_search)
html ( " <h1>branch</h1> \n " ) ;
html ( " <h1>branch</h1> \n " ) ;
html ( " <form method='get' action=''> \n " ) ;
html ( " <form method='get' action=''> \n " ) ;
add_hidden_formfields ( 0 , 1 , c git_query_ page) ;
add_hidden_formfields ( 0 , 1 , c tx- > qry . page) ;
// html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>");
// html("<table summary='branch selector' class='grid'><tr><td id='branch-dropdown-cell'>");
html ( " <select name='h' onchange='this.form.submit();'> \n " ) ;
html ( " <select name='h' onchange='this.form.submit();'> \n " ) ;
for_each_branch_ref ( print_branch_option , c git_query_ head) ;
for_each_branch_ref ( print_branch_option , c tx- > qry . head) ;
html ( " </select> \n " ) ;
html ( " </select> \n " ) ;
// html("</td><td>");
// html("</td><td>");
html ( " <noscript><input type='submit' id='switch-btn' value='switch'/></noscript> \n " ) ;
html ( " <noscript><input type='submit' id='switch-btn' value='switch'/></noscript> \n " ) ;
@ -531,22 +534,22 @@ void cgit_print_pageheader(char *title, int show_search)
html ( " <h1>search</h1> \n " ) ;
html ( " <h1>search</h1> \n " ) ;
html ( " <form method='get' action=' " ) ;
html ( " <form method='get' action=' " ) ;
if ( c git_ virtual_root)
if ( c tx- > cfg . virtual_root)
html_attr ( cgit_fileurl ( c git_query_ repo, " log " ,
html_attr ( cgit_fileurl ( c tx- > qry . repo, " log " ,
c git_query_ path, NULL ) ) ;
c tx- > qry . path, NULL ) ) ;
html ( " '> \n " ) ;
html ( " '> \n " ) ;
add_hidden_formfields ( 1 , 0 , " log " ) ;
add_hidden_formfields ( 1 , 0 , " log " ) ;
html ( " <select name='qt'> \n " ) ;
html ( " <select name='qt'> \n " ) ;
html_option ( " grep " , " log msg " , c git_query_ grep) ;
html_option ( " grep " , " log msg " , c tx- > qry . grep) ;
html_option ( " author " , " author " , c git_query_ grep) ;
html_option ( " author " , " author " , c tx- > qry . grep) ;
html_option ( " committer " , " committer " , c git_query_ grep) ;
html_option ( " committer " , " committer " , c tx- > qry . grep) ;
html ( " </select> \n " ) ;
html ( " </select> \n " ) ;
html ( " <input class='txt' type='text' name='q' value=' " ) ;
html ( " <input class='txt' type='text' name='q' value=' " ) ;
html_attr ( c git_query_ search) ;
html_attr ( c tx- > qry . search) ;
html ( " '/> \n " ) ;
html ( " '/> \n " ) ;
html ( " </form> \n " ) ;
html ( " </form> \n " ) ;
} else {
} else {
if ( ! c git_index_info | | html_include ( cgit_ index_info) )
if ( ! c tx- > cfg . index_info | | html_include ( ctx - > cfg . index_info) )
html ( default_info ) ;
html ( default_info ) ;
}
}
@ -555,16 +558,34 @@ void cgit_print_pageheader(char *title, int show_search)
html ( " <td id='content'> \n " ) ;
html ( " <td id='content'> \n " ) ;
}
}
void cgit_print_filemode ( unsigned short mode )
void cgit_print_snapshot_start ( const char * mimetype , const char * filename ,
struct cacheitem * item )
{
{
htmlf ( " Content-Type: %s \n " , mimetype ) ;
if ( S_ISDIR ( mode ) )
htmlf ( " Content-Disposition: inline; filename= \" %s \" \n " , filename ) ;
html ( " d " ) ;
htmlf ( " Last-Modified: %s \n " , http_date ( item - > st . st_mtime ) ) ;
else if ( S_ISLNK ( mode ) )
htmlf ( " Expires: %s \n " , http_date ( item - > st . st_mtime +
html ( " l " ) ;
ttl_seconds ( item - > ttl ) ) ) ;
else if ( S_ISGITLINK ( mode ) )
html ( " \n " ) ;
html ( " m " ) ;
else
html ( " - " ) ;
html_fileperm ( mode > > 6 ) ;
html_fileperm ( mode > > 3 ) ;
html_fileperm ( mode ) ;
}
}
/* vim:set sw=8: */
void cgit_print_snapshot_links ( const char * repo , const char * head ,
const char * hex , int snapshots )
{
const struct cgit_snapshot_format * f ;
char * filename ;
for ( f = cgit_snapshot_formats ; f - > suffix ; f + + ) {
if ( ! ( snapshots & f - > bit ) )
continue ;
filename = fmt ( " %s-%s%s " , cgit_repobasename ( repo ) , hex ,
f - > suffix ) ;
cgit_snapshot_link ( filename , NULL , NULL , ( char * ) head ,
( char * ) hex , filename ) ;
html ( " <br/> " ) ;
}
}