Jump to content

Module talk:JCW

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Headbomb (talk | contribs) at 06:55, 29 October 2020 (Update for JCW-doi-redirects: other another example). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconAcademic Journals Template‑class
WikiProject iconThis module is within the scope of WikiProject Academic Journals, a collaborative effort to improve the coverage of Academic Journals on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
TemplateThis module does not require a rating on Wikipedia's content assessment scale.

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)[reply]

@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)[reply]

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)[reply]

@Johnuniq and Galobtter: anything you can do to help here? Headbomb {t · c · p · b} 19:03, 6 March 2020 (UTC)[reply]
@Headbomb: I'll have a look while hoping that Galobtter either says they will do it, or gives me a couple of days to play around (I imagine neither of us wants to do some work and then find the other finishes first). What is the following trying to do?
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 to User:JL-Bot/Maintenance.cfg if the == is true, or to false otherwise. I need to understand stuff before diving in. Johnuniq (talk) 00:44, 7 March 2020 (UTC)[reply]
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)[reply]
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)[reply]

@Johnuniq: the general idea is that there are four pages where this is called

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)[reply]

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)[reply]

@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)[reply]
@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)[reply]
I think you're saying you want the first. Johnuniq (talk) 03:36, 7 March 2020 (UTC)[reply]

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)[reply]

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)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]
On User:JL-Bot/Questionable.cfg is the only place it's relevant. Headbomb {t · c · p · b} 17:58, 7 March 2020 (UTC)[reply]
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)[reply]
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)[reply]
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)[reply]
Looks good, thanks. Headbomb {t · c · p · b} 00:19, 8 March 2020 (UTC)[reply]

Update for JCW-doi-redirects

@Johnuniq:, could you do a tweak where the DOI prefix links generated by {{JCW-doi-redirects|Foobar|10.1001|10.1002}}

and those generated by {{JCW-selected|Foobar|10.1001|10.1002}}

are the same (i.e. in the style of JCW-selected style), this way it's easy to search for which articles are using those DOIs prefixes? In {{JCW-doi-redirects}}, |1= will always be a regular article link (Foobar), while |2/3/4...= will always be DOIs prefixes. Headbomb {t · c · p · b} 01:42, 29 October 2020 (UTC)[reply]

I have totally forgotten what this is all about and need simple instructions. The first example shows 10.1001 as a link to an article (which is a redirect). The second shows the doi template syntax and links to an enwiki search. I don't know what "DOI prefix links" are generated. It would be clearer for me if you were to show the wikitext for what the first example should output. Also show any other changes needed with sample input wikitext and the wanted output. I can use that to understand the problem and as testcases. Johnuniq (talk) 06:43, 29 October 2020 (UTC)[reply]
@Johnuniq: Well, there's the examples above. The current version of {{JCW-doi-redirects}}, which currently outputs the non-desired 10.1001. The desired output is {{doi|10.1001}}, from a template that already has the functionality ({{JCW-selected}}). Headbomb {t · c · p · b} 06:48, 29 October 2020 (UTC)[reply]
If you want to see it used in concrete examples, see User:JL-Bot/Questionable.cfg/Publishers#B. Compare the entries for the 'Baishideng Publishing Group', with plain links, with those from Bentham Science Publishers, with search links. Or those from the two entries of the European Mathematical Society in User:JL-Bot/Publishers.cfg#E (one with plain links, the other with search links). Headbomb {t · c · p · b} 06:53, 29 October 2020 (UTC)[reply]