Upload files to "/"
This commit is contained in:
parent
5a9e890f57
commit
b5b7acb88f
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
|||||||
CC?=cc
|
CC?=cc
|
||||||
CFLAGS?=-pedantic -Wall -Wextra
|
CFLAGS?=-pedantic -Wall -Wextra -s -Os
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(CC) $(CFLAGS) img.c -o 8img
|
$(CC) $(CFLAGS) img.c -o 8img
|
||||||
|
6
config.h
6
config.h
@ -1,7 +1,7 @@
|
|||||||
#define TITLE "8img gallery"
|
#define TITLE "8img gallery"
|
||||||
#define POST_PER_PAGE 10
|
#define POST_PER_PAGE 5
|
||||||
|
|
||||||
/* Absolute path to */
|
/* Absolute path to */
|
||||||
#define ROOT "8img_dir"
|
#define ROOT "."
|
||||||
#define DB ROOT"/db"
|
#define DB ROOT"/db"
|
||||||
#define CSS ROOT"/styles.css"
|
#define CSS ROOT"/style.css"
|
||||||
|
24
img.c
24
img.c
@ -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) {
|
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 */
|
/* 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++)
|
for (size_t i = 0; i < ut.size; i++)
|
||||||
fprintf(fp, "<a href='%s.html'> [%s] </a>", ut.tags[i], ut.tags[i]);
|
fprintf(fp, "<a id='alltags' href='%s.html'> [%s] </a>", ut.tags[i], ut.tags[i]);
|
||||||
fputs("</p><br>\n<div class='bar'></div>\n", fp);
|
fputs("\n<br><br><div id='bar'></div><br>\n", fp);
|
||||||
|
|
||||||
/* Images */
|
/* Images */
|
||||||
size_t images = 0;
|
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++)
|
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;
|
p = i;
|
||||||
images++;
|
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++) {
|
for (size_t i = 0; i <= pages; i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if (i == page)
|
if (i == page)
|
||||||
fprintf(fp, "<a href='%s.html'>(0) </a> ", file);
|
fprintf(fp, "<a id='pager' href='%s.html'>(0) </a> ", file);
|
||||||
|
|
||||||
else
|
else
|
||||||
fprintf(fp, "<a href='%s.html'>[0] </a> ", file);
|
fprintf(fp, "<a id='pager' href='%s.html'>[0] </a> ", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
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);
|
snprintf(new_path, sizeof(new_path), "%s-%zu.html", file, i);
|
||||||
|
|
||||||
if (i == page)
|
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
|
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;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
style.css
Normal file
20
style.css
Normal 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%;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user