X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/a7cb3090902e23e2b0f2371539ade7ec5a4ba01b..bd1e29b8c4d2c2e0329789d1baf0a879617aeee4:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index cd93fe969..90e623330 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -14,7 +14,8 @@ use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles %pagesources %destsources %depends %depends_simple %hooks - %forcerebuild %loaded_plugins}; + %forcerebuild %loaded_plugins @autofiles %dellinks + %delrenderedfiles}; use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage deptype @@ -22,7 +23,7 @@ our @EXPORT = qw(hook debug error template htmlpage deptype htmllink readfile writefile pagetype srcfile pagename displaytime will_render gettext urlto targetpage add_underlay pagetitle titlepage linkpage newpagefile - inject add_link + inject add_link add_autofile %config %links %pagestate %wikistate %renderedfiles %pagesources %destsources); our $VERSION = 3.00; # plugin interface version, next is ikiwiki version @@ -881,7 +882,7 @@ sub bestlink ($$) { $l.="/" if length $l; $l.=$link; - if (exists $links{$l}) { + if (exists $pagesources{$l}) { return $l; } elsif (exists $pagecase{lc $l}) { @@ -891,7 +892,7 @@ sub bestlink ($$) { if (length $config{userdir}) { my $l = "$config{userdir}/".lc($link); - if (exists $links{$l}) { + if (exists $pagesources{$l}) { return $l; } elsif (exists $pagecase{lc $l}) { @@ -1081,11 +1082,10 @@ sub htmllink ($$$;@) { } my @attrs; - if (defined $opts{rel}) { - push @attrs, ' rel="'.$opts{rel}.'"'; - } - if (defined $opts{class}) { - push @attrs, ' class="'.$opts{class}.'"'; + foreach my $attr (qw{rel class title}) { + if (defined $opts{$attr}) { + push @attrs, " $attr=\"$opts{$attr}\""; + } } return "$linktext"; @@ -1408,7 +1408,7 @@ sub check_content (@) { my %old=map { $_ => 1 } split("\n", readfile(srcfile($pagesources{$params{page}}))); foreach my $line (split("\n", $params{content})) { - push @diff, $line if ! exists $old{$_}; + push @diff, $line if ! exists $old{$line}; } $params{diff}=join("\n", @diff); } @@ -1896,6 +1896,14 @@ sub add_link ($$) { unless grep { $_ eq $link } @{$links{$page}}; } +sub add_autofile ($) { + my $addfile=shift; + my ($file,$page) = verify_src_file($addfile,$config{srcdir}); + if ($page) { + push @autofiles, $file; + } +} + sub pagespec_translate ($) { my $spec=shift; @@ -2071,7 +2079,7 @@ use overload ( '""' => sub { $_[0][0] }, '0+' => sub { 0 }, '!' => sub { bless $_[0], 'IkiWiki::SuccessReason'}, - '&' => sub { $_[0]->merge_influences($_[1]); $_[0] }, + '&' => sub { $_[0]->merge_influences($_[1], 1); $_[0] }, '|' => sub { $_[1]->merge_influences($_[0]); $_[1] }, fallback => 1, ); @@ -2084,7 +2092,7 @@ use overload ( '""' => sub { $_[0][0] }, '0+' => sub { 1 }, '!' => sub { bless $_[0], 'IkiWiki::FailReason'}, - '&' => sub { $_[1]->merge_influences($_[0]); $_[1] }, + '&' => sub { $_[1]->merge_influences($_[0], 1); $_[1] }, '|' => sub { $_[0]->merge_influences($_[1]); $_[0] }, fallback => 1, ); @@ -2110,8 +2118,17 @@ sub influences_static { sub merge_influences { my $this=shift; my $other=shift; - foreach my $influence (keys %{$other->[1]}) { - $this->[1]{$influence} |= $other->[1]{$influence}; + my $anded=shift; + + if (! $anded || (($this || %{$this->[1]}) && + ($other || %{$other->[1]}))) { + foreach my $influence (keys %{$other->[1]}) { + $this->[1]{$influence} |= $other->[1]{$influence}; + } + } + else { + # influence blocker + $this->[1]={}; } } @@ -2168,7 +2185,7 @@ sub match_link ($$;@) { my $from=exists $params{location} ? $params{location} : ''; my $links = $IkiWiki::links{$page}; - return IkiWiki::FailReason->new("$page has no links") + return IkiWiki::FailReason->new("$page has no links", "" => 1) unless $links && @{$links}; my $bestlink = IkiWiki::bestlink($from, $link); foreach my $p (@{$links}) {