From: Joey Hess <joey@kitenet.net>
Date: Wed, 5 Jan 2011 20:26:09 +0000 (-0400)
Subject: better handling of relative permalinks
X-Git-Tag: 3.20110105~5
X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/ea734d451ce7680906618b41ac35a0f3904b154a?hp=--cc

better handling of relative permalinks

This way, do=goto will go to the page relative to
the current location, while the permalinks in feeds
will be absolute (unless an url is not configured at all).
---

ea734d451ce7680906618b41ac35a0f3904b154a
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index cdb926271..f3d6f20d6 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})).
 			"#".page_to_id($params{page});
 	}
 
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index abc8f1b1a..ad6d1a8e3 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -298,6 +298,11 @@ sub pagetemplate (@) {
 			if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
 	}
 
+	foreach my $field (qw{permalink}) {
+		$template->param($field => IkiWiki::urlabs($pagestate{$page}{meta}{$field}, $config{url}))
+			if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
+	}
+
 	foreach my $field (qw{description}) {
 		$template->param($field => HTML::Entities::encode_numeric($pagestate{$page}{meta}{$field}))
 			if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index 92083a7ad..d6292c3f2 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -225,7 +225,7 @@ sub store ($$$) {
 		wikiname => $config{wikiname},
 	);
 	
-	$template->param(permalink => urlto($config{recentchangespage}, undef, 1)."#change-".titlepage($change->{rev}))
+	$template->param(permalink => urlto($config{recentchangespage})."#change-".titlepage($change->{rev}))
 		if exists $config{url};
 	
 	IkiWiki::run_hooks(pagetemplate => sub {
diff --git a/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn b/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn
index dfe41e138..143bf0edc 100644
--- a/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn
+++ b/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn
@@ -23,6 +23,8 @@
   to absolute urls when fulling out templates, while allowing them
   to be left as partial urls internally, for use by goto. --[[Joey]]
 
+  > This reversion has now been fixed. --[[Joey]]
+
 ## old attempt
 
 It looks like all links in websites are absolute paths, this has some limitations: