From 4bfa321f784683cef90f63f83d1aa7fe741a196e Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 25 Jul 2018 21:50:06 +0200 Subject: make: implemented atom_legacy_entry_id setting This allows current users to avoid atom entry id changes. --- src/blogc-make/atom.c | 12 +++++++++++- src/blogc-make/settings.c | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/blogc-make/atom.c b/src/blogc-make/atom.c index ae5e0c1..b953876 100644 --- a/src/blogc-make/atom.c +++ b/src/blogc-make/atom.c @@ -84,11 +84,21 @@ bm_atom_deploy(bm_settings_t *settings, bc_error_t **err) char *post_url = bm_generate_filename(NULL, post_prefix, "{{ FILENAME }}", post_ext); + char *entry_id = NULL; + if (bc_str_to_bool(bc_trie_lookup(settings->settings, "atom_legacy_entry_id"))) { + entry_id = bc_strdup_printf("%s%s/{{ FILENAME }}/", + post_prefix[0] == '\0' ? "" : "/", post_prefix); + } + else { + entry_id = bc_strdup(post_url); + } + char *content = bc_strdup_printf(atom_template, atom_url->str, atom_url->str, - post_url, post_url); + entry_id, post_url); bc_string_free(atom_url, true); free(post_url); + free(entry_id); if (-1 == write(fd, content, strlen(content))) { *err = bc_error_new_printf(BLOGC_MAKE_ERROR_ATOM, diff --git a/src/blogc-make/settings.c b/src/blogc-make/settings.c index 2029199..719afe1 100644 --- a/src/blogc-make/settings.c +++ b/src/blogc-make/settings.c @@ -43,6 +43,7 @@ static const struct default_settings_map { {"atom_prefix", "atom"}, {"atom_ext", ".xml"}, {"atom_order", "DESC"}, + {"atom_legacy_entry_id", NULL}, // generic {"date_format", "%b %d, %Y, %I:%M %p GMT"}, -- cgit v1.2.3-18-g5258