Question about Links

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about Links

seanizer-2
Hello,
 
I am a new User of mediawiki, and I am planning to put it up on my martial
arts related site. Being a wiki newbie, I don't know if and how I can do the
following:
When I write something like [[mypage]] and "mypage" doesn't exist yet, I
would like registered users to get a link to the edit screen for mypage
(standard behaviour), but unregistered readers should receive only an
emphasized version of "mypage", e.g. <b>mypage</b>. That way, I could
include lots of terminology in my site and gradually fill it up with
contents without going public with dozens of broken links (I know this is
not exactly the wiki way, but it is a business site, and I'd prefer not
having everybody editing it).
 
So basically: If a user is logged in, [[mypage]] would translate to <a
href=" /wiki/index.php?title=mypage&action=edit">mypage</a>, otherwise it
would translate to <b>mypage</b>. I am a programmer geek :-), so I guess I
could eventually come up with a solution for this myself, but I was
wondering if there is a "standardized hack" for such a behavior. Many thanks
in advance,
 
Sean Floyd
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Question about Links

Rob Church
I don't know of a standard hack. You'd want to look at changing the
parser's link section, and disabling the parser cache, which could
lead to a performance drain on a larger site.


Rob Church

On 26/01/06, [hidden email] <[hidden email]> wrote:

> Hello,
>
> I am a new User of mediawiki, and I am planning to put it up on my martial
> arts related site. Being a wiki newbie, I don't know if and how I can do the
> following:
> When I write something like [[mypage]] and "mypage" doesn't exist yet, I
> would like registered users to get a link to the edit screen for mypage
> (standard behaviour), but unregistered readers should receive only an
> emphasized version of "mypage", e.g. <b>mypage</b>. That way, I could
> include lots of terminology in my site and gradually fill it up with
> contents without going public with dozens of broken links (I know this is
> not exactly the wiki way, but it is a business site, and I'd prefer not
> having everybody editing it).
>
> So basically: If a user is logged in, [[mypage]] would translate to <a
> href=" /wiki/index.php?title=mypage&action=edit">mypage</a>, otherwise it
> would translate to <b>mypage</b>. I am a programmer geek :-), so I guess I
> could eventually come up with a solution for this myself, but I was
> wondering if there is a "standardized hack" for such a behavior. Many thanks
> in advance,
>
> Sean Floyd
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

RE: Question about Links

seanizer-2
OK,

I looked into the parser, but fortunately there seems to be an easier way
through hooks. Correct me if I'm wrong, but one way to do it seems to be to
add a hook to the ParserAfterTidy event
(http://www.mediawiki.org/wiki/Help:MediaWiki_hooks/ParserAfterTidy), that
replaces
        <a href="[^>]+&action=edit">([^<]+)</a>
with
        <b>$1</b>
If the user is not logged in. But how do I find out whether he is logged in?
Do I have access to a user object for the current user?

Sean

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Rob Church
Sent: Donnerstag, 26. Januar 2006 11:12
To: MediaWiki announcements and site admin list
Subject: Re: [Mediawiki-l] Question about Links

I don't know of a standard hack. You'd want to look at changing the
parser's link section, and disabling the parser cache, which could
lead to a performance drain on a larger site.


Rob Church

On 26/01/06, [hidden email] <[hidden email]> wrote:
> Hello,
>
> I am a new User of mediawiki, and I am planning to put it up on my martial
> arts related site. Being a wiki newbie, I don't know if and how I can do
the

> following:
> When I write something like [[mypage]] and "mypage" doesn't exist yet, I
> would like registered users to get a link to the edit screen for mypage
> (standard behaviour), but unregistered readers should receive only an
> emphasized version of "mypage", e.g. <b>mypage</b>. That way, I could
> include lots of terminology in my site and gradually fill it up with
> contents without going public with dozens of broken links (I know this is
> not exactly the wiki way, but it is a business site, and I'd prefer not
> having everybody editing it).
>
> So basically: If a user is logged in, [[mypage]] would translate to <a
> href="/wiki/index.php?title=mypage&action=edit">mypage</a>, otherwise it
> would translate to <b>mypage</b>. I am a programmer geek :-), so I guess I
> could eventually come up with a solution for this myself, but I was
> wondering if there is a "standardized hack" for such a behavior. Many
thanks
> in advance,
>
> Sean Floyd
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l

_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Question about Links

Rob Church
Yes, that's simpler and cleaner. Should have thought of that. :-)

global $wgUser;
if( $wgUser->isAnon() ) {
  /* strip things */
}


Rob Church

On 26/01/06, [hidden email] <[hidden email]> wrote:

