Shout – First TiddlyWiki Plugin

Okay, it’s remarkably lame, but here’s my first TiddlyWiki plugin. It defines a new shout macro – you include <<shout some-message>> in a tiddler and it includes A SHOUTING VERSION OF THE MESSAGE.

I adapted it from the sparklines plugin. The important code is at the end – you create a macro by defining a value config.macros.helloWorld, then you simply implement config.macros.helloWorld.handler. This function receives a place variable, defining where the macro will go, and the parameters that were passed into the macro (params).

javascript

  1. /***
  2. |''Name''|ShoutPlugin|
  3. |''Description''|Make yourself heard - capitalises all text|
  4. |''Version''|1.0.0|
  5. |''Status''|stable|
  6. |''Source''|http://www.example.com/plugins.html#Shout|
  7. |''License''|[[BSD open source license]]|
  8. |''~CoreVersion''|2.4.0|
  9. |''Feedback''|[[TiddlyWiki community|http://groups.google.com/group/TiddlyWiki]] |
  10. |''Keywords''|exclamation|
  11. !Usage
  12. {{{
  13. <<shout message-to-be-shouted-about>>
  14. }}}
  15. Pretty simple really
  16. !!Examples
  17. {{{<<shout these tiddlers are making me thirsty!!!>>}}}
  18. !Code
  19. ***/
  20. //{{{
  21. if(!version.extensions.ShoutPlugin) {
  22. version.extensions.ShoutPlugin = {installed:true};
  23.  
  24. //--
  25. //-- Shout
  26. //--
  27.  
  28. config.macros.shout = {};
  29. config.macros.shout.handler = function(place,macroName,params)
  30. {
  31.  var greeting = createTiddlyElement(place,"span",null,"greeting",params.join(" ").toUpperCase());
  32.   place.appendChild(greeting);
  33. };
  34.  
  35.  
  36. }
  37. //}}}