Is a request for "navigate to draft" justified?

I wanted to create a tiddler and navigate to its draft. I did figure out how to do it but there were some traps along the way that I think should be avoided in the future:

The doc for ActionCreateTiddlerWidget informs that we, inside $action-createtiddler, can access the variables

  • createTiddler-title
  • createTiddler-draftTitle

The doc gives an example for what to put inside a button so it creates a new tid and navigates to it:

<$action-createtiddler $basetitle="foo" $template="HelloThere">
	<$action-navigate $to=<<createTiddler-title>>/>
</$action-createtiddler>

Fair enough.

Before you read on, I want to you tell yourself what you would change if you instead want to navigate to the tiddlers draft.

NO, don’t read more. Look at the above an answer it to yourself.

My guess is that a majority here simply exchanged createTiddler-title for createTiddler-draftTitle. But that navigates to the veiwmode tiddler titled Draft of 'foo' which obviously doesn’t exist!

Instead something very different is required (and this is not in that doc tiddler):

<$action-createtiddler $basetitle="foo" $template="HelloThere">
	<$action-sendmessage $message="tm-edit-tiddler" $param=<<createTiddler-title>>/>
</$action-createtiddler>

This is confusing, so I’m considering requesting a modification to the ActionNavigateWidget like this:

<$action-navigate $to=<<createTiddler-title>> $mode=edit /> (or perhaps =draft)

Is this reasonable? I would say it is a very common use case. (BTW, there is also a $scroll property in $action-navigate… even if I don’t understand what navigation without scrolling even means.)

Thoughts?

Hi @twMat I think this is perhaps a documentation issue. The way that “createTiddler-draftTitle” is documented encourages you to try to what you tried.

However, the fundamental point is that <$action-createtiddler> always creates an ordinary tiddler, and doesn’t put it into edit mode. Thus the challenge was never to navigate to the draft, it was to create a draft (which we called “editing”).

It doesn’t really make sense to extend the <$action-navigate> widget to also be able to edit the tiddler; it just mixes up two functionally unrelated widgets. By that token we should merge all widgets that are commonly used together; our design goal is the opposite: to figure out a set of small, non-overlapping primitives where the power comes from using them in combination.

1 Like

Thanks for your reply Jeremy.

OK. Then, as you say, it is a doc matter. - I did look into that but it turns out that the doc tiddler is a bit tricky to edit: Each example is a separate tiddler (plus they seem to be invoked in different ways -!?)

Very interesting. It sounds like a huge project. Basically trying to identify the primitive use cases an “re-group” them to re-make the widgets? (…but backward compat? …or do you mean deprecating the existing ones? I don’t quite understand. And who is capable of identifying the primitive use cases? Or are they apparent now after 15+ years?)

Sorry for the confusion. I was trying to say that this proposal would be the same as the absurd argument that we would merge all widgets that are commonly used together.

LOL! It did sound very “ambitious”. Sorry for my misinterpretation.

What then is a typical use case for the drafttitle variable? Maybe someone could give a short example?

I am not convinced that there are many good ones; I think the motivation for adding this support was symmetry with the existing $savedrafttitle attribute, to make it easier to migrate existing code.

1 Like

All right, I’m willing to accept any example of its use, even a mediocre one. I have no idea how to use it at all (and I didn’t have for the previous $safedrafttitle).
:frowning_face:

As Jeremy pointed out the createTiddler-draftTitle is there for feature parity with the old parameters.

There are some rare usecases for this variable, but I don’t want to show them. Those examples would cause more problems as they solve.

The example that Mat gives in the OP is the way to go and I’ll try to add it to docs. There is an issue at Github already. [PR] Add example #5 to ActionCreateTiddlerWidget.tid · Issue #7200 · Jermolene/TiddlyWiki5 · GitHub

1 Like

At the time the docs was written. TW v5.1.22 I didn’t know a better way to make it work.

The goal of the examples are

  • Show code, that is easy to understand for new users
  • It needs to be possible to copy / paste the code into a new tiddler and it has to work
  • The example shown should create a button that also works without the need to copy paste anything

Improved contributions are very welcome.


Why it is as it is at the moment.

Clicking the example buttons also activate to the “Recent” tab in the right sidebar, so the users can see, that the tiddlers are created. … While testing the function and documentation I did hit the button several times and there was no feedback. … That’s why the extra code.

