Mark,
Great work, I had a hunch it could be done, and you got there 1st, "good on
ya".
It is quite elegant, and I will re-engineer it for a global macro and named
templates. Thanks very much.
I will keep it in my own repository and when I get around to building a
community website, I will put it there however I think we can take this and
modularise it differently.
What interests me is, if you include text in the <<fieldsvalues>> you have
actually stored a tiddler in a field. This allows us to store multiple
tiddlers in one tiddler using its fields, or in a data tiddler (Aside from
JSON files) and generate tiddlers from these in addition to cloning.
By providing $(attribs)$ to the buttonactions action-createtiddler we can
leverage its $basetitle $savetitle and $timestamp so we can also provide
the naming standard, get the title of the resultant tiddler and decide if
it is time stamped as a clone or a new tiddler.
If we can generalise this effectively it makes a number of otherwise
difficult things quite easy. See the inspiration that has followed below.
I am thinking of the following macros,
1. One to pack the current or named tiddler into a "parametised tiddler"
including or excluding details as desired. Field or variable.
2. One to unpack (or create a tiddler) from a "parametised tiddler" to a
new tiddler including or excluding details as desired
The following use the 1st & 2nd or will be options of them
3. One to do both 1 and 2 at the same time (as we have discussed in this
thread)
4. One to unpack a "parametised tiddler" to "the current" tiddler
including or excluding details as desired
5. One to do both 1 and 4 at the same time (add/replaces fields from
another tiddler)
You have inspired me to think of then using the above to support,
- Archiving multiple tiddlers in one (packing tiddlers)
- Provide an unpack as well Generate a set of different tiddlers from
one tiddler
- Making a copy of a tiddler inside one of its own fields
- Creating a tiddler with its own unpack button
- Creating a tiddler than can generate multiple sets of tiddlers with
unique names eg; A New Project may have 5 tiddlers
- View all project items
- Create that projects items
- Edit a projects items details
- etc..
- Using a stored macro tiddler and generating a customised macro tiddler
with custom settings.
- Using a set of packed tiddlers for Wizards, demos, templated processes
etc...
- and more
I love a good algorithium
Regards
Tony
On Sunday, 12 August 2018 04:56:19 UTC+10, Mark S. wrote:
>
> This code is deceptively short, but it appears to do what you want:
>
> \define catvalue() <$text text="""$(value2)$"""/>
> \define fieldsvalues()
> <$list filter="[all[current]fields[]] -[[tiddler-template-caption]]
> -[[text]]" variable="field"><$set name="value2" tiddler=<<currentTiddler>>
> field=<<field>> emptyValue=""><<field>>="<<catvalue>>" </$set> </$list>
> \end
> \define buttonactions() <$action-createtiddler $basetitle={{!!title}} $(
> attribs)$ text={{!!text}} />
>
> <$wikify name="attribs" text=<<fieldsvalues>> >
>
> <$button actions=<<buttonactions>>>Create clone
> </$button>
> </$wikify>
>
>
> I say deceptively because of all the wrong paths I went down before
> getting to it. It turns out that actioncreatetiddlerwidget has this weird
> thing that when you attempt to add fields to a just-created tiddler it
> makes a perfect clone ---- but wipes out the original! If real, that seems
> like a bug to me. So that path didn't work.
>
> You'll be happy to know that part of this solution requires the
> wikify-a-list trick you demonstrated in another thread. Note that the text
> field is handled separately in order to avoid recursion.
>
> This code needs to be "remembered" or stored somewhere, but not sure where.
>
> HTH
> -- Mark
>
>
> On Thursday, August 2, 2018 at 7:46:30 PM UTC-7, TonyM wrote:
>>
>> Folks/Team,
>>
>> I am creating a tool to create tiddlers from template tiddlers and will
>> share today (if I resolve this).
>>
>> However to do so I am using the following to clone the tiddler to a new
>> tiddler name eg "task 1" and open for edit (which the user then modifies)
>>
>> \whitespace trim
>> <$button message="tm-new-tiddler" param=<<currentTiddler>> tooltip="Clone
>> this 'template'" aria-label="Clone this 'template'" class=<<tv-config-
>> toolbar-class>> >
>> <$action-setfield $field=template-source $value=<<currentTiddler>>/>
>> *<$action-deletefield $field=tiddler-template-caption/**>*
>> {{$:/core/images/clone-button}}
>> </$button>
>>
>>
>> - I identify which tiddlers are templates by the existence of the
>> field *tiddler-template-caption*
>> - During the clone which works perfectly the tiddler-template-caption
>> also
>> gets cloned
>> - Unfortunately this means the new tiddlers now appear in the list of
>> tiddler templates
>> - In the above code *<$action-deletefield
>> $field=tiddler-template-caption/*> deletes the field from the
>> template tiddler not the new one.
>> - How can I delete this field from the new tiddler with the yet to be
>> determined name?
>>
>> I believe I need to use message="tm-new-tiddler" param=<<currentTiddler>>
>> rather than ActionCreateTiddlerWidget to clone the tiddler, where I would
>> use the $savetitle.
>> I want the clone to work regardless of the fields and their content so I
>> do not want to explicitly create the fields, I just want them to come from
>> the template tiddler except for *tiddler-template-caption.*
>>
>> Note: <$action-setfield $field=template-source
>> $value=<<currentTiddler>>/> updates the template tiddler before the clone,
>> this saves the user doing it.
>>
>> How can I trigger *<$action-deletefield $field=tiddler-template-caption/**>
>> on the new tiddler after it is named/created without an additional
>> "trigger"*
>>
>> Thanks
>> Tony
>>
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/3ca0bdb7-2f48-471b-8aed-9a74762f3ec8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.