> OK,
>
> I looked into the parser, but fortunately there seems to be an easier way
> through hooks. Correct me if I'm wrong, but one way to do it seems to be to
> add a hook to the ParserAfterTidy event
> (http://www.mediawiki.org/wiki/Help:MediaWiki_hooks/ParserAfterTidy), that
> replaces
>         <a href="[^>]+&action=edit">([^<]+)</a>
> with
>         <b>$1</b>
> If the user is not logged in. But how do I find out whether he is logged in?
> Do I have access to a user object for the current user?
>
> Sean
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Rob Church
> Sent: Donnerstag, 26. Januar 2006 11:12
> To: MediaWiki announcements and site admin list
> Subject: Re: [Mediawiki-l] Question about Links
>
> I don't know of a standard hack. You'd want to look at changing the
> parser's link section, and disabling the parser cache, which could
> lead to a performance drain on a larger site.
>
>
> Rob Church
>
> On 26/01/06, [hidden email] <[hidden email]> wrote:
> > Hello,
> >
> > I am a new User of mediawiki, and I am planning to put it up on my martial
> > arts related site. Being a wiki newbie, I don't know if and how I can do
> the
> > following:
> > When I write something like [[mypage]] and "mypage" doesn't exist yet, I
> > would like registered users to get a link to the edit screen for mypage
> > (standard behaviour), but unregistered readers should receive only an
> > emphasized version of "mypage", e.g. <b>mypage</b>. That way, I could
> > include lots of terminology in my site and gradually fill it up with
> > contents without going public with dozens of broken links (I know this is
> > not exactly the wiki way, but it is a business site, and I'd prefer not
> > having everybody editing it).
> >
> > So basically: If a user is logged in, [[mypage]] would translate to <a
> > href="/wiki/index.php?title=mypage&action=edit">mypage</a>, otherwise it
> > would translate to <b>mypage</b>. I am a programmer geek :-), so I guess I
> > could eventually come up with a solution for this myself, but I was
> > wondering if there is a "standardized hack" for such a behavior. Many
> thanks
> > in advance,
> >
> > Sean Floyd
> > _______________________________________________
> > MediaWiki-l mailing list
> > [hidden email]
> > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> >
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

RE: Question about Links

seanizer-2
Yes, but so far it doesn't work. I don't know, maybe I'm doing something
wrong. Here is my exact code (from the end of LocalSettings.php):

global $wgHooks;
$wgHooks['ParserAfterTidy'][] = 'hideeditlinks';
function hideeditlinks(&$parser, &$text) {
        global $wgUser;
        if( $wgUser->isAnon() ) {
                $text = eregi_replace(
                        "<a href=[^>]+action=edit[^>]+>([^<]+)</a>",
                        "<b>\\1</b>",
                        $text);
        }
        return true;
}

It doesn't replace anything, in fact I have no idea if it is ever called.

Btw: I am running the most current version of mediawiki (downloaded last
week) and php 4.3.7 using apache for windows on my desktop machine for
testing.

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Rob Church
Sent: Donnerstag, 26. Januar 2006 14:23
To: MediaWiki announcements and site admin list
Subject: Re: [Mediawiki-l] Question about Links

Yes, that's simpler and cleaner. Should have thought of that. :-)

global $wgUser;
if( $wgUser->isAnon() ) {
  /* strip things */
}


Rob Church

On 26/01/06, [hidden email] <[hidden email]> wrote:
> OK,
>
> I looked into the parser, but fortunately there seems to be an easier way
> through hooks. Correct me if I'm wrong, but one way to do it seems to be
to
> add a hook to the ParserAfterTidy event
> (http://www.mediawiki.org/wiki/Help:MediaWiki_hooks/ParserAfterTidy), that
> replaces
>         <a href="[^>]+&action=edit">([^<]+)</a>
> with
>         <b>$1</b>
> If the user is not logged in. But how do I find out whether he is logged
in?

> Do I have access to a user object for the current user?
>
> Sean
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Rob Church
> Sent: Donnerstag, 26. Januar 2006 11:12
> To: MediaWiki announcements and site admin list
> Subject: Re: [Mediawiki-l] Question about Links
>
> I don't know of a standard hack. You'd want to look at changing the
> parser's link section, and disabling the parser cache, which could
> lead to a performance drain on a larger site.
>
>
> Rob Church
>
> On 26/01/06, [hidden email] <[hidden email]> wrote:
> > Hello,
> >
> > I am a new User of mediawiki, and I am planning to put it up on my
martial
> > arts related site. Being a wiki newbie, I don't know if and how I can do
> the
> > following:
> > When I write something like [[mypage]] and "mypage" doesn't exist yet, I
> > would like registered users to get a link to the edit screen for mypage
> > (standard behaviour), but unregistered readers should receive only an
> > emphasized version of "mypage", e.g. <b>mypage</b>. That way, I could
> > include lots of terminology in my site and gradually fill it up with
> > contents without going public with dozens of broken links (I know this
is
> > not exactly the wiki way, but it is a business site, and I'd prefer not
> > having everybody editing it).
> >
> > So basically: If a user is logged in, [[mypage]] would translate to <a
> > href="/wiki/index.php?title=mypage&action=edit">mypage</a>, otherwise it
> > would translate to <b>mypage</b>. I am a programmer geek :-), so I guess
I

> > could eventually come up with a solution for this myself, but I was
> > wondering if there is a "standardized hack" for such a behavior. Many
> thanks
> > in advance,
> >
> > Sean Floyd
> > _______________________________________________
> > MediaWiki-l mailing list
> > [hidden email]
> > http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
> >
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l

_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Question about Links

