Upload files to "/"

This commit is contained in:
8nl 2024-11-10 14:26:37 +00:00
parent 5a9e890f57
commit b5b7acb88f
4 changed files with 36 additions and 16 deletions

View File

@ -1,5 +1,5 @@
CC?=cc
CFLAGS?=-pedantic -Wall -Wextra
CFLAGS?=-pedantic -Wall -Wextra -s -Os
all:
$(CC) $(CFLAGS) img.c -o 8img

View File

@ -1,7 +1,7 @@
#define TITLE "8img gallery"
#define POST_PER_PAGE 10
#define POST_PER_PAGE 5
/* Absolute path to */
#define ROOT "8img_dir"
#define ROOT "."
#define DB ROOT"/db"
#define CSS ROOT"/styles.css"
#define CSS ROOT"/style.css"

24
img.c
View File

@ -239,13 +239,13 @@ RDB_CLOSE:
}
struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut, struct DB_STR *db, const size_t page, const size_t pages) {
fprintf(fp, "<html>\n<head>\n<link rel='stylesheet' href='%s'>\n<title>%s</title>\n</head>\n<body>", CSS, TITLE);
fprintf(fp, "<html>\n<head>\n<link rel='stylesheet' href='%s'>\n<title>%s</title>\n</head>\n<body>\n<center>", CSS, TITLE);
/* Tags */
fputs("\n<p class='alltags'>\n<a href='index.html'> [all] </a>", fp);
fputs("\n<a id='alltags' href='index.html'> [all] </a>", fp);
for (size_t i = 0; i < ut.size; i++)
fprintf(fp, "<a href='%s.html'> [%s] </a>", ut.tags[i], ut.tags[i]);
fputs("</p><br>\n<div class='bar'></div>\n", fp);
fprintf(fp, "<a id='alltags' href='%s.html'> [%s] </a>", ut.tags[i], ut.tags[i]);
fputs("\n<br><br><div id='bar'></div><br>\n", fp);
/* Images */
size_t images = 0;
@ -264,11 +264,11 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
}
}
fprintf(fp, "<article><a href='%s'><img class='img' src='%s' alt='%s'></a></article><br><br>\n", p->filename, p->filename, p->filename);
fprintf(fp, "<a href='%s'><img src='%s' alt='%s'></a><br>", p->filename, p->filename, p->filename);
for (size_t i = 0; i < p->size; i++)
fprintf(fp, "<a href='%s.html'> %s</a>", p->tags[i], p->tags[i]);
fprintf(fp, "<a id='tags' href='%s.html'> %s</a>", p->tags[i], p->tags[i]);
fputs("\n<div class='bar'></div><br>\n", fp);
fputs("\n<br><br><div id='bar'></div><br>\n", fp);
p = i;
images++;
@ -279,10 +279,10 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
for (size_t i = 0; i <= pages; i++) {
if (i == 0) {
if (i == page)
fprintf(fp, "<a href='%s.html'>(0) </a> ", file);
fprintf(fp, "<a id='pager' href='%s.html'>(0) </a> ", file);
else
fprintf(fp, "<a href='%s.html'>[0] </a> ", file);
fprintf(fp, "<a id='pager' href='%s.html'>[0] </a> ", file);
}
else {
@ -290,15 +290,15 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
snprintf(new_path, sizeof(new_path), "%s-%zu.html", file, i);
if (i == page)
fprintf(fp, "<a href='%s'>(%zu) </a>", new_path, i);
fprintf(fp, "<a id='pager' href='%s'>(%zu) </a>", new_path, i);
else
fprintf(fp, "<a href='%s'>[%zu] </a>", new_path, i);
fprintf(fp, "<a id='pager' href='%s'>[%zu] </a>", new_path, i);
}
}
fprintf(fp, "</body></html>\n");
fprintf(fp, "\n</center>\n</body>\n</html>\n");
return p;
}

20
style.css Normal file
View File

@ -0,0 +1,20 @@
body { background-color: #1d2021; }
/* Links */
a { text-decoration: none; }
#tags { color: 8ec07c;}
#pager { color: #b16286; }
#alltags { color: #83a598; }
#bar {
width: 100%;
height: 10px;
background-color: #ebdbb2;
}
img {
height: auto;
width: auto;
max-width: 50%;
max-height: 50%;
}