* The last release accidentially installed ikiwiki as ikiwiki.pl, now fixed.

* Add --version.
* Man page format fixups.
* Add a %pagecase which maps lower-case page names to the actual case
  used in the filename. Use this in bestlinks calculation instead of
  forcing the link to lowercase.
* Also use %pagecase in various other places that want to check if a page
  with a given name exists.
* This means that links to pages with mixed case names will now work,
  even if the link is in some other case mixture, and mixed case pages
  should be fully supported throughout ikiwiki.
* Recommend rebuilding wikis on upgrade to this version.
master
joey 2006-08-13 02:03:43 +00:00
parent 85ecbc6c4e
commit 4b36dee35a
16 changed files with 76 additions and 45 deletions

View File

@ -12,7 +12,7 @@ use Memoize;
memoize("abs2rel"); memoize("abs2rel");
memoize("pagespec_translate"); memoize("pagespec_translate");
use vars qw{%config %links %oldlinks %oldpagemtime %pagectime use vars qw{%config %links %oldlinks %oldpagemtime %pagectime %pagecase
%renderedfiles %pagesources %depends %hooks %forcerebuild}; %renderedfiles %pagesources %depends %hooks %forcerebuild};
sub defaultconfig () { #{{{ sub defaultconfig () { #{{{
@ -238,7 +238,7 @@ sub bestlink ($$) { #{{{
# goes down the directory tree to the base looking for matching # goes down the directory tree to the base looking for matching
# pages. # pages.
my $page=shift; my $page=shift;
my $link=lc(shift); my $link=shift;
my $cwd=$page; my $cwd=$page;
do { do {
@ -247,9 +247,11 @@ sub bestlink ($$) { #{{{
$l.=$link; $l.=$link;
if (exists $links{$l}) { if (exists $links{$l}) {
#debug("for $page, \"$link\", use $l");
return $l; return $l;
} }
elsif (exists $pagecase{lc $l}) {
return $pagecase{lc $l};
}
} while $cwd=~s!/?[^/]+$!!; } while $cwd=~s!/?[^/]+$!!;
#print STDERR "warning: page $page, broken link: $link\n"; #print STDERR "warning: page $page, broken link: $link\n";
@ -333,7 +335,7 @@ sub htmllink ($$$;$$$) { #{{{
} }
if (! grep { $_ eq $bestlink } values %renderedfiles) { if (! grep { $_ eq $bestlink } values %renderedfiles) {
return "<span><a href=\"". return "<span><a href=\"".
cgiurl(do => "create", page => $link, from => $page). cgiurl(do => "create", page => lc($link), from => $page).
"\">?</a>$linktext</span>" "\">?</a>$linktext</span>"
} }
@ -395,6 +397,7 @@ sub loadindex () { #{{{
$links{$page}=[@{$items{link}}]; $links{$page}=[@{$items{link}}];
$depends{$page}=$items{depends}[0] if exists $items{depends}; $depends{$page}=$items{depends}[0] if exists $items{depends};
$renderedfiles{$page}=$items{dest}[0]; $renderedfiles{$page}=$items{dest}[0];
$pagecase{lc $page}=$page;
} }
$pagectime{$page}=$items{ctime}[0]; $pagectime{$page}=$items{ctime}[0];
} }
@ -588,7 +591,7 @@ sub match_glob ($$) { #{{{
sub match_link ($$) { #{{{ sub match_link ($$) { #{{{
my $page=shift; my $page=shift;
my $link=shift; my $link=lc(shift);
my $links = $links{$page} or return undef; my $links = $links{$page} or return undef;
foreach my $p (@$links) { foreach my $p (@$links) {

View File

@ -346,12 +346,11 @@ sub cgi_editpage ($$) { #{{{
# This untaint is safe because titlepage removes any problematic # This untaint is safe because titlepage removes any problematic
# characters. # characters.
my ($page)=$form->field('page'); my ($page)=$form->field('page');
$page=titlepage(possibly_foolish_untaint(lc($page))); $page=titlepage(possibly_foolish_untaint($page));
if (! defined $page || ! length $page || if (! defined $page || ! length $page ||
$page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) { $page=~/$config{wiki_file_prune_regexp}/ || $page=~/^\//) {
error("bad page name"); error("bad page name");
} }
$page=lc($page);
my $from; my $from;
if (defined $form->field('from')) { if (defined $form->field('from')) {
@ -359,7 +358,7 @@ sub cgi_editpage ($$) { #{{{
} }
my $file; my $file;
my $type; my $type;
if (exists $pagesources{$page}) { if (exists $pagesources{$page}) {
$file=$pagesources{$page}; $file=$pagesources{$page};
$type=pagetype($file); $type=pagetype($file);
@ -457,7 +456,7 @@ sub cgi_editpage ($$) { #{{{
} }
@page_locs = grep { @page_locs = grep {
! exists $pagesources{lc($_)} && ! exists $pagecase{lc $_} &&
! page_locked($_, $session, 1) ! page_locked($_, $session, 1)
} @page_locs; } @page_locs;
@ -485,8 +484,8 @@ sub cgi_editpage ($$) { #{{{
if (! defined $form->field('editcontent') || if (! defined $form->field('editcontent') ||
! length $form->field('editcontent')) { ! length $form->field('editcontent')) {
my $content=""; my $content="";
if (exists $pagesources{lc($page)}) { if (exists $pagesources{$page}) {
$content=readfile(srcfile($pagesources{lc($page)})); $content=readfile(srcfile($pagesources{$page}));
$content=~s/\n/\r\n/g; $content=~s/\n/\r\n/g;
} }
$form->field(name => "editcontent", value => $content, $form->field(name => "editcontent", value => $content,
@ -617,11 +616,11 @@ sub cgi () { #{{{
cgi_prefs($q, $session); cgi_prefs($q, $session);
} }
elsif ($do eq 'blog') { elsif ($do eq 'blog') {
my $page=titlepage(lc($q->param('title'))); my $page=titlepage($q->param('title'));
# if the page already exists, munge it to be unique # if the page already exists, munge it to be unique
my $from=$q->param('from'); my $from=$q->param('from');
my $add=""; my $add="";
while (exists $oldpagemtime{"$from/$page$add"}) { while (exists $pagecase{lc "$from/$page$add"}) {
$add=1 unless length $add; $add=1 unless length $add;
$add++; $add++;
} }

View File

@ -260,13 +260,12 @@ sub add_page (@) { #{{{
# directory name or trigger ".." disallowing code. # directory name or trigger ".." disallowing code.
$page=~s!([/.])!"__".ord($1)."__"!eg; $page=~s!([/.])!"__".ord($1)."__"!eg;
$page=$feed->{dir}."/".$page; $page=$feed->{dir}."/".$page;
$page=lc($page);
($page)=$page=~/$IkiWiki::config{wiki_file_regexp}/; ($page)=$page=~/$IkiWiki::config{wiki_file_regexp}/;
if (! defined $page || ! length $page) { if (! defined $page || ! length $page) {
$page=$feed->{dir}."/item"; $page=$feed->{dir}."/item";
} }
my $c=""; my $c="";
while (exists $IkiWiki::pagesources{$page.$c} || while (exists $IkiWiki::pagecase{lc $page} ||
-e pagefile($page.$c)) { -e pagefile($page.$c)) {
$c++ $c++
} }

View File

@ -358,6 +358,7 @@ sub refresh () { #{{{
debug("new page $page") unless exists $pagectime{$page}; debug("new page $page") unless exists $pagectime{$page};
push @add, $file; push @add, $file;
$links{$page}=[]; $links{$page}=[];
$pagecase{lc $page}=$page;
$pagesources{$page}=$file; $pagesources{$page}=$file;
if ($config{getctime} && -e "$config{srcdir}/$file") { if ($config{getctime} && -e "$config{srcdir}/$file") {
$pagectime{$page}=rcs_getctime("$config{srcdir}/$file"); $pagectime{$page}=rcs_getctime("$config{srcdir}/$file");

View File

@ -11,6 +11,11 @@ clean:: extra_clean
install:: extra_install install:: extra_install
pure_install:: extra_install pure_install:: extra_install
VER=$(shell perl -e '$$_=<>;print m/\((.*?)\)/'<debian/changelog)
ikiwiki: ikiwiki.pl
perl -pe '$$_="" if /use lib/; $$_="our \$$version=\"$(VER)\";\n" if /VERSION_AUTOREPLACE/' ikiwiki.pl > ikiwiki
extra_build: extra_build:
./ikiwiki.pl doc html --templatedir=templates --underlaydir=basewiki \ ./ikiwiki.pl doc html --templatedir=templates --underlaydir=basewiki \
--wikiname="ikiwiki" --verbose --no-rcs \ --wikiname="ikiwiki" --verbose --no-rcs \
@ -50,5 +55,6 @@ extra_install:
WriteMakefile( WriteMakefile(
'NAME' => 'IkiWiki', 'NAME' => 'IkiWiki',
'PM_FILTER' => 'grep -v "removed by Makefile"', 'PM_FILTER' => 'grep -v "removed by Makefile"',
'EXE_FILES' => ['ikiwiki.pl'], 'EXE_FILES' => ['ikiwiki'],
'clean' => {FILES => 'ikiwiki'},
); );

View File

@ -5,15 +5,16 @@ For example "\[[WikiLink]]".
If you ever need to write something like "\[[WikiLink]] without creating a If you ever need to write something like "\[[WikiLink]] without creating a
wikilink, just prefix it with a "\", like "\\\\[[WikiLink]]". wikilink, just prefix it with a "\", like "\\\\[[WikiLink]]".
Note that there are some special [[SubPage/LinkingRules]] that come into There are some special [[SubPage/LinkingRules]] that come into play when
play when linking between [[SubPage]]s. linking between [[SubPage]]s.
WikiLinks can be entered in any case you like, the page they link to is Also, iIf the file linked to by a WikiLink looks like an image, it will
always lowercased.
Note that if the file linked to by a WikiLink looks like an image, it will
be displayed inline on the page. be displayed inline on the page.
WikiLinks are matched with page names in a case-insensative manner, so you
don't need to worry about getting the case the same, and can capitalise
links at the start of a sentence, and so on.
It's also possible to write a WikiLink that uses something other than the It's also possible to write a WikiLink that uses something other than the
page name as the link text. For example "\[[foo_bar|SandBox]]" links to the page name as the link text. For example "\[[foo_bar|SandBox]]" links to the
SandBox page, but the link will appear like this: [[foo_bar|SandBox]] SandBox page, but the link will appear like this: [[foo_bar|SandBox]]

14
debian/changelog vendored
View File

@ -1,10 +1,22 @@
ikiwiki (1.18) UNRELEASED; urgency=low ikiwiki (1.18) UNRELEASED; urgency=low
* The last release accidentially installed ikiwiki as ikiwiki.pl, now fixed.
* Add --version.
* Man page format fixups.
* If the meta plugin overides the page title, set a title_overridden * If the meta plugin overides the page title, set a title_overridden
variable in the template to true. This allows doing things with the variable in the template to true. This allows doing things with the
templates conditional on the title being overriden. templates conditional on the title being overriden.
* Add a %pagecase which maps lower-case page names to the actual case
used in the filename. Use this in bestlinks calculation instead of
forcing the link to lowercase.
* Also use %pagecase in various other places that want to check if a page
with a given name exists.
* This means that links to pages with mixed case names will now work,
even if the link is in some other case mixture, and mixed case pages
should be fully supported throughout ikiwiki.
* Recommend rebuilding wikis on upgrade to this version.
-- Joey Hess <joeyh@debian.org> Sat, 12 Aug 2006 13:45:05 -0400 -- Joey Hess <joeyh@debian.org> Sat, 12 Aug 2006 21:26:29 -0400
ikiwiki (1.17) unstable; urgency=low ikiwiki (1.17) unstable; urgency=low

2
debian/postinst vendored
View File

@ -4,7 +4,7 @@ set -e
# Change this when some incompatible change is made that requires # Change this when some incompatible change is made that requires
# rebuilding all wikis. # rebuilding all wikis.
firstcompat=1.13 firstcompat=1.18
if [ "$1" = configure ] && \ if [ "$1" = configure ] && \
dpkg --compare-versions "$2" lt "$firstcompat"; then dpkg --compare-versions "$2" lt "$firstcompat"; then

View File

@ -1 +1 @@
ikiwiki is licensed under the terms of the GNU [GPL](GPL). ikiwiki is licensed under the terms of the GNU [[GPL]].

View File

@ -0,0 +1,4 @@
ikiwiki should support pages that have uppercase in their filenames.
However, links to such pages should not need to exactly preserve the case.
[[todo/done]]

View File

@ -1,11 +0,0 @@
Being case insensative is handy, but it does make the [[BackLinks]] and
[[blog]] links a bit ugly compared to other links. It should be possible to
support pagenames that have uppercase, while still allowing them to be
linked to using any case.
Also, newly created pagenames that include upper case characters should
perhaps not automatically be converted to lower case then.
Also, it's currently possible to check in a filename with uppercase and
ikiwiki will render it that way, but fail to edit it online, fail to link to
it properly from other pages, etc.

View File

@ -75,6 +75,10 @@ These options control the mode that ikiwiki is operating in.
along with this one. --rebuild will also force feeds to be polled even if along with this one. --rebuild will also force feeds to be polled even if
they were polled recently. they were polled recently.
* --version
Print ikiwiki version number.
# CONFIG OPTIONS # CONFIG OPTIONS
These options configure the wiki. Note that plugins can add additional These options configure the wiki. Note that plugins can add additional
@ -160,7 +164,7 @@ configuration options of their own.
Specifies the url to the ikiwiki [[CGI]] script wrapper. Required when Specifies the url to the ikiwiki [[CGI]] script wrapper. Required when
building the wiki for links to the cgi script to be generated. building the wiki for links to the cgi script to be generated.
* --historyurl http://url/trunk/\[[file]]?root=wiki * --historyurl url
Specifies the url to link to for page history browsing. In the url, Specifies the url to link to for page history browsing. In the url,
"\[[file]]" is replaced with the file to browse. It's common to use "\[[file]]" is replaced with the file to browse. It's common to use
@ -170,7 +174,7 @@ configuration options of their own.
Specifies the email address that ikiwiki should use for sending email. Specifies the email address that ikiwiki should use for sending email.
* --diffurl http://url/trunk/\[[file]]?root=wiki&amp;r1=\[[r1]]&amp;r2=\[[r2]] * --diffurl url
Specifies the url to link to for a diff of changes to a page. In the url, Specifies the url to link to for a diff of changes to a page. In the url,
"\[[file]]" is replaced with the file to browse, "\[[r1]]" is the old "\[[file]]" is replaced with the file to browse, "\[[r1]]" is the old

View File

@ -3,6 +3,8 @@ $ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
delete @ENV{qw{IFS CDPATH ENV BASH_ENV}}; delete @ENV{qw{IFS CDPATH ENV BASH_ENV}};
package IkiWiki; package IkiWiki;
our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
use warnings; use warnings;
use strict; use strict;
use lib '.'; # For use without installation, removed by Makefile. use lib '.'; # For use without installation, removed by Makefile.
@ -65,7 +67,11 @@ sub getconfig () { #{{{
}, },
"pingurl" => sub { "pingurl" => sub {
push @{$config{pingurl}}, $_[1]; push @{$config{pingurl}}, $_[1];
} },
"version" => sub {
print "ikiwiki version $version\n";
exit;
},
) || usage(); ) || usage();
if (! $config{setup}) { if (! $config{setup}) {

View File

@ -8,8 +8,12 @@ print ".TH $prog $section\n";
while (<>) { while (<>) {
s{(\\?)\[\[([^\s\]]+)\]\]}{$1 ? "[[$2]]" : $2}eg; s{(\\?)\[\[([^\s\]]+)\]\]}{$1 ? "[[$2]]" : $2}eg;
s/^#\s/.SH /; if (/^#\s/) {
s/^#\s/.SH /;
<>; # blank;
}
s/^\s+//; s/^\s+//;
s/-/\\-/g;
s/^Warning:.*//g; s/^Warning:.*//g;
s/^$/.PP\n/; s/^$/.PP\n/;
s/\`//g; s/\`//g;

View File

@ -1,16 +1,16 @@
#!/usr/bin/perl #!/usr/bin/perl
use warnings; use warnings;
use strict; use strict;
use Test::More tests => 5; use Test::More tests => 8;
sub test ($$$) { sub test ($$$) {
my $page=shift; my $page=shift;
my $link=shift; my $link=shift;
my @existing_pages=@{shift()}; my @existing_pages=@{shift()};
%IkiWiki::links=(); %IkiWiki::pagecase=();
foreach my $page (@existing_pages) { foreach my $page (@existing_pages) {
$IkiWiki::links{$page}=[]; $IkiWiki::pagecase{lc $page}=$page;
} }
return IkiWiki::bestlink($page, $link); return IkiWiki::bestlink($page, $link);
@ -20,5 +20,8 @@ BEGIN { use_ok("IkiWiki"); }
is(test("bar", "foo", ["bar"]), "", "broken link"); is(test("bar", "foo", ["bar"]), "", "broken link");
is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link"); is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link");
is(test("bar", "FoO", ["bar", "foo"]), "foo", "simple link with different input case");
is(test("bar", "foo", ["bar", "fOo"]), "fOo", "simple link with different page case");
is(test("bar", "FoO", ["bar", "fOo"]), "fOo", "simple link with different page and input case");
is(test("bar", "foo", ["bar", "foo", "bar/foo"]), "bar/foo", "simple subpage link"); is(test("bar", "foo", ["bar", "foo", "bar/foo"]), "bar/foo", "simple subpage link");
is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link"); is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link");

View File

@ -12,9 +12,9 @@ sub linkify ($$$$) {
# This is what linkify and htmllink need set right now to work. # This is what linkify and htmllink need set right now to work.
# This could change, if so, update it.. # This could change, if so, update it..
%IkiWiki::links=(); %IkiWiki::pagecase=();
foreach my $page (@existing_pages) { foreach my $page (@existing_pages) {
$IkiWiki::links{$page}=[]; $IkiWiki::pagecase{lc $page}=$page;
$IkiWiki::renderedfiles{"$page.mdwn"}=$page; $IkiWiki::renderedfiles{"$page.mdwn"}=$page;
} }
%IkiWiki::config=IkiWiki::defaultconfig(); %IkiWiki::config=IkiWiki::defaultconfig();