diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-06-10 02:24:07 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-06-10 02:24:07 +0200 |
commit | c5e94b1db232921a4c5eb7f5aa620055e76b3414 (patch) | |
tree | c1564dea1afba01ef7c7432a23a1e0795152d6b6 /src/blogc-make | |
parent | cab17026f64ba78bfd9dcac6327607af8e396ebd (diff) | |
download | blogc-c5e94b1db232921a4c5eb7f5aa620055e76b3414.tar.gz blogc-c5e94b1db232921a4c5eb7f5aa620055e76b3414.tar.bz2 blogc-c5e94b1db232921a4c5eb7f5aa620055e76b3414.zip |
Revert "make: disable pagination rules if <= 0 posts per page"
This reverts commit cab17026f64ba78bfd9dcac6327607af8e396ebd.
Poorly implemented :/
Diffstat (limited to 'src/blogc-make')
-rw-r--r-- | src/blogc-make/rules.c | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c index 93f504c..aea9c0f 100644 --- a/src/blogc-make/rules.c +++ b/src/blogc-make/rules.c @@ -36,18 +36,6 @@ posts_ordering(bm_ctx_t *ctx, bc_trie_t *variables, const char *variable) } -static bool -posts_pagination_enabled(bm_ctx_t *ctx, const char *variable) -{ - if (ctx == NULL || ctx->settings == NULL || ctx->settings->settings == NULL) - return false; - - return 0 < strtol( - bc_trie_lookup(ctx->settings->settings, variable), - NULL, 10); // FIXME: improve -} - - static void posts_pagination(bm_ctx_t *ctx, bc_trie_t *variables, const char *variable) { @@ -73,9 +61,6 @@ index_outputlist(bm_ctx_t *ctx) if (ctx == NULL || ctx->settings->posts == NULL) return NULL; - if (!posts_pagination_enabled(ctx, "posts_per_page")) - return NULL; - bc_slist_t *rv = NULL; const char *html_ext = bc_trie_lookup(ctx->settings->settings, "html_ext"); @@ -134,9 +119,6 @@ atom_outputlist(bm_ctx_t *ctx) if (ctx == NULL || ctx->settings->posts == NULL) return NULL; - if (!posts_pagination_enabled(ctx, "atom_posts_per_page")) - return NULL; - bc_slist_t *rv = NULL; const char *atom_prefix = bc_trie_lookup(ctx->settings->settings, "atom_prefix"); @@ -191,9 +173,6 @@ atom_tags_outputlist(bm_ctx_t *ctx) if (ctx == NULL || ctx->settings->posts == NULL || ctx->settings->tags == NULL) return NULL; - if (!posts_pagination_enabled(ctx, "atom_posts_per_page")) - return NULL; - bc_slist_t *rv = NULL; const char *atom_prefix = bc_trie_lookup(ctx->settings->settings, "atom_prefix"); @@ -255,13 +234,13 @@ pagination_outputlist(bm_ctx_t *ctx) if (ctx == NULL || ctx->settings->posts == NULL) return NULL; - if (!posts_pagination_enabled(ctx, "posts_per_page")) - return NULL; - long num_posts = bc_slist_length(ctx->posts_fctx); long posts_per_page = strtol( bc_trie_lookup(ctx->settings->settings, "posts_per_page"), NULL, 10); // FIXME: improve + if (posts_per_page <= 0) + return NULL; + size_t pages = ceilf(((float) num_posts) / posts_per_page); const char *pagination_prefix = bc_trie_lookup(ctx->settings->settings, @@ -395,9 +374,6 @@ tags_outputlist(bm_ctx_t *ctx) if (ctx == NULL || ctx->settings->posts == NULL || ctx->settings->tags == NULL) return NULL; - if (!posts_pagination_enabled(ctx, "posts_per_page")) - return NULL; - bc_slist_t *rv = NULL; const char *tag_prefix = bc_trie_lookup(ctx->settings->settings, "tag_prefix"); |