Inserting the variable of another Tiddler content into a Macro...or using a macro in a macro....

124 views
Skip to first unread message

Jan Johannpeter

unread,
Nov 9, 2012, 7:46:15 PM11/9/12
to TiddlyWiki
Hello
I would like to create a tiddler containing Links to all open tiddlers.
I know the saveStoryPlugin does aproximately this, but i would like the new tiddler to be created in EditMode the focus set on the title so that the first action would be to change it and add an extra button
to open it.

I found this script code
<script>
var out = "" ;
story.forEachTiddler(
  function (title, element) {
 out += "[["+title+"]]\n" ;
});
return out ;
</script> 

Which gives me the desired TiddlerLinks.

An option would be to create Tiddler containing this and inserting the containing slice....

<<newTiddler label:"Neuer Eintrag" accessKey:1 focus:Title text:"<<Tiddler: PseudoStory##list>>" Tag:"TagXY">>

Of course the brackets interfere in the syntax... is there another way to do so?

Thanks for help...


PMario

unread,
Nov 10, 2012, 4:54:39 AM11/10/12
to TiddlyWiki
Hi Jan,

Can you discribe, what you want to achieve? May be there is an easier
solution.

2 examples, that may do what you want.

http://hoster.peermore.com/recipes/TeamWork/tiddlers.wiki#%5B%5BNewTiddler%20with%20evaluated%20text%5D%5D
http://hoster.peermore.com/recipes/TeamWork/tiddlers.wiki#%5B%5BNewTiddler%20with%20prototype%20text%5D%5D

have fun!
mario

Jan Johannpeter

unread,
Nov 10, 2012, 7:05:37 AM11/10/12
to tiddl...@googlegroups.com
Hello Mario
Thanks for your help. I am creating a collection where other users can
create stories. (In fact it is a collection little games for theatre
classes at school, several games are used in a lesson.)
The saveStoryButton will be placed on the Menu. The advantage the
newTiddlerPlugin compared to saveStory would be, that it is possible to
created the new StoryTiddler in editMode with the focus set on the
title, to make the users change the storyname immediately. I would even
like bette to have a prompt saying " insert a name for your new tiddler
here"


I tried a workararound inserting the NewTiddlerplugin syntax in
forEachTiddler.

<<forEachTiddler where 'story.getTiddler(tiddler.title)'
write
' "[["+tiddler.title+"]]\n" '
begin '"<<newTiddler label:Test tag:hinzugef�gt tag:stunde
title:yourTitle focus:title text:"'
end '"}"+"}>"+">"'
none '""'
>>
The rusult should be <<newTiddler label:Test tag:hinzugef�gt tag:stunde
title:yourTitle focus:title text:"story content">>

This starts to work but:
1. I would need an expression to get the Links into the order of the
story...
2. I can't insert the " to frame the textcontent, is there a way to
replace it?

3. Perhaps ther is a much easier way

Thanks again for help
Jan

Eric Shulman

unread,
Nov 10, 2012, 8:15:25 AM11/10/12
to TiddlyWiki
> The saveStoryButton will be placed on the Menu. The advantage the
> newTiddlerPlugin compared to saveStory would be, that it is possible to
> created the new StoryTiddler in editMode with the focus set on the
> title, to make the users change the storyname immediately.  I would even
> like bette to have a prompt saying " insert a name for your new tiddler
> here"

Except for changing the storyname, it's not clear to me what advantage
there is in opening the newly created story tiddler in edit mode...
and, you *can* use <<saveStory>> to "prompt for tiddlername" with the
'ask' option:
<<saveStory ask "label" "helptext" tag tag tag...>>

Note also that your approach -- generating a <<newTiddler>> macro --
won't actually achieve the results you want, for one very important
reason: the list of tiddlers that are open when you *generate and
render* the <<newTiddler>> macro will almost certainly be different
from the tiddlers that are open when you later *click* on the rendered
menu link. Because the <<newTiddler>> macro's parameters are not
generated when you click, it will always create a story using the same
initial set of open tiddlers, rather than the *currently* open set.

Fortunately, there is a solution for this type of problem:
http://www.TiddlyTools.com/#ClickifyPlugin
allows you to re-calculate macro parameters whenever a rendered
command is clicked. You simply install the plugin and then add
"clickify" to the front of the macro call.

For your purposes, you can completely skip the <<forEachTiddler>>
action, and use "evaluated parameters" with <<newTiddler>> to generate
the list of open tiddlers. You can also prompt for a story name at
the same time!

Something like this:

<<clickify newTiddler
label:Test focus:title tag:hinzugef gt tag:stunde
title:{{prompt('enter a new story name','MyNewStory')}}
text:{{
var out="";
story.forEachTiddler(function(t){out+="[["+t+"]]\n";});
out;
}}
>>

To generate the list of open tiddlers, the text:{{...}} parameter
defines an empty output variable, then appends tiddlers titles, and
then references that output variable as the last statement processed
within the code, so that the resulting list of titles is "returned" as
the parameter value.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
http://www.TiddlyTools.com/#Donations

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact

Jan Johannpeter

unread,
Nov 10, 2012, 5:59:46 PM11/10/12
to tiddl...@googlegroups.com
Thanks a lot Eric, It works...I have been trying this for a month.
One last wish remains...can i somehow make use of the excludeStoryTag in
the expression

var out="";
story.forEachTiddler(function(t){out+="[["+t+"]]\n";});
out;

to exclude the unwanted tiddlers? To achieve the best of both worlds.

Eric Shulman

unread,
Nov 10, 2012, 7:08:59 PM11/10/12
to TiddlyWiki
> One last wish remains...can i somehow make use of the excludeStoryTag in
> the expression
>
> var out="";
> story.forEachTiddler(function(t){out+="[["+t+"]]\n";});
> out;
>
> to exclude the unwanted tiddlers? To achieve the best of both worlds.

story.forEachTiddler(function(t){
var tid=store.getTiddler(t);
if(!tid||!tid.isTagged("excludeStory"))
out+="[["+t+"]]\n";});

Note use of "!tid" to check to see if the tiddler exists. This is
because the current story may be displaying *shadow* tiddlers -- which
don't "exist" in the normal sense, and are not tagged in any event.

If you want to include only "real" (non-shadow) tiddlers in the
result, change the conditional to:
if(tid&&!tid.isTagged("excludeStory"))

Jan Johannpeter

unread,
Nov 13, 2012, 9:21:46 AM11/13/12
to tiddl...@googlegroups.com
Hello Eric!
Thanks once more for your help, I didn't answer immediately for it took
me some time to understand and get it to work, now its wonderfull...
yippie! Jan

<<clickify newTiddler
label:Zusammenstellung focus:title tag:hinzugefᅵgt tag:Stunde
title:{{prompt('bitte geben Sie einen Namen fᅵr Ihre
Zusammenstellung ein','')}}
text:{{
var out="";
story.forEachTiddler(function(t){
var tid=store.getTiddler(t);
if(tid&&!tid.isTagged("excludeStory"))
out+="[["+t+"]]\n";})
out;
Reply all
Reply to author
Forward
0 new messages