Mailing List Archive

Dynamically declaring parser functions?
My use case is this:

I have three alternative access points to the wiki, where some things
are not allowed - e.g. videos. Each access point has different
extensions disabled, and then tags and parser functions show "as is" on
screen, which looks bad.

My goal is to hide those, obviously.

I'm upgrading MW from 1.29 to 1.35; My previous solution is here:
https://github.com/kolzchut/mediawiki-extensions-NoopTags

Basically I hooked ParserFirstCallInitHook and LanguageGetMagic to
dynamically declare empty stubs for those missing function parsers and
tags, using global variables $wgNoopTagsFunctionBlacklist and
$wgNoopTagsBlacklist.


This doesn't work in MW 1.35, because LanguageGetMagic was removed. I
tried bypassing the issue by hooking GetMagicVariableIDsHook, but
apparently that's only for "variables" ({{variable}}), and not parser
functions.

Is there a way to achieve my goal? Either by fixing my extension or
doing something completely different which I haven't thought about?

Thanks in advance
Dror


_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Dynamically declaring parser functions? [ In reply to ]
Why not just use the normal magic i18n file? You could just not load it
when you don't want it.

--
Brian

On Sunday, April 18, 2021, FreedomFighterSparrow <
FreedomFighterSparrow@gmail.com> wrote:

> My use case is this:
>
> I have three alternative access points to the wiki, where some things are
> not allowed - e.g. videos. Each access point has different extensions
> disabled, and then tags and parser functions show "as is" on screen, which
> looks bad.
>
> My goal is to hide those, obviously.
>
> I'm upgrading MW from 1.29 to 1.35; My previous solution is here:
> https://github.com/kolzchut/mediawiki-extensions-NoopTags
>
> Basically I hooked ParserFirstCallInitHook and LanguageGetMagic to
> dynamically declare empty stubs for those missing function parsers and
> tags, using global variables $wgNoopTagsFunctionBlacklist and
> $wgNoopTagsBlacklist.
>
>
> This doesn't work in MW 1.35, because LanguageGetMagic was removed. I
> tried bypassing the issue by hooking GetMagicVariableIDsHook, but
> apparently that's only for "variables" ({{variable}}), and not parser
> functions.
>
> Is there a way to achieve my goal? Either by fixing my extension or doing
> something completely different which I haven't thought about?
>
> Thanks in advance
> Dror
>
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
Re: Dynamically declaring parser functions? [ In reply to ]
Thanks for replying!

The original idea was to make it very easy to change things up in
LocalSettings.php, without ever touching code (which must be committed,
pulled, etc).
For example, if I disable extension:EmbedVideo in my "kiosk" mode, I
just add the relevant parser functions to $wgNoopTagsFunctionBlacklist
in LocalSettings.php.

However, I don't make enough changes to which extensions are loaded for
this to be too onerous.

How do I go about actually implementing this? I would have to create a
different magic i18n file for every facet of the site (determined by
subdomain), as each has a different set of parser functions to override,
wouldn't I? How do I conditionally load those?

Dror

On 19.4.2021 9:04, Brian Wolff wrote:
> Why not just use the normal magic i18n file? You could just not load it
> when you don't want it.
>
> --
> Brian
>
> On Sunday, April 18, 2021, FreedomFighterSparrow
> <FreedomFighterSparrow@gmail.com
> <mailto:FreedomFighterSparrow@gmail.com>> wrote:
>
> My use case is this:
>
> I have three alternative access points to the wiki, where some
> things are not allowed - e.g. videos. Each access point has
> different extensions disabled, and then tags and parser functions
> show "as is" on screen, which looks bad.
>
> My goal is to hide those, obviously.
>
> I'm upgrading MW from 1.29 to 1.35; My previous solution is here:
> https://github.com/kolzchut/mediawiki-extensions-NoopTags
> <https://github.com/kolzchut/mediawiki-extensions-NoopTags>
>
> Basically I hooked ParserFirstCallInitHook and LanguageGetMagic to
> dynamically declare empty stubs for those missing function parsers
> and tags, using global variables $wgNoopTagsFunctionBlacklist and
> $wgNoopTagsBlacklist.
>
>
> This doesn't work in MW 1.35, because LanguageGetMagic was removed.
> I tried bypassing the issue by hooking GetMagicVariableIDsHook, but
> apparently that's only for "variables" ({{variable}}), and not
> parser functions.
>
> Is there a way to achieve my goal? Either by fixing my extension or
> doing something completely different which I haven't thought about?
>
> Thanks in advance
> Dror
>
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org <mailto:Wikitech-l@lists.wikimedia.org>
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> <https://lists.wikimedia.org/mailman/listinfo/wikitech-l>
>
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>



