Skip to content

Instantly share code, notes, and snippets.

@bridgkick
Created May 12, 2009 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bridgkick/110689 to your computer and use it in GitHub Desktop.
Save bridgkick/110689 to your computer and use it in GitHub Desktop.
VKI Basecamp commands
CmdUtils.CreateCommand({
name: "clean",
//takes: {"what": noun_arb_text},
//modifiers: {with: noun_arb_text, in: noun_arb_text},
preview: function( pblock, what, mods ) {
// args contains .with and .in, both of which are input objects.
//var msg = 'Cleans"{$what}" with {$with} in {$in}.';
var msg = 'Cleans extra lines, headers and HRs.';
//var subs = {what: what.text, with: mods.with.text, in: mods.in.text};
pblock.innerHTML = CmdUtils.renderTemplate( msg );
},
execute: function( what, mods ) {
// If the scope text isn't specified, use the current selection.
//var text = mods.in.text || CmdUtils.getSelection();
var text = CmdUtils.getSelection();
var newText = text.replace( /^[\-_]{3,}.*$/m, "<HR/>\n");
newText = newText.replace( /^(From:)/m, "p{font-size:65%;}. $1");
newText = newText.replace( /Dave Eckman\nVKI Studios \nw: http:\/\/www.vkistudios.com\ne: deckman@vkistudios.com\nt: \(604\) 733-1474\nf: \(604\) 733-2480\ntoll free: 1-866-733-8899\n\nGoogle Authorized Consultant – Analytics, Website Optimizer, Adwords\nOmniture Certified Professional – Implementation, Sales/, "");
newText = newText.replace( /(\s*\n){3,}/g, "\n\n");
newText = newText.replace( /^\s*-\s*(.*$)/mg, "* $1");
CmdUtils.setSelection( newText, {text:newText} );
}
});
CmdUtils.CreateCommand({
name: "green",
preview: function( pblock, what, mods ) {
var msg = 'Wraps selection in a padded, left-bordered block.';
pblock.innerHTML = CmdUtils.renderTemplate( msg );
},
execute: function( what, mods ) {
var text = CmdUtils.getSelection();
var newText = "<div style='border-left:1px solid green;padding-left:1em;margin-left:1em;'>\n\n"
newText += text
newText += "\n</div>"
CmdUtils.setSelection( newText, {text:newText} );
}
});
CmdUtils.CreateCommand({
name: "code",
preview: function( pblock, what, mods ) {
var msg = 'Inserts wiki codes for a monospaced paragraph.';
pblock.innerHTML = CmdUtils.renderTemplate( msg );
},
execute: function( what, mods ) {
var text = CmdUtils.getSelection();
var newText = "p{font-family:monospace;line-height:1.0em}. "
newText += text
CmdUtils.setSelection( newText, {text:newText} );
}
});
CmdUtils.CreateCommand({
name: "bc",
takes: {"pattern": noun_arb_text},
//modifiers: {with: noun_arb_text, in: noun_arb_text},
preview: function( pblock, pattern) {
var searchTerm = pattern.text;
var template= 'Finds the project containing "${pattern}" in the name or project code.';
var subs = { pattern: searchTerm };
pblock.innerHTML = CmdUtils.renderTemplate( template, subs );
},
execute: function( pattern ) {
}
});
CmdUtils.CreateCommand({
name: "order",
//takes: {"what": noun_arb_text},
//modifiers: {with: noun_arb_text, in: noun_arb_text},
preview: function( pblock, what, mods ) {
// args contains .with and .in, both of which are input objects.
//var msg = 'Cleans"{$what}" with {$with} in {$in}.';
var msg = 'Order module tags.';
//var subs = {what: what.text, with: mods.with.text, in: mods.in.text};
pblock.innerHTML = CmdUtils.renderTemplate( msg );
},
execute: function( what, mods ) {
// If the scope text isn't specified, use the current selection.
//var text = mods.in.text || CmdUtils.getSelection();
var text = CmdUtils.getSelection();
var newText = text.replace( /{module_webapps,(\d+),c,(\d+)}/m, "{module_webapps,$1,c,$2,,,,,,,date}");
newText = newText.replace( /{module_webapps,(\d+),a,}/m, "{module_webapps,$1,a,,,,,,,,date}");
CmdUtils.setSelection( newText, {text:newText} );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment