On Sunday, February 28, 2016 at 10:02:57 PM UTC-8, Mark S. wrote:
>
> Eric, you're seeing this as someone who can whip up a special filter any 
> time you need one. For the rest of us, how to make a filter isn't even 
> documented. This isn't a one time problem that Mat has with his particular 
> use case, it's a problem that comes up over and over whenever any one tries 
> to push the boundaries even slightly.  
>
For instance, AFAIK, there is no filter for comparison operations. 
> Reporting on tiddlers that are newer than some arbitrary date, or that have 
> an indexed field greater some number would be useful in many situations. I 
> put out a request for such a filter in July 2015 and there was interest ... 
> but no follow up. I don't want to nag anyone -- I want to be able to roll 
> my own solutions like it was possible with your InlineJavascriptPlugin. 
>

There are two issues here:

1) What is the best course of action when the functionality you want isn't 
*currently* provided by the core.  Some possible responses:
   * find a workaround using different core functionality
   * open an 'issue' on github and request the missing feature
   * write your own custom javascript macro, filter, widget, etc.

2) How can people with "limited" programming skills extend TW core to fit 
their particular use-cases.

   * You point to my InlineJavascriptPlugin as an acceptable way to "roll 
your own solution" (for TWClassic only).  However, this means that you are 
already able to write your own javascript code.  In which case, there's 
VERY little difference between using something like InlineJavascriptPlugin, 
and writing a TW5 javascript macro.  There's just a little bit of a 
different 'framework' that surrounds your custom code.

The easiest way to get started is to pick any javascript macro definition 
in the core, clone that tiddler, and then edit the definition to replace 
the existing code with your own custom code.  For example, the <<now>> 
macro is a good one to start with:
   http://tiddlywiki.com/#%24%3A%2Fcore%2Fmodules%2Fmacros%2Fnow.js
Even without documentation, it's a very simple module, and it's fairly 
clear what the code is doing.

There are only four things you need to change:

1) set the title of the tiddler

2) give the macro a name:
exports.name = "MACRONAME"

3) define the names of any params
exports.params = [ {name: "PARAM1"}, {name: "PARAM2"} ];
note: if your macro uses no parameters, define an empty param array:
exports.params = [ ];

4) define the macro 'run' function, passing in the named params, which are 
used to generate text output that is returned for further processing 
depending on the calling context (e.g., rendering, use as a widget 
parameter, etc.)
exports.run = function(PARAM1,PARAM2) {
 ... your javascript code here ...
 return ...some computed text value...
};

That's it.  Just save-and-reload for the macro definition to take effect, 
and then you can write <<MACRONAME PARAM1:"foo" PARAM2:"bar">> to invoke 
your own custom javascript macro.  WHEE!  What Fun!

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/30043fb9-7d28-4bc9-bfc5-cef8c17336a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to