0
0
mirror of https://github.com/gophernicus/gophernicus.git synced 2025-06-30 22:18:49 -04:00

Merge pull request #1 from wesker-albert/feature/add-custom-formatting

Add custom formatting
This commit is contained in:
Wesker 2024-04-21 03:02:22 +00:00 committed by GitHub
commit f1eb50dd88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 7 deletions

View File

@ -7,4 +7,4 @@
# OPTIONS="-h full.hostname -D \"I find your lack of gopher disturbing.\""
#
# modify and set your options here:
OPTIONS="-h beast -nv"
OPTIONS="-h localhost -nv"

View File

@ -84,15 +84,17 @@ void footer(state *st)
}
/* Create horizontal line */
strrepeat(line, '_', st->out_width);
snprintf(line, sizeof(line), LINE_FORMAT);
/* Create right-aligned footer message */
snprintf(buf, sizeof(buf), FOOTER_FORMAT, st->server_platform);
snprintf(msg, sizeof(msg), "%*s", st->out_width - 1, buf);
/* Create center-aligned footer message */
snprintf(buf, sizeof(buf), FOOTER_FORMAT);
snprintf(msg, sizeof(msg), "%*s", st->out_width + 1 / 2, buf);
/* Menu footer? */
if (st->req_filetype == TYPE_MENU || st->req_filetype == TYPE_QUERY) {
info(st, EMPTY, TYPE_INFO);
info(st, line, TYPE_INFO);
info(st, EMPTY, TYPE_INFO);
info(st, msg, TYPE_INFO);
printf("." CRLF);
}

View File

@ -251,8 +251,9 @@ size_t strlcat(char *dst, const char *src, size_t siz);
#define SERVER_SOFTWARE_FULL SERVER_SOFTWARE "/" VERSION " (%s)"
#define PROGNAME "gophernicus"
#define HEADER_FORMAT "[%s]"
#define FOOTER_FORMAT "Gophered by Gophernicus/" VERSION " on %s"
#define HEADER_FORMAT "UMBRELLA%s"
#define FOOTER_FORMAT "UELS V0.1 • UMBRELLA CORP • OUR BUSINESS IS LIFE ITSELF..."
#define LINE_FORMAT "•-----------------------------------------------------------------•"
#define UNITS "KB", "MB", "GB", "TB", "PB", NULL
#define DATE_FORMAT "%Y-%b-%d %H:%M" /* See man 3 strftime */

View File

@ -485,6 +485,7 @@ void gopher_menu(state *st)
sdirent dir[MAX_SDIRENT];
struct tm *ltime;
struct stat file;
char line[BUFSIZE];
char buf[BUFSIZE];
char pathname[BUFSIZE];
char displayname[BUFSIZE];
@ -527,8 +528,11 @@ void gopher_menu(state *st)
if (fgets(buf, sizeof(buf), fp) == NULL) strclear(buf);
chomp(buf);
snprintf(line, sizeof(line), LINE_FORMAT);
info(st, buf, TYPE_TITLE);
info(st, EMPTY, TYPE_INFO);
info(st, line, TYPE_INFO);
info(st, EMPTY, TYPE_INFO);
fclose(fp);
}
}
@ -549,8 +553,11 @@ void gopher_menu(state *st)
/* Output menu title */
snprintf(buf, sizeof(buf), HEADER_FORMAT, displayname);
snprintf(line, sizeof(line), LINE_FORMAT);
info(st, buf, TYPE_TITLE);
info(st, EMPTY, TYPE_INFO);
info(st, line, TYPE_INFO);
info(st, EMPTY, TYPE_INFO);
}
}