Module talk:SDcat: Difference between revisions

Content deleted Content added
comment
 
(14 intermediate revisions by 6 users not shown)
Line 1:
{{WikiProject banner shell|
{{WikiProject Short descriptions}}
}}
== Testing ==
{| class="wikitable"
Line 39 ⟶ 42:
 
==The following seemed too off-topic for the CFD discussion==
So I found my way here from [[Wikipedia:Categories for discussion/Log/2020 August 7#Category:Short description with empty Wikidata description|there]]. Forgetting about wikidata for a second, would it somehow be possible to detect pages with <em>multiple '''multiple local'''</em> short descriptions? That would be an issue infinitely more worthy of maintenance categorization, especially when the these do not match. I believe the most common scenario will be one description manually entered in the article's wikitext, and the other automatically generated from infobox parameters (which may or may not be positioned in that order, which may or may not matter—please advise). ―[[special:contributions/cobaltcigs|cobaltcigs]] 14:36, 28 September 2020 (UTC)
:
: {{re|cobaltcigs}} Infobox templates that generate short descriptions should be in the [[:Category:Templates that generate short descriptions]] and they should all add the <code>noreplace</code> parameter. Having the noreplace parameter prevents the short description from replacing any earlier defined short description, so the order won't matter: any explicit use of {{tl|short description}} will override a generated one.
: If you think there's a maintenance value in looking at articles that have a generated and an explicit short description, then you can search for <code><nowiki>hastemplate:"Infobox settlement" hastemplate:"short description"</nowiki></code>, for example (and repeat for each of the other 36 templates in [[:Category:Templates that generate short descriptions]]). There are currently 527,822 articles with both {{tl|Infobox settlement}} and {{tl|short description}}. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 17:18, 28 September 2020 (UTC)
:: Negatory on the category, then? ―[[special:contributions/cobaltcigs|cobaltcigs]] 16:01, 30 September 2020 (UTC)
::: Nah, go ahead. Don't let my minor misgivings stop you. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 20:59, 30 September 2020 (UTC)
:::: I was only asking about technical feasibility. I think it would probably require the same technique [[Module:Citation/CS1/Configuration|used by Module:Citation]], which makes date-formating decisions by looking for "use mdy/dmy dates" templates in the surrounding wikitext of articles where it is used. So we would instead have to look for a direct use of {{tl|short description}} plus one of the 36 templates which also use it, minus those using a parameter to suppress the extra description? That might be straightforward enough, but how would the module determine that these have the same or different content? It seems that would require viewing the rendered page html.
:::: Speaking of rendered page html, it appears that (by default at least) a manually entered {{tl|short description}} and one generated from {{tl|infobox settlement}} are styled with identical html <code><nowiki><div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none"></nowiki></code>. This makes it difficult to confirm which description (if any) has taken precedence. ―[[special:contributions/cobaltcigs|cobaltcigs]] 03:33, 4 October 2020 (UTC)
::::: Modules indeed can't read the rendered html as they run on the server before the displayed text is generated. Modules can use the <code><nowiki>mw.title.getCurrentTitle():getContent()</nowiki></code> method to read the current page's unparsed content, and finding the templates is trivial, but you won't be able to compare the contents unless you use <code><nowiki>mw.getCurrentFrame():expandTemplate{}</nowiki></code> to explicitly expand the generated template or require [[Module:Settlement short description]] and call it. Frankly, I wouldn't bother.
::::: The manually entered {{tl|short description}} and the one generated from {{tl|infobox settlement}} are styled in identical spans because they are functionally identical (and because the generated one actually calls [[Template:short description]]). You don't need to confirm which one takes precedence because you already know that the one which is manually entered has precedence because of <code>noreplace</code> being added in the generator{{snd}} see [[Module:Settlement short description]] line 30. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 18:06, 4 October 2020 (UTC)
 
{{unindent}} Okay so some amount of research later, I've come to realize this "noreplace" parameter is actually passed along as the second parameter to a certain <code><nowiki>{{SHORTDESC:...|...}}</nowiki></code> "magic word"—and that this mechanism is totally separate from the hidden(-by-default) span tag, which only uses the first parameter. Fair enough. I suppose I was preoccupied with the span tag because I use client-side css like this to make the description (or potentially multiple descriptions) clearly visible:
<syntaxhighlight lang="css">
.shortdescription { display: block !important; color: red; white-space: pre-wrap; font-family: monospace; font-size: larger; width: auto; border-bottom: 1px dashed black; }
.shortdescription::before { content: "{{short description|"; color: black; }
.shortdescription::after { content: "}}"; color: black; }
</syntaxhighlight>
As designed I don't see any robust way to identify and unhide only the description that, based on whatever internal noreplace-logic, is ultimately used. Perhaps the name <code>noreplace</code> could be appended to the span's list of classes, when applicable. Then one could at least use javascript to examine the spans' classes and decide by elimination which one to unhide. ―[[special:contributions/cobaltcigs|cobaltcigs]] 19:50, 4 October 2020 (UTC)
:
: If you're going to use JavaScript then you can access the API and read the value of "Local description" from the "Page information" for each article (there's a link to it in the left margin box called 'tools'). That's where the backend database stores the overriding value supplied by the {{tl|short description}} via the <nowiki>{{SHORTDESC:}}</nowiki> magic word. If you want to understand better about how the 'noreplace' parameter works, you should check out [[phab:T193857]] where we thrashed out the logic of it. --[[User:RexxS|RexxS]] ([[User talk:RexxS|talk]]) 02:02, 5 October 2020 (UTC)