Jump to content

Extension:Drafts

From mediawiki.org
MediaWiki extensions manual
Drafts
Release status: beta
Implementation Ajax, Special page , MyWiki
Description Adds the ability to save a draft of a page on the server while editing.
Author(s) Trevor Parscaltalk
Latest version 0.3.7
MediaWiki 1.35+
PHP 5.3+
Database changes Yes
Tables drafts
License GNU General Public License 2.0 or later
Download
  • $wgDraftsAutoSaveInputBased
  • $wgDraftsAutoSaveWait
  • $wgDraftsAutoSaveTimeout
  • $wgDraftsLifeSpan
  • $wgDraftsCleanRatio
Quarterly downloads 22 (Ranked 103rd)
Translate the Drafts extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The Drafts extension adds the ability to save a draft of a page on the server while editing. Users must be logged in to save drafts, as they are tied to their user account. Drafts are always discarded when they are used to save the page they came from.

User Interface

[edit]

Saving Drafts

[edit]

Drafts are always saved when the user clicks preview or show changes, however, the following behavior is dependent on whether the client's browser has JavaScript enabled or disabled.

Behavior JavaScript Enabled JavaScript Disabled
Save Draft Button
  • Initially Disabled to indicate no change
  • Enabled upon change
  • Disabled and renamed upon save to indicate success or failure
Always enabled
Automatic Saving
  • Only after a change
  • Waits for 120 seconds (configurable) of inactivity
  • Can be disabled if configured to 0 seconds

None

Accessing Drafts

[edit]

If a draft has been saved the user can access them by

  • Returning to the edit screen for the article they saved the draft of, where a list of existing drafts for that user and article will appear at the top of the edit page.
  • Visiting the drafts special page (Special:Drafts) where there is a list of all drafts for that user.

Edge Cases

[edit]
  • When a page is moved, the drafts which refer to that page are moved with it
  • When a draft is created for a new page but the page is never saved, the draft will still be available for creating the page and will retain the title and namespace
  • When a draft is created for a page and the page is then deleted, the draft will remain, and the behavior will then be just as for drafts of uncreated pages

Draft Expiration

[edit]

Drafts automatically expire if not modified for a longer specific length of time (configurable). To prevent excessively frequent modifications to the database, these drafts are only actually pruned from the database a fraction of the times (configurable) which a request for a list of drafts are made. Even if pruning never takes place, expired drafts will not be accessible to users.

Installation

[edit]
  • Download and move the extracted Drafts folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Drafts
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'Drafts' );
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • Configure as required
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

The extension needs its own table within the MediaWiki database, and this is the reason you have to execute the update.php script. However, you may be able to save executing the update script if you manually import the contents of the extensions/Drafts/Drafts.sql file into your database, but don't do it directly with MySql because the SQL file itself relies on MediaWiki variables for finding the correct database prefix and table options.

Configuration

[edit]

The following parameters can be set by defining values for the following variables in your LocalSettings.php file.

Parameter Description Default Value
$egDraftsAutoSaveWait Seconds to wait before automatically saving the draft, if $egDraftsAutoSaveInputBased is set, the user needs to be inactive for this time, for autosave to work 120 (2 minutes)
$egDraftsAutoSaveTimeout Seconds to wait until giving up on a response from the server 10 (use 0 to disable)
$egDraftsAutoSaveInputBased If true the autosave is based on user input and a draft is saved only when the user stops typing for the specified time, otherwise it saves the draft even if the user is typing. False
$egDraftsLifeSpan Days since last change to keep drafts in the database 30 (about a month)
$egDraftsCleanRatio Ratio of times which drafts should be removed from the database when a list of drafts is requested 1000 (as in once in 1000 times)