User:Mr. Stradivarius/gadgets/Draftify

From Wikipedia, the free encyclopedia

The Draftify gadget allows you to move a userspace draft to the draft namespace, tag it with a draft template, and notify the user of your action. It will also optionally allow you to give the user advice about changing their username, or to soft-block them because their name violates the username policy.

Installation[edit]

Add the following to your common.js:

importScript('User:Mr. Stradivarius/gadgets/Draftify.js'); // Linkback: [[User:Mr. Stradivarius/gadgets/Draftify.js]]

After you have saved the page, you may need to bypass your browser cache.

Usage[edit]

  1. Go to a page in the User or User talk namespaces that you would like to move to the Draft namespace.
  2. Click on the "Draftify" menu item.
  3. Choose your settings.
  4. Click "Submit".

The page will then be moved and tagged, and the user will be optionally notified and optionally soft-blocked, depending on the settings you chose.

Where it will run[edit]

This gadget will run on most pages in the User and User talk namespaces. However, it will not run in your own userspace, and it will not run if the user page does not belong to a registered user. It also doesn't run if the current page has been deleted or doesn't exist, and it will only run on normal wiki pages - user .js and .css pages are excluded.

Settings window[edit]

When you click on the "Draftify" menu item, you should see a window with the various settings that you can choose.

  • New draft name: This will be the new name of the draft after it is moved. The name is always prepended with Draft:, so there is no need to add the "Draft:" prefix yourself. This field is required.
  • Leave a redirect behind: Check this box if you would like to leave a redirect behind. The box is always checked if you do not have sufficient user rights to suppress redirects.
  • Notify the user of the page move: Uncheck this box if you would not like the user to be notified. This box is automatically checked if you check either the "Suggest that the user change their username" or the "Soft-block the user" checkbox.
  • Suggest that the user change their username: Check this box to notify the user that they need to change their username. This should only be used for usernames that give the impression that the account represents a group, organization or website.
  • Soft-block the user and leave a block notice: Check this to soft-block the user. This block settings are such that the user will be able to create another account straight away. This box is never checked if you do not have sufficient rights to block other users.
  • Watch user talk page: Check this to watch the user talk page. This option is only available if you notify the user of the page move.
  • Watch source page and target page: Check this box to watch both the old page name and the new page name. If you are using Draftify directly on a user page (not a user subpage), the "watch user talk page" setting takes precedence for the source page.

Progress notifications[edit]

After you have finished adjusting the settings, click "Submit". This will initiate the process of moving and tagging the current page, and optionally soft-blocking and notifying the user.

If all of the actions are successfully completed, the gadget will open the user's talk page to the section they were warned at. This section will have a heading with the current month and year (in the format "Month YYYY"). If the latest section on the page already has a heading of the current month and year, then the gadget will use that rather than adding a new section.

If there are any errors, the gadget will stop at the first one and display an error message. In this case, the user's talk page will not be opened. The gadget isn't clever enough to know how to deal with these errors, so you won't be able to use it again until you reload the page.

Customisation[edit]

As well as choosing your settings each time you use the gadget, you can also change the defaults. To do this, you have to edit your common.js page.

First, add the following line directly above the line where you loaded the script:

Draftify = {}; // Don't remove this line! It is necessary for Draftify settings.

Then you can add custom settings directly below that, and above the line where you loaded the script. So your common.js page should contain code that looks something like this:

Draftify = {}; // Don't remove this line! It is necessary for Draftify settings.
Draftify.redirect = true;
Draftify.watchusertalk = false;
Draftify.watchdraft = false;
Draftify.menulocation = "p-personal";
importScript('User:Mr. Stradivarius/gadgets/Draftify.js'); // Linkback: [[User:Mr. Stradivarius/gadgets/Draftify.js]]

redirect[edit]

Draftify.redirect = true;

Whether the "Leave a redirect behind" checkbox is checked or not. The default is false. This setting will not have any effect for users who cannot suppress redirects.

