[wp-docs] Codex tools/tips

J.D. Grimes jdg at efieldguide.com
Sat Jul 13 22:09:34 UTC 2013


Hi everyone,

I'm wondering if any of you have any tips/tools that you use to make contributing to codex easier. Like pre made templates, etc. I got tired of typing some things over and over, so I decided to let JavaScript do the job for me. I've added the following as bookmarks (using FireFox browser), and they have made some of the simple things simpler. To use them, just select some text in the edit textarea and then click the bookmark. (Sorry they look a little messy.)

Format code ("code" becomes "<tt>code</tt>":

javascript:function%20__replaceIt_tt()%20{%20var%20textarea%20%20=%20document.getElementsByTagName(%20'textarea'%20)[0];%20var%20tag%20%20%20%20%20%20%20=%20'tt';%20var%20before%20%20%20%20=%20textarea.value.substring(%200,%20textarea.selectionStart%20);%20var%20after%20%20%20%20%20=%20textarea.value.substring(%20textarea.selectionEnd%20);%20var%20selection%20=%20textarea.value.substring(%20textarea.selectionStart,%20textarea.selectionEnd%20);%20%20textarea.value%20=%20before%20+%20'<'%20+%20tag%20+%20'>'%20+%20selection%20+%20'</'%20+%20tag%20+%20'>'%20+%20after;%20%20return%20undefined;%20}%20__replaceIt_tt();

Link to the page for a class ("Class" becomes "<tt>[[Class_Reference/Class | Class]]</tt>"):

javascript:function%20__replaceIt_class()%20{%20var%20textarea%20%20=%20document.getElementsByTagName(%20'textarea'%20)[0];%20var%20before%20%20%20%20=%20textarea.value.substring(%200,%20textarea.selectionStart%20);%20var%20after%20%20%20%20%20=%20textarea.value.substring(%20textarea.selectionEnd%20);%20var%20selection%20=%20textarea.value.substring(%20textarea.selectionStart,%20textarea.selectionEnd%20);%20%20textarea.value%20=%20before%20+%20'<tt>[[Class_Reference/'%20+%20selection%20+%20'%20|%20'%20+%20selection%20+%20']]</tt>'%20+%20after;%20%20return%20undefined;%20}%20__replaceIt_class();

Link to the page for a function ("function" becomes "<tt>[[Function_Reference/function | function()]]</tt>"):

javascript:function%20__replaceIt_function()%20{%20var%20textarea%20%20=%20document.getElementsByTagName(%20'textarea'%20)[0];%20var%20before%20%20%20%20=%20textarea.value.substring(%200,%20textarea.selectionStart%20);%20var%20after%20%20%20%20%20=%20textarea.value.substring(%20textarea.selectionEnd%20);%20var%20selection%20=%20textarea.value.substring(%20textarea.selectionStart,%20textarea.selectionEnd%20);%20%20textarea.value%20=%20before%20+%20'<tt>[[Function_Reference/'%20+%20selection%20+%20'%20|%20'%20+%20selection%20+%20'()]]</tt>'%20+%20after;%20%20return%20undefined;%20}%20__replaceIt_function();

Link to the page for a filter ("filter" becomes "<tt>[[Plugin_API/Filter_Reference/filter | 'filter']]</tt>"):

javascript:function%20__replaceIt_filter()%20{%20var%20textarea%20%20=%20document.getElementsByTagName(%20'textarea'%20)[0];%20var%20before%20%20%20%20=%20textarea.value.substring(%200,%20textarea.selectionStart%20);%20var%20after%20%20%20%20%20=%20textarea.value.substring(%20textarea.selectionEnd%20);%20var%20selection%20=%20textarea.value.substring(%20textarea.selectionStart,%20textarea.selectionEnd%20);%20%20textarea.value%20=%20before%20+%20'<tt>[[Plugin_API/Filter_Reference/'%20+%20selection%20+%20'%20|%20\''%20+%20selection%20+%20'\']]</tt>'%20+%20after;%20%20return%20undefined;%20}%20__replaceIt_filter();

Link to the page for an action ("action" becomes "<tt>[[Plugin_API/Action_Reference/action | 'action']]</tt>"):

javascript:function%20__replaceIt_action()%20{%20var%20textarea%20%20=%20document.getElementsByTagName(%20'textarea'%20)[0];%20var%20before%20%20%20%20=%20textarea.value.substring(%200,%20textarea.selectionStart%20);%20var%20after%20%20%20%20%20=%20textarea.value.substring(%20textarea.selectionEnd%20);%20var%20selection%20=%20textarea.value.substring(%20textarea.selectionStart,%20textarea.selectionEnd%20);%20%20textarea.value%20=%20before%20+%20'<tt>[[Plugin_API/Action_Reference/'%20+%20selection%20+%20'%20|%20\''%20+%20selection%20+%20'\']]</tt>'%20+%20after;%20%20return%20undefined;%20}%20__replaceIt_action();

Sorry that is so messy!

I would love to know if anyone has a better idea, or other tools or tips. I know that we'll be migrating away from mediawiki, and I don't know how things will change.

-J.D.


More information about the wp-docs mailing list