Page MenuHomePhabricator

Lua DISPLAYTITLE precondition predicate
Closed, DeclinedPublic

Description

Hello. There are a lot of pages that use DISPLAYTITLE inproperly and it's just ignored. Could you, please, provide a simple Lua boolean function that checks whether two its parameters are equivalent for this magic word, using current values of both configuration variables? Because you are using something like this to check if a new title will be displayed at all, I thing it is matter of minutes to create an initerface. Thank you.

Event Timeline

IKhitron created this task.May 7 2016, 5:17 PM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptMay 7 2016, 5:17 PM
Danny_B added a subscriber: Danny_B.

Rather than such function, having reusable functions and/or variables.

  • mw.title could distinguish mw.title.text and i.e. mw.title.canonicalText
  • mw.ustring or mw.text could have mw.ustring.canonicalize() / mw.text.canonicalize()

etc...

Then you could simply do comparison yourself and such data would be reusable for other purposes...

@IKhitron Usecase would be handy too... Thx...

Hi, @Danny_B. I don't know what exactly happens in there, so I can't understand the most of your first post. I read media wiki description of DISPLAYTITLE, but it does not help to me. And about usecase - what do you mean in this case? Examples of true and false results? Something else? Thanks.

Use case = A description of what you would like to achieve, and why.
Reading the current task summary, I cannot easily gather what this request is about - could you rephrase please?

Very well, @Alkapper. here you are. All the story.
There are two articles in some wikipedia, "IPod" and "C sharp". They have the code: {{DISPLAYTITLE:<i>iPod</i>}} and {{DISPLAYTITLE:C#}]. The first article name will be changed. The second request will be ignored, because it does not "look" as the article name. We do not use this magic word in our wiki. Instead, we use a template that calls this magic word. I'd like to add to this template a simple check: If the parameter will cause to ignoring the magic word, add this article to tracking category. So, I asked for a boolean function that can be used as conditional in #if statement. Thank you.

That actually sounds more like a work for T35033: Tracking categories (tracking) in handling of {{DISPLAYTITLE:}}...

It sounds like this, @Danny_B, but I had a very good reason to ask Lua function and not tracking category. It takes years to get a category, I'm still waiting in tasks for Imagemap and Math.
But it should take minutes to export existing functions.

Nothing will actually guarantee you, that whoever is able to implement the tracking category won't be faster than whoever could implement the request for Scribunto. Not even speaking about code review and deployment process.

Anyway, I'll split the tracking category request to separate task, so you can follow both and whatever is done earlier, you'll be able to use...

I see no reason that this has anything to do with Lua. I think my patch at https://gerrit.wikimedia.org/r/#/c/158098/ is a much better solution.

It is very nice for me, indeed, @Jackmcbarn, but:

  1. It looks like you force wikis to see the message, even if they did not ask for this.
  2. It was not approved for two years, so I can't imagine how decades it needs.

Thank you,
Igal

Aklapper triaged this task as Lowest priority.May 8 2016, 2:58 PM
Anomie added a subscriber: Anomie.May 9 2016, 3:40 PM
  • mw.title could distinguish mw.title.text and i.e. mw.title.canonicalText

That wouldn't really help you here. You'd have to strip some HTML first.

  • mw.ustring or mw.text could have mw.ustring.canonicalize() / mw.text.canonicalize()

Neither of those are at all appropriate. I'd expect mw.ustring.canonicalize() to be more or less mw.ustring.toNFC(), and I have no idea what mw.text.canonicalize() should do.

Even mw.title.canonicalize() wouldn't really make sense as the solution here, since the transformation for displaytitle is more complicated than just "canonicalization": it parses '' and ''', removes strip markers, sanitizes some inline CSS, removes many HTML tags and escapes others, "normalizes" character references (&#1234; and &amp; sort of stuff), removes HTML tags again, decodes the character references, and then basically sees if newTitle = mw.title.new( mangled ) is non-nil, has no fragment, and newTitle.equals( currentTitle ). "Canonicalization" would just pass it through mw.title.new( input ).fullText and be done with it.

  • mw.title could distinguish mw.title.text and i.e. mw.title.canonicalText

That wouldn't really help you here. You'd have to strip some HTML first.

  • mw.ustring or mw.text could have mw.ustring.canonicalize() / mw.text.canonicalize()

Neither of those are at all appropriate. I'd expect mw.ustring.canonicalize() to be more or less mw.ustring.toNFC(), and I have no idea what mw.text.canonicalize() should do.
Even mw.title.canonicalize() wouldn't really make sense as the solution here, since the transformation for displaytitle is more complicated than just "canonicalization": it parses '' and ''', removes strip markers, sanitizes some inline CSS, removes many HTML tags and escapes others, "normalizes" character references (&#1234; and &amp; sort of stuff), removes HTML tags again, decodes the character references, and then basically sees if newTitle = mw.title.new( mangled ) is non-nil, has no fragment, and newTitle.equals( currentTitle ). "Canonicalization" would just pass it through mw.title.new( input ).fullText and be done with it.

That was just a quick shot to illustrate the idea... Trying to explain that having a single purpose boolean return function is not as flexible as separate reusable function(s)/variable(s)...

@Jackmcbarn, I saw the message in tech news 21. Does this mean that your patch is merged? If so: 1. Wow. 2. Thank you. 3. This ticket should be closed as irrelevant.

Jackmcbarn closed this task as Declined.May 14 2016, 4:07 PM

Closing since T28546, now fixed, was a better solution.