aboutsummaryrefslogtreecommitdiff
path: root/src/site.c
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <yps@yaroslavps.com>2022-03-24 01:09:48 +0300
committerYaroslav de la Peña Smirnov <yps@yaroslavps.com>2022-03-24 01:09:48 +0300
commit75906fbb296d2ed7cd9ca05e1b7bf0c92f84a30b (patch)
tree863208f0605c1b609cf00d1e0e418c923ed40724 /src/site.c
parent9297781c79dbfe68a817474d0395001fd9746770 (diff)
downloadrevela-75906fbb296d2ed7cd9ca05e1b7bf0c92f84a30b.tar.gz
revela-75906fbb296d2ed7cd9ca05e1b7bf0c92f84a30b.zip
Switch from unja to roscha
Still a WIP, some bugs need to be fixed. Also change the license to GPL from LGPL. It was always meant to be GPL, not sure what brain fart caused this.
Diffstat (limited to 'src/site.c')
-rw-r--r--src/site.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/site.c b/src/site.c
index 2d3922b..058da13 100644
--- a/src/site.c
+++ b/src/site.c
@@ -8,7 +8,7 @@
#include "fs.h"
#include "log.h"
-#include "hashmap.h"
+#include "hmap.h"
/* TODO: handle error cases for paths that are too long */
@@ -154,7 +154,7 @@ images_walk(struct bstnode *node, void *data)
}
joinpathb(htmlpath, image->dst, index_html);
- hashmap_insert(image->album->preserved, base, (char *)base);
+ hmap_set(image->album->preserved, base, (char *)base);
int isupdate = file_is_uptodate(htmlpath, &site->render.modtime);
if (isupdate == -1) return false;
@@ -215,7 +215,7 @@ albums_walk(struct bstnode *node, void *data)
struct stat dstat;
if (!nmkdir(album->slug, &dstat, site->dry_run)) return false;
- hashmap_insert(site->album_dirs, album->slug, (char *)album->slug);
+ hmap_set(site->album_dirs, album->slug, (char *)album->slug);
if (!site->dry_run) {
if (!render_set_album_vars(&site->render, album)) return false;
@@ -226,7 +226,7 @@ albums_walk(struct bstnode *node, void *data)
return false;
}
- hashmap_insert(album->preserved, index_html, (char *)index_html);
+ hmap_set(album->preserved, index_html, (char *)index_html);
ssize_t deleted = rmextra(album->slug, album->preserved, prerm_imagedir,
album, site->dry_run);
if (deleted < 0) {
@@ -321,6 +321,8 @@ site_build(struct site *site)
{
struct stat dstat;
char staticp[PATH_MAX];
+ char startwd[PATH_MAX];
+ getcwd(startwd, PATH_MAX);
if (!nmkdir(site->output_dir, &dstat, false)) return false;
@@ -335,7 +337,7 @@ site_build(struct site *site)
}
if (!render_make_index(&site->render, index_html)) return false;
- hashmap_insert(site->album_dirs, index_html, (char *)index_html);
+ hmap_set(site->album_dirs, index_html, (char *)index_html);
joinpathb(staticp, site->root_dir, STATICDIR);
if (stat(staticp, &dstat)) {
@@ -354,7 +356,7 @@ site_build(struct site *site)
return false;
}
- chdir(site->root_dir);
+ chdir(startwd);
return true;
}
@@ -391,9 +393,11 @@ site_init(struct site *site)
site->rel_content_dir = strlen(site->root_dir) + 1;
InitializeMagick(NULL);
site->wand = NewMagickWand();
- site->album_dirs = hashmap_new();
+ site->album_dirs = hmap_new();
site->render.dry_run = site->dry_run;
+ roscha_init();
+
return true;
}
@@ -409,7 +413,9 @@ site_deinit(struct site *site)
DestroyMagick();
}
if (!site->dry_run) {
- hashmap_free(site->album_dirs);
+ hmap_free(site->album_dirs);
render_deinit(&site->render);
}
+
+ roscha_deinit();
}