notify[edit]

Draftify.notify = false;

Whether the "Notify the user of the page move" checkbox is checked. The default is true.

softblock[edit]

Draftify.softblock = true;

Whether the "Soft-block the user and leave a block notice" checkbox is checked. The default is false. This setting will not have any effect for users without sufficient rights to block other users.

suggestrename[edit]

Draftify.suggestrename = true;

Whether the "Suggest that the user change their username" checkbox is checked. The default is false.

watchusertalk[edit]

Draftify.watchusertalk = false;

Whether the "Watch user talk page" checkbox is checked. The default is true.

watchdraft[edit]

Draftify.watchdraft = false;

Whether the "Watch source page and target page" checkbox is checked. The default is true.

You can also specify this option with the alias watch. This alias is retained for backwards compatibility.

movesummary[edit]

Draftify.movesummary = "My custom move summary";

The edit summary used when you move the page. The default is "the Draft namespace is the preferred location for Articles for Creation submissions".

tagtemplate[edit]

Draftify.tagtemplate = "{{subst:User:Mr. Stradivarius/my tag template|user=$1}}";

The template that articles are tagged with. This takes a parameter $1, the username of the user whose userspace the draft is in.

See #Customising templates to avoid problems with templates being substituted when you save your common.js or skin.js page.

tagsummary[edit]

Draftify.tagsummary = "Tag page with custom tag template";

The edit summary that is used when tagging drafts.

notifytemplate[edit]

Draftify.notifytemplate = "{{subst:User:Mr. Stradivarius/my notification template|to=$1|from=$2}} ~~~~";

The template that is used when notifying users. It takes three parameters:

  • $1 - The new page name after the move
  • $2 - The current page name

The default value is {{subst:uw-draftmoved|1=$1|from=$2}} ~~~~.

See #Customising templates to avoid problems with templates being substituted when you save your common.js or skin.js page.

notifysummarymoveonly[edit]

Draftify.notifysummarymoveonly = "Your draft has been moved";

The edit summary to use when notifying users, when you are only moving the page, and not soft-blocking the user or suggesting that they change their username. The default value is "Your draft page has been moved".

notifysummarysuggestrename[edit]

Draftify.notifysummarymoveonly = "Your draft has been moved and you may need to change your username";

The edit summary to use when notifying users when also suggesting that they change their username. The default is "Your draft page has been moved, and you may need to change your username".

notifysummarysoftblock[edit]

Draftify.notifysummarysoftblock = "Your draft has been moved and you have been soft-blocked";

The edit summary to use when notifying users when they have been soft-blocked. The default is "Your draft page has been moved, and you have been indefinitely blocked from editing because your username gives the impression that the account represents a group, organization or website".

softblocktemplate[edit]

Draftify.softblocktemplate = "{{subst:User:Mr. Stradivarius/my softblock template}}";

The template to use when soft-blocking users. This will be displayed directly below the notification that their draft has been moved.

See #Customising templates to avoid problems with templates being substituted when you save your common.js or skin.js page.

softblocksummary[edit]

Draftify.softblocksummary = "Soft-block";

The edit summary to use when soft-blocking users. The default is "{{uw-softerblock}} <!-- Promotional username, soft block -->".

suggestrenametemplate[edit]

Draftify.suggestrenametemplate = "{{subst:User:Mr. Stradivarius/my rename suggesting template}}";

The template to use when suggesting that users change their usernames. This will be displayed directly below the notification that their draft has been moved.

See #Customising templates to avoid problems with templates being substituted when you save your common.js or skin.js page.

menulocation[edit]

Draftify.menulocation = "p-tb";