Bugzilla from rowan.collins@gmail.com
On 26/01/06, Sean Floyd <[hidden email]> wrote:
> Yes, but so far it doesn't work. I don't know, maybe I'm doing something
> wrong. Here is my exact code (from the end of LocalSettings.php):

Well, it looks sane enough - maybe you're just not seeing the result
because you're seeing a cached page (not just browser cache, but the
internal parser cache). Try testing it using an edit preview (which
will never be cached) rather than just viewing the page.

If this *is* the problem, you'll need to look into disabling or
working around the parser cache (I think there's a LocalSettings
variable to turn it right off, or if you want to be really clever you
could "teach it" to distinguish logged-in/logged-out views).

> It doesn't replace anything, in fact I have no idea if it is ever called.

Well, you can find out if it's being called by adding a line like
 wfDebug( "hideeditlinks called" );
and setting $wgDebugLogFile in LocalSettings.php to somewhere
writable. Obviously, you can output whatever debug info you like, e.g.
to see if the regex is correct.

Happy Hacking!
--
Rowan Collins BSc
[IMSoP]
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

RE: Question about Links

seanizer-2
Thanks for the info, being a total newbie there are so many things I don't
know yet.

Yes, it works when I switch off the cache using
$wgCacheEpoch="20091118200000";

The next thing I'd like to figure out will be a bit tougher though:
I'd like the replacement to be done before the file goes into the cache and
only logged in users should see "live" pages, all others see cached ones.
It'll probably require automatically updating all kinds of other pages when
a new page is created, but that's the kind of stuff I love to write. I just
miss a detailed API documentation, but I guess eventually I'll find out most
things I need through trial and error.

Thanks for your help,

Sean

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Rowan Collins
Sent: Donnerstag, 26. Januar 2006 16:04
To: MediaWiki announcements and site admin list
Subject: Re: [Mediawiki-l] Question about Links

On 26/01/06, Sean Floyd <[hidden email]> wrote:
> Yes, but so far it doesn't work. I don't know, maybe I'm doing something
> wrong. Here is my exact code (from the end of LocalSettings.php):

Well, it looks sane enough - maybe you're just not seeing the result
because you're seeing a cached page (not just browser cache, but the
internal parser cache). Try testing it using an edit preview (which
will never be cached) rather than just viewing the page.

If this *is* the problem, you'll need to look into disabling or
working around the parser cache (I think there's a LocalSettings
variable to turn it right off, or if you want to be really clever you
could "teach it" to distinguish logged-in/logged-out views).

> It doesn't replace anything, in fact I have no idea if it is ever called.

Well, you can find out if it's being called by adding a line like
 wfDebug( "hideeditlinks called" );
and setting $wgDebugLogFile in LocalSettings.php to somewhere
writable. Obviously, you can output whatever debug info you like, e.g.
to see if the regex is correct.

Happy Hacking!
--
Rowan Collins BSc
[IMSoP]
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l

_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Question about Links

Rob Church
That doesn't switch off the cache, however. It sets a time which
invalidates all earlier cache entries regardless of individual
expiries. $wgUseParserCache is the setting required.


Rob Church

On 26/01/06, Sean Floyd <[hidden email]> wrote:

> Thanks for the info, being a total newbie there are so many things I don't
> know yet.
>
> Yes, it works when I switch off the cache using
> $wgCacheEpoch="20091118200000";
>
> The next thing I'd like to figure out will be a bit tougher though:
> I'd like the replacement to be done before the file goes into the cache and
> only logged in users should see "live" pages, all others see cached ones.
> It'll probably require automatically updating all kinds of other pages when
> a new page is created, but that's the kind of stuff I love to write. I just
> miss a detailed API documentation, but I guess eventually I'll find out most
> things I need through trial and error.
>
> Thanks for your help,
>
> Sean
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Rowan Collins
> Sent: Donnerstag, 26. Januar 2006 16:04
> To: MediaWiki announcements and site admin list
> Subject: Re: [Mediawiki-l] Question about Links
>
> On 26/01/06, Sean Floyd <[hidden email]> wrote:
> > Yes, but so far it doesn't work. I don't know, maybe I'm doing something
> > wrong. Here is my exact code (from the end of LocalSettings.php):
>
> Well, it looks sane enough - maybe you're just not seeing the result
> because you're seeing a cached page (not just browser cache, but the
> internal parser cache). Try testing it using an edit preview (which
> will never be cached) rather than just viewing the page.
>
> If this *is* the problem, you'll need to look into disabling or
> working around the parser cache (I think there's a LocalSettings
> variable to turn it right off, or if you want to be really clever you
> could "teach it" to distinguish logged-in/logged-out views).
>
> > It doesn't replace anything, in fact I have no idea if it is ever called.
>
> Well, you can find out if it's being called by adding a line like
>  wfDebug( "hideeditlinks called" );
> and setting $wgDebugLogFile in LocalSettings.php to somewhere
> writable. Obviously, you can output whatever debug info you like, e.g.
> to see if the regex is correct.
>
> Happy Hacking!
> --
> Rowan Collins BSc
> [IMSoP]
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l