Last modified: 2004-12-07 01:27:35 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T2981, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 981 - Support .. (dotdot) syntax for subpage links
Support .. (dotdot) syntax for subpage links
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-12-02 18:59 UTC by John Andrews
Modified: 2004-12-07 01:27 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Example implementation of requested feature. (1.46 KB, text/plain)
2004-12-02 19:02 UTC, John Andrews
Details

Description John Andrews 2004-12-02 18:59:35 UTC
Please allow links with dotdot syntax to reference up the subpage
hierarchy.  This is very useful for deep subpage hierarchies (which
are perhaps only useful in intranets).

Here are simple examples (assume we are editing page A/B/C/D):

    [../E]     -->   references A/B/C/E
    [../../../W/X]  --> references A/W/X

Here is a mediocre implementation for version 1.3.8 (if this gets mangled,
email me at john_b_andrews@yahoo.com for a copy):

Parser.php diff:

1197,1213d1196
<	# JBA inserted code here
<	# The two inserted code snippets allow .. syntax like this:
<	# [[../Foo]] or [[../../Bar]]
<	# Limitations:
<	#	- ..s can only occur at beginning
<	#	- cannot go past your top subpage
<	#	- cannot just do .. or ../..; must have / and something not-..
<	$jba_cd_dot_dot = 0; # count # of leading ../ occurrences
<	$jba_orig_m1 = $m[1];
<	if(substr($m[1],0,3) == '../') {
<	    while(substr($m[1],0,3) == '../') {
<		$jba_cd_dot_dot = $jba_cd_dot_dot + 1;
<		$m[1] = substr($m[1],3);
<	    }
<	    $m[1] = '/' . $m[1];
<	}
<	# JBA end of code insertion
1224,1241c1207
<			# JBA inserted code here
<			$jba_prefix = $this->mTitle->getPrefixedText();		# Prefix to be prepended
< 
<			# Remove $jba_cd_dot_dot number of /words on the end of the prefix
<			if ($jba_cd_dot_dot) {
<			    $jba_substrings = explode('/', $jba_prefix);
<			    $jba_substrings = array_slice($jba_substrings, 0, -$jba_cd_dot_dot);
<			    # Implode seems to malfunction if $jba_substrings is one element.
<			    if (count($jba_substrings) == 1) {
<				$jba_prefix = $jba_substrings[0];
<			    }
<			    else {
<				$jba_prefix = implode('/', $jba_substrings);
<			    }
<			}
< 
<			# Prepend the prefix to the suffix to form the link.
<			$link = $jba_prefix . '/' . trim($noslash);
---
>			$link = $this->mTitle->getPrefixedText(). '/' . trim($noslash);
1243c1209
<			    $text= $jba_orig_m1;
---
> 			    $text= $m[1];
1245,1246d1210
<			# JBA end of code insertion
Comment 1 John Andrews 2004-12-02 19:02:43 UTC
Created attachment 141 [details]
Example implementation of requested feature.
Comment 2 Shane King 2004-12-07 01:27:35 UTC
I've added this feature to the HEAD (1.5) branch of CVS.

Assuming we're at page A/B/C/D:

[[../../]] links to A/B
[[../../E]] links to A/B/E

If no link title is given, then the full page path will be used, except if the
link is followed by an extra slash, eg

[[../F/]] renders simply as F, while [[../F]] will render as A/B/C/F. Of course
you can use the pipe title format as per any other link.

Note you can not go above the top level page with this, for this example
[[../../../../G]] will not be reated as a valid link.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links