DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:custombuttons

CustomButtons Plugin

Compatible with DokuWiki

  • 2017-02-19 "Frusterick Manners" unknown
  • 2016-06-26 "Elenor Of Tsort" unknown
  • 2015-08-10 "Detritus" unknown
  • 2014-09-29 "Hrun" yes

plugin A plugin for adding custom buttons to the toolbar, to shortcut commonly used code blocks

Last updated on
2014-12-10
Provides
Admin, Action
Repository
Source

Similar to codebutton_ext, newline, snippets

Tagged with button, shortcut, toolbar

Description

A plugin for adding custom buttons to the toolbar, to shortcut commonly used code blocks. The latest version has a user-friendly back-end that lets you add two types of shortcut buttons:

  1. Plain blocks of text: This is useful when you want to shortcut URLs, email addresses and generally complicated wiki tags that you use often.
  2. Wiki Format blocks: This should be used when the tags you want to shortcut have an opening and closing part and the user should add something in the middle. ex:
    <file bash bash.sh></file>

Note: Icon by Joseph North!

Download and Installation

Download and install the plugin using the Plugin Manager using the URL given above. Refer to Plugins on how to install plugins manually.

Examples

To add some button you should login as admin and click to the “Admin Button”.

Shortcut button for a commonly used URL

Shortcut button for adding a bash script

Deleting

Just click at a radio button and then click “Delete”.

Using the buttons

After you have successfully inserted some buttons you should be able to see them at the edit toolbar, as shown below.

Multiline Codes

If you want to have a shortcut for a common used multiline template (eg. a table) you can use “\n” in the code field to denote the line change.

Example:

Label: 3x3 Table
Code: ^ header1  ^ header2  ^ header3  ^\n|  valueA1  |  valueA2  |  valueA3  |\n|  valueB1  |  valueB2  |  valueB3  |

Bugs

Text-Icons are too small to read in Binky.

Some dokuwiki releases resize icons to 16×16 size. Just comment the width resizing in /lib/scripts/edit.js (around line 40)

 ...
    // create the icon and add it to the button
    $ico.attr('src', icon);
    //Disable resizing icons
   // $ico.attr('width', 16);
   $ico.attr('height', 16);
    $btn.append($ico);
 ...

If you use a dokuwiki template (like vector for example) including “user.js” file, copy the function who manages toolbar button from “edit.js” dokuwiki file and disable icon localy in the user.js file. Do not forget to activate the template option “user-script overwrite”.

Code field does not insert code

Hello,

When setting up the custom button to insert code, it does not work when using the button. Instead of inserting code field, it inserts label field.

Regards.

— The Guy 2015-02-13 10:42

Conflict with Indexmenu plugin

Having “Custombuttons 2014-12-10” and “indexmenu 2014-11-24” on DW 2012-01-25b “Angua” results in “Navigation tree is not displayed” issue (the_tree_is_not_displayed).

mubedmubed

2015-01-08 17:41

Feature requests

Placeholder symbol

It would be great to have a placeholder symbol for the selected text, e.g “&&” or “$$”. This has two benefits:

  1. You don't need three fields to define the button command. You type it like “<pre>$$<post>” instead
  2. It's possible to use the selected text more than once: [[http://mysearch.com?s=&&|Search result for "&&"]]

Variable Substitution

It would be great to be able to insert other data as well, eg dates, username etc

eg I have a button that inserts

<todo startdate:yyyy-mm-dd @user>//my text here//</todo>

I'd like to be able to have custom button fill in information such as the date, time and username (or any other info calculated from that eg:

<todo startdate:@Date@ due:@date@+10 @@user@>Update AVG boot disk</todo>

would show as

<todo startdate:2015-02-25 due:2105-03-07 @Chris>Update AVG boot disk</todo>

:-) To achieve the above date substitutions edit your action.php file in the plugin folder to include these additional lines:

    protected function loadCBData() {
        $json = new JSON(JSON_LOOSE_TYPE);
        $file = @file_get_contents(DOKU_PLUGIN . "custombuttons/config.json");
        if(!$file) return false;
 
/** Start of new lines */
        $file = str_replace('@@TODAY@@',date("Y-m-d"),$file);
        $file = str_replace('@@USER@@',$client,$file);
        $file = str_replace('@@ONEWEEK@@',date("Y-m-d",strtotime('+7 days')),$file);
        $file = str_replace('@@TWOWEEKS@@',date("Y-m-d",strtotime('+14 days')),$file);
        $file = str_replace('@@THREEWEEKS@@',date("Y-m-d",strtotime('+21 days')),$file);
        $file = str_replace('@@FOURWEEKS@@' ,date("Y-m-d",strtotime('+28 days')),$file);
        $file = str_replace('@@ONEMONTH@@',date("Y-m-d",strtotime('+30 days')),$file);
/** End of new lines */
 
        return $json->decode($file);
    }

I'm still working on getting the username substituted in… If I'd known it was this simple I'd have done it ages ago. The placeholders to put in your button text are @@TODAY@@, @@ONEWEEK@@ etc. Hopefully its obvious enough to make your own tweaks.

Add button "Edit Selected"

A simple button, next to “Delete Selected”, which gives the possibility to change the fields of an existing button.

Torpedo 2015/05/25 22:36

Let every users create their own buttons

A great improvment would be to give the ability for every users (not only the admin) to create their own buttons.

plugin/custombuttons.txt · Last modified: 2017-03-06 22:44 by 95.77.223.113