… This extra code doesn’t really belong to the action-createtidddler widget, that’s why the example code shown and the code executed is slightly different. As I did create the docs I thought it would be the best way to create working examples with feedback.

I thought, if users want to know, how to activate the Recent tab, they can open the example tiddlers and can see, what’s going on.

I’m pretty sure that if I did show the extra code, there would be users, which would have reported issues. … I had to make a decision, knowing it always is the wrong one.

The reason, that every example is a separate tiddler is the \define testCreate() pragma at the beginning. Using button-actions that way is “best practice”. But pragmas must be at the top of a tiddler, so it’s impossible to use them with the current doc-macros.


If someone can make a doc-macro that is able to

  • handle pragmas,
  • create a plain text code-preview
  • create working HTML output
  • avoid code duplication for easy maintainability

And where the whole example text is in the middle of other wikitext, then let us know, or better create a PR at GitHub.

Hey amigo, I wasn’t really complaining, I just said it is tricky to edit, which it is. Your reasoning probably made full sense.

Maybe you should announce this request more publicly (and elaborate a bit on why each bullet is desirable)?

Yea, … All the doc-macros should be improved with the new functionalities available now. Most of the doc-macros are 8 years old

They have been a big improvement, but they also have their flaws.

There is a new PR [DOC] Improve ActionCreateTiddlerWidget documentation by pmario ¡ Pull Request #7202 ¡ Jermolene/TiddlyWiki5 ¡ GitHub and a

new preview TiddlyWiki — a non-linear personal web notebook … Where the last example is a new one

1 Like

I came across the variables createTiddler-title and createTiddler-draftTitle when they were added to the createtiddler widget and had no idea what the draft title was about, and ignored it.

As a result I quickly added the edit-tiddler action to my own documentation and used that. As @twMat documented.

   <$action-createtiddler $basetitle="" tags="" text="">
      	<$action-sendmessage $message="tm-edit-tiddler" $param=<<createTiddler-title>>/>
    </$action-createtiddler>
  • Improve the documentation and change nothing else would be my suggestion.

The simplest approach is to add this example to the documentation at the top even before the navigate only version, as it is possibly the most common use (is for me at least), and possibly deprecate ‘createTiddler-draftTitle’.

However I do think a new documentation tiddler that summarises the whole subject is the best approach, including;

  • Be found when searching for “new tiddler” currently the only title that comes up is is WidgetMessage: tm-new-tiddler, a challenge for new users.
  • Using the UI to create and edit as in “Creating and editing tiddlers”
    • Setting the default new tiddler title
    • Creating tiddlers from missing links
  • Choosing between
    • tm-new-tiddler message on buttons
    • tm-new-tiddler message on within sendmessage
    • using actioncreate tiddler widget for
      • silent creation
      • create and open in story (no navigation)
      • and navigate to
      • and open for edit

This same document tiddler could also point to “Adopt a Titles Policy” which could be expanded to provide guidance on various title strategies.

  • New with trailing increment
  • Setting the default new tiddler/Jounal title(s) (again)
  • Making up names
  • Using the system namespace
  • The problem with compound titles
    etc…

I would write such a documentation tiddler, but I do not know how to submit a new documentation tiddler from TiddlyWiki.com which is the method I currently use.

  • In my own documentation I place the pragma at the top for use and present a copy later in the text;

Resulting in
Snag_2b4871

Yes, but that duplicates the example code shown and the code used. … So it makes maintenance more complex and error prone. That’s the reason why we have the eg: <<.example ... macros. They only contain the code once and show the plain-text version and the rendered version.

Thanks for this. I’ll close my issue. BTW, I note that the template that is used contains the text:

This is a tiddler used as a template in: [[ActionCreateTiddlerWidget Example 3]]

I understand that but found it a necessary evil.

However

  • I have looked into it further and a solution is as follows

Create An example code tiddler

\define macro(param)
content
\end
<<macro "param">>

Then in the documentation tiddler

\import [[Example code]]
;Description
* blah

<$codeblock code={{Example code}} />

;Result
<<macro "param">>

Resulting in

  • With code only in one place, the exception being the macro call.
  • it may be difficult to make a documentation macro for this but perhaps a template could be created.