DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:summary_enforcement

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tips:summary_enforcement [2009-02-28 16:47] – fixed broken 'caching' link efegetips:summary_enforcement [2023-06-19 15:20] (current) – [Plugin available] asheenlevrai
Line 3: Line 3:
 This enhancement requires the user to either provide a summary or check "minor changes" before saving a section or a page, thus requiring that all major changes be given a description.  You may also tweak it to always require a summary, regardless of whether "minor changes" is checked. This enhancement requires the user to either provide a summary or check "minor changes" before saving a section or a page, thus requiring that all major changes be given a description.  You may also tweak it to always require a summary, regardless of whether "minor changes" is checked.
  
-===== Version Dependencies =====+===== Description =====
  
-At the time of this writing, the current stable version of Dokuwiki ([[http://www.splitbrain.org/go/dokuwiki|2006-03-09]]) contains a small bug that must first be fixed before adding this enhancement.  The bug is in file ''lib/scripts/edit.js'function ''initChangeCheck()'' Change the following two lines:+The enhancement is very simple.  When the user edits a section or a page, the ''Save'' button is initially disabled and cannot be pressed.  The user may press ''Preview'' to preview the page, but in order to save the page the user must first either:
  
-<code javascript> +  * Provide a non-blank summary; or 
-    summary.onchange = summaryCheck+  * Check the "minor changes" checkbox
-    summary.onkeyup  = summaryCheck; +
-</code>+
  
-to these lines:+The ''Save'' button is enabled whenever there is a summary in the summary field or whenever the "minor changes" checkbox is checked.  Of course, the user may both enter a summary and check "minor changes", and the ''Save'' button will be enabled.
  
-<code javascript> +It's possible to modify the code so that a summary is always requiredas explained below.
-    addEvent(summary, 'change', summaryCheck); +
-    addEvent(summary, 'keyup', summaryCheck); +
-</code>+
  
-This fix has already been checked in and will appear in subsequent releases of Dokuwiki.+===== Plugin available =====
  
-===== Description =====+There's also a plugin available, which provides the function: [[:plugin:enforcesummary|enforcesummary]]
  
-The enhancement is very simple.  When the user edits a section or a page, the ''Save'' button is initially disabled and cannot be pressed The user may press ''Preview'' to preview the page, but in order to save the page the user must first either:+NOTE: This plugin looks like it's no longer maintained by its author.
  
-  * Provide a non-blank summary; or +===== Dokuwiki 2011-11-10 “Angua” =====
-  * Check the "minor changes" checkbox+
  
-The ''Save'' button is enabled whenever there is a summary in the summary field or whenever the "minor changes" checkbox is checked.  Of course, the user may both enter a summary and check "minor changes", and the ''Save'button will be enabled.+To install this enhancement, put the following Javascript code into the ''script.js'' file in your template directory.  You'll need to create the file if it doesn't already exist.
  
-It's possible to modify the code so that a summary is always requiredas explained below.+This code uses jQuery, which has been [[devel:javascript#jquery|included]] with Dokuwiki since 2011-11-10 “Angua”.  If you are using an older version, you should [[:install:upgrade]] (or use the older code for this enhancement, given below). 
 + 
 +<file javascript script.js> 
 +jQuery(document).ready(function() { 
 + minSummaryLength = 15; 
 + $editButton = jQuery("#edbtn__save"); 
 + $minorEdit = jQuery("#minoredit"); 
 + $summary = jQuery("#edit__summary"); 
 + $summary.keyup(enforceSummary).focus(enforceSummary); 
 + $minorEdit.change(enforceSummary); 
 + enforceSummary(); // To disable form submission on page load. 
 +}); 
 +function enforceSummary() { 
 + if ($summary.val() && $summary.val().length < minSummaryLength && !$minorEdit.is(':checked')) { 
 + $summary.addClass("missing"); 
 + $editButton.attr("disabled"true).css("color", "#999"); 
 + } else { 
 + $summary.removeClass("missing"); 
 + $editButton.removeAttr("disabled").css("color", "black"); 
 +
 +
 +</file>
  
-===== The Javascript =====+===== Older Dokuwiki versions =====
  
 To install this enhancement, put the following Javascript code into the ''script.js'' file in your template directory.  You'll need to create the file if it doesn't already exist. To install this enhancement, put the following Javascript code into the ''script.js'' file in your template directory.  You'll need to create the file if it doesn't already exist.
Line 84: Line 99:
 </code> </code>
  
-===== The CSS =====+==== The CSS ====
  
 Most browsers will not give you a visual indication that the button is disabled; they just won't let you click on the button.  If you want a disabled ''Save'' button to be grayed out, include the following CSS in one of your template's stylesheets: Most browsers will not give you a visual indication that the button is disabled; they just won't let you click on the button.  If you want a disabled ''Save'' button to be grayed out, include the following CSS in one of your template's stylesheets:
Line 228: Line 243:
  
  --- //[[yarony@jungo.com|Yaron Yogev]] 2008/06/30 18:44//  --- //[[yarony@jungo.com|Yaron Yogev]] 2008/06/30 18:44//
 +
 +I have an alternate version of the enforceSummary function which uses a popup instead
 +<code>
 +function enforceSummary()
 +{
 +    var btn_save = document.getElementById('edbtn__save');
 +    var summary_input = document.getElementById('edit__summary');
 +    var minoredit_input = document.getElementById('minoredit');
 + 
 +    if(summary_input.value.replace(/^\s+/,"") === '' && !minoredit_input.checked)
 +    {
 +        btn_save.onclick=function(e)
 +        {
 +            alert("You must enter an edit summary first");
 +            return false;
 +        }
 +    }
 +}
 +</code>
 +--- James 2011/3/9
 +
 +Great plugin!
 +
 +But right now Dokuwiki fills the "Edit Summary" field automatically when someone uses the [[:section_editing|Section Editing]] feature (such as right now while I'm editing).
 +
 +How do I disable this feature, to enforce a really meaningful summary?
 +
 +--- Augusto 2016-03-07
 +
tips/summary_enforcement.1235836062.txt.gz · Last modified: 2009-09-17 18:05 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki