An idea for linking

In my projects, I put the data in system tiddlers with name like $:/user/project/cat/event/72. These can be user tiddler in the sense that their content is of the very same kind of logic than non-system tiddlers.

In one case for instance, this content is a description of a use case scenario and in an other it’s a description of what went wrong in a post. If the include image ef samples of code, the go to child tiddlers with name like $:/user/project/cat/event/72/bug.png and sometimes it can get 2 or 3 level deep. So fine. But to transclude the latter, I must code to explicitly $:/user/project/cat/event/72/bug.png and also for some of them I copy the whole back to an other points (that’s the scenario and the pages to be tested in my real life case). And thus I have to copy all the tiddlers (I can’t avoid it) and change the code within to alter reference s like$:/user/project/cat/event/72/bug.png to $:/user/project/cat/event/96/bug.pngwhich is not difficult but tedious and complexify duplication code.

What if we could have a way to use $:./bug.png in tiddler $:/user/project/cat/event/72 to be internally translated to $:/user/project/cat/event/72/bug.png? It would also facilitates the initial writing!

I’m not sure if I understand what you want.

But what about using the system tiddlers as a prefix like: [prefix[$:/user/project/cat/event/72/]] ?
Mind the slash foward at the end. It will return everything but the system tiddler itself.

The other way around would be to add a suffix with addsuffix operator to the system tiddler.
[$:/user/project/cat/event/72]addsuffix[/bug.png]]
Again mind the slash forward at the beginning of the suffix.

Your current tiddler:

$:/user/project/cat/event/72

You want

$:./bug.png to map to $:/user/project/cat/event/72/bug.png

Right?

The solution would be to have a macro like

<<link-local "bug.png">>

which then maps to

$:/user/project/cat/event/72/bug.png

Would that accomplish the result?

I use prefix in many places of my codes already. You can’t escape it with that kind of organization.

But what I want is to operate like if a real filesystem. In html, having a linkk to bug.png would be the way to go. I feel it should be the same for system tiddler, but with ./ to make it easy on the parser and still differentiate it to linking to user tiddler. Thus $:./bug.png is my proposition of a solution for this little problem.

It would bring a solution, but when I transclude, I need an other macro. And an other one for image, whereas the are wikitext for coding all that . And since wikitext and macro are not mixing very well, a local macro would not be as useful as it ,ould have been.

So I don’think it’s the correct way to address this problem.

A (simplified!) implementation could be: when encountering $:./some/stuff, transform it in <<local "$:./some/stuff">> or {{{ [[$:./some/stuff]local[]] }}} and the result would be what I want ($:/user/here/some/stuff) if current tiddler is a system tiddler ($:/user/here in this example) or left unchanged otherwise ($:./some/stuff - which is not referencing a system tiddler and that’s pretty well what is needed indeed).

First;

  • Have a look at the lookup operator as its about adding prefixes and returning content from tiddlers.
  • Consider @pmario uni-link/alias plugin as a possible avenue for something similar.
  • Consider having both a data tiddler and another tiddler with a different title that transcludes the data tiddler.

Off line I am experimenting with the equivalent of file system folder “look a likes” in tiddlywiki and there are a lot of opportunities, where I seperate the folder from the tiddlers within them (even although the folders are tiddlers).

  • However with tiddlywiki you can both have your cake (place things in folders) and eat it too (use simple names).

What you ask for can be designed, well at least something very similar already. The hard part is trying to design a generic solution that will be applicable to make user cases and to taking it all the possibilities that can branch from such a solution.

Techniques that may apply;

  • Extract a path prefix and assign it to a variable eg event-prefix=$:/user/project/cat/event/72
    • Address everything with this event-prefix Applied
    • perhaps if the "reference given has the prefix / such as in /bug.png you apply the prefix. try lookup<event-prefix>

I could go on for hours, but rest assured there are many ways to introduce similar features.

May be you try this:

A global name-space and macro definition

title: my-namespace-definitions
tags: $:/tags/Macro

\define ns-img() name/space/x/
\define img-text(title) <$text text={{{ [<ns-img>][<__title__>] +[join[]] }}}/>
\define img-link(title) <$link to={{{ [<ns-img>][<__title__>] +[join[]] }}}><<__title__>> </$link>
\define img(title) <$transclude tiddler={{{ [<ns-img>][<__title__>] +[join[]] }}}/>

Using the macros

<<img-text "test.png">>

<<img-link "test.png">>

<<img "test.png">>

I have difficulties with lookup.

Say the tiddlers I want to use are named /user/data/round/1$:/user/data/round/5. They are dictionnary where keys are t1, t2, t3. (note that for this example, my tiddlers are no more system tiddlers so no worry about semicolon)

I want to get all t2 from round 1 to 3.

So far I have:

{{{ [range[3]addprefix[/user/data/round/]getindex[t3]] }}}

Now, say I want to use lookup to get the same effect.

{{{ [range[3]lookup::index[/user/data/round/],[t2]] }}}

This is indeed hard to understand this is what is to be coded from the docs. I tahnk you for hinting me on lookup. May I hope that my example could be included in the doc (I can try to propose it)? It could surely help an other one sooner or later.

This being said, I’m not too sure about what you are telling me to do. I will have to get an other look at it later.