Page MenuHomePhabricator

Parser functions to obtain talk page, namespace, talk namespace, basename, etc. for named targets
Closed, ResolvedPublic

Description

Author: darklama

Description:
Now that there is a method of conveting relative paths to absolute paths, it
would be nice if as an enhancements to this function could be made to allow
named paths in addition to using a relative path name in order to get a absolute
path name.

Some examples:

{{#rel2abs:Talk|Help:ParserFunction}}, will result in Help_talk:ParserFunction
{{#rel2abs:Namespace|Help:ParserFunction}}, will result in Help
{{#rel2abs:Talkspace|Help:ParserFunction}}, will result in Help_talk
{{#rel2abs:Basename|Help:Very/Deep/Path/What/Can/We/Do}}, will result in Help:Very


Version: unspecified
Severity: enhancement

Details

Reference
bz8249

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:30 PM
bzimport added a project: ParserFunctions.
bzimport set Reference to bz8249.
bzimport added a subscriber: Unknown Object (MLST).

robchur wrote:

If implemented, these should either be separate parser functions, or else a new
base function; it isn't appropriate to extend rel2abs to perform these tasks.

darklama wrote:

I figure this is fits in with what rel2abs does. Talk pages and Namespaces are
relative to the base path given, resulting in an absolute path. Basename fits in
as shorthand for how ever many ../ are needed to get to the top level of the
tree. None of the pages would need to exist nor any check to make sure its a
valid talk page or namespace prefix.

Reimplementation of the builtin variables as a parserfunction library

as rel2abs already have two parameters, it would be difficult to change it's
behavior, so I though the best way was to re-implement the built in variables
to be able to check on a given path instead of current title.

attachment PathFunctions.patch ignored as obsolete

darklama wrote:

Looks good Carl, from looking at the attachment it seems to do what I was
talking about. I just noticed possibly one subtile bug, in which basepagenamee
seems to be returning the same value as basepagename.

darklama wrote:

The introduction of the {{#titleparts}} ParserFunction provides a solution for obtaining only part of the title, which was partially what I was hoping to have addressed by this proposal. If someone could add a complementary parser function to the ParserFunction extension, to obtain the namespace part, something like:

then I believe this bug could be closed as fixed.

Adaptation if namespace functions in ParserFunctions

Similar to the previous patch, but only things made for the namespace part of the title

attachment ParserFunctions_Namespace.patch ignored as obsolete

happy_melon wrote:

This should be implemented by allowing these variables to take one parameter, the full title to evaluate on. The current implementation then becomes the 'fallback' case where there is no such value, a natural default. So {{FULLPAGENAME:Foo}} would be transparent, and {{NAMESPACE:Help:Foo}} == Help.

Created attachment 5606
Patch adding core parser function versions of the various variables

I couldn't get attachment 2860 to work because I was forgetting to set $wgPathFunctionsUseNoPrefixHash=true, so I made this patch. It adds the functions to CoreParserFunctions.php (alongside {{ns:}}), instead of adding them as a separate extension. Other differences include:

  • Some calls to wfEscapeWikiText()
  • Correct behavior when targeting [[0]]
  • Correct escaping on BASEPAGENAMEE
  • No debugging code in NAMESPACE
  • Behavior when getting the talk page for a namespace where $title->canTalk() returns false.

I've long wished for something like what either of these patches provides.

attachment xx.diff ignored as obsolete

Functions for namespaces added in r46630.

  • Bug 17287 has been marked as a duplicate of this bug. ***

rememberthedot wrote:

Proposed patch v1

New patch against current tree that adds FULLPAGENAME, PAGENAME, BASEPAGENAME, SUBPAGENAME, SUBJECTPAGENAME, and TALKPAGENAME.

Attached:

*PAGENAME functions added in r46662