I have a huge Wikipedia with many pages, many of which are out of date. I want to apply custom CSS styles to each link based on the age of the linked page.
I have been looking at the source code of MediaWiki and for each link I can get the DBKey starting from the LinkTarget. The source code can be viewed here.
I'm looking for a process that basically goes like this:
$dbKey = $target->getDBkey(); $page = find_page_by_title($dbKey); $last_revision = get_last_revision($page); // Additional processing based on the date of $last_revision
Alternatively, if there is a way to get this information from the API, I could add a JS snippet to recolor the link.
Can someone direct me to resources to accomplish this?
You can use HtmlPageLinkRendererEnd hook.
https://www.mediawiki.org/wiki/Manual:Hooks/HtmlPageLinkRendererEnd
Simply add the following to your LocalSettings.php file:
Just change '20230704142055' to your desired or current date.
You may also need to add this code to the top of your php file.