cGit-UI for Git Repositories

cGit-UI – is a web interface for Git Repositories. cGit CGI script is writen in C and therefore it's fast enough

3 Commits   0 Branches   1 Tag
05d292b2 (kx 2023-03-24 03:51:10 +0300   1) 
05d292b2 (kx 2023-03-24 03:51:10 +0300   2) #ifdef HAVE_CONFIG_H
05d292b2 (kx 2023-03-24 03:51:10 +0300   3) #include <config.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300   4) #endif
05d292b2 (kx 2023-03-24 03:51:10 +0300   5) 
05d292b2 (kx 2023-03-24 03:51:10 +0300   6) #include <stdlib.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300   7) #include <stdio.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300   8) #include <sys/sysinfo.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300   9) #include <sys/types.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  10) #ifdef HAVE_INTTYPES_H
05d292b2 (kx 2023-03-24 03:51:10 +0300  11) #include <inttypes.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  12) #else
05d292b2 (kx 2023-03-24 03:51:10 +0300  13) #include <stdint.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  14) #endif
05d292b2 (kx 2023-03-24 03:51:10 +0300  15) #include <stddef.h>   /* offsetof(3) */
05d292b2 (kx 2023-03-24 03:51:10 +0300  16) #include <dirent.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  17) #include <sys/stat.h> /* chmod(2)    */
05d292b2 (kx 2023-03-24 03:51:10 +0300  18) #include <sys/file.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  19) #include <sys/mman.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  20) #include <fcntl.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  21) #include <limits.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  22) #include <string.h>   /* strdup(3)   */
05d292b2 (kx 2023-03-24 03:51:10 +0300  23) #include <libgen.h>   /* basename(3) */
05d292b2 (kx 2023-03-24 03:51:10 +0300  24) #include <ctype.h>    /* tolower(3)  */
05d292b2 (kx 2023-03-24 03:51:10 +0300  25) #include <errno.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  26) #include <time.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  27) #include <sys/time.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  28) #include <pwd.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  29) #include <grp.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  30) #include <stdarg.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  31) #include <locale.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  32) #include <unistd.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  33) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  34) #include <git2.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  35) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  36) #include <nls.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  37) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  38) #include <defs.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  39) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  40) #include <fatal.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  41) #include <http.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  42) #include <html.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  43) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  44) #include <dlist.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  45) #include <strbuf.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  46) #include <repolist.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  47) #include <wrapper.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  48) #include <system.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  49) #include <date.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  50) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  51) #include <ctx.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  52) #include <git-shared.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  53) #include <ui-shared.h>
05d292b2 (kx 2023-03-24 03:51:10 +0300  54) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  55) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  56) static void print_log_start( struct strbuf *sb )
05d292b2 (kx 2023-03-24 03:51:10 +0300  57) {
05d292b2 (kx 2023-03-24 03:51:10 +0300  58)   if( !sb ) return;
05d292b2 (kx 2023-03-24 03:51:10 +0300  59)   strbuf_addstr( sb, "\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  60)   strbuf_addf( sb, "              <div class=\"repo-log-header\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  61)   strbuf_addf( sb, "                <div class=\"row\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  62)   strbuf_addf( sb, "                  <div class=\"col-date\"><div class=\"log-date\">Date</div></div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  63)   strbuf_addf( sb, "                  <div class=\"col-cmsg\"><div class=\"log-cmsg trunc\">Commit Message</div></div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  64)   strbuf_addf( sb, "                  <div class=\"col-rev\"><div class=\"log-rev trunc\">Rev</div></div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  65)   strbuf_addf( sb, "                  <div class=\"col-author\"><div class=\"log-author trunc\">Author</div></div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  66)   strbuf_addf( sb, "                </div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  67)   strbuf_addf( sb, "              </div>\n\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  68)   strbuf_addf( sb, "              <div class=\"log\">\n\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  69) }
05d292b2 (kx 2023-03-24 03:51:10 +0300  70) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  71) static void print_log_stop( struct strbuf *sb )
05d292b2 (kx 2023-03-24 03:51:10 +0300  72) {
05d292b2 (kx 2023-03-24 03:51:10 +0300  73)   if( !sb ) return;
05d292b2 (kx 2023-03-24 03:51:10 +0300  74)   strbuf_addf( sb, "              </div> <!-- End of Log -->\n\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  75) }
05d292b2 (kx 2023-03-24 03:51:10 +0300  76) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  77) static void print_direction( struct strbuf *sb, const char *relative_path, int reminder, int limit )
05d292b2 (kx 2023-03-24 03:51:10 +0300  78) {
05d292b2 (kx 2023-03-24 03:51:10 +0300  79)   char *path = NULL;
05d292b2 (kx 2023-03-24 03:51:10 +0300  80)   int   page_size = atoi( ctx.vars.page_size );
05d292b2 (kx 2023-03-24 03:51:10 +0300  81)   int   prev, next;
05d292b2 (kx 2023-03-24 03:51:10 +0300  82) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  83)   if( !sb ) return;
05d292b2 (kx 2023-03-24 03:51:10 +0300  84) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  85)   if( relative_path && *relative_path )
05d292b2 (kx 2023-03-24 03:51:10 +0300  86)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300  87)     path = (char *)xmalloc( strlen( relative_path ) + 2 );
05d292b2 (kx 2023-03-24 03:51:10 +0300  88)     path[0] = '/';
05d292b2 (kx 2023-03-24 03:51:10 +0300  89)     sprintf( (char *)&path[1], relative_path );
05d292b2 (kx 2023-03-24 03:51:10 +0300  90)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300  91)   else
05d292b2 (kx 2023-03-24 03:51:10 +0300  92)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300  93)     path = (char *)xmalloc( 1 );
05d292b2 (kx 2023-03-24 03:51:10 +0300  94)     path[0] = '\0';
05d292b2 (kx 2023-03-24 03:51:10 +0300  95)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300  96) 
05d292b2 (kx 2023-03-24 03:51:10 +0300  97)   strbuf_addf( sb, "              <div class=\"log-direction\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  98)   strbuf_addf( sb, "                <div class=\"row\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300  99)   strbuf_addf( sb, "                  <div class=\"left col-prev\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 100)   strbuf_addf( sb, "                    <div class=\"prev-log-direction\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 101) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 102)   if( ctx.query.ofs )
05d292b2 (kx 2023-03-24 03:51:10 +0300 103)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300 104)     prev = ctx.query.ofs - page_size;
05d292b2 (kx 2023-03-24 03:51:10 +0300 105)     if( prev < 0 ) prev = 0;
05d292b2 (kx 2023-03-24 03:51:10 +0300 106) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 107)     if( ctx.env.query_string && *ctx.env.query_string )
05d292b2 (kx 2023-03-24 03:51:10 +0300 108)       strbuf_addf( sb, "                      <a href=\"/%s%s/?ofs=%d&%s\">&#x226a;&nbsp; Prev</a>\n", ctx.repo.name, path, prev, ctx.env.query_string );
05d292b2 (kx 2023-03-24 03:51:10 +0300 109)     else
05d292b2 (kx 2023-03-24 03:51:10 +0300 110)       strbuf_addf( sb, "                      <a href=\"/%s%s/?ofs=%d\">&#x226a;&nbsp; Prev</a>\n", ctx.repo.name, path, prev );
05d292b2 (kx 2023-03-24 03:51:10 +0300 111)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300 112) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 113)   strbuf_addf( sb, "                    </div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 114)   strbuf_addf( sb, "                  </div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 115)   strbuf_addf( sb, "                  <div class=\"right col-next\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 116)   strbuf_addf( sb, "                    <div class=\"next-log-direction\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 117) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 118)   if( reminder )
05d292b2 (kx 2023-03-24 03:51:10 +0300 119)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300 120)     next = ctx.query.ofs + page_size;
05d292b2 (kx 2023-03-24 03:51:10 +0300 121) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 122)     if( ctx.env.query_string && *ctx.env.query_string )
05d292b2 (kx 2023-03-24 03:51:10 +0300 123)       strbuf_addf( sb, "                      <a href=\"/%s%s/?ofs=%d&%s\">Next &nbsp;&#x226b;</a>\n", ctx.repo.name, path, next, ctx.env.query_string );
05d292b2 (kx 2023-03-24 03:51:10 +0300 124)     else
05d292b2 (kx 2023-03-24 03:51:10 +0300 125)       strbuf_addf( sb, "                      <a href=\"/%s%s/?ofs=%d\">Next &nbsp;&#x226b;</a>\n", ctx.repo.name, path, next );
05d292b2 (kx 2023-03-24 03:51:10 +0300 126)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300 127) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 128)   strbuf_addf( sb, "                    </div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 129)   strbuf_addf( sb, "                  </div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 130)   strbuf_addf( sb, "                </div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 131)   strbuf_addf( sb, "              </div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 132) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 133)   free( path );
05d292b2 (kx 2023-03-24 03:51:10 +0300 134) }
05d292b2 (kx 2023-03-24 03:51:10 +0300 135) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 136) static void print_commit_line( struct strbuf *sb, git_commit *commit, const char *relative_path, const char *revision )
05d292b2 (kx 2023-03-24 03:51:10 +0300 137) {
05d292b2 (kx 2023-03-24 03:51:10 +0300 138)   char *path = NULL;
05d292b2 (kx 2023-03-24 03:51:10 +0300 139) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 140)   if( !sb || !commit ) return;
05d292b2 (kx 2023-03-24 03:51:10 +0300 141) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 142)   if( relative_path && *relative_path )
05d292b2 (kx 2023-03-24 03:51:10 +0300 143)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300 144)     path = (char *)xmalloc( strlen( relative_path ) + 2 );
05d292b2 (kx 2023-03-24 03:51:10 +0300 145)     path[0] = '/';
05d292b2 (kx 2023-03-24 03:51:10 +0300 146)     sprintf( (char *)&path[1], relative_path );
05d292b2 (kx 2023-03-24 03:51:10 +0300 147)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300 148)   else
05d292b2 (kx 2023-03-24 03:51:10 +0300 149)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300 150)     path = (char *)xmalloc( 1 );
05d292b2 (kx 2023-03-24 03:51:10 +0300 151)     path[0] = '\0';
05d292b2 (kx 2023-03-24 03:51:10 +0300 152)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300 153) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 154)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300 155)     char id[GIT_OID_HEXSZ+1] = { 0 };
05d292b2 (kx 2023-03-24 03:51:10 +0300 156) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 157)     const git_oid       *oid     = git_commit_id( commit );
05d292b2 (kx 2023-03-24 03:51:10 +0300 158)     const char          *message = git_commit_summary( commit );
05d292b2 (kx 2023-03-24 03:51:10 +0300 159)     git_time_t           date    = git_commit_time( commit );
05d292b2 (kx 2023-03-24 03:51:10 +0300 160)     int                  offset  = git_commit_time_offset( commit );
05d292b2 (kx 2023-03-24 03:51:10 +0300 161)     const git_signature *author  = git_commit_author( commit );
05d292b2 (kx 2023-03-24 03:51:10 +0300 162) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 163)     const char *query_string = ctx_remove_query_param( ctx.env.query_string, "rev" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 164) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 165)     query_string = ctx_remove_query_param( query_string, "op" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 166) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 167)     offset = (offset % 60) + ((offset / 60) * 100);
05d292b2 (kx 2023-03-24 03:51:10 +0300 168) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 169)     if( git_oid_fmt( (char *)&id[0], oid ) < 0 || strcmp( (char *)&id[0], revision ) ) return;
05d292b2 (kx 2023-03-24 03:51:10 +0300 170) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 171) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 172)     strbuf_addf( sb, "                <div class=\"row\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 173)     if( date != -1 )
05d292b2 (kx 2023-03-24 03:51:10 +0300 174)     {
05d292b2 (kx 2023-03-24 03:51:10 +0300 175)       strbuf_addf( sb, "                  <div class=\"col-date\"><div onclick=\"trunc(this)\" class=\"log-date trunc\">" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 176)       cgit_print_age( sb, (time_t)date, offset, 0 );
05d292b2 (kx 2023-03-24 03:51:10 +0300 177)       strbuf_addf( sb, "</div></div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 178)     }
05d292b2 (kx 2023-03-24 03:51:10 +0300 179)     else
05d292b2 (kx 2023-03-24 03:51:10 +0300 180)     {
05d292b2 (kx 2023-03-24 03:51:10 +0300 181)       strbuf_addf( sb, "                  <div class=\"col-date\"><div onclick=\"trunc(this)\" class=\"log-date trunc\">unknown</div></div>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 182)     }
05d292b2 (kx 2023-03-24 03:51:10 +0300 183)     strbuf_addf( sb, "                  <div class=\"col-cmsg\"><div onclick=\"trunc(this)\" class=\"log-cmsg trunc\">%s</div></div>\n", (char *)message );
05d292b2 (kx 2023-03-24 03:51:10 +0300 184)     if( query_string && *query_string )
05d292b2 (kx 2023-03-24 03:51:10 +0300 185)     {
05d292b2 (kx 2023-03-24 03:51:10 +0300 186)       strbuf_addf( sb, "                  <div class=\"col-rev\"><div onclick=\"trunc(this)\" class=\"log-rev trunc\"><a title=\"Compare with Previous\" href=\"/%s%s/?op=diff&rev=%s&%s\"><span class=\"rev-short\">%0.8s</span></a></div></div>\n", ctx.repo.name, path, (char *)revision, query_string, (char *)revision );
05d292b2 (kx 2023-03-24 03:51:10 +0300 187)     }
05d292b2 (kx 2023-03-24 03:51:10 +0300 188)     else
05d292b2 (kx 2023-03-24 03:51:10 +0300 189)     {
05d292b2 (kx 2023-03-24 03:51:10 +0300 190)       strbuf_addf( sb, "                  <div class=\"col-rev\"><div onclick=\"trunc(this)\" class=\"log-rev trunc\"><a title=\"Compare with Previous\" href=\"/%s%s/?op=diff&rev=%s\"><span class=\"rev-short\">%0.8s</span></a></div></div>\n", ctx.repo.name, path, (char *)revision, (char *)revision );
05d292b2 (kx 2023-03-24 03:51:10 +0300 191)     }
05d292b2 (kx 2023-03-24 03:51:10 +0300 192)     strbuf_addf( sb, "                  <div class=\"col-author\"><div onclick=\"trunc(this)\" class=\"log-author trunc\">%s</div></div>\n", (char *)author->name );
05d292b2 (kx 2023-03-24 03:51:10 +0300 193)     strbuf_addf( sb, "                </div>\n\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 194)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300 195) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 196)   free( path );
05d292b2 (kx 2023-03-24 03:51:10 +0300 197) }
05d292b2 (kx 2023-03-24 03:51:10 +0300 198) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 199) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 200) static void cgit_print_log( struct strbuf *sb, const char *relative_path, const char *revision )
05d292b2 (kx 2023-03-24 03:51:10 +0300 201) {
05d292b2 (kx 2023-03-24 03:51:10 +0300 202)   struct cgit_hex_commits *commits = NULL;
05d292b2 (kx 2023-03-24 03:51:10 +0300 203)   size_t i, limit, reminder, page_size = (size_t)atoi( ctx.vars.page_size );
05d292b2 (kx 2023-03-24 03:51:10 +0300 204) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 205)   if( !sb ) return;
05d292b2 (kx 2023-03-24 03:51:10 +0300 206) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 207)   print_log_start( sb );
05d292b2 (kx 2023-03-24 03:51:10 +0300 208) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 209)   cgit_fill_commits_list( &commits, ctx.query.ofs, relative_path, revision );
05d292b2 (kx 2023-03-24 03:51:10 +0300 210) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 211)   limit = min( page_size, commits->len );
05d292b2 (kx 2023-03-24 03:51:10 +0300 212) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 213)   for( i = 0; i < limit; ++i )
05d292b2 (kx 2023-03-24 03:51:10 +0300 214)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300 215)     git_commit *commit = NULL;
05d292b2 (kx 2023-03-24 03:51:10 +0300 216)     commit = lookup_commit_by_hex( commits->hex[i] );
05d292b2 (kx 2023-03-24 03:51:10 +0300 217) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 218)     print_commit_line( sb, commit, relative_path, (const char *)commits->hex[i] );
05d292b2 (kx 2023-03-24 03:51:10 +0300 219) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 220)     git_commit_free( commit );
05d292b2 (kx 2023-03-24 03:51:10 +0300 221)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300 222) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 223)   reminder = commits->len - limit;
05d292b2 (kx 2023-03-24 03:51:10 +0300 224) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 225)   cgit_hex_commits_free( commits );
05d292b2 (kx 2023-03-24 03:51:10 +0300 226) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 227)   print_log_stop( sb );
05d292b2 (kx 2023-03-24 03:51:10 +0300 228) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 229)   if( !(!ctx.query.ofs && !reminder) )
05d292b2 (kx 2023-03-24 03:51:10 +0300 230)     print_direction( sb, relative_path, (int)reminder, (int)limit );
05d292b2 (kx 2023-03-24 03:51:10 +0300 231) }
05d292b2 (kx 2023-03-24 03:51:10 +0300 232) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 233) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 234) void cgit_print_log_page( void )
05d292b2 (kx 2023-03-24 03:51:10 +0300 235) {
05d292b2 (kx 2023-03-24 03:51:10 +0300 236)   FILE  *fp;
05d292b2 (kx 2023-03-24 03:51:10 +0300 237)   struct strbuf buf = STRBUF_INIT;
05d292b2 (kx 2023-03-24 03:51:10 +0300 238) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 239)   fp = xfopen( ctx.page.header, "r" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 240)   (void)strbuf_env_fread( &buf, fp );
05d292b2 (kx 2023-03-24 03:51:10 +0300 241)   fclose( fp );
05d292b2 (kx 2023-03-24 03:51:10 +0300 242) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 243)   strbuf_addf( &buf, "        <div class=\"content segment\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 244)   strbuf_addf( &buf, "          <div class=\"container\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 245)   strbuf_addf( &buf, "            <div class=\"cgit-main-content\">\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 246) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 247)   if( ctx.repo.name )
05d292b2 (kx 2023-03-24 03:51:10 +0300 248)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300 249)     cgit_print_log( &buf, ctx.repo.relative_path, (!strcmp( ctx.query.rev, "0" )) ? (const char *)&ctx.repo.relative_info.revision[0] : ctx.query.rev );
05d292b2 (kx 2023-03-24 03:51:10 +0300 250)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300 251)   else
05d292b2 (kx 2023-03-24 03:51:10 +0300 252)   {
05d292b2 (kx 2023-03-24 03:51:10 +0300 253)     strbuf_addf( &buf, "              <h1>Requested resource cannot be shown</h1>\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 254)     strbuf_addf( &buf, "              <p class='leading'>Repository '%s' not found.</p>\n", ctx.repo.name );
05d292b2 (kx 2023-03-24 03:51:10 +0300 255)   }
05d292b2 (kx 2023-03-24 03:51:10 +0300 256) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 257)   strbuf_addf( &buf, "            </div> <!-- End of cgit-main-content -->\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 258)   strbuf_addf( &buf, "          </div> <!-- End of container -->\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 259)   strbuf_addf( &buf, "        </div> <!-- End of content segment -->\n" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 260) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 261)   fp = xfopen( ctx.page.footer, "r" );
05d292b2 (kx 2023-03-24 03:51:10 +0300 262)   (void)strbuf_env_fread( &buf, fp );
05d292b2 (kx 2023-03-24 03:51:10 +0300 263)   fclose( fp );
05d292b2 (kx 2023-03-24 03:51:10 +0300 264) 
05d292b2 (kx 2023-03-24 03:51:10 +0300 265)   ctx.page.size = buf.len;
05d292b2 (kx 2023-03-24 03:51:10 +0300 266)   cgit_print_http_headers();
05d292b2 (kx 2023-03-24 03:51:10 +0300 267)   strbuf_write( &buf, STDOUT_FILENO );
05d292b2 (kx 2023-03-24 03:51:10 +0300 268)   strbuf_release( &buf );
05d292b2 (kx 2023-03-24 03:51:10 +0300 269) }