diff --git a/img.c b/img.c
index b09f609..58dc405 100644
--- a/img.c
+++ b/img.c
@@ -242,9 +242,9 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
fprintf(fp, "\n
\n\n%s\n\n", CSS, TITLE);
/* Tags */
- fputs("\n\nall ", fp);
+ fputs("\n
\n [all] ", fp);
for (size_t i = 0; i < ut.size; i++)
- fprintf(fp, "%s ", ut.tags[i], ut.tags[i]);
+ fprintf(fp, " [%s] ", ut.tags[i], ut.tags[i]);
fputs("
\n\n", fp);
/* Images */
@@ -276,7 +276,7 @@ struct DB_STR *build_html(FILE *fp, const char *file, const struct UNIQ_TAGS ut,
break;
}
- for (size_t i = 0; i < pages; i++) {
+ for (size_t i = 0; i <= pages; i++) {
if (i == 0) {
if (i == page)
fprintf(fp, "(0) ", file);
@@ -314,6 +314,11 @@ void build(const char *file, const struct UNIQ_TAGS ut, struct DB_STR *db) {
while (p != NULL) {
struct DB_STR *i = p->next;
+ if (count == POST_PER_PAGE) {
+ count = 0;
+ pages++;
+ }
+
if (!strcmp(file, "index"))
count++;
@@ -323,11 +328,6 @@ void build(const char *file, const struct UNIQ_TAGS ut, struct DB_STR *db) {
count++;
}
- if (count >= POST_PER_PAGE) {
- count = 0;
- pages++;
- }
-
p = i;
}