New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linked and formatted user names #527
Changes from 13 commits
60a396c
8a7e0ee
62c8004
7c2f8ee
b3d353e
7f08182
2d6df79
2345e87
5a9ce44
4485a89
ddb55c7
6496c33
f379edc
6198904
2a2a43c
118e005
6384941
f97db66
30f6ec4
533772e
15f3bc4
c18baa7
c095302
898f93a
cd4635e
4d5fc92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
require_once DOKU_INC . 'inc/parser/renderer.php'; | ||
|
||
/** | ||
* Tests for Doku_Renderer::_resolveInterWiki() | ||
*/ | ||
class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { | ||
|
||
function testDefaults() { | ||
$Renderer = new Doku_Renderer(); | ||
$Renderer->interwiki = getInterwiki(); | ||
$Renderer->interwiki['scheme'] = '{SCHEME}://example.com'; | ||
$Renderer->interwiki['withslash'] = '/test'; | ||
$Renderer->interwiki['onlytext'] = ':onlytext{NAME}'; //with {URL} double urlencoded | ||
$Renderer->interwiki['withquery'] = ':anyns:{NAME}?do=edit'; | ||
|
||
$tests = array( | ||
// shortcut, reference and expected | ||
array('wp', 'foo @+%/#txt', 'http://en.wikipedia.org/wiki/foo @+%/#txt'), | ||
array('amazon', 'foo @+%/#txt', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/#txt'), | ||
array('doku', 'foo @+%/#txt', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F#txt'), | ||
array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090/path/naar/?query=foo%20%40%2B%25%2F'), | ||
array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'), | ||
//relative url | ||
array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), | ||
array('skype', 'foo @+%/#txt', 'skype:foo @+%/#txt'), | ||
//dokuwiki id's | ||
array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'), | ||
array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=wiki:users:foo#txt'), | ||
array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo&do=edit#txt') | ||
); | ||
|
||
foreach($tests as $test) { | ||
$url = $Renderer->_resolveInterWiki($test[0], $test[1]); | ||
|
||
$this->assertEquals($test[2], $url); | ||
} | ||
} | ||
|
||
function testNonexisting() { | ||
$Renderer = new Doku_Renderer(); | ||
$Renderer->interwiki = getInterwiki(); | ||
|
||
$shortcut = 'nonexisting'; | ||
$reference = 'foo @+%/'; | ||
$url = $Renderer->_resolveInterWiki($shortcut, $reference); | ||
$expected = 'http://www.google.com/search?q=foo%20%40%2B%25%2F&btnI=lucky'; | ||
|
||
$this->assertEquals($expected, $url); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,13 @@ amazon.de http://www.amazon.de/exec/obidos/ASIN/{URL}/splitbrain-21/ | |
amazon.uk http://www.amazon.co.uk/exec/obidos/ASIN/ | ||
paypal https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business= | ||
phpfn http://www.php.net/{NAME} | ||
coral http://{HOST}.{PORT}.nyud.net:8090/{PATH}?{QUERY} | ||
coral http://{HOST}.{PORT}.nyud.net:8090{PATH}?{QUERY} | ||
freecache http://freecache.org/{NAME} | ||
sb http://www.splitbrain.org/go/ | ||
skype skype:{NAME} | ||
google.de http://www.google.de/search?q= | ||
go http://www.google.com/search?q={URL}&btnI=lucky | ||
user :wiki:users:{NAME} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would use singular here, so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed. |
||
|
||
# To support VoIP/SIP links | ||
callto callto://{NAME} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -685,7 +685,7 @@ function externallink($url, $name = null) { | |
} | ||
|
||
/** | ||
*/ | ||
*/ | ||
function interwikilink($match, $name = null, $wikiName, $wikiUri) { | ||
global $conf; | ||
|
||
|
@@ -697,19 +697,28 @@ function interwikilink($match, $name = null, $wikiName, $wikiUri) { | |
$link['name'] = $this->_getLinkTitle($name, $wikiUri, $isImage); | ||
|
||
//get interwiki URL | ||
$url = $this->_resolveInterWiki($wikiName,$wikiUri); | ||
$exists = null; | ||
$url = $this->_resolveInterWiki($wikiName, $wikiUri, $exists); | ||
|
||
if ( !$isImage ) { | ||
$class = preg_replace('/[^_\-a-z0-9]+/i','_',$wikiName); | ||
if(!$isImage) { | ||
$class = preg_replace('/[^_\-a-z0-9]+/i', '_', $wikiName); | ||
$link['class'] = "interwiki iw_$class"; | ||
} else { | ||
$link['class'] = 'media'; | ||
} | ||
|
||
//do we stay at the same server? Use local target | ||
if( strpos($url,DOKU_URL) === 0 ){ | ||
if(strpos($url, DOKU_URL) === 0 OR strpos($url, DOKU_BASE) === 0) { | ||
$link['target'] = $conf['target']['wiki']; | ||
} | ||
if($exists !== null && !$isImage) { | ||
if($exists) { | ||
$link['class'] .= ' wikilink1'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes sense to add the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a icon. This user.png is of famfamfam image set. |
||
} else { | ||
$link['class'] .= ' wikilink2'; | ||
$link['rel'] = 'nofollow'; | ||
} | ||
} | ||
|
||
$link['url'] = $url; | ||
$link['title'] = htmlspecialchars($link['url']); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn. I forgot about this usecase. this will break with your change. You no longer can create a shortcut to have special protocol links like skype:, mailto: or javascript:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could use a (pseudo) full link syntax instead?
But users would expect these to work too then:
which doesn't really make sense. Maybe we can do something like in mime.conf and prefix things that should be resolved as page name with a !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FS#2713 suggests using
_shortcut
or.shortcut
for internal links, you added!shortcut
as well.Which variant do we like?