The location of the "Draftify" menu item. The following options are available:

  • "p-personal" - your personal toolbar, with links to your user page, talk page, and preferences.
  • "p-cactions" - content actions toolbar. In the Vector skin, this is the dropdown menu in the top-right that says "More". In other skins, this is the toolbar with "Read", "Edit", and "View history" tabs. This is the default.
  • "p-views" (Vector skin only) - the toolbar with "Read", "Edit", and "View history" tabs.
  • "p-navigation" - Menu on the left-hand side with links to "Main page" and "Contents".
  • "p-interaction" - Interaction menu on the left-hand side with links to "Help" and "About Wikipedia".
  • "p-tb" - Tools menu on the left-hand side with links to "What links here" and "Related changes".

menuposition[edit]

Draftify.menuposition = "#t-whatlinkshere";

The position of the "Draftify" menu item in the menu specified in the "menulocation" option. This should be a CSS selector of an item in the same menu that you want the "Draftify" link to appear directly before.

For example, if you set the link to display in the tools menu, and you want the link to appear directly before the "What links here" link, then you would set it to "#t-whatlinkshere". The list of possible values will vary depending on the menu you chose, your user rights, and what user scripts and gadgets you have installed. Common values include the following:

Views menu (Vector only)

  • "#ca-watch" - directly before the star for watching pages.

Content actions menu

  • "#ca-delete" - directly before the "Delete" link.
  • "#ca-move" - directly before the "Move" link.
  • "#ca-protect" - directly before the "Protect" link.
  • "#ca-watch" - (not on Vector) directly before the star for watching pages.

Personal toolbar

  • "#pt-sandbox" - directly before the "Sandbox" link.
  • "#pt-preferences" - directly before the "Preferences" link.
  • "#pt-betafeatures" - directly before the "Beta" link.
  • "#pt-watchlist" - directly before the "Watchlist" link.
  • "#pt-mycontris" - directly before the "Contributions" link.
  • "#pt-logout" - directly before the "Log out" link.

Tools menu

  • "#t-whatlinkshere" - directly before the "What links here" link.
  • "#t-recentchangeslinked" - directly before the "Related changes" link.
  • "#t-contributions" - directly before the "User contributions" link.
  • "#t-log" - directly before the "Logs" link.
  • "#t-blockip" - directly before the "Block user" link.
  • "#t-emailuser" - directly before the "Email this user" link.
  • "#t-userrights" - directly before the "User rights management" link.
  • "#t-upload" - directly before the "Upload file" link.
  • "#t-specialpages" - directly before the "Special pages" link.
  • "#t-permalink" - directly before the "Permanent link" link.
  • "#t-info" - directly before the "Page information" link.

The default behaviour is for the "Draftify" item to be put at the end of the list when it is loaded. (Other list items loaded later may be placed after it.)

Customising templates[edit]

If you want to customise any options that contain templates, you should be aware that they could be interpreted as wikitext on your personal .js page. For example, if you add the template {{subst:3x|hello}}, when you save the page, it will transform into hellohellohello. This is probably not what you want.

To avoid this, you can use <nowiki>...</nowiki> tags inside JavaScript comments. For example, you can put the opening tag on the line before your template, and the closing tag on the line after your template:

// <nowiki>
Draftify.softblocktemplate = "{{subst:User:Mr. Stradivarius/my softblock template}}";
// </nowiki>

Or you could put them at the start and the end of your config options:

// <nowiki>
Draftify = {}; // Don't remove this line! It is necessary for Draftify settings.
Draftify.tagtemplate = "{{subst:User:Mr. Stradivarius/my tag template|user=$1}}";
Draftify.notifytemplate = "{{subst:User:Mr. Stradivarius/my notification template|to=$1|from=$2}} ~~~~";
Draftify.softblocktemplate = "{{subst:User:Mr. Stradivarius/my softblock template}}";
// </nowiki>
importScript('User:Mr. Stradivarius/gadgets/Draftify.js'); // Linkback: [[User:Mr. Stradivarius/gadgets/Draftify.js]]

You could even put them right at the start and the end of your .js page, but note that if you do this then linkback links won't appear in the list of linkback links for the script.

To do[edit]

The following features are planned to be added at some stage in the future:

  • Remove {{userspace draft}} templates when tagging
  • Put tag template below protection templates