From 577b5327f14a2f8847929c3b8047bb631b3ef335 Mon Sep 17 00:00:00 2001 From: urosm Date: Sat, 17 Feb 2024 18:20:30 +0100 Subject: [PATCH] update ikiwiki plugins --- IkiWiki/Plugin/frontlinkpages.pm | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 IkiWiki/Plugin/frontlinkpages.pm diff --git a/IkiWiki/Plugin/frontlinkpages.pm b/IkiWiki/Plugin/frontlinkpages.pm new file mode 100644 index 0000000..61b972c --- /dev/null +++ b/IkiWiki/Plugin/frontlinkpages.pm @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +package IkiWiki::Plugin::frontlinkpages; + +use warnings; +use strict; +use IkiWiki 3.00; + +sub import { + hook(type => "pagetemplate", id => "frontlinkpages", call => \&pagetemplate); +} + +sub pagetemplate (@) { + my %params=@_; + + my $template=$params{template}; + + if (! $template->query(name => "frontlinkpages")) { + return; + } + + my $quick=exists $params{quick} ? IkiWiki::yesno($params{quick}) : 0; + + my $num=0; + if ($params{limit}) { + $num=$params{limit}; + } + if ($params{feedlimit} && $num < $params{feedlimit} && $num > 0) { + $num=$params{feedlimit}; + } + if ($params{skip} && $num) { + $num+=$params{skip}; + } + + my @pages = pagespec_match_list($params{page}, "link($params{page})", + deptype => deptype($quick ? "presence" : "content"), + filter => sub { $_[0] eq $params{page} }, + # sort => exists $params{sort} ? $params{sort} : "age title", + reverse => IkiWiki::yesno($params{reverse}), + ($num ? (num => $num) : ()), + ); + + my $destpage=$params{destpage}; + my @contents; + for (@pages) { + if ($pagesources{$_}) { + my $title = $pagestate{$_}{meta}{title}; + push @contents, { + content => IkiWiki::get_inline_content($_, $destpage), + pageurl => urlto($_, $destpage), + title => $title ? $title : pagetitle(IkiWiki::basename($_)), + ctime => displaytime($IkiWiki::pagectime{$_}, $params{timeformat}, 1), + mtime => displaytime($IkiWiki::pagemtime{$_}, $params{timeformat}) + } + } + } + $template->param(frontlinkpages => \@contents); +} + +1