~aprates/gempress

fa2bd5b6cef7c9456b9b54a0a248a3e696229810 — Antonio Prates 7 months ago fae9d54
Allow overriding feedDir with absolute value

Useful for mounting into another capsule withing a folder, like
translations, for example.
3 files changed, 15 insertions(+), 3 deletions(-)

M capsule-example.conf
M src/atom.c
M src/lib.sh
M capsule-example.conf => capsule-example.conf +4 -1
@@ 19,7 19,10 @@ templateDir="/home/user/johndoe/gempress/template"
gmiLinkHome="=> / Capsule Home"

# Folder where posts are stored inside localBaseDir (optional)
#feedDir=""  # defaults to "log"
feedDir="log"

# Folder where posts are stored inside from page root (optional)
#absoluteFeedDir=""  # defaults to feedDir value

# Maximum number of atom entries (optional)
#maxAtomEntries=""  # defaults to "15"

M src/atom.c => src/atom.c +4 -1
@@ 93,6 93,9 @@ void readConfigFromLine(string line) {
  if (startsWith(line, "feedDir"))
    feedDir = getConfigValue(line);

  if (startsWith(line, "absoluteFeedDir"))
    feedDir = getConfigValue(line);

  if (startsWith(line, "maxAtomEntries"))
    maxAtomEntries = ofString(getConfigValue(line));



@@ 152,7 155,7 @@ string toAtomEntry(string line) {
          lastUpdated = updated;
        else if (strcmp(updated, lastUpdated) > 0)
          lastUpdated = updated;
        url = startsWith(url, "/") ? url : join3s("/", feedDir, url);
        url = startsWith(url, "/") ? url : join4s("/", feedDir, "/", url);
        url = maybeToHttps(join2s(remoteBaseUrl, url));
        return join3s(
            join3s("  <entry>\n    <id>", url, "</id>\n"),

M src/lib.sh => src/lib.sh +7 -1
@@ 10,6 10,12 @@ maxHomeEntries=5
capsule=$PWD/capsule
website=$PWD/website # if you change here also change capsule-to-website.sh

# set absoluteFeedDir
if [[ -z $absoluteFeedDir ]];
then
    absoluteFeedDir=$feedDir
fi

# takes a clean copy of gmi folder ot capsule folder
function takeCleanCopyOfLocalBaseDir() {
    if [[ -d $capsule ]];


@@ 27,7 33,7 @@ function appendFeedToHome() {
    for feed in $capsule/$feedDir/feed.gmi; do
        head -$maxHomeEntries $feed
    done > $capsule/index.gmi.feed
    sed -i "s/=> /=> $feedDir\//" $capsule/index.gmi.feed
    sed -i "s/=> /=> $absoluteFeedDir\//" $capsule/index.gmi.feed
    cat $capsule/index.gmi.feed >> $capsule/index.gmi
    rm $capsule/index.gmi.feed
}