AutoSectionsPlugin
Automatically make editable sections based on headings
Usage
This plugin automatically adds the "edit" links to all the headings (
---++
etc.) making the sections underneath them editable right in place.
If the plugin is installed and enabled, all the headings get the "edit" links, except for some special circumstances (see below).
When the mouse cursor is over an "edit" link, the area edited with the link changes its background.
In addition to edit a section, you can see the raw text of a section by clicking the "raw" link. This is handy to copy-paste a section from a topic to another.
Whether to show or hide all the "edit" links can be controlled by setting
AUTOSECTIONS
preferences variable.
* Set AUTOSECTIONS = on
It comes with a variable
%EDITAUTOSECTIONS%
, which is expanded as an "Edit Sections" button. If this variable is used anywhere, all the "edit" links on the headings are hidden by default, only until you click the button.
The
%EDITAUTOSECTIONS%
button can optionally take the parameters below to change custom button labels:
Parameter |
Default |
Description |
DEFAULT or label |
"Edit Sections" |
The button label to start editing sections. |
endlabel |
"Finish Editing" |
The button label to end editing sections. |
Preferences variables and configurations
Preference Variable |
Configuration |
Description |
AUTOSECTIONS |
$cfg{Plugins}{AutoSectionsPlugin}{Default} |
Enable/disable the plugin. Possible values are on , off , and hover . |
AUTOSECTIONS_EDITLABEL |
$cfg{Plugins}{AutoSectionsPlugin}{EditLabel} |
Alter the "edit" link label. Specify off to hide the link. |
AUTOSECTIONS_RAWLABEL |
$cfg{Plugins}{AutoSectionsPlugin}{RawLabel} |
Alter the "raw" link label. Specify off to hide the link. |
AUTOSECTIONS_CANCELLABEL |
$cfg{Plugins}{AutoSectionsPlugin}{CancelLabel} |
Alter the "cancel" link label. |
Variables can be included in any of the link labels, such as
%ICON{...}%.
How exactly are the sections determined?
The headings are detected as a nested structure. For example, a section under the level 2 heading (
---++
) will contain all the level 3, 4, 5, ... sections (
---+++
,
---++++
, etc.) right underneath it.
One exception is that a level 1 heading (
---+
) is interpreted the same as level 2 (
---++
). The reason is because it is usually encouraged to use the level 1 heading only once at the top of each page, and if it were interpreted to contain everything else, the "edit" link would be to edit the entire page. The level 1 heading rather allows you to edit the top portion of the page more quickly (typically a few paragraphs plus
%TOC%
).
Is it possible to add a new section or remove an existing section?
Yes. Since the text in the edit box will simply replace the edited section, just edit a nearby section to put any additional headings (
---++
) at an appropriate position, or erase the whole section.
How can I hide "edit" links by default?
There are several ways that affect the default behavior:
- At the TWiki installation level (configure):
-
$TWiki::cfg{Plugins}{AutoSectionsPlugin}{Default} = 0;
- In the WebPreferences, or in an individual topic:
* Set AUTOSECTIONS = off
- Use the
%EDITAUTOSECTIONS%
button somewhere in the topic
- Append
?AutoSections=off
to the URL
I want to have the section edit links but they look annoying
You can hide "edit" links and display a link only when the mouse cursor is over the link by setting AUTOSECTIONS as follows.
* Set AUTOSECTIONS = hover
How can I show "edit" links on some occasions only?
Append
?AutoSections=on
to the URL, which will enable the "edit" links regardless of the settings.
When are "edit" links not added to some headings, while it is enabled?
This plugin only detects the heading notations that appear in the raw text (saved text).
Headings that result from the below will
not have the "edit" links:
- Explicit HTML tags: <h1>, <h2>, etc.
- The
---++
notations generated by variable expansion
-
* Set SOMEVAR = ---++
-
%SOMEVAR%
- Included topics via %INCLUDE{...}%
- Insufficient
CHANGE
permission
What if MultiEditPlugin (namely <section>
tags) is used at the same time?
MultiEditPlugin allows you to add sections anywhere by placing
<section>
tags, which would result in confusing "edit" links together with this plugin.
In order to minimize the potential confusion, all the "edit" links on headings are suppressed when some
<section>
tags are present.
Thus, this plugin can be installed in a non-destructive way even if
MultiEditPlugin has already been installed.
On the other hand, if
AUTOSECTIONS
variable is explicitly set to
on
, the heading-based "edit" links are rather respected, while all the
<section>
tags are ignored.
When there are a lot of images, the page seems to be scrolled in a strange way right after a section is saved.
This is currently a known issue that results from the plugin trying to take you back to the original position you were editing, while the exact image size is unpredictable until the images are actually loaded.
Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
- For an automated installation, run the configure script and follow "Find More Extensions" in the in the Extensions section.
- Or, follow these manual installation steps:
- Download the ZIP file from the Plugins home (see below).
- Unzip
AutoSectionsPlugin.zip
in your twiki installation directory. Content: File: | Description: |
data/TWiki/AutoSectionsPlugin.txt | Plugin topic |
data/TWiki/VarEDITAUTOSECTIONS.txt | %EDITAUTOSECTIONS% variable documentation |
lib/TWiki/Plugins/AutoSectionsPlugin.pm | Plugin Perl module |
pub/TWiki/AutoSectionsPlugin/AutoSections.js | JavaScript |
- Set the ownership of the extracted directories and files to the webserver user.
- Install the dependencies.
- Plugin configuration and testing:
- Run the configure script and enable the plugin in the Plugins section.
- Configure additional plugin settings in the Extensions section if needed.
- Test if the installation was successful using the example above.
Plugin Info
Many thanks to the following sponsors for supporting this work:
- Acknowledge any sponsors here
Related Topics: TWikiPlugins,
DeveloperDocumentationCategory,
TWikiPreferences