From d2e3741a6f289bd25b75683990a0548f41661a85 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 23 Nov 2010 00:00:11 +0000 Subject: Use local paths for redirection where possible --- IkiWiki/Plugin/editpage.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Plugin/editpage.pm') diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 1a04a72b5..8915211d4 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -156,13 +156,13 @@ sub cgi_editpage ($$) { my $previewing=0; if ($form->submitted eq "Cancel") { if ($form->field("do") eq "create" && defined $from) { - redirect($q, urlto($from, undef, 1)); + redirect($q, urlto($from, undef)); } elsif ($form->field("do") eq "create") { - redirect($q, $config{url}); + redirect($q, baseurl(undef)); } else { - redirect($q, urlto($page, undef, 1)); + redirect($q, urlto($page, undef)); } exit; } @@ -262,7 +262,7 @@ sub cgi_editpage ($$) { @page_locs=$page; } else { - redirect($q, urlto($page, undef, 1)); + redirect($q, urlto($page, undef)); exit; } } @@ -434,7 +434,7 @@ sub cgi_editpage ($$) { else { # The trailing question mark tries to avoid broken # caches and get the most recent version of the page. - redirect($q, urlto($page, undef, 1)."?updated"); + redirect($q, urlto($page, undef)."?updated"); } } -- cgit v1.2.3 From 296e5cb2fd3690e998b3824d54d317933c595873 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 23 Nov 2010 00:12:17 +0000 Subject: Use local paths for the CGI URL --- IkiWiki/Plugin/comments.pm | 2 +- IkiWiki/Plugin/editpage.pm | 2 +- IkiWiki/Plugin/inline.pm | 2 +- IkiWiki/Plugin/openid.pm | 6 +++--- IkiWiki/Plugin/poll.pm | 2 +- IkiWiki/Plugin/recentchanges.pm | 2 +- IkiWiki/Plugin/remove.pm | 2 +- IkiWiki/Plugin/rename.pm | 2 +- IkiWiki/Plugin/search.pm | 4 ++-- IkiWiki/Plugin/websetup.pm | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) (limited to 'IkiWiki/Plugin/editpage.pm') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index eefd65741..00945b753 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -301,7 +301,7 @@ sub editcomment ($$) { required => [qw{editcontent}], javascript => 0, params => $cgi, - action => $config{cgiurl}, + action => IkiWiki::cgiurl(), header => 0, table => 0, template => { template('editcomment.tmpl') }, diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 8915211d4..837bfed13 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -75,7 +75,7 @@ sub cgi_editpage ($$) { required => [qw{editcontent}], javascript => 0, params => $q, - action => $config{cgiurl}, + action => IkiWiki::cgiurl(), header => 0, table => 0, template => { template("editpage.tmpl") }, diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 1fe40a5ea..765271564 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -300,7 +300,7 @@ sub preprocess_inline (@) { IkiWiki->can("cgi_editpage")) { # Add a blog post form, with feed buttons. my $formtemplate=template_depends("blogpost.tmpl", $params{page}, blind_cache => 1); - $formtemplate->param(cgiurl => $config{cgiurl}); + $formtemplate->param(cgiurl => IkiWiki::cgiurl()); $formtemplate->param(rootpage => rootpage(%params)); $formtemplate->param(rssurl => $rssurl) if $feeds && $rss; $formtemplate->param(atomurl => $atomurl) if $feeds && $atom; diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index 3b75c31a2..0220a3cf6 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -77,7 +77,7 @@ sub openid_selector { my $template=IkiWiki::template("openid-selector.tmpl"); $template->param( - cgiurl => $config{cgiurl}, + cgiurl => IkiWiki::cgiurl(), (defined $openid_error ? (openid_error => $openid_error) : ()), (defined $openid_url ? (openid_url => $openid_url) : ()), ($real_cgi_signin ? (nonopenidform => $real_cgi_signin->($q, $session, 1)) : ()), @@ -148,7 +148,7 @@ sub validate ($$$;$) { } my $cgiurl=$config{openid_cgiurl}; - $cgiurl=$config{cgiurl} if ! defined $cgiurl; + $cgiurl=IkiWiki::cgiurl() if ! defined $cgiurl; my $trust_root=$config{openid_realm}; $trust_root=$cgiurl if ! defined $trust_root; @@ -249,7 +249,7 @@ sub getobj ($$) { } my $cgiurl=$config{openid_cgiurl}; - $cgiurl=$config{cgiurl} if ! defined $cgiurl; + $cgiurl=IkiWiki::cgiurl() if ! defined $cgiurl; return Net::OpenID::Consumer->new( ua => $ua, diff --git a/IkiWiki/Plugin/poll.pm b/IkiWiki/Plugin/poll.pm index 988f4c113..27df104ab 100644 --- a/IkiWiki/Plugin/poll.pm +++ b/IkiWiki/Plugin/poll.pm @@ -52,7 +52,7 @@ sub preprocess (@) { foreach my $choice (@choices) { if ($open && exists $config{cgiurl}) { # use POST to avoid robots - $ret.="
\n"; + $ret.="\n"; } my $percent=$total > 0 ? int($choices{$choice} / $total * 100) : 0; $ret.="

