bfc1508d (kx 2023-03-24 03:55:33 +0300 1)
bfc1508d (kx 2023-03-24 03:55:33 +0300 2) #ifdef HAVE_CONFIG_H
bfc1508d (kx 2023-03-24 03:55:33 +0300 3) #include <config.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 4) #endif
bfc1508d (kx 2023-03-24 03:55:33 +0300 5)
bfc1508d (kx 2023-03-24 03:55:33 +0300 6) #include <stdlib.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 7) #include <stdio.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 8) #include <sys/sysinfo.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 9) #include <sys/types.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 10) #ifdef HAVE_INTTYPES_H
bfc1508d (kx 2023-03-24 03:55:33 +0300 11) #include <inttypes.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 12) #else
bfc1508d (kx 2023-03-24 03:55:33 +0300 13) #include <stdint.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 14) #endif
bfc1508d (kx 2023-03-24 03:55:33 +0300 15) #include <stddef.h> /* offsetof(3) */
bfc1508d (kx 2023-03-24 03:55:33 +0300 16) #include <dirent.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 17) #include <sys/stat.h> /* chmod(2) */
bfc1508d (kx 2023-03-24 03:55:33 +0300 18) #include <sys/file.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 19) #include <sys/mman.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 20) #include <fcntl.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 21) #include <limits.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 22) #include <string.h> /* strdup(3) */
bfc1508d (kx 2023-03-24 03:55:33 +0300 23) #include <libgen.h> /* basename(3) */
bfc1508d (kx 2023-03-24 03:55:33 +0300 24) #include <ctype.h> /* tolower(3) */
bfc1508d (kx 2023-03-24 03:55:33 +0300 25) #include <errno.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 26) #include <time.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 27) #include <sys/time.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 28) #include <pwd.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 29) #include <grp.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 30) #include <stdarg.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 31) #include <locale.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 32) #include <unistd.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 33)
bfc1508d (kx 2023-03-24 03:55:33 +0300 34) #include <nls.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 35)
bfc1508d (kx 2023-03-24 03:55:33 +0300 36) #include <defs.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 37)
bfc1508d (kx 2023-03-24 03:55:33 +0300 38) #include <fatal.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 39) #include <http.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 40) #include <html.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 41)
bfc1508d (kx 2023-03-24 03:55:33 +0300 42) #include <dlist.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 43) #include <strbuf.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 44) #include <repolist.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 45) #include <wrapper.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 46) #include <system.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 47) #include <date.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 48)
bfc1508d (kx 2023-03-24 03:55:33 +0300 49) #include <ctx.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 50) #include <ui-shared.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 51) #include <ui-repolist.h>
bfc1508d (kx 2023-03-24 03:55:33 +0300 52)
bfc1508d (kx 2023-03-24 03:55:33 +0300 53)
bfc1508d (kx 2023-03-24 03:55:33 +0300 54)
bfc1508d (kx 2023-03-24 03:55:33 +0300 55) void csvn_print_direction( struct strbuf *sb, int prev, int next )
bfc1508d (kx 2023-03-24 03:55:33 +0300 56) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 57) strbuf_addf( sb, " <div class=\"direction\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 58) strbuf_addf( sb, " <div class=\"row\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 59) strbuf_addf( sb, " <div class=\"left col-prev\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 60) strbuf_addf( sb, " <div class=\"prev-direction\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 61)
bfc1508d (kx 2023-03-24 03:55:33 +0300 62) if( prev )
bfc1508d (kx 2023-03-24 03:55:33 +0300 63) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 64) if( ctx.env.query_string && *ctx.env.query_string )
bfc1508d (kx 2023-03-24 03:55:33 +0300 65) strbuf_addf( sb, " <a href=\"%s?ofs=%d&%s\">≪ Prev</a>\n", ctx.repo.relative_href, prev, ctx.env.query_string );
bfc1508d (kx 2023-03-24 03:55:33 +0300 66) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 67) strbuf_addf( sb, " <a href=\"%s?ofs=%d\">≪ Prev</a>\n", ctx.repo.relative_href, prev );
bfc1508d (kx 2023-03-24 03:55:33 +0300 68) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 69) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 70) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 71) if( ctx.env.query_string && *ctx.env.query_string )
bfc1508d (kx 2023-03-24 03:55:33 +0300 72) strbuf_addf( sb, " <a href=\"%s?%s\">≪ Prev</a>\n", ctx.repo.relative_href, ctx.env.query_string );
bfc1508d (kx 2023-03-24 03:55:33 +0300 73) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 74) strbuf_addf( sb, " <a href=\"%s\">≪ Prev</a>\n", ctx.repo.relative_href );
bfc1508d (kx 2023-03-24 03:55:33 +0300 75) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 76)
bfc1508d (kx 2023-03-24 03:55:33 +0300 77) strbuf_addf( sb, " </div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 78) strbuf_addf( sb, " </div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 79) strbuf_addf( sb, " <div class=\"right col-next\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 80) strbuf_addf( sb, " <div class=\"next-direction\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 81)
bfc1508d (kx 2023-03-24 03:55:33 +0300 82) if( next )
bfc1508d (kx 2023-03-24 03:55:33 +0300 83) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 84) if( ctx.env.query_string && *ctx.env.query_string )
bfc1508d (kx 2023-03-24 03:55:33 +0300 85) strbuf_addf( sb, " <a href=\"%s?ofs=%d&%s\">Next ≫</a>\n", ctx.repo.relative_href, next, ctx.env.query_string );
bfc1508d (kx 2023-03-24 03:55:33 +0300 86) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 87) strbuf_addf( sb, " <a href=\"%s?ofs=%d\">Next ≫</a>\n", ctx.repo.relative_href, next );
bfc1508d (kx 2023-03-24 03:55:33 +0300 88) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 89) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 90) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 91) if( ctx.env.query_string && *ctx.env.query_string )
bfc1508d (kx 2023-03-24 03:55:33 +0300 92) strbuf_addf( sb, " <a href=\"%s?%s\">Next ≫</a>\n", ctx.repo.relative_href, ctx.env.query_string );
bfc1508d (kx 2023-03-24 03:55:33 +0300 93) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 94) strbuf_addf( sb, " <a href=\"%s\">Next ≫</a>\n", ctx.repo.relative_href );
bfc1508d (kx 2023-03-24 03:55:33 +0300 95) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 96)
bfc1508d (kx 2023-03-24 03:55:33 +0300 97) strbuf_addf( sb, " </div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 98) strbuf_addf( sb, " </div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 99) strbuf_addf( sb, " </div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 100) strbuf_addf( sb, " </div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 101) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 102)
bfc1508d (kx 2023-03-24 03:55:33 +0300 103) void csvn_print_repolist_header( struct strbuf *sb )
bfc1508d (kx 2023-03-24 03:55:33 +0300 104) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 105) strbuf_addf( sb, " <div class=\"repo-list-header\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 106) strbuf_addf( sb, " <div class=\"row\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 107) strbuf_addf( sb, " <div class=\"col-name\">Name</div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 108) strbuf_addf( sb, " <div class=\"col-desc\">Description</div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 109) strbuf_addf( sb, " <div class=\"col-owner\"><div class=\"repo-owner trunc\">Owner</div></div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 110) strbuf_addf( sb, " <div class=\"col-rev\"><div class=\"repo-rev trunc\">Rev</div></div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 111) strbuf_addf( sb, " <div class=\"col-idle\"><div class=\"repo-idle trunc\">Idle</div></div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 112) strbuf_addf( sb, " </div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 113) strbuf_addf( sb, " </div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 114) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 115)
bfc1508d (kx 2023-03-24 03:55:33 +0300 116) void csvn_print_section_start( struct strbuf *sb, const char *name )
bfc1508d (kx 2023-03-24 03:55:33 +0300 117) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 118) if( !sb ) return;
bfc1508d (kx 2023-03-24 03:55:33 +0300 119)
bfc1508d (kx 2023-03-24 03:55:33 +0300 120) strbuf_addf( sb, " <div class=\"section\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 121) if( name && *name )
bfc1508d (kx 2023-03-24 03:55:33 +0300 122) strbuf_addf( sb, " <div class=\"section-header\">%s</div>\n\n", name );
bfc1508d (kx 2023-03-24 03:55:33 +0300 123) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 124) strbuf_addf( sb, " <div class=\"section-header\"></div>\n\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 125) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 126)
bfc1508d (kx 2023-03-24 03:55:33 +0300 127) void csvn_print_section_stop( struct strbuf *sb )
bfc1508d (kx 2023-03-24 03:55:33 +0300 128) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 129) if( !sb ) return;
bfc1508d (kx 2023-03-24 03:55:33 +0300 130) strbuf_addf( sb, " </div> <!-- end of section -->\n\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 131) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 132)
bfc1508d (kx 2023-03-24 03:55:33 +0300 133) void csvn_print_repo( struct strbuf *sb, struct repo *repo )
bfc1508d (kx 2023-03-24 03:55:33 +0300 134) {
c7693c71 (kx 2023-04-12 19:21:06 +0300 135) struct variable repo_root = { (unsigned char *)"repo-root", { 0 }, DT_PATH },
c7693c71 (kx 2023-04-12 19:21:06 +0300 136) owner = { (unsigned char *)"owner", { 0 }, DT_STRING },
bfc1508d (kx 2023-03-24 03:55:33 +0300 137) description = { (unsigned char *)"description", { 0 }, DT_STRING };
c7693c71 (kx 2023-04-12 19:21:06 +0300 138) struct variable *rroot = NULL;
bfc1508d (kx 2023-03-24 03:55:33 +0300 139) struct variable *auth = NULL;
bfc1508d (kx 2023-03-24 03:55:33 +0300 140) struct variable *desc = NULL;
bfc1508d (kx 2023-03-24 03:55:33 +0300 141)
bfc1508d (kx 2023-03-24 03:55:33 +0300 142) struct strbuf buf = STRBUF_INIT;
bfc1508d (kx 2023-03-24 03:55:33 +0300 143) size_t revision = csvn_repo_last_changed_revision( &buf, repo );
bfc1508d (kx 2023-03-24 03:55:33 +0300 144)
bfc1508d (kx 2023-03-24 03:55:33 +0300 145) time_t time = 0;
bfc1508d (kx 2023-03-24 03:55:33 +0300 146)
bfc1508d (kx 2023-03-24 03:55:33 +0300 147) if( !sb || !repo || !repo->path ) return;
bfc1508d (kx 2023-03-24 03:55:33 +0300 148)
c7693c71 (kx 2023-04-12 19:21:06 +0300 149) rroot = lookup( repo, &repo_root );
c7693c71 (kx 2023-04-12 19:21:06 +0300 150) auth = lookup( repo, &owner );
c7693c71 (kx 2023-04-12 19:21:06 +0300 151) desc = lookup( repo, &description );
c7693c71 (kx 2023-04-12 19:21:06 +0300 152) time = csvn_repo_last_changed_time( repo );
bfc1508d (kx 2023-03-24 03:55:33 +0300 153)
bfc1508d (kx 2023-03-24 03:55:33 +0300 154) strbuf_addf( sb, " <div class=\"row\">\n" );
c7693c71 (kx 2023-04-12 19:21:06 +0300 155) if( rroot )
c7693c71 (kx 2023-04-12 19:21:06 +0300 156) strbuf_addf( sb, " <div class=\"col-name\"><a href=\"/%s/%s/\"><div class=\"repo-name\">%s</div></a></div>\n", (const char *)rroot->_v.vptr, repo->path, repo->path );
c7693c71 (kx 2023-04-12 19:21:06 +0300 157) else
c7693c71 (kx 2023-04-12 19:21:06 +0300 158) strbuf_addf( sb, " <div class=\"col-name\"><a href=\"/%s/\"><div class=\"repo-name\">%s</div></a></div>\n", repo->path, repo->path );
bfc1508d (kx 2023-03-24 03:55:33 +0300 159)
bfc1508d (kx 2023-03-24 03:55:33 +0300 160) if( desc )
bfc1508d (kx 2023-03-24 03:55:33 +0300 161) strbuf_addf( sb, " <div class=\"col-desc\"><div onclick=\"trunc(this)\" class=\"repo-desc trunc\">%s</div></div>\n", (const char *)desc->_v.vptr );
bfc1508d (kx 2023-03-24 03:55:33 +0300 162) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 163) strbuf_addf( sb, " <div class=\"col-desc\"><div onclick=\"trunc(this)\" class=\"repo-desc trunc\">none</div></div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 164)
bfc1508d (kx 2023-03-24 03:55:33 +0300 165) if( auth )
bfc1508d (kx 2023-03-24 03:55:33 +0300 166) strbuf_addf( sb, " <div class=\"col-owner\"><div onclick=\"trunc(this)\" class=\"repo-owner trunc\">%s</div></div>\n", (const char *)auth->_v.vptr );
bfc1508d (kx 2023-03-24 03:55:33 +0300 167) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 168) strbuf_addf( sb, " <div class=\"col-owner\"><div onclick=\"trunc(this)\" class=\"repo-owner trunc\">none</div></div>\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 169)
bfc1508d (kx 2023-03-24 03:55:33 +0300 170) if( revision )
bfc1508d (kx 2023-03-24 03:55:33 +0300 171) strbuf_addf( sb, " <div class=\"col-rev\"><div onclick=\"trunc(this)\" class=\"repo-rev trunc\">%s</div></div>\n", buf.buf );
bfc1508d (kx 2023-03-24 03:55:33 +0300 172) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 173) strbuf_addf( sb, " <div class=\"col-rev\"><div onclick=\"trunc(this)\" class=\"repo-rev trunc\">%s</div></div>\n", "0" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 174)
bfc1508d (kx 2023-03-24 03:55:33 +0300 175) strbuf_release( &buf );
bfc1508d (kx 2023-03-24 03:55:33 +0300 176)
bfc1508d (kx 2023-03-24 03:55:33 +0300 177) if( time != -1 )
bfc1508d (kx 2023-03-24 03:55:33 +0300 178) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 179) struct strbuf buf = STRBUF_INIT;
bfc1508d (kx 2023-03-24 03:55:33 +0300 180) csvn_print_age( &buf, time, 0, TM_YEAR );
bfc1508d (kx 2023-03-24 03:55:33 +0300 181) strbuf_addf( sb, " <div class=\"col-idle\"><div onclick=\"trunc(this)\" class=\"repo-idle trunc\">%s</div></div>\n", buf.buf );
bfc1508d (kx 2023-03-24 03:55:33 +0300 182) strbuf_release( &buf );
bfc1508d (kx 2023-03-24 03:55:33 +0300 183) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 184) else
bfc1508d (kx 2023-03-24 03:55:33 +0300 185) strbuf_addf( sb, " <div class=\"col-idle\"><div onclick=\"trunc(this)\" class=\"repo-idle trunc\">%s</div></div>\n", "unknown" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 186)
bfc1508d (kx 2023-03-24 03:55:33 +0300 187) strbuf_addf( sb, " </div>\n\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 188) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 189)
bfc1508d (kx 2023-03-24 03:55:33 +0300 190)
bfc1508d (kx 2023-03-24 03:55:33 +0300 191) int csvn_print_page_repolist( struct strbuf *sb, struct dlist *config, int start_no, int n )
bfc1508d (kx 2023-03-24 03:55:33 +0300 192) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 193) struct dlist *list = NULL;
bfc1508d (kx 2023-03-24 03:55:33 +0300 194) int length = 0;
bfc1508d (kx 2023-03-24 03:55:33 +0300 195)
bfc1508d (kx 2023-03-24 03:55:33 +0300 196) if( !config || !sb ) return length;
bfc1508d (kx 2023-03-24 03:55:33 +0300 197)
bfc1508d (kx 2023-03-24 03:55:33 +0300 198) list = config;
bfc1508d (kx 2023-03-24 03:55:33 +0300 199)
bfc1508d (kx 2023-03-24 03:55:33 +0300 200) if( start_no > 0 )
bfc1508d (kx 2023-03-24 03:55:33 +0300 201) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 202) list = parent_section_node_repolist_nth( config, start_no );
bfc1508d (kx 2023-03-24 03:55:33 +0300 203) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 204) struct section *section = (struct section *)list->data;
bfc1508d (kx 2023-03-24 03:55:33 +0300 205) struct dlist *rlist = parent_rlist_node_repolist_nth( config, start_no );
bfc1508d (kx 2023-03-24 03:55:33 +0300 206)
bfc1508d (kx 2023-03-24 03:55:33 +0300 207) csvn_print_section_start( sb, (const char *)section->name );
bfc1508d (kx 2023-03-24 03:55:33 +0300 208)
bfc1508d (kx 2023-03-24 03:55:33 +0300 209) while( rlist )
bfc1508d (kx 2023-03-24 03:55:33 +0300 210) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 211) struct repo *repo = (struct repo *)rlist->data;
bfc1508d (kx 2023-03-24 03:55:33 +0300 212)
bfc1508d (kx 2023-03-24 03:55:33 +0300 213) csvn_print_repo( sb, repo );
bfc1508d (kx 2023-03-24 03:55:33 +0300 214) if( n && ++length == n )
bfc1508d (kx 2023-03-24 03:55:33 +0300 215) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 216) csvn_print_section_stop( sb );
bfc1508d (kx 2023-03-24 03:55:33 +0300 217) return length;
bfc1508d (kx 2023-03-24 03:55:33 +0300 218) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 219)
bfc1508d (kx 2023-03-24 03:55:33 +0300 220) rlist = dlist_next( rlist );
bfc1508d (kx 2023-03-24 03:55:33 +0300 221) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 222) csvn_print_section_stop( sb );
bfc1508d (kx 2023-03-24 03:55:33 +0300 223) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 224) list = dlist_next( list );
bfc1508d (kx 2023-03-24 03:55:33 +0300 225) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 226)
bfc1508d (kx 2023-03-24 03:55:33 +0300 227) while( list )
bfc1508d (kx 2023-03-24 03:55:33 +0300 228) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 229) struct section *section = (struct section *)list->data;
bfc1508d (kx 2023-03-24 03:55:33 +0300 230)
bfc1508d (kx 2023-03-24 03:55:33 +0300 231) if( section->type == ST_REPOS )
bfc1508d (kx 2023-03-24 03:55:33 +0300 232) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 233) csvn_print_section_start( sb, (const char *)section->name );
bfc1508d (kx 2023-03-24 03:55:33 +0300 234)
bfc1508d (kx 2023-03-24 03:55:33 +0300 235) struct dlist *rlist = section->list;
bfc1508d (kx 2023-03-24 03:55:33 +0300 236) while( rlist )
bfc1508d (kx 2023-03-24 03:55:33 +0300 237) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 238) struct repo *repo = (struct repo *)rlist->data;
bfc1508d (kx 2023-03-24 03:55:33 +0300 239)
bfc1508d (kx 2023-03-24 03:55:33 +0300 240) csvn_print_repo( sb, repo );
bfc1508d (kx 2023-03-24 03:55:33 +0300 241) if( n && ++length == n )
bfc1508d (kx 2023-03-24 03:55:33 +0300 242) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 243) csvn_print_section_stop( sb );
bfc1508d (kx 2023-03-24 03:55:33 +0300 244) return length;
bfc1508d (kx 2023-03-24 03:55:33 +0300 245) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 246)
bfc1508d (kx 2023-03-24 03:55:33 +0300 247) rlist = dlist_next( rlist );
bfc1508d (kx 2023-03-24 03:55:33 +0300 248) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 249)
bfc1508d (kx 2023-03-24 03:55:33 +0300 250) csvn_print_section_stop( sb );
bfc1508d (kx 2023-03-24 03:55:33 +0300 251) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 252) list = dlist_next( list );
bfc1508d (kx 2023-03-24 03:55:33 +0300 253) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 254)
bfc1508d (kx 2023-03-24 03:55:33 +0300 255) return length;
bfc1508d (kx 2023-03-24 03:55:33 +0300 256) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 257)
bfc1508d (kx 2023-03-24 03:55:33 +0300 258)
bfc1508d (kx 2023-03-24 03:55:33 +0300 259) void csvn_print_repolist_page( void )
bfc1508d (kx 2023-03-24 03:55:33 +0300 260) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 261) FILE *fp;
bfc1508d (kx 2023-03-24 03:55:33 +0300 262) struct strbuf buf = STRBUF_INIT;
bfc1508d (kx 2023-03-24 03:55:33 +0300 263) int psize = 200, rnum = 0, pos = 0, prev, next;
bfc1508d (kx 2023-03-24 03:55:33 +0300 264)
bfc1508d (kx 2023-03-24 03:55:33 +0300 265) fp = xfopen( ctx.page.header, "r" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 266) (void)strbuf_env_fread( &buf, fp );
bfc1508d (kx 2023-03-24 03:55:33 +0300 267) fclose( fp );
bfc1508d (kx 2023-03-24 03:55:33 +0300 268)
bfc1508d (kx 2023-03-24 03:55:33 +0300 269) strbuf_addf( &buf, " <div class=\"content segment\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 270) strbuf_addf( &buf, " <div class=\"container\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 271) strbuf_addf( &buf, " <div class=\"csvn-main-content\">\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 272)
bfc1508d (kx 2023-03-24 03:55:33 +0300 273) if( ctx.vars.page_size && *ctx.vars.page_size )
bfc1508d (kx 2023-03-24 03:55:33 +0300 274) sscanf( ctx.vars.page_size, "%d", &psize );
bfc1508d (kx 2023-03-24 03:55:33 +0300 275)
bfc1508d (kx 2023-03-24 03:55:33 +0300 276) if( ctx.vars.num_of_repos && *ctx.vars.num_of_repos )
bfc1508d (kx 2023-03-24 03:55:33 +0300 277) sscanf( ctx.vars.num_of_repos, "%d", &rnum );
bfc1508d (kx 2023-03-24 03:55:33 +0300 278)
bfc1508d (kx 2023-03-24 03:55:33 +0300 279) if( ctx.query.ofs > 0) pos = ctx.query.ofs;
bfc1508d (kx 2023-03-24 03:55:33 +0300 280) if( ctx.query.ofs > rnum-1 ) pos = rnum - rnum % psize;
bfc1508d (kx 2023-03-24 03:55:33 +0300 281) if( pos < 0 ) pos = 0;
bfc1508d (kx 2023-03-24 03:55:33 +0300 282)
bfc1508d (kx 2023-03-24 03:55:33 +0300 283) prev = pos - psize;
bfc1508d (kx 2023-03-24 03:55:33 +0300 284) if( prev < 0 ) prev = 0;
bfc1508d (kx 2023-03-24 03:55:33 +0300 285)
bfc1508d (kx 2023-03-24 03:55:33 +0300 286) next = pos + psize;
bfc1508d (kx 2023-03-24 03:55:33 +0300 287) if( next > rnum-1 ) next = rnum - rnum % psize;
bfc1508d (kx 2023-03-24 03:55:33 +0300 288) if( next < 0 ) next = 0;
bfc1508d (kx 2023-03-24 03:55:33 +0300 289)
bfc1508d (kx 2023-03-24 03:55:33 +0300 290) csvn_print_repolist_header( &buf );
bfc1508d (kx 2023-03-24 03:55:33 +0300 291) (void)csvn_print_page_repolist( &buf, config, pos, psize );
bfc1508d (kx 2023-03-24 03:55:33 +0300 292) csvn_print_direction( &buf, prev, next );
bfc1508d (kx 2023-03-24 03:55:33 +0300 293)
bfc1508d (kx 2023-03-24 03:55:33 +0300 294) strbuf_addf( &buf, " </div> <!-- End of csvn-main-content -->\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 295) strbuf_addf( &buf, " </div> <!-- End of container -->\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 296) strbuf_addf( &buf, " </div> <!-- End of content segment -->\n" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 297)
bfc1508d (kx 2023-03-24 03:55:33 +0300 298) fp = xfopen( ctx.page.footer, "r" );
bfc1508d (kx 2023-03-24 03:55:33 +0300 299) (void)strbuf_env_fread( &buf, fp );
bfc1508d (kx 2023-03-24 03:55:33 +0300 300) fclose( fp );
bfc1508d (kx 2023-03-24 03:55:33 +0300 301)
bfc1508d (kx 2023-03-24 03:55:33 +0300 302) ctx.page.size = buf.len;
bfc1508d (kx 2023-03-24 03:55:33 +0300 303) csvn_print_http_headers();
bfc1508d (kx 2023-03-24 03:55:33 +0300 304) strbuf_write( &buf, STDOUT_FILENO );
bfc1508d (kx 2023-03-24 03:55:33 +0300 305) strbuf_release( &buf );
bfc1508d (kx 2023-03-24 03:55:33 +0300 306) }