Importing a tiddler with a specific name

I’d like to create an interface where one can browse for a favicon and replace the existing one. The $browse widget can be used easily enough to allow selecting and importing an image as a new tiddler. However, I don’t appear to have any control over what this tiddler is called, nor can I (as far as I can tell) even see what the tiddler was imported as in order to rename it.

I tried setting tv-auto-open-on-import to no and adding a $navigate widget inside that variable setting. That prevented $:/Import from popping. But I would still need a way to rename the item being imported – not only can I not figure out how one could trigger some arbitrary action widgets once this step is done, I don’t see any good way to actually do the rename – the contents of $:/Import staging the tiddlers to be imported is multi-level JSON, so TW doesn’t have any built-in user-accessible way to work with that as far as I’m aware.

Any suggestions?

The <$browse> widget needs an update to catch up to some of the newer improvements in <$dropzone>, which would make this easier. If you have the opportunity to open an issue for that, it would be helpful.

Something along these lines might work as a two step process (untested code):

\define set-favicon-actions()
<$action-sendmessage $message="tm-rename-tiddler" from={{{[[$:/Import]links[]first[]]}}} to="$:/favicon.ico"/>
\end

<$navigator>
<$browse/>
</$navigator>
<$list filter="[[$:/Import]plugin-type[import]]">
<$button actions=<<set-favicon-actions>> >
import and set as favicon
<$action-sendmessage $message="tm-perform-import" $param="$:/Import"/>
</$button>
</$list>

A suggestion is building your own drop zone which responds to the dropping of an image intended as a favicon.

Perhaps a simpler way is a view template button that appears on any appropriate image that clones the image and replaces the favicon. Open a newly imported image and click the button.

Existing button svgs can be used with a little modification in recent tiddlywiki versions so the button could do the same for this image standard as well.

Thanks Saq and Tones, I am going to be gone for a couple of days here, but I’ll take a look at your suggestions when I get back.

1 Like

Saq,

I tested your code and it works like a dream (out of the box). I can also see other cases where this pattern will work really well.

So, thanks so much.

I can now see a related method to modify and clone internal svg’s into the favicon as complementary.

I think this is going into my own “visitor” bookmarklet, that I apply to any wiki, so I can give the tab a unique icon, if not save the new favicon on my own wikis.

I am still working through the implications of;
{{{[[$:/Import]links[]first[]]}}}
and future variations of this

and

<$navigator>
<$browse/>
</$navigator>

Wow!

Just to update, this worked perfectly out of the box for me, too. Thanks!