This commit is contained in:
Your Name 2024-11-11 12:53:11 +03:00
parent f9616dddda
commit a8435d3bcb
3 changed files with 42 additions and 31 deletions

View File

@ -6,6 +6,6 @@
#define CSS "style.css"
#define LOGO "logo.png"
#define DESC "+100500 photos of windowmaker"
#define DESC "from outer space"
#define TITLE "8img gallery"
#define POST_PER_PAGE 5

27
img.c
View File

@ -22,7 +22,7 @@ struct UNIQ_TAGS {
};
char *gen_id(const char *filename) {
const char *alf = "qwertyUIOPasdfghjklQWERTASDFGHJKLZXCVBNMzxcvbnm1234567890";
const char *alf = "qwertyuiopasdfghjklzxcvbnmZXCVBNMASDFGHJKLQWERTYUIOP1234567890";
char *ext = strrchr(filename, '.');
if (ext == NULL)
@ -256,13 +256,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>\n<center><a href='index.html'><img id='logo' src='%s'></a><h1 id='text'>%s</h1></center><h1 id='text'>Page %zu</h1><center>", CSS, TITLE, LOGO, DESC, page);
fprintf(fp, "<html>\n<head>\n<link rel='stylesheet' href='%s'>\n<title>%s</title>\n</head>\n<body>\n<a href='index.html'><img id='logo' src='%s'></a><h1 id='desc'>%s<br>%s/p%zu</h1><center>", CSS, TITLE, LOGO, DESC, file, page);
/* Tags */
fputs("\n<a id='alltags' 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 id='alltags' href='%s.html'> [%s] </a>", ut.tags[i], ut.tags[i]);
fputs("\n<br><br><div id='bar'></div><br>\n", fp);
fprintf(fp, "<a id='alltags' href='%s.html'> %s</a>", ut.tags[i], ut.tags[i]);
fputs("\n<br><br><div class='bar'></div><br>\n", fp);
/* Images */
size_t images = 0;
@ -283,9 +283,9 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
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 id='tags' href='%s.html'> %s</a>", p->tags[i], p->tags[i]);
fprintf(fp, "<a class='tags' href='%s.html'> %s</a>", p->tags[i], p->tags[i]);
fputs("\n<br><br><div id='bar'></div><br>\n", fp);
fputs("\n<br><br><div class='bar'></div><br>\n", fp);
p = i;
images++;
@ -293,13 +293,14 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
break;
}
fputs("<div class='pager'>\n", fp);
for (size_t i = 0; i <= pages; i++) {
if (i == 0) {
if (i == page)
fprintf(fp, "<a id='pager' href='%s.html'>(0) </a> ", file);
fprintf(fp, "<a id='curr' href='%s.html'>0</a> ", file);
else
fprintf(fp, "<a id='pager' href='%s.html'>[0] </a> ", file);
fprintf(fp, "<a href='%s.html'>0</a> ", file);
}
else {
@ -307,15 +308,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 id='pager' href='%s'>(%zu) </a>", new_path, i);
fprintf(fp, "<a id='curr' href='%s'>%zu</a>", new_path, i);
else
fprintf(fp, "<a id='pager' href='%s'>[%zu] </a>", new_path, i);
fprintf(fp, "<a href='%s'> %zu </a>", new_path, i);
}
}
fprintf(fp, "\n</center>\n</body>\n</html>\n");
fprintf(fp, "\n</div>\n</center>\n</body>\n</html>\n");
return p;
}
@ -462,7 +463,7 @@ int main(int argc, char **argv) {
else if (!strcmp(argv[0], "rebuild"))
rebuild();
else if (!strcmp(argv[0], "rebuild"))
else if (!strcmp(argv[0], "version"))
puts("8img version: 1.0\nWritten under WTFPL License.");
else

View File

@ -1,22 +1,32 @@
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;
body {
margin: auto;
padding: 2em;
}
#text { color: #ebdbb2; }
a {
text-decoration: none;
color: #000000;
}
.pager #curr {
color: #ffffff;
background-color: #000000;
}
.bar {
width: 100%;
height: 5px;
background-color: #000000;
}
img {
height: auto;
width: auto;
max-width: 50%;
max-height: 50%;
display: block;
max-width: 80%;
}
/*
#desc { color: #000000; }
.tags { color: #000000; }
.pager {}
.pager a { text-decoration: underline; }
*/