1 [[!meta author="""http://smcv.pseudorandom.co.uk/"""]]
3 [[!meta authorurl="""http://smcv.pseudorandom.co.uk/"""]]
5 [[!meta title="""change to todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both on ikiwiki"""]]
7 [[!meta permalink="http://ikiwiki.info/recentchanges/#change-8935a131d02ac13b6024dff9cbf7a5f837fcdc04"]]
9 <div id="change-8935a131d02ac13b6024dff9cbf7a5f837fcdc04" class="metadata">
10 <span class="desc"><br />Changed pages:</span>
11 <span class="pagelinks">
13 <a href="http://git.ikiwiki.info/?p=ikiwiki;a=blobdiff;f=doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn;h=8b0501041379278330dbdb52c3232dc26fef5d2c;hp=f8ec4c420469f47168ced54b93dbe75fa39dfdab;hb=8935a131d02ac13b6024dff9cbf7a5f837fcdc04;hpb=1968317cacc2f555af17286acf26a60ce616cc40" title="diff" rel="nofollow">[[diff|wikiicons/diff.png]]</a><a href="http://ikiwiki.info/ikiwiki.cgi?page=todo%2Fwant_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both&do=goto" rel="nofollow">todo/want to avoid ikiwiki using http or https in urls to allow serving both</a>
17 <span class="desc"><br />Changed by:</span>
18 <span class="committer">
20 <a href="http://smcv.pseudorandom.co.uk/" rel="nofollow">smcv</a>
23 <span class="desc"><br />Commit type:</span>
24 <span class="committype">web</span>
25 <span class="desc"><br />Date:</span>
26 <span class="changedate"><span class="relativedate" title="Tue, 23 Nov 2010 00:37:28 +0000">00:37:28 11/23/10</span></span>
27 <span class="desc"><br /></span>
31 <a href="http://ikiwiki.info/ikiwiki.cgi?rev=8935a131d02ac13b6024dff9cbf7a5f837fcdc04&do=revert" title="revert" rel="nofollow">[[revert|wikiicons/revert.png]]</a>
34 <div class="changelog">
37 updated branch, not tested properly yet<br />
44 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
45 index f8ec4c4..8b05010 100644
46 --- a/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn
47 +++ b/doc/todo/want_to_avoid_ikiwiki_using_http_or_https_in_urls_to_allow_serving_both.mdwn
48 @@ -147,7 +147,7 @@ you don't like my approach:
52 -[[!template id=gitbranch branch=smcv/ready/localurl author="[[smcv]]"]]
53 +[[!template id=gitbranch branch=smcv/localurl author="[[smcv]]"]]
54 [[!tag patch]]
56 OK, here's an alternative approach, closer in spirit to what was initially
57 @@ -165,14 +165,17 @@ whether `url` and `cgiurl` are on the same server with the the same URL
58 scheme. In theory you could use things like `//static.example.com/wiki/`
59 and `//dynamic.example.com/ikiwiki.cgi` to preserve choice of http/https
60 while switching server, but I don't know how consistently browsers
64 "local" here is short for "locally valid", because these URLs are neither
65 fully relative nor fully absolute, and there doesn't seem to be a good name
68 -I've tested this on a demo website with the CGI enabled, and it seems to
69 +I tested an earlier version on a demo website with the CGI enabled, and it seemed to
70 work nicely (there might be bugs in some plugins, I didn't try all of them).
71 +I haven't yet re-tested with my updated branch, which is why it's not `ready/`
74 The `$config{url}` and `$config{cgiurl}` are both HTTP, but if I enable
75 `httpauth`, set `cgiauthurl` to a HTTPS version of the same site and log
76 in via that, links all end up in the HTTPS version.
77 @@ -217,11 +220,19 @@ New API added by this branch:
79 >>> That makes a great deal of sense, bravo for actually removing
80 >>> parameters in the common case while maintaining backwards
81 - >>> compatability!
82 + >>> compatability! --[[Joey]]
84 + >>>> Done in my `localurl` branch; not tested in a whole-wiki way
85 + >>>> yet, but I did add a regression test. I've used
86 + >>>> `urlto(x, undef)` rather than `urlto(x)` so far, but I could
87 + >>>> go back through the codebase using the short form if you'd
88 + >>>> prefer. --[[smcv]]
90 >>> It does highlight that it would be better to have a
91 >>> `absolute_urlto($link)` (or maybe `absolute(urlto($link))` )
92 >>> rather than the 3 parameter form. --[[Joey]]
94 + >>> Possibly. I haven't added this.
96 * `IkiWiki::baseurl` has a new second argument which works like the
97 third argument of `urlto`
98 @@ -232,19 +243,34 @@ New API added by this branch:
99 >> (But I assume changes to `urlto` will follow through here anyway.)
100 >> --[[Joey]]
102 + >>> I had to use it a bit more, as a replacement for `$config{url}`
103 + >>> when doing things like referencing stylesheets or redirecting to
104 + >>> the top of the wiki.
106 + >>> I ended up redoing this without the extra parameter. Previously,
107 + >>> `baseurl(undef)` was the absolute URL; now, `baseurl(undef)` is
108 + >>> the local path. I know you objected to me using `baseurl()` in
109 + >>> an earlier branch, because `baseurl().$x` looks confusingly
110 + >>> similar to `baseurl($x)` but has totally different semantics;
111 + >>> I've generally written it `baseurl(undef)` now, to be more
112 + >>> explicit. --[[smcv]]
114 * `IkiWiki::cgiurl` uses `$local_cgiurl` if passed `local_cgiurl => 1`
116 - > Possibly changed to making this always be local unless `cgiurl => $x`
117 - > is given: see below --[[smcv]]
118 + > Now changed to always use the `$local_cgiurl`. --[[smcv]]
120 * `IkiWiki::cgiurl` omits the trailing `?` if given no named parameters
121 except `cgiurl` and/or `local_cgiurl`
123 > I assume you have no objection to this --[[smcv]]
125 - >> Nod, although I don't know of a use case. --[[Joey]]
126 + >> Nod, although I don't know of a use case. --[[Joey]]
128 + >>> The use-case is that I can replace `$config{cgiurl}` with
129 + >>> `IkiWiki::cgiurl()` for things like the action attribute of
130 + >>> forms. --[[smcv]]
135 * I don't think anything except `openid` calls `cgiurl` without also
136 passing in `local_cgiurl => 1`, so perhaps that should be the default;
137 @@ -265,6 +291,10 @@ Bugs:
138 >>> if `absolute()` were implemented as suggested above, it could also
139 >>> be used with cgiurl if necessary.) --[[Joey]]
141 + >>>> Done (minus `absolute()`). --[[smcv]]
143 +Potential future things:
145 * It occurs to me that `IkiWiki::cgiurl` could probably benefit from being
146 exported? Perhaps also `IkiWiki::baseurl`?
148 @@ -285,4 +315,7 @@ Bugs:
149 > AFACIS, `baseurl` is only called in 3 places so I don't think that's
150 > needed. --[[Joey]]
152 - >> OK, wontfix. --[[smcv]]
153 + >> OK, wontfix. For what it's worth, my branch has 6 uses in IkiWiki
154 + >> core code (IkiWiki, CGI, Render and the pseudo-core part of editpage)
155 + >> and 5 in plugins, since I used it for things like redirection back
156 + >> to the top of the wiki --[[smcv]]
161 <!-- 8935a131d02ac13b6024dff9cbf7a5f837fcdc04 -->