aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blogc-make/rules.c12
-rw-r--r--src/blogc-make/settings.c1
2 files changed, 10 insertions, 3 deletions
diff --git a/src/blogc-make/rules.c b/src/blogc-make/rules.c
index f1a0be9..96cf51d 100644
--- a/src/blogc-make/rules.c
+++ b/src/blogc-make/rules.c
@@ -31,10 +31,16 @@ posts_ordering(bm_ctx_t *ctx, bc_trie_t *variables, const char *variable)
return; // something is wrong, let's not add any variable
const char *value = bm_ctx_settings_lookup_str(ctx, variable);
- if (value != NULL && ((0 == strcmp(value, "ASC")) || (0 == strcmp(value, "asc"))))
- return; // user explicitly asked for ASC
+ bool asc = 0 == strcasecmp(value, "asc");
+ bool sort = bc_str_to_bool(bm_ctx_settings_lookup(ctx, "posts_sort"));
- bc_trie_insert(variables, "FILTER_REVERSE", bc_strdup("1"));
+ if (sort) {
+ bc_trie_insert(variables, "FILTER_SORT", bc_strdup("1"));
+ }
+
+ if ((sort && asc) || (!sort && !asc)) {
+ bc_trie_insert(variables, "FILTER_REVERSE", bc_strdup("1"));
+ }
}
diff --git a/src/blogc-make/settings.c b/src/blogc-make/settings.c
index 05e610a..be976e3 100644
--- a/src/blogc-make/settings.c
+++ b/src/blogc-make/settings.c
@@ -28,6 +28,7 @@ static const struct default_settings_map {
{"main_template", "main.tmpl"},
{"source_ext", ".txt"},
{"listing_entry", NULL},
+ {"posts_sort", NULL},
// pagination
{"pagination_prefix", "page"},