~dmbaturin/soupault

1

conditionally skip publication of a page

Raphaël Bauduin <rb@raphinou.com>
Details
Message ID
<bcdf3180-409d-4f9e-8560-fff42805827d@raphinou.com>
DKIM signature
missing
Download raw message
Hi,

I have deployed a website completely managed with Soupault at 
https://www.myowndb.com (feel free to add it to the list).
I include a blog section, and I would like to write blog posts in 
advance, but have them only published at their respective publication date.
Each post has a publication date that I succesfully use in the index, 
and that could be used in a test to decide if the post should be 
published or not.
But I haven't seen a way to do it. Additionally a post not yet published 
should not have its page built but should also be excluded from the index.

Is this possible with Soupault?

Thanks
Details
Message ID
<830b2b4b-0d70-f5dc-8924-5089c9aa3db4@baturin.org>
In-Reply-To
<bcdf3180-409d-4f9e-8560-fff42805827d@raphinou.com> (view parent)
DKIM signature
missing
Download raw message
Hi Raphaël,

This is an interesting question. The usual way to skip a draft page is 
to use the `settings.ignore_extentions` option,
but that's purely static and won't work for your idea.

What could work is the save hook 
(https://soupault.app/reference-manual/#hooks-save).
You could check the date from the index entry there and just do nothing 
if the date is in the future.
There's https://soupault.app/reference-manual/#Date.to_timestamp to 
convert dates to UNIX timestamps for easy comparison,
ignoring the issue of timezones (I intentionally decided not to open 
that can of worms ;).

The only problem is that the `save` hook doesn't have access to the 
`index_entry` variable now.
That's just because I thought there were no use cases for that, it 
should be easy to add.

(You'll also need to set `index.index_first = true` so that all pages 
have access to their own index entries)

If you tell me which OS you use soupault on, I can make a preview build 
with that within a couple of days.
I've been planning to make 4.8.0 release soon anyway — there are a few 
useful additions,
but I got overwhelmed with other things so the release got pushed back.

On 11/20/23 16:59, Raphaël Bauduin wrote:
> Hi,
>
> I have deployed a website completely managed with Soupault at 
> https://www.myowndb.com (feel free to add it to the list).
> I include a blog section, and I would like to write blog posts in 
> advance, but have them only published at their respective publication 
> date.
> Each post has a publication date that I succesfully use in the index, 
> and that could be used in a test to decide if the post should be 
> published or not.
> But I haven't seen a way to do it. Additionally a post not yet 
> published should not have its page built but should also be excluded 
> from the index.
>
> Is this possible with Soupault?
>
> Thanks
>
Reply to thread Export thread (mbox)