Discussion:
[tw] [TW5] is ther a way to restrict where a macro is called from?
(too old to reply)
m***@gmail.com
2017-10-03 12:05:09 UTC
Permalink
Raw Message
Ideally, i would like to create a macro, but i want it to only be called
from my approved places in the wiki.
Is there a way to check either the caller or the macro's place in the
rendered hierarchy, such that i can limit its behavior based on that?
--
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+***@googlegroups.com.
To post to this group, send email to ***@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/6010a1f4-3b3e-453e-a0af-58075414267e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2017-10-03 12:14:13 UTC
Permalink
Raw Message
You can check the currentTiddler against an approved list of places, but
anything you make can be modified by other people. If you make javascript
macros than you can make it harder to get around but there isn't any way to
prevent someone who knows a bit about what they are doing from getting
around it.
--
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+***@googlegroups.com.
To post to this group, send email to ***@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/38a250ea-2d46-420a-8977-d26d563ebf8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Mark S.' via TiddlyWiki
2017-10-03 13:43:44 UTC
Permalink
Raw Message
Depending on your use case, you might be able to use the
ImportVariablesWidget to re-use macros only when you want them.

Mark
Post by m***@gmail.com
Ideally, i would like to create a macro, but i want it to only be called
from my approved places in the wiki.
Is there a way to check either the caller or the macro's place in the
rendered hierarchy, such that i can limit its behavior based on that?
--
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+***@googlegroups.com.
To post to this group, send email to ***@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/f0439820-daa9-4d09-bd45-d9f4a17144c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
m***@gmail.com
2017-10-03 21:51:24 UTC
Permalink
Raw Message
Thanks for the responses. I decided to go with the currentTiddler method,
and since this macro is in javascript,
some poking around in the tiddlywiki source shows that i can reference
this.getvariable("currentTiddler") from inside the macro.

While i can't make this method secure against a determined and
knowledgeable person,
I'm opting for the 'locks only keep the honest people out' approach.
Post by m***@gmail.com
Ideally, i would like to create a macro, but i want it to only be called
from my approved places in the wiki.
Is there a way to check either the caller or the macro's place in the
rendered hierarchy, such that i can limit its behavior based on that?
--
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+***@googlegroups.com.
To post to this group, send email to ***@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/7dea48fa-c9a6-4cd6-a5fb-54e2aa6042df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
PMario
2017-10-04 09:23:48 UTC
Permalink
Raw Message
Post by m***@gmail.com
Thanks for the responses. I decided to go with the currentTiddler method,
and since this macro is in javascript,
some poking around in the tiddlywiki source shows that i can reference
this.getvariable("currentTiddler") from inside the macro.
TLDR;

IMO you should describe the functionality, that you want to have a bit
closer. ... I think you want to use an approach that begs for trouble.

----------------- Reasoning ---------------------

Your described approach is very error prone and even you or your users (for
sure) will break it by accident.

lets say:

tiddlerOK ... is a tiddler where the macro is ok
tiddlerNok ... macro should not run

Now consider this:

tiddlerNok contains your macro for testing and you call it like this:

tiddlerOK contains the following code:

{{tiddlerNok}} <-- your macro may work

and

{{||tiddlerNok}} <-- macro fails since currentTiddler is still set to
tiddlerOK


The same may happen if you use the <$list> widget with the variable
parameter set to eg: variable="listItem". ... Inside the widget scope
currentTiddler isn't set. ... if the variable assignment is missing
currentTiddler will be set.

Constructions described above are all over the places. .. So I think it
will cause you quite some headache. .. If not immediately it may cause very
hard to find problems in the future.

just some thoughts!
mario
--
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+***@googlegroups.com.
To post to this group, send email to ***@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/72c5f9cd-0f77-4277-a2ee-9074c78741c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...