Extension:CharInsert
From MediaWiki.org
|
CharInsert Release status: stable |
|||
|---|---|---|---|
| Implementation | Tag, Page action | ||
| Description | Create JavaScript character insert boxes. | ||
| Author(s) | Brion Vibber | ||
| License | GPL | ||
| Download | Download snapshot Subversion [Help] |
||
|
|||
|
Check usage (experimental) |
|||
CharInsert is an extension that creates JavaScript links that when clicked, insert predefined text into the text box.
These links are usually used in MediaWiki:Edittools system message (for an example, see Wikipedia:MediaWiki:Edittools).
Contents |
[edit] Syntax
Use <charinsert> tags with a space-separated list of characters or tags for which you wish to allow insertion.
You can use + sign inside a tag to define a place to:
- insert selected text or
- place cursor if no text was selected.
You have to enclose templates and spaces inside <nowiki>:
<charinsert><nowiki>== + ==</nowiki> <nowiki>{{stub}}</nowiki></charinsert>
[edit] Usage and sample output
<charinsert>Á á Ć ć É é Í í Ĺ ĺ Ń ń Ó ó Ŕ ŕ Ś ś Ú ú Ý ý Ź ź</charinsert>
→
Á á Ć ć É é Í í Ĺ ĺ Ń ń Ó ó Ŕ ŕ Ś ś Ú ú Ý ý Ź ź
Note: Clicking the links will have no effect since there is no text box.
[edit] Notes
- Generated JavaScript links also work in other areas around edit window, e.g. in MediaWiki:Copyrightwarning or MediaWiki:Newarticletext, on the page preloaded with Inputbox, and even from the text preview.
- They can also be used in MediaWiki:Uploadtext to insert image description templates.
- Generated JavaScript links use
insertTags()from wikibits.js. - Unlike toolbar buttons on top, this extension doesn't provide a way to specify inserted "sample text".
[edit] Installation
- Download the latest snapshot and extract it to your extensions directory.
- Put the following line near the end of your LocalSettings.php file:
require_once("$IP/extensions/CharInsert/CharInsert.php");
- Add
<charinsert></charinsert>tags into Mediawiki:Edittools or another appopriate system message that gets displayed on edit/create pages (like the copyright warnings), depending e.g. on where the CharInsert tools shall appear on the page.
[edit] Advanced Installation
- You can wrap your charinsert lists into
<div class="my-buttons"></div>tags and then add style sheets to Mediawiki:Common.css to influence the looks of the links that CharInsert produces. This site (www.mediawiki.org) does that to make the links appear like buttons. Another example is given below, it creates the box as shown in the screenshot.
/******* Extra buttons for 'edittools' (modified from www.mediawiki.org/MediaWiki:Common.css) ********/
.my-buttons {
/* padding: 1em; */
/* margin:5px; */
}
.my-buttons a {
color: black;
background-color: #c0d0e0 ;
font-family:monospace;
font-size: 115%;
text-decoration: none;
border: thin #069 outset;
line-spacing:5pt;
}
.my-buttons a:hover {
background-color: #d0e0f0;
border-style:outset;
}
.my-buttons a:active {
background-color: #e0f0e0;
border-style: inset;
}
- Furthermore, using Javascript, a dropdown box can be added that makes several groups of CharInsert links selectable e.g. in case there are too many of them to be displayed on one screen, or if you want to separate special and diacritical characters from wiki syntax etc. This site, the english and the german Wikipedias all implement this in a different way. This describes the mediawiki.org way unmodified:
- 1. Wrap the whole list of charinsert tags into this div (the "id=" is the important part):
<div id="specialchars" class="my-buttons" style="margin-top:10px; border:1px solid #aaaaaa; padding:1px; text-align:center; font-size:110%;" title="Click on the wanted special character."> ... </div>
- 2. Wrap each individual block of charinserts into p tags like this:
<p class="specialbasic" id="Wiki-Syntax" style="display:none"> ... </p>
- Note:
-
- Don't customise the word 'specialbasic'
- The text behind "id=" will identify this group in the dropdown menu.
- Make sure there is one group without the 'display:none' directive: That will be the default choice in the dropdown menu. On this site, it is called 'Standard' while the other groups are named by the language for which the characters are significant.
-
- 3. Copy the following two pages to your wiki (you will probably have to create the pages on your wiki first): Mediawiki:Edittools.js and Mediawiki:Editpage.js
- 4. Add the following code to your Mediawiki:Common.js:
var load_edittools = true;
// extra drop down menu on editing for adding special characters
importScript( 'MediaWiki:Edittools.js' );
// Editpage scripts
if( wgAction == 'edit' || wgAction == 'submit' ) {
importScript( 'MediaWiki:Editpage.js' );
}
- Note:
-
- The JS programs contain their own styles for "my-buttons" thus overlaying the custom styles explained above.
- The JS programs are probably MW-version dependant. They have worked in a 1.15.3 wiki (copied from 1.16 from this site)
-
|
|
This extension is being used on one or more of Wikimedia's wikis. This means that the extension is stable and works well enough to be used by such high traffic websites. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page. |
| Language: | English • Deutsch • 日本語 • Русский |
|---|