User:D'Ranged 1/script/CustomRefToolbar
This is my customized version of the RefToolbar gadget; anyone is welcome to copy it and modify it for their own use. Before attempting to create your own forms, you should read and understand the information about RefToolbar, see the RefToolbar article.
RefToolbar is the creation of User:Mr.Z-man, he deserves more praise than he's received for creating an excellent gadget that makes entering citations correctly much easier. I've customized his gadget to better serve my needs while editing; the default tool is incredibly powerful and is a beautiful thing; his work has had a vast impact on the accuracy of Wikipedia. He is continuing to modify the gadget as needs arise; I sincerely appreciate his hard work. Many thanks, good sir!
The key files to reference in creating your own modifications are:
- Module:Citation/CS1/Whitelist - a list of the parameter names currently approved for use.
- MediaWiki:RefToolbarConfig.js - the structure of the forms
- MediaWiki:RefToolbarMessages-en.js - the labels for the form fields, dialog boxes, tooltips, etc.
The script
[edit]The first line of the script initiates the script; you must include this.
// Set user options
[edit]The first line in this section sets the date format to be used in all date-related fields; the default is <date> <monthname> <year>
, so if you prefer that format, you may omit this line.
The second line adds the autodate function to the indicated date fields. I often am the person submitting a web page to an archive website, so I added archive-date
to this list. I also sometimes reference articles the same day they're published, so I added date
. The default is for this feature to only be activated for accessdate
; unless you often cite references dated the same day you're citing them, or are archiving sites for the first time, I recommend not adding this line.
The third line sets the templates to automatically show the parsed version when Preview is clicked. I find it helpful to see if I've made any errors in data entry; if you're working on a slower computer or one without much memory, you should probably also omit this line.
These three settings will impact any templates you call using RefToolbar, not just ones you create. If you don't want to create customized forms but do want to change the default date setting, etc., you can just add these to your script and omit everything else. Be sure to end with });
on a line by itself at the end of the settings; this ends the script.
// Cite template definitions
[edit]This section contains the customized forms definitions. The structure is new citeTemplate('template', 'form'
, where template
is the name of the citation template and form
is the name of the form the tool will load to enter data into the template. Note that the default is to name the form the same as the template; I modified the names to show that they're different forms than the default.
Note that if you don't create a modified version of a template already present in RefToolbar the default template will still be available in the drop-down list.
// Cite template headings, field labels, and tooltips
[edit]Note that my modified templates use some different parameter names than the standard ones; I had to add labels and tooltips for those to this section. For example, I use author-link
, rather than authorlink
, so I added code for the label and the tooltip. (Code for the label and tooltip for authorlink
are included in the default tool.) If you're using a field that is currently in MediaWiki:RefToolbarConfig.js, you won't need to modify this section. If you add fields in your forms that are not currently used there, or use aliases of current parameter names, you'll need to add those to this section. Since it is likely you'll modify this to include templates that are not currently in RefToolbarConfig.js, you will have to reference that file to see what fields to add to this section.
Note that this section also needs to end with });
on a line by itself at the end of the settings, so if you include user options, there will be two lines containing this at the end of the script.
Responsibility
[edit]As you will often be reminded, you are responsible for any changes you make to Wikipedia by using this tool. You may also need to revisit any modifications you make to ensure that you're still using acceptable parameter names, etc. It is my fervent hope that these instructions prove useful; I am in awe of the incredible contributions of Wikipedia's editors; hopefully this will make those contributions easier to make.
I will try to respond to questions; please feel free to post on my Talk page.
Happy editing!