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/CGI.pm | 4 ++-- IkiWiki/Plugin/comments.pm | 4 ++-- IkiWiki/Plugin/editpage.pm | 10 +++++----- IkiWiki/Plugin/goto.pm | 2 +- IkiWiki/Plugin/openid.pm | 2 +- IkiWiki/Plugin/poll.pm | 4 ++-- IkiWiki/Plugin/remove.pm | 2 +- IkiWiki/Plugin/websetup.pm | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index f2a32a958..ed6959f89 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -231,11 +231,11 @@ sub cgi_prefs ($$) { if ($form->submitted eq 'Logout') { $session->delete(); - redirect($q, $config{url}); + redirect($q, baseurl(undef)); return; } elsif ($form->submitted eq 'Cancel') { - redirect($q, $config{url}); + redirect($q, baseurl(undef)); return; } elsif ($form->submitted eq 'Save Preferences' && $form->validate) { diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index a39dab36c..eefd65741 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -386,7 +386,7 @@ sub editcomment ($$) { if ($form->submitted eq CANCEL) { # bounce back to the page they wanted to comment on, and exit. # CANCEL need not be considered in future - IkiWiki::redirect($cgi, urlto($page, undef, 1)); + IkiWiki::redirect($cgi, urlto($page, undef)); exit; } @@ -552,7 +552,7 @@ sub editcomment ($$) { # Jump to the new comment on the page. # The trailing question mark tries to avoid broken # caches and get the most recent version of the page. - IkiWiki::redirect($cgi, urlto($page, undef, 1). + IkiWiki::redirect($cgi, urlto($page, undef). "?updated#".page_to_id($location)); } 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"); } } diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm index 348a663ef..7f31fa5ca 100644 --- a/IkiWiki/Plugin/goto.pm +++ b/IkiWiki/Plugin/goto.pm @@ -64,7 +64,7 @@ sub cgi_goto ($;$) { ) } else { - IkiWiki::redirect($q, urlto($link, undef, 1)); + IkiWiki::redirect($q, urlto($link, undef)); } exit; diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index fae9fb77f..3b75c31a2 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -175,7 +175,7 @@ sub auth ($$) { IkiWiki::redirect($q, $setup_url); } elsif ($csr->user_cancel) { - IkiWiki::redirect($q, $config{url}); + IkiWiki::redirect($q, IkiWiki::baseurl(undef)); } elsif (my $vident = $csr->verified_identity) { $session->param(name => $vident->url); diff --git a/IkiWiki/Plugin/poll.pm b/IkiWiki/Plugin/poll.pm index b333e2cdc..988f4c113 100644 --- a/IkiWiki/Plugin/poll.pm +++ b/IkiWiki/Plugin/poll.pm @@ -103,7 +103,7 @@ sub sessioncgi ($$) { my $oldchoice=$session->param($choice_param); if (defined $oldchoice && $oldchoice eq $choice) { # Same vote; no-op. - IkiWiki::redirect($cgi, urlto($page, undef, 1)); + IkiWiki::redirect($cgi, urlto($page, undef)); exit; } @@ -153,7 +153,7 @@ sub sessioncgi ($$) { error($@) if $@; my $cookie = CGI::Cookie->new(-name=> $session->name, -value=> $session->id); print $cgi->redirect(-cookie => $cookie, - -url => urlto($page, undef, 1)); + -url => urlto($page, undef)); exit; } } diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index 1717c8cf3..ab1897663 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -240,7 +240,7 @@ sub sessioncgi ($$) { if (! exists $pagesources{$parent}) { $parent="index"; } - IkiWiki::redirect($q, urlto($parent, '/', 1)); + IkiWiki::redirect($q, urlto($parent, undef)); } } else { diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 9c032fdc6..ef9a93886 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -344,7 +344,7 @@ sub showform ($$) { IkiWiki::decode_form_utf8($form); if ($form->submitted eq "Cancel") { - IkiWiki::redirect($cgi, $config{url}); + IkiWiki::redirect($cgi, IkiWiki::baseurl(undef)); return; } elsif (($form->submitted eq 'Save Setup' || $form->submitted eq 'Rebuild Wiki') && $form->validate) { -- cgit v1.2.3 From 78c595736ef6903ad8e7bab232875474aedfd328 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 23 Nov 2010 00:06:07 +0000 Subject: Use local paths when including Javascript --- IkiWiki/Plugin/relativedate.pm | 11 +++++------ IkiWiki/Plugin/toggle.pm | 11 +++++------ IkiWiki/Plugin/wmd.pm | 9 ++++----- 3 files changed, 14 insertions(+), 17 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/relativedate.pm b/IkiWiki/Plugin/relativedate.pm index 7296889ab..4ae0be861 100644 --- a/IkiWiki/Plugin/relativedate.pm +++ b/IkiWiki/Plugin/relativedate.pm @@ -28,18 +28,17 @@ sub format (@) { if (! ($params{content}=~s!^(]*>)!$1.include_javascript($params{page})!em)) { # no tag, probably in preview mode - $params{content}=include_javascript($params{page}, 1).$params{content}; + $params{content}=include_javascript(undef).$params{content}; } return $params{content}; } -sub include_javascript ($;$) { - my $page=shift; - my $absolute=shift; +sub include_javascript ($) { + my $from=shift; - return ''."\n". - ''; } diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm index 1f93f87fe..af4d2ba3a 100644 --- a/IkiWiki/Plugin/toggle.pm +++ b/IkiWiki/Plugin/toggle.pm @@ -70,19 +70,18 @@ sub format (@) { $params{content}=~s/
//g; if (! ($params{content}=~s!^(]*>)!$1.include_javascript($params{page})!em)) { # no tag, probably in preview mode - $params{content}=include_javascript($params{page}, 1).$params{content}; + $params{content}=include_javascript(undef).$params{content}; } } return $params{content}; } -sub include_javascript ($;$) { - my $page=shift; - my $absolute=shift; +sub include_javascript ($) { + my $from=shift; - return ''."\n". - ''; } diff --git a/IkiWiki/Plugin/wmd.pm b/IkiWiki/Plugin/wmd.pm index 71d7c9d17..134cfb910 100644 --- a/IkiWiki/Plugin/wmd.pm +++ b/IkiWiki/Plugin/wmd.pm @@ -31,14 +31,13 @@ sub formbuilder_setup (@) { $form->field("do") eq "comment"; $form->tmpl_param("wmd_preview", "
\n". - include_javascript(undef, 1)); + include_javascript(undef)); } -sub include_javascript ($;$) { - my $page=shift; - my $absolute=shift; +sub include_javascript ($) { + my $from=shift; - my $wmdjs=urlto("wmd/wmd.js", $page, $absolute); + my $wmdjs=urlto("wmd/wmd.js", $from); return <<"EOF"