Module talk:JCW
![]() | Academic Journals Template‑class | ||||||
|
p.selected
I'm looking at the request at WP:VPT. However I can't help but fiddle with code and I'm afraid I would also adjust several mostly style issues. First I need to understand what p.selected and the following are supposed to do.
if doi then
text = text..string.format("\n** <code>\{\{doi\|[https://en.wikipedia.org/w/index.php?sort=relevance&title=Special%%3ASearch&profile=advanced&fulltext=1&advancedSearch-current={}&ns0=1&ns118=1&search=insource%%3A%%2F%s%%5C%%2F%%20*%%2F %s]\}\}<\/code>", doi, doi)
text = mw.ustring.gsub(text, "%%2F10%.(%d)", "\/10\\.%1")
end
Is there an example of p.selected being used and its output (possibly from Special:ExpandTemplates)?
The above code puts a URL into text with the doi value inserted in two places. It then does the gsub to possibly insert /10\
in the URL (I think I decoded that correctly, perhaps not). What is a typical doi value? Surely it never includes %2F
? I'm thinking that the doi value, if necessary, should be changed with a gsub, and the result inserted into the URL in two locations. There is no need to put the URL through the gsub? Would that work? Johnuniq (talk) 02:59, 5 January 2020 (UTC)
@Johnuniq: Basically, {{JCW-selected|Foobar|Rawr|doi1=10.4321|doi2=10.3216|doi3=10.5446}}
gives
This could be equivalently be rendered with {{doi prefix}} like so
But the module choked on putting stuff templates last time around, so I had to URL encode a bunch of stuff so insource:/10\.1234/\ *
search links work. Headbomb {t · c · p · b} 03:06, 5 January 2020 (UTC)
Imprint/Parents
@Johnuniq and Galobtter:, I'm trying to introduce two new iterative parameters |imprint#=
and |parent#=
in {{JCW-selected}}
The idea being that
{{JCW-selected|Foobar|YoYeah|imprint1=Imprint1|imprint2=Imprint2|imprint3=...|doi1=10.4321}} {{JCW-selected|Foobar|parent1=Barfoo1|parent2=Barfoo2|parent3=...|doi1=10.4321}}
would give
and
I tried [1], but it made things explode and time out. A bit of help would be nice here. Headbomb {t · c · p · b} 09:06, 16 February 2020 (UTC)
- @Johnuniq and Galobtter: anything you can do to help here? Headbomb {t · c · p · b} 19:03, 6 March 2020 (UTC)
if mw.title.getCurrentTitle().fullText == 'User:JL-Bot/Publishers.cfg' or 'User:JL-Bot/Maintenance.cfg' then source = nil end
- Is it trying to see if the current page is one of the two user cfg pages? The
if
condition evaluates toUser:JL-Bot/Maintenance.cfg
if the==
is true, or tofalse
otherwise. I need to understand stuff before diving in. Johnuniq (talk) 00:44, 7 March 2020 (UTC)- Johnuniq, feel free to (and thanks for) work on this - I really don't have much time for wikistuff atm so won't really be able to help with this. Galobtter (pingó mió) 04:10, 7 March 2020 (UTC)
- Where can I play? What-links-here suggests Module:JCW is not used much. What is its status? Can I just edit it without worrying if something will break? Are there any testcases? There should be at least one test in a sandbox with the wikitext of a full example call to {{JCW-selected}} using all wanted bells and whistles, and the wikitext of what the output should be. That would help me understand what it's trying to do, and would be needed for testing. Preferably without red links. Johnuniq (talk) 00:58, 7 March 2020 (UTC)
- Is it trying to see if the current page is one of the two user cfg pages? The
@Johnuniq: the general idea is that there are four pages where this is called
- User:JL-Bot/Citations.cfg via {{JCW-exclude}}
- User:JL-Bot/Questionable.cfg via {{JCW-selected}} and {{JCW-pattern}}
- User:JL-Bot/Publishers.cfg via {{JCW-selected}} and {{JCW-pattern}}
- User:JL-Bot/Maintenance.cfg via {{JCW-pattern}}
I believe that piece of code is simply telling that |source=
of {{JCW-selected}} is simply irrelevant on User:JL-Bot/Publishers.cfg and User:JL-Bot/Maintenance.cfg. I think this is mostly because {{JCW-selected}} could be used on that page, but currently isn't.
As far as playing is concern, you can play pretty much on the live versions of the templates and modules and the below examples generated from the above code.
JL-Bot only cares about the plain text of the .cfg pages. Only the people maintaining the pages (i.e. me) might care about how they render, and it's really not a big deal if they're temporarily borked. Headbomb {t · c · p · b} 01:39, 7 March 2020 (UTC)
Or if you want a more concrete example
Code | Live | Goal |
{{JCW-selected |Hindawi Publishing Corporation |imprint1=International Scholarly Research Notices |doi1=10.1155 |doi2=10.3814 |doi3=10.4061 |doi4=10.5402 |doi5=10.6064 |doi6=10.7167 |doi7=10.7217 }} {{JCW-selected |International Scholarly Research Notices |parent1=Hindawi Publishing Corporation |doi1=10.5402 }} |
Headbomb {t · c · p · b} 01:48, 7 March 2020 (UTC)
- @Headbomb: I'll have a look at it but I will also refactor the code. Details matter to me and I want to know if you really want the first of the following for one of the results, or should it be the second? The first has the <code> font for the 10.1155 search link, while the second uses the normal font.
- I will have some other questions, and will put a version of what you posted above at User:Johnuniq/sandbox2 adjusted to suit the tests I will use. Johnuniq (talk) 02:55, 7 March 2020 (UTC)
- @Johnuniq: Fixed the fonts. I think? There was an inconsistency, but it didn't look like your example. Headbomb {t · c · p · b} 02:59, 7 March 2020 (UTC)
- I think you're saying you want the first. Johnuniq (talk) 03:36, 7 March 2020 (UTC)
- @Johnuniq: Fixed the fonts. I think? There was an inconsistency, but it didn't look like your example. Headbomb {t · c · p · b} 02:59, 7 March 2020 (UTC)
Questions
@Headbomb: The search URL from the module is slightly different from {{doi-prefix}}'s output. To see this, copy the URL shown in the above examples and paste it into an editor. The first of the following lines is the URL parameter from the module, and the second is from the template. I've tried to highlight the two differences.
- ?sort=relevance&title=Special%3ASearch&profile=advanced&fulltext=1&advancedSearch-current={}&ns0=1&ns118=1&search=insource%3A/10\.1155%5C%2F%20*%2F
- ?sort=relevance&title=Special%%3ASearch&profile=advanced&fulltext=1&advancedSearch-current={}&ns0=1&ns118=1&search=insource%3A%2F10%5C.1155%5C%2F%20*%2F
Which is wanted? Perhaps there is a good reason for what the template outputs and the second should be used (although they seem to do the same thing)? Johnuniq (talk) 07:14, 7 March 2020 (UTC)
- I believe the difference is mostly in how urls are handled by modules and templates, but that they both produce the same thing in the end? It's also possible that there's a mistake somewhere. Headbomb {t · c · p · b} 07:17, 7 March 2020 (UTC)
- The goal is a
insource:/10\.1155\/ */
search in the main and draft spaces, so whatever achieves that. Headbomb {t · c · p · b} 07:22, 7 March 2020 (UTC) - There was an error in the doi-prefix template (%%3A→%3A), although it didn't affect anything. The second part is a module vs template difference, I think. %2F10%5C is simply the html encoded version of /10\. Headbomb {t · c · p · b} 07:27, 7 March 2020 (UTC)
- Also I notice that your recent changes to the module have made (Unknown) appear when it wasn't there before. Might not be important, since this is just the talk page of the module and is still suppressed on the relevant user pages. Might be worth switching to a whitelist to allow, instead of a blacklist to disallowed. Headbomb {t · c · p · b} 07:33, 7 March 2020 (UTC)
- After my edit, the source is nil (not displayed) at User:JL-Bot/Publishers.cfg and User:JL-Bot/Maintenance.cfg and is either the given source or "Unknown" at other pages. I can easily do a whitelist instead. On what pages should the given source or "Unknown" be displayed? Johnuniq (talk) 08:16, 7 March 2020 (UTC)
- On User:JL-Bot/Questionable.cfg is the only place it's relevant. Headbomb {t · c · p · b} 17:58, 7 March 2020 (UTC)
- I have done a first pass at implementing the requested changes. I will do a more thorough check in a day or two. Some behavior is different, for example the module will now show an error if there is no target or if both doi and doi1 parameters are used. Testing needed! Johnuniq (talk) 08:38, 7 March 2020 (UTC)
- From a brief look, everything seems to work just fine. I haven't tried intentionally breaking things though. Headbomb {t · c · p · b} 18:04, 7 March 2020 (UTC)
- I have finished tweaking the code. More testing soon would be good because if more than a few days elapse before another request I will have forgotten what it's all about and will be harder to move. Johnuniq (talk) 00:00, 8 March 2020 (UTC)
- From a brief look, everything seems to work just fine. I haven't tried intentionally breaking things though. Headbomb {t · c · p · b} 18:04, 7 March 2020 (UTC)
- After my edit, the source is nil (not displayed) at User:JL-Bot/Publishers.cfg and User:JL-Bot/Maintenance.cfg and is either the given source or "Unknown" at other pages. I can easily do a whitelist instead. On what pages should the given source or "Unknown" be displayed? Johnuniq (talk) 08:16, 7 March 2020 (UTC)
- Also I notice that your recent changes to the module have made (Unknown) appear when it wasn't there before. Might not be important, since this is just the talk page of the module and is still suppressed on the relevant user pages. Might be worth switching to a whitelist to allow, instead of a blacklist to disallowed. Headbomb {t · c · p · b} 07:33, 7 March 2020 (UTC)
- The goal is a
- I believe the difference is mostly in how urls are handled by modules and templates, but that they both produce the same thing in the end? It's also possible that there's a mistake somewhere. Headbomb {t · c · p · b} 07:17, 7 March 2020 (UTC)