This page (revision-8) was last changed on 29-Mar-2024 09:09 by Juan Pablo 

This page was created on 30-Mar-2020 17:37 by Juan Pablo

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Version Date Modified Size Author Changes ... Change note
8 29-Mar-2024 09:09 2 KB Juan Pablo to previous WikiFiltersBcc195432.431-43471.431.4ec88.19809.2Bxss.meEsiInclude src=HttpBxss.meRpb.png ==> WikiFilters
7 29-Mar-2024 05:34 2 KB fHLvlxbf to previous | to last WikiFiltersBcc195432.431-43471.431.4ec88.19809.2Bxss.me ==> WikiFiltersBcc195432.431-43471.431.4ec88.19809.2Bxss.meEsiInclude src=HttpBxss.meRpb.png
6 27-Mar-2024 03:37 2 KB fHLvlxbf to previous | to last WikiFilters ==> WikiFiltersBcc195432.431-43471.431.4ec88.19809.2Bxss.me
5 01-Apr-2020 18:58 2 KB Juan Pablo to previous | to last
4 31-Mar-2020 19:49 2 KB Juan Pablo to previous | to last Finished How to write a filter
3 31-Mar-2020 19:05 747 bytes Juan Pablo to previous | to last draft - second iteration
2 30-Mar-2020 20:49 596 bytes Juan Pablo to previous | to last packaging
1 30-Mar-2020 17:37 418 bytes Juan Pablo to last Initial draft

Difference between version and

At line 19 added 5 lines
* {{void initialize( Engine, Properties )}}: called whenever a new [PageFilter|WikiFilters] is instantiated and reset.
* {{String preTranslate( Context, String content )}}: called after the page has been fetched from the [page repository|WikiPageProviders], but before it has been translated from [WikiMarkup] to HTML.
* {{String postTranslate( Context context, String htmlContent )}}: called after the page has been translated into HTML, but before it is shown to the user.
* {{String preSave( Context context, String content )}}: called before the page is committed to the repository.
* {{void postSave( Context context, String content )}}: called after the page has been committed to the repository successfully.
At line 25 added 18 lines
{{PageFilter}} offers empty {{default}} methods for the last four of the above, so you can focus on the events you want to process.
! Caveats
* {{preTranslate(..)}}: contrary to what it may appear, this method is called __twice__
** First, after the page has been fetched from the page repository, but before it has been translated from [WikiMarkup] to HTML
** Then life goes on an the {{Page}} eventually gets saved
** ..Then {{postSave(..)}} triggers the update of the {{Page}}'s references
** ..Which in turn renders the page (so it can be known where the {{Page}} is referencing)
** ..Which in turn triggers {{preTranslate(..)}}, again
** Bottom line: actions on this method should be idempotent
* {{postSave(..)}}: Note that at this point it is useless to change the page data anymore.
** Filters that hook to this event are typically general notification filters - such as sending email.
! {{BasicPageFilter}}
Most of the time, the only thing done on the {{initialize(..)}} method is to store a reference to the {{Engine}} received. If you want to skip this step, instead of implementing {{PageFilter}}, you cand extend from {{BasicPageFilter}}, which does exactly this.