Closed pamtbaau closed 3 years ago
Excellent input yet again, thank you! To be honest, this was my very first Grav plugin, and I may have found this hook in some other plugin, tried it and found that it worked. In any case I didn't really know what I was doing (I still don't in many cases, but I'm getting there). The way you put it, using onPageContentProcessed
seems the best idea to me. I shall try that. :-)
Aaaaand done :-)
And tested for cached and non-cached circumstances?
Heh, ah, you got me there! Of course this needs a recaching for all the pages with email addresses. Hmmmmm… how could I trigger a cache rebuild on plugin update? This is tricky?!
Doesn't upgrading a plugin/theme using GPM automatically delete cache? Not, sure, you might want to test that.
Hmmmm I don't think it does, I did a quick check. :-\
I could keep the code for onOutputGenerated
, it shouldn't do anything if the addresses have been munged already… and then delete it in a later update… pppphhhhhh I think I'll do that.
I tried the following:
bin/gpm install antispam
blueprints.yaml
to 1.4bin/gpm update
But please only trust your own situation.
Hmmm, like I said I only did a quick check, and at least the image cache does not get rebuilt apparently. How do you check for a cache clear? I'd really like this solution, mine is messy!
How do you check for a cache clear?
When running $ bin/gpm update
the command will tell you so:
$ bin/gpm update
GPM Releases Configuration: Stable
Found 13 packages installed of which 1 need updating
01. Antispam [v1.4 -> v1.5]
Continue with the update process? [Y|n] (yes/no) [yes]:
>
GPM Releases Configuration: Stable
Preparing to install Antispam [v1.5]
|- Downloading package... 100%
|- Checking destination... ok
|- Installing package... ok
'- Success!
Clearing cache
Cleared: /www/grav/site-dev/cache/twig/*
Cleared: /www/grav/site-dev/cache/doctrine/*
Cleared: /www/grav/site-dev/cache/compiled/*
Touched: /www/grav/site-dev/user/config/system.yaml
$
Oh, that's sweet! Thanks for telling me. You seem to be right as well, I uninstalled and reinstalled the plugin on several projects and all went very smoothly, I'm just having the oddest issue with one email address that gets eaten, somehow. But this is likely a different bug, which I will look into after going outside and clearing my head for a bit. The plugin update seems fine, so thanks again!
What is the rationale for running the obfusculation during
onOutputGenerated
? This event runs on every page request, which seems unnecessary to me.Events
onPageContentRaw
(before processing Markdown) andonPageContentProcessed
(after Markdown) only runs once when page has not yet been cached, or cache has been invalidated. Any reason why the obfusculation shouldn't run during one of these events?