Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
183 views
in Technique[技术] by (71.8m points)

Does Tiddlywiki support hierarchy or namespacing?

I'd like to arrange tiddlers in an outline style of hierarchy with an arbitrary nesting depth and with "clean" tiddler titles.

If I have top-level tiddlers A and B, I'd like to have both A:foo and B:foo (or A/foo and B/foo)

It would be nice to have the titles for both be just Foo, but if the title has to be A:foo or A/foo that's probably fine, though a bit heavy when you get several levels deep and need to add lots of tiddlers:

A/content/objects/users/Sally

A/content/objects/users/Bill

...

If I have to type all that out and keep it straight manually, it's a bit cumbersome. I'd really just like to open the A/content/objects/users tiddler and create a Sally or Bill tiddler from there.

Is there a way to do this (either with or without plugins)?

question from:https://stackoverflow.com/questions/65867014/does-tiddlywiki-support-hierarchy-or-namespacing

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

One way... create a tiddler that will display a "Create New Node" button while you are editing a given node. In my example, let's call it "NewNodeTemplate". Add this tag to it: "$:/tags/EditTemplate". This will force the template to be used while editing any tiddler.

Then place this in the body of the tiddler:

define Concatenate()
$(first)$$(divider)$$(second)$
end

<$set name=first value={{!!namespace}}>
<$set name="divider" filter="[all[current]has:field[namespace]]" value="/" emptyValue="">
<$set name=second value={{!!caption}}>
<$reveal type="nomatch" state="!!caption" text="">
<$button>
<$action-createtiddler $basetitle="New node" namespace=<<Concatenate>>/>
Create New Node
</$button>
</$reveal>

For this to work, you have to manually create the root tiddler/node of the namespace. So, create the "A" root tiddler. In that node create a "caption" field and put "A" in it (or whatever you want to appear in the namespace for A). Once you add the caption field the "Create New Node" button will appear. Click it to create the child node of the namespace. Warning: The node does not automatically appear in the Story River--look on the More/Recent tab in the sidebar. You should have a "New node" tiddler. Open it. It should have a namespace field pre-populated. Next, change the title and add the caption "Foo"---the "Create New Node" button should appear. Repeat.

Customize the EditTemplate tiddler for your own button text and default tiddler title. Plus if you want to automatically open the newly created tiddler in the Story River, I think there are few ways to do that. I'm not a fan of this... but you can add $savetitle="!!tiddler-title" to createtiddler widget, and add the navigate widget to display the new tiddler in the River:

define Concatenate()
$(first)$$(divider)$$(second)$
end

<$set name=first value={{!!namespace}}>
<$set name="divider" filter="[all[current]has:field[namespace]]" value="/" emptyValue="">
<$set name=second value={{!!caption}}>
<$reveal type="nomatch" state="!!caption" text="">
<$button>
<$action-createtiddler $basetitle="New node" $savetitle="!!tiddler-title" namespace=<<Concatenate>>/>
Create New Node
<$action-navigate $to={{!!tiddler-title}}/>
</$button>
</$reveal>

The only thing now is to create a Tiddler that shows the outline that you are looking for.

Does this work for you?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...