Hi,
some time ago I asked whether we should start using the MediaWiki namespace for bars of links that recur on several articles; take, for example, the list of links at the bottom of each Greek letter (http://en.wikipedia.org/wiki/Beta).
As far as I remember, it was said that the problem would be that we would get a large number of self-links.
My suggestion to solve that problem was to have {{msg:}} automatically change [[blahblah]] to '''blahblah''' when it is inserted into the page "blahblah".
I have attempted to code this, and I came up with the following. This patch has the side-effect of changing all self-links to bold text, even when they're not inserted using {{msg:}}.
I've tested this on "normal" self-links, and it appears to be working fine. I can't test it with stuff inserted with {{msg:}} because the MediaWiki stuff doesn't seem to work for me (see Message-ID: bverjf$meb$1@sea.gmane.org - any help appreciated :/).
Thanks, Timwi
Index: phase3/includes/OutputPage.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/includes/OutputPage.php,v retrieving revision 1.79 diff -u -r1.79 OutputPage.php --- phase3/includes/OutputPage.php 30 Jan 2004 17:07:50 -0000 1.79 +++ phase3/includes/OutputPage.php 30 Jan 2004 23:57:02 -0000 @@ -1054,6 +1054,10 @@ $s .= $sk->makeLink( $link, $text, "", $trail ); */ } + if( $nt->getPrefixedText() == $wgTitle->getPrefixedText() ) { + $s .= "<strong>" . $text . "</strong>" . $trail; + continue; + } if( $ns == $media ) { $s .= $sk->makeMediaLinkObj( $nt, $text ) . $trail; $wgLinkCache->addImageLinkObj( $nt );
On Saturday 31 January 2004 07:58 am, Timwi wrote:
Hi,
some time ago I asked whether we should start using the MediaWiki namespace for bars of links that recur on several articles; take, for example, the list of links at the bottom of each Greek letter (http://en.wikipedia.org/wiki/Beta).
As far as I remember, it was said that the problem would be that we would get a large number of self-links.
My suggestion to solve that problem was to have {{msg:}} automatically change [[blahblah]] to '''blahblah''' when it is inserted into the page "blahblah".
I have attempted to code this, and I came up with the following. This patch has the side-effect of changing all self-links to bold text, even when they're not inserted using {{msg:}}.
What about links to other sections of the article. (eg. [[samearticle#References]] ?
Best, Sascha Noyes
Sascha Noyes wrote:
What about links to other sections of the article. (eg. [[samearticle#References]] ?
Thanks! Fixed:
Index: phase3/includes/OutputPage.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/includes/OutputPage.php,v retrieving revision 1.79 diff -u -r1.79 OutputPage.php --- phase3/includes/OutputPage.php 30 Jan 2004 17:07:50 -0000 1.79 +++ phase3/includes/OutputPage.php 1 Feb 2004 14:15:16 -0000 @@ -1054,6 +1054,11 @@ $s .= $sk->makeLink( $link, $text, "", $trail ); */ } + if( $nt->getPrefixedText() == $wgTitle->getPrefixedText() + and substr( $link, "#" ) == FALSE ) { + $s .= "<strong>" . $text . "</strong>" . $trail; + continue; + } if( $ns == $media ) { $s .= $sk->makeMediaLinkObj( $nt, $text ) . $trail; $wgLinkCache->addImageLinkObj( $nt );
Now that I got the MediaWiki namespace to work on my installation, I notice that my patch does not work for things inserted using {{msg:}}. Please do not commit ;-) ... I'll work on it.
Timwi
Here is the newest patch for the suggested change. I have tested it thoroughly and it works perfectly now. (I've learnt that strpos *is* different from substr ;-) )
Now, some more questions: - Am I authorised to commit this change to CVS? - Can someone put it on test.wikipedia.org then? - How long until it will be put live on the real servers?
Thanks, Timwi
Index: phase3/includes/OutputPage.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/includes/OutputPage.php,v retrieving revision 1.79 diff -u -r1.79 OutputPage.php --- phase3/includes/OutputPage.php 30 Jan 2004 17:07:50 -0000 1.79 +++ phase3/includes/OutputPage.php 1 Feb 2004 14:45:44 -0000 @@ -1054,6 +1054,11 @@ $s .= $sk->makeLink( $link, $text, "", $trail ); */ } + if( ( $nt->getPrefixedText() == $wgTitle->getPrefixedText() ) && + ( strpos( $link, "#" ) == FALSE ) ) { + $s .= "<strong>" . $text . "</strong>" . $trail; + continue; + } if( $ns == $media ) { $s .= $sk->makeMediaLinkObj( $nt, $text ) . $trail; $wgLinkCache->addImageLinkObj( $nt );
On Sun, 01 Feb 2004 14:49:39 +0000, Timwi wrote:
Here is the newest patch for the suggested change. I have tested it thoroughly and it works perfectly now. (I've learnt that strpos *is* different from substr ;-) )
Now, some more questions:
- Am I authorised to commit this change to CVS?
- Can someone put it on test.wikipedia.org then?
- How long until it will be put live on the real servers?
Current CVS HEAD is the live version, any new features should either wait or go into a separate branch until a new stable branch is cut. Having a joined devel branch again after the current freeze will simplify the test.wikipedia.org update. It's currently running my 'squid' branch.
Gabriel Wicke wrote:
On Sun, 01 Feb 2004 14:49:39 +0000, Timwi wrote:
Here is the newest patch for the suggested change. I have tested it thoroughly and it works perfectly now. (I've learnt that strpos *is* different from substr ;-) )
Now, some more questions:
- Am I authorised to commit this change to CVS?
- Can someone put it on test.wikipedia.org then?
- How long until it will be put live on the real servers?
Current CVS HEAD is the live version, any new features should either wait or go into a separate branch until a new stable branch is cut. Having a joined devel branch again after the current freeze will simplify the test.wikipedia.org update. It's currently running my 'squid' branch.
Hm. Can you simplify this for someone who doesn't really know anything about CVS branches? :-) What exactly do I have to type on the command line to commit this change to the correct branch? Then what do I have to do to get it up on test.wikipedia.org?
Thanks, Timwi
Timwi wrote:
Hm. Can you simplify this for someone who doesn't really know anything about CVS branches? :-) What exactly do I have to type on the command line to commit this change to the correct branch? Then what do I have to do to get it up on test.wikipedia.org?
I'd second this request. I've taught myself PHP, and I'm itching to start doing a little bit of development, but the next big thing I need to learn is CVS.
Jimmy Wales wrote:
Timwi wrote:
Hm. Can you simplify this for someone who doesn't really know anything about CVS branches? :-) What exactly do I have to type on the command line to commit this change to the correct branch? Then what do I have to do to get it up on test.wikipedia.org?
I'd second this request. I've taught myself PHP, and I'm itching to start doing a little bit of development, but the next big thing I need to learn is CVS.
All you need for starters is here: http://sourceforge.net/docman/display_doc.php?docid=14033&group_id=1
Magnus
wikitech-l@lists.wikimedia.org