aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make/atom.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-07-24 02:27:48 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-07-24 02:27:51 +0200
commitc16c86bcc01dff2a984aeffd58e2402a876cc12d (patch)
tree7f2b3a6ea5951f7f684d550549069e0f1f0452f0 /src/blogc-make/atom.c
parent355c8d37d0ce570e45fe8b905fee6417be35942e (diff)
downloadblogc-c16c86bcc01dff2a984aeffd58e2402a876cc12d.tar.gz
blogc-c16c86bcc01dff2a984aeffd58e2402a876cc12d.tar.bz2
blogc-c16c86bcc01dff2a984aeffd58e2402a876cc12d.zip
make: handle empty prefixes properly
still needs to add integration tests
Diffstat (limited to 'src/blogc-make/atom.c')
-rw-r--r--src/blogc-make/atom.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/blogc-make/atom.c b/src/blogc-make/atom.c
index d5f5387..0e4e631 100644
--- a/src/blogc-make/atom.c
+++ b/src/blogc-make/atom.c
@@ -20,11 +20,11 @@ static const char atom_template[] =
"<feed xmlns=\"http://www.w3.org/2005/Atom\">\n"
" <title type=\"text\">{{ SITE_TITLE }}{%% ifdef FILTER_TAG %%} - "
"{{ FILTER_TAG }}{%% endif %%}</title>\n"
- " <id>{{ BASE_URL }}/%s{%% ifdef FILTER_TAG %%}/{{ FILTER_TAG }}"
+ " <id>{{ BASE_URL }}%s%s{%% ifdef FILTER_TAG %%}/{{ FILTER_TAG }}"
"{%% endif %%}%s</id>\n"
" <updated>{{ DATE_FIRST_FORMATTED }}</updated>\n"
" <link href=\"{{ BASE_DOMAIN }}{{ BASE_URL }}/\" />\n"
- " <link href=\"{{ BASE_DOMAIN }}{{ BASE_URL }}/%s{%% ifdef FILTER_TAG %%}"
+ " <link href=\"{{ BASE_DOMAIN }}{{ BASE_URL }}%s%s{%% ifdef FILTER_TAG %%}"
"/{{ FILTER_TAG }}{%% endif %%}%s\" rel=\"self\" />\n"
" <author>\n"
" <name>{{ AUTHOR_NAME }}</name>\n"
@@ -34,10 +34,10 @@ static const char atom_template[] =
" {%% block listing %%}\n"
" <entry>\n"
" <title type=\"text\">{{ TITLE }}</title>\n"
- " <id>{{ BASE_URL }}/%s/{{ FILENAME }}/</id>\n"
+ " <id>{{ BASE_URL }}%s%s/{{ FILENAME }}/</id>\n"
" <updated>{{ DATE_FORMATTED }}</updated>\n"
" <published>{{ DATE_FORMATTED }}</published>\n"
- " <link href=\"{{ BASE_DOMAIN }}{{ BASE_URL }}/%s/{{ FILENAME }}/\" />\n"
+ " <link href=\"{{ BASE_DOMAIN }}{{ BASE_URL }}%s%s/{{ FILENAME }}/\" />\n"
" <author>\n"
" <name>{{ AUTHOR_NAME }}</name>\n"
" <email>{{ AUTHOR_EMAIL }}</email>\n"
@@ -66,9 +66,12 @@ bm_atom_deploy(bm_settings_t *settings, bc_error_t **err)
const char *atom_prefix = bc_trie_lookup(settings->settings, "atom_prefix");
const char *atom_ext = bc_trie_lookup(settings->settings, "atom_ext");
const char *post_prefix = bc_trie_lookup(settings->settings, "post_prefix");
+ const char *atom_slash = atom_prefix[0] == '\0' ? "" : "/";
+ const char *post_slash = post_prefix[0] == '\0' ? "" : "/";
- char *content = bc_strdup_printf(atom_template, atom_prefix, atom_ext,
- atom_prefix, atom_ext, post_prefix, post_prefix);
+ char *content = bc_strdup_printf(atom_template, atom_slash, atom_prefix,
+ atom_ext, atom_slash, atom_prefix, atom_ext, post_slash, post_prefix,
+ post_slash, post_prefix);
if (-1 == write(fd, content, strlen(content))) {
*err = bc_error_new_printf(BLOGC_MAKE_ERROR_ATOM,