_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Dynamically declaring parser functions? [ In reply to ]
Thanks for replying!

The original idea was to make it very easy to change things up in
LocalSettings.php, without ever touching code (which must be committed,
pulled, etc).
For example, if I disable extension:EmbedVideo in my "kiosk" mode, I
just add the relevant parser functions to $wgNoopTagsFunctionBlacklist
in LocalSettings.php.

However, I don't make enough changes to which extensions are loaded for
this to be too onerous.

How do I go about actually implementing this? I would have to create a
different magic i18n file for every facet of the site (determined by
subdomain), as each has a different set of parser functions to override,
wouldn't I? How do I conditionally load those?

Dror

On 19.4.2021 9:04, Brian Wolff wrote:
> Why not just use the normal magic i18n file? You could just not load it
> when you don't want it.
>
> --
> Brian
>
> On Sunday, April 18, 2021, FreedomFighterSparrow
> <FreedomFighterSparrow@gmail.com
> <mailto:FreedomFighterSparrow@gmail.com>> wrote:
>
> My use case is this:
>
> I have three alternative access points to the wiki, where some
> things are not allowed - e.g. videos. Each access point has
> different extensions disabled, and then tags and parser functions
> show "as is" on screen, which looks bad.
>
> My goal is to hide those, obviously.
>
> I'm upgrading MW from 1.29 to 1.35; My previous solution is here:
> https://github.com/kolzchut/mediawiki-extensions-NoopTags
> <https://github.com/kolzchut/mediawiki-extensions-NoopTags>
>
> Basically I hooked ParserFirstCallInitHook and LanguageGetMagic to
> dynamically declare empty stubs for those missing function parsers
> and tags, using global variables $wgNoopTagsFunctionBlacklist and
> $wgNoopTagsBlacklist.
>
>
> This doesn't work in MW 1.35, because LanguageGetMagic was removed.
> I tried bypassing the issue by hooking GetMagicVariableIDsHook, but
> apparently that's only for "variables" ({{variable}}), and not
> parser functions.
>
> Is there a way to achieve my goal? Either by fixing my extension or
> doing something completely different which I haven't thought about?
>
> Thanks in advance
> Dror
>
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org <mailto:Wikitech-l@lists.wikimedia.org>
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> <https://lists.wikimedia.org/mailman/listinfo/wikitech-l>
>
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>


_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: Dynamically declaring parser functions? [ In reply to ]
It might be (more) feasible to use Lua (and Extension:Scribunto) for this,
or even just templates more generally, as this allows one to define on-wiki
mechanisms dynamically in a more flexible way.

(I've not fully read the thread, apologies if this is incompatible with a
requirement, I thought I'd mention it as it seemed likely to be of use.)

On Sun, Apr 18, 2021 at 2:40 PM FreedomFighterSparrow <
FreedomFighterSparrow@gmail.com> wrote:

> My use case is this:
>
> I have three alternative access points to the wiki, where some things
> are not allowed - e.g. videos. Each access point has different
> extensions disabled, and then tags and parser functions show "as is" on
> screen, which looks bad.
>
> My goal is to hide those, obviously.
>
> I'm upgrading MW from 1.29 to 1.35; My previous solution is here:
> https://github.com/kolzchut/mediawiki-extensions-NoopTags
>
> Basically I hooked ParserFirstCallInitHook and LanguageGetMagic to
> dynamically declare empty stubs for those missing function parsers and
> tags, using global variables $wgNoopTagsFunctionBlacklist and
> $wgNoopTagsBlacklist.
>
>
> This doesn't work in MW 1.35, because LanguageGetMagic was removed. I
> tried bypassing the issue by hooking GetMagicVariableIDsHook, but
> apparently that's only for "variables" ({{variable}}), and not parser
> functions.
>
> Is there a way to achieve my goal? Either by fixing my extension or
> doing something completely different which I haven't thought about?
>
> Thanks in advance
> Dror
>
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>