diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-21 15:42:16 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-04-21 15:42:16 -0300 |
commit | fa016a15156bf8122b2d3dccaecca53f471d6ecb (patch) | |
tree | 12e8ec4c971455b7a1578fdb9c4eaf0e37f018c3 /src/renderer.c | |
parent | 8d8f508b859647461d1e9f13eeab647ceae54597 (diff) | |
download | blogc-fa016a15156bf8122b2d3dccaecca53f471d6ecb.tar.gz blogc-fa016a15156bf8122b2d3dccaecca53f471d6ecb.tar.bz2 blogc-fa016a15156bf8122b2d3dccaecca53f471d6ecb.zip |
refactored blocks
- changed block names:
- single_source -> entry
- multiple_sources -> listing
- multiple_sources_once -> listing_once
- added -t cli option, to build listing pages, instead of guess it from
the number of source files provided.
Diffstat (limited to 'src/renderer.c')
-rw-r--r-- | src/renderer.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/renderer.c b/src/renderer.c index ffd46c9..69206c3 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -18,15 +18,13 @@ char* -blogc_render(b_slist_t *tmpl, b_slist_t *sources) +blogc_render(b_slist_t *tmpl, b_slist_t *sources, bool listing) { if (tmpl == NULL || sources == NULL) return NULL; - bool single_source = sources->next == NULL; - b_slist_t *current_source = NULL; - b_slist_t *multiple_sources_start = NULL; + b_slist_t *listing_start = NULL; b_string_t *str = b_string_new(); @@ -49,8 +47,8 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources) case BLOGC_TEMPLATE_BLOCK_STMT: if_count = 0; - if (0 == strcmp("single_source", stmt->value)) { - if (!single_source) { + if (0 == strcmp("entry", stmt->value)) { + if (listing) { // we can just skip anything and walk until the next // 'endblock' @@ -63,9 +61,9 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources) current_source = sources; tmp_source = current_source->data; } - else if ((0 == strcmp("multiple_sources", stmt->value)) || - (0 == strcmp("multiple_sources_once", stmt->value))) { - if (single_source) { + else if ((0 == strcmp("listing", stmt->value)) || + (0 == strcmp("listing_once", stmt->value))) { + if (!listing) { // we can just skip anything and walk until the next // 'endblock' @@ -76,9 +74,9 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources) break; } } - if (0 == strcmp("multiple_sources", stmt->value)) { + if (0 == strcmp("listing", stmt->value)) { if (current_source == NULL) { - multiple_sources_start = tmp; + listing_start = tmp; current_source = sources; } tmp_source = current_source->data; @@ -95,14 +93,14 @@ blogc_render(b_slist_t *tmpl, b_slist_t *sources) break; case BLOGC_TEMPLATE_ENDBLOCK_STMT: - if (multiple_sources_start != NULL && current_source != NULL) { + if (listing_start != NULL && current_source != NULL) { current_source = current_source->next; if (current_source != NULL) { - tmp = multiple_sources_start; + tmp = listing_start; continue; } else - multiple_sources_start = NULL; + listing_start = NULL; } break; |