User:Tokenzero/infoboxJournal

infoboxJournal.js (source) is a user script for adding and standardizing infobox journal templates.

Install by adding the following to your common.js page (or your skin.js page):

You may have to create this page if you don't already have one.

Use by clicking Infobox journal in the More dropdown menu (next to Read/Edit/View history):
 * on the view page of an article—redirects you to a diff previewing a proposed edit.
 * on an edit page—modifies your current working textarea and summary.
 * in either case it displays a helper box on top with warnings and a list of parameters to double-check.

Functionality:
 * Adds a standard infobox journal if there is none.
 * Reformats existing infobox journal to a 'standard form' template (standardizing whitespace, empty parameters to be filled, and the order of parameters).
 * Removes redundant italic title templates (the infobox already calls it).
 * Pre-fills a number of parameters automatically (see parameter documentation); prefilling is prone to errors, so check the helper box.
 * title, based on – watch out for infoboxes on non-journal articles (e.g. like a society that publishes the journal)
 * frequency, based on Category:Academic journals by publication frequency (and its subcategories)
 * language, based on Category:Academic journals by language
 * publisher, based on Category:Academic journals by publisher
 * discipline, based on Category:Academic journals by subject area
 * openaccess based on Category:Open access journals
 * history, based on Category:Publications by decade of establishment / Category:Publications by decade of disestablishment / Category:Defunct journals
 * website based on Official website (and synonyms)
 * ISSN based on ISSN (warns if multiple are present)
 * eISSN based on eISSN (warns if multiple are present)
 * Replaces  (hyphen) and   (mdash) with   (ndash) in history
 * Removes boxwidth if empty/comment only
 * Removes obsolete parameters: RSS, atom

New version
I made a lot of changes, some things may have regressed accidentally.
 * Fixed: normalizes YYYY – XXXX and YYYY to XXXX to YYYY–XXXX
 * Fixed: considers Category:Defunct journals for XXX–?
 * Fixed: (if I understand correctly, the problem was that categories were fetched from the latest saved version, not from the visible edited area): If a parameter is empty, and there is a pre-fill option, prefill it. E.g. after do  when you run the script (+ other standardization as normal).
 * Fixed sorting, so that it groups identifiers together, like so
 * Params nlm/bluebook/mathscinet and peer-reviewed/image_size/alt are now "weakly suggested": they will not be added by default, but will appear in "Proposed changes". I thought about making a simple prompt/checkbox, but unfortunately for now this looks like overkill.
 * Should caption or ISSNlabel maybe be only weakly suggested as well? Tokenzero (talk) 13:57, 12 October 2019 (UTC)
 * ISSNlabel should only really be used if there are ISSN2/OCLC2/etc, so it could be weakly suggested (or just omitted by default). It's just convenient to already have there in case since it makes things more convenient to expand if need be, but it's really a corner case. Caption being weakly suggested would be fine, possibly with instructions that it should only be used to add information about the cover (e.g. Cover of the July 1923 issue), but which can normally be ommitted. &#32; Headbomb {t · c · p · b} 22:20, 12 October 2019 (UTC)

I would suggest splitting things in three categories. If running on the current version of Tijdschrift voor Gerontologie en Geriatrie, those would look like

&#32; Headbomb {t · c · p · b} 22:38, 12 October 2019 (UTC)
 * Ok, should work as above now. For the comments: I guess the " " comments about synonyms can be skipped altogether, because they are handled automatically anyway (keeping the existing key if it was a synonym, sorting it in the same place as the "canonical" key, and reporting duplicates if two synonymous keys were already present)? For the others, like "  ", do we want to actually insert them, at least when inserting a new infobox template, or should it just show up in the helper box (under "new value" similar to absent, or right of that like warnings do, or as a small  icon with a hover hint)? Tokenzero (talk) 13:14, 13 October 2019 (UTC)

Comments can probably be ignored yes. They could be displayed in the suggestion column for additional parameters as guidance though, e.g. Obviously whichever ends up in the additional parameter list would be whichever isn't found in the box. &#32; Headbomb {t · c · p · b} 13:58, 13 October 2019 (UTC)


 * I removed the comments in favor of tooltips. The tooltips take the "description" in TemplateData (when changing them keep in mind they appear in VisualEditor as well). I really don't think all that info should be displayed and repeated all the time, especially since the script is likely used by more experienced users. As for the synonyms I don't think anybody needs to know they even exist. It's better to keep the instructions terse, otherwise they are more of a hindrance than a help, obscuring things that actually need to be pointed. Tokenzero (talk) 21:53, 27 October 2019 (UTC)
 * No strong feelings either way. I'd move the tooltips to the right personally though. I never saw them until you mentioned them existing. &#32; Headbomb {t · c · p · b} 22:06, 27 October 2019 (UTC)

