X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/8d3f65c293b400b874d76a28c0b78840373e05b5..60dc17c39cd14c72af04ff59146277e240e53e13:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 03b4b666e..f1a5f8058 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1,6 +1,7 @@ #!/usr/bin/perl package IkiWiki; + use warnings; use strict; use Encode; @@ -336,7 +337,7 @@ sub readfile ($;$$) { #{{{ return $ret; } #}}} -sub prep_writefile ($$) { +sub prep_writefile ($$) { #{{{ my $file=shift; my $destdir=shift; @@ -360,7 +361,7 @@ sub prep_writefile ($$) { } return 1; -} +} #}}} sub writefile ($$$;$$) { #{{{ my $file=shift; # can include subdirs @@ -532,13 +533,18 @@ sub displaytime ($;$) { #{{{ return decode_utf8(POSIX::strftime($format, localtime($time))); } #}}} -sub beautify_url ($) { #{{{ +sub beautify_urlpath ($) { #{{{ my $url=shift; if ($config{usedirs}) { $url =~ s!/index.$config{htmlext}$!/!; } - $url =~ s!^$!./!; # Browsers don't like empty links... + + # Ensure url is not an empty link, and + # if it's relative, make that explicit to avoid colon confusion. + if ($url !~ /\//) { + $url="./$url"; + } return $url; } #}}} @@ -548,7 +554,7 @@ sub urlto ($$) { #{{{ my $from=shift; if (! length $to) { - return beautify_url(baseurl($from)."index.$config{htmlext}"); + return beautify_urlpath(baseurl($from)."index.$config{htmlext}"); } if (! $destsources{$to}) { @@ -557,7 +563,7 @@ sub urlto ($$) { #{{{ my $link = abs2rel($to, dirname(htmlpage($from))); - return beautify_url($link); + return beautify_urlpath($link); } #}}} sub htmllink ($$$;@) { #{{{ @@ -596,7 +602,7 @@ sub htmllink ($$$;@) { #{{{ return " "create", - page => pagetitle(lc($link), 1), + page => lc($link), from => $lpage ). "\" rel=\"nofollow\">?$linktext" @@ -604,7 +610,7 @@ sub htmllink ($$$;@) { #{{{ } $bestlink=abs2rel($bestlink, dirname(htmlpage($page))); - $bestlink=beautify_url($bestlink); + $bestlink=beautify_urlpath($bestlink); if (! $opts{noimageinline} && isinlinableimage($bestlink)) { return "\"$linktext\""; @@ -1196,6 +1202,12 @@ sub gettext { #{{{ } } #}}} +sub yesno ($) { #{{{ + my $val=shift; + + return (defined $val && lc($val) eq gettext("yes")); +} #}}} + sub pagespec_merge ($$) { #{{{ my $a=shift; my $b=shift;