\n"; diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 562f61d40..3542b2228 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -84,7 +84,7 @@ sub sessioncgi ($$) { method => 'POST', javascript => 0, params => $q, - action => $config{cgiurl}, + action => IkiWiki::cgiurl(), stylesheet => 1, template => { template('revert.tmpl') }, fields => [qw{revertmessage do sid rev}], diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index ab1897663..336a781ed 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -100,7 +100,7 @@ sub confirmation_form ($$) { method => 'POST', javascript => 0, params => $q, - action => $config{cgiurl}, + action => IkiWiki::cgiurl(), stylesheet => 1, fields => [qw{do page}], ); diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index ad5e72645..614a4cf5c 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -126,7 +126,7 @@ sub rename_form ($$$) { method => 'POST', javascript => 0, params => $q, - action => $config{cgiurl}, + action => IkiWiki::cgiurl(), stylesheet => 1, fields => [qw{do page new_name attachment}], ); diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index 8fb9dff0c..78eb750b5 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -58,7 +58,7 @@ sub pagetemplate (@) { if ($template->query(name => "searchform")) { if (! defined $form) { my $searchform = template("searchform.tmpl", blind_cache => 1); - $searchform->param(searchaction => $config{cgiurl}); + $searchform->param(searchaction => IkiWiki::cgiurl()); $searchform->param(html5 => $config{html5}); $form=$searchform->output; } @@ -176,7 +176,7 @@ sub cgi ($) { # only works for GET requests chdir("$config{wikistatedir}/xapian") || error("chdir: $!"); $ENV{OMEGA_CONFIG_FILE}="./omega.conf"; - $ENV{CGIURL}=$config{cgiurl}, + $ENV{CGIURL}=IkiWiki::cgiurl(); IkiWiki::loadindex(); $ENV{HELPLINK}=htmllink("", "", "ikiwiki/searching", noimageinline => 1, linktext => "Help"); diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index ef9a93886..6a5190301 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -288,7 +288,7 @@ sub showform ($$) { fieldsets => [ [main => gettext("main")], ], - action => $config{cgiurl}, + action => IkiWiki::cgiurl(), template => {type => 'div'}, stylesheet => 1, ); -- cgit v1.2.3 From 1f019ac2aaa2ba3ec06764f9e62679918cae435d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 23 Nov 2010 00:19:10 +0000 Subject: Use local paths for most references to pages --- IkiWiki/Plugin/comments.pm | 8 ++++---- IkiWiki/Plugin/editpage.pm | 2 +- IkiWiki/Plugin/img.pm | 4 ++-- IkiWiki/Plugin/parentlinks.pm | 2 +- IkiWiki/Plugin/recentchanges.pm | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'IkiWiki/Plugin/editpage.pm') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 00945b753..f11a81736 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -237,7 +237,7 @@ sub preprocess { } if ($params{page} =~ m/\/\Q$config{comments_pagename}\E\d+_/) { - $pagestate{$page}{meta}{permalink} = urlto(IkiWiki::dirname($params{page}), undef, 1). + $pagestate{$page}{meta}{permalink} = urlto(IkiWiki::dirname($params{page}), undef). "#".page_to_id($params{page}); } @@ -372,7 +372,7 @@ sub editcomment ($$) { error(gettext("bad page name")); } - my $baseurl = urlto($page, undef, 1); + my $baseurl = urlto($page, undef); $form->title(sprintf(gettext("commenting on %s"), IkiWiki::pagetitle($page))); @@ -810,14 +810,14 @@ sub pagetemplate (@) { if ($shown) { if ($template->query(name => 'commentsurl')) { $template->param(commentsurl => - urlto($page, undef, 1).'#comments'); + urlto($page, undef).'#comments'); } if ($template->query(name => 'atomcommentsurl') && $config{usedirs}) { # This will 404 until there are some comments, but I # think that's probably OK... $template->param(atomcommentsurl => - urlto($page, undef, 1).'comments.atom'); + urlto($page, undef).'comments.atom'); } if ($template->query(name => 'commentslink')) { diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 837bfed13..b3ae1fded 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -98,7 +98,7 @@ sub cgi_editpage ($$) { error(gettext("bad page name")); } - my $baseurl = urlto($page, undef, 1); + my $baseurl = urlto($page, undef); my $from; if (defined $form->field('from')) { diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index bd527c8c8..b554a3dfc 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -152,8 +152,8 @@ sub preprocess (@) { $imgurl=urlto($imglink, $params{destpage}); } else { - $fileurl="$config{url}/$file"; - $imgurl="$config{url}/$imglink"; + $fileurl=urlto($file, undef); + $imgurl=urlto($imglink, undef); } if (! exists $params{class}) { diff --git a/IkiWiki/Plugin/parentlinks.pm b/IkiWiki/Plugin/parentlinks.pm index bbd2c5752..203ea13b6 100644 --- a/IkiWiki/Plugin/parentlinks.pm +++ b/IkiWiki/Plugin/parentlinks.pm @@ -27,7 +27,7 @@ sub parentlinks ($) { if (! length $page) { # dynamic page return { - url => $config{url}, + url => IkiWiki::baseurl(undef), page => $config{wikiname}, }; } diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 3542b2228..de12bb2c6 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -127,7 +127,7 @@ sub sessioncgi ($$) { exit 0; } - IkiWiki::redirect($q, urlto($config{recentchangespage}, '')); + IkiWiki::redirect($q, urlto($config{recentchangespage}, undef)); exit 0; } @@ -178,7 +178,7 @@ sub store ($$$) { else { $_->{link} = pagetitle($_->{page}); } - $_->{baseurl}="$config{url}/" if length $config{url}; + $_->{baseurl}=IkiWiki::baseurl(undef) if length $config{url}; $_; } @{$change->{pages}} @@ -226,7 +226,7 @@ sub store ($$$) { wikiname => $config{wikiname}, ); - $template->param(permalink => "$config{url}/$config{recentchangespage}/#change-".titlepage($change->{rev})) + $template->param(permalink => urlto($config{recentchangespage}, undef)."#change-".titlepage($change->{rev})) if exists $config{url}; IkiWiki::run_hooks(pagetemplate => sub { -- cgit v1.2.3