Todo

 * Use TemplateData as much as possible (mostly done).
 * Add categories based on infobox parameters.
 * Standardize image attributes, e.g.
 * Alphabetize what is found in columns-list, e.g.

Requests

 * Remove needs-infobox from WikiProject banners [automatically save]
 * Tag the talk page with WikiProject Academic Journals [automatically save]
 * Tag the file in image with WikiProject Academic Journals [automatically save]
 * Create (at some point between version 1.0.0.0 of this script and the heat death of the universe) a similar script for infobox magazine
 * Invoke WP:JWB to perform other cleanup while we're at it?
 * Update Category:Academic journals by publication frequency detection logic (to cover all the '# times per year journals' categories). This should be done in a generic fashion, since some of those categories might get deleted as empty [The 'special cases' are 1/2/3/4/6/12/26/52 times per year should remain empty because they redirect to the Annual/Biannual/Triannual/Quarterly/Bimonthly/Biweekly/Weekly journals categories, but it doesn't hurt to have code that could handle them]. On top of the Irregular/Continous journals, and Journals more frequent than weekly‎ categories. &#32; Headbomb {t · c · p · b} 03:17, 17 August 2019 (UTC)

Discussion

 * Normalize frequency
 * Annually; 1/year [+ spaced variants, like 1 / year]; Once per year → Annual
 * Biannually; 2/year; Twice per year → Biannual
 * Triannually/Triennial; 3/year; Thrice per year; Three times per year; 3 times per year → Triannual
 * Quarterly; 4/year; Four times per year; 4 times per year → Triannual
 * 6/year; Six times per year; 6 times per year → Bimonthly
 * 12/year; Twelve times per year; 12 times per year → Monthly
 * 26/year; Twenty-six times per year; 26 times per year; Every two weeks → Biweekly
 * 52/year; Fifty-two times per year; 52 times per year; Every week → Weekly
 * 365/year; Three-hundred-and-sixty-five times per year; 365 times per year; Every day → Daily
 * Continuously → Continuous
 * Irregularly → Irregular
 * etc... The idea is that this takes the same form as  Journal of Stuff. So Annual, Biannual, Triannual, Quarterly, Bimonthly, Monthly, Biweekly, Weekly, Daily, Continous, Irregular.

Mmm, that might be a bit contentious: bimonthly etc. are ambiguous, which is why people use 2/month, 6/year (or things like fortnightly). Also the -ally forms seems significantly more prevalent to me. You should discuss that (see e.g. this old discussion) if you really want to normalize it. Also I discourage normalizing just for the sake of normalization, it's usually futile ;) Tokenzero (talk) 20:00, 10 August 2019 (UTC)
 * Well, this would match how Category:Bimonthly journals, etc... are used. But you're right that some discussion might be needed here. &#32; Headbomb {t · c · p · b} 20:18, 10 August 2019 (UTC)


 * Pre-fill abbreviation with abbrevIso.js.
 * Won't do, sorry. It's actually quite complicated, because I either have to include the whole code on Wikipedia or set up a server to run it, which is overkill. Moreover, making this automatically would dissuade from checking the abbrev carefully; even experienced users should look at the list of compound matches etc., so copy-pasting the results is negligible effort, in comparison. Tokenzero (talk) 13:57, 12 October 2019 (UTC)


 * Add Category:Defunct journals if there is a Category:Publications disestablished in ... category
 * So you basically want Category:Defunct journals to be equal to the intersection of Category:Academic journals and Defunct_periodicals (which contains Publications disestablished in ...)? Isn't there some existing solution for that? Tokenzero (talk) 13:57, 12 October 2019 (UTC)
 * Just a straight up if you find one subcategory of Category:Publications by year of disestablishment, add Category:Defunct journals. &#32; Headbomb {t · c · p · b} 22:16, 27 October 2019 (UTC)


 * This may need updating after deletion of the "journals associated with" categories, see Categories_for_discussion/Log/2020_June_10. – Fayenatic  L ondon 12:21, 19 June 2020 (UTC)

Bugs

 * Bug: On American Ecclesiastical Review, dig deeper to find Category:Catholic University of America academic journals
 * You mean to prefill publisher? Like treat subcats of Category:Academic journals associated with non-profit organizations as if they were in Category:Academic journals by publisher? Tokenzero (talk) 23:08, 15 August 2019 (UTC)
 * Yes. Going pretty deep in the category tree of Category:Academic journals by publisher. &#32; Headbomb {t · c · p · b} 23:11, 15 August 2019 (UTC)
 * The script is currently looking 9 levels deep, but adding more changes nothing here (more precisely, it goes bottom up from each cat the article has, but only through cat names containing journal). These two are currently not anywhere in the subtree of Category:Academic journals by publisher, as far as I checked. Which is maybe intended. But by the way, shouldn't Category:Academic journals published by museums be in Category:Academic journals by publisher? Tokenzero (talk) 23:24, 15 August 2019 (UTC)
 * If the issue is just that it's not in the category tree, that's fine. Certainly an easy fix to categorize them properly. &#32; Headbomb {t · c · p · b} 23:29, 15 August 2019 (UTC)


 * Bug: On American Ecclesiastical Review (and pretty much every other journal), it suggests to add yes despite no open access categories being present. &#32; Headbomb {t · c · p · b} 23:42, 15 August 2019 (UTC)
 * Likewise Creative Commons-related categories should be ignored. Too often, those are used to indicate supported optional licensing, rather than accross-the-board licensing. &#32; Headbomb {t · c · p · b} 23:42, 15 August 2019 (UTC)
 * Fixed (I think), thanks for noticing it quickly :) Tokenzero (talk) 23:53, 15 August 2019 (UTC)
 * Thanks for fixing quickly! &#32; Headbomb {t · c · p · b} 23:55, 15 August 2019 (UTC)
 * Bug: It adds issn, rather than ISSN &#32; Headbomb {t · c · p · b} 00:14, 16 August 2019 (UTC)
 * Bug: In Journal of Psychoactive Drugs, it missed the official website template. &#32; Headbomb {t · c · p · b} 13:47, 16 August 2019 (UTC)
 * Bug: In Antarctic Science, it fails to add Cambridge University Press &#32; Headbomb {t · c · p · b} 13:53, 16 August 2019 (UTC)
 * Hmmm, works for me now, weird. Perhaps a disconnection hiccup when fetching categories, I should make the script issue a warning when they occur. Any other cases like that? Tokenzero (talk) 18:12, 16 August 2019 (UTC)
 * I'll keep an eye on things. This was the version that it failed on. You can test on User:Headbomb/sandbox4. It suggests filling the parameter to that, but it doesn't actually fill it.&#32; Headbomb {t · c · p · b} 19:41, 16 August 2019 (UTC)
 * Ah, yes, thanks for the sandbox example. It was prioritizing original parameters even if they were empty. Now it replaces a param with default/prefill if it was originally whitespace-only or equal to the default comment value (it keeps prioritizing other comments over prefills); also now it deletes non-default parameters that are whitespace-only (keeps comments, except boxwidth etc.) – is that how you want it? Tokenzero (talk) 20:25, 16 August 2019 (UTC)
 * Comments can be overridden if the parameter is otherwise empty. &#32; Headbomb {t · c · p · b} 20:27, 16 August 2019 (UTC)
 * I think non-default comments are rare and there's a few cases like < !--no-- > where it's better to keep it, no? Tokenzero (talk) 20:30, 16 August 2019 (UTC)
 * Well, for that case, you would have no before having < !--no-- >. IMO the warning in the helper box should be enough. Otherwise if you have < !--ISO 4 abbreviation-- >, then the script couldn't fill it with its own suggestion. &#32; Headbomb {t · c · p · b} 20:38, 16 August 2019 (UTC)


 * If you add a new box, it loads up the old style infobox with all the abbreviation/nlm/bluebook/etc... You need to run the script on an existing box to get the 'modern' version of the script . Not sure if I've diagnosed the conditions correctly however. &#32; Headbomb {t · c · p · b} 17:10, 21 October 2019 (UTC)
 * That was actually intentional, my line of thinking was that a new infobox is more likely to need them and it's easier to remove them than add them. But it's a simple "if", I disabled it so now it behaves the same as for non-new infoboxes. Tokenzero (talk) 21:46, 27 October 2019 (UTC)