After my last post I considered the possibility of writing a macro for
this, and finished it quicker than I expected. My macro sounds exactly
like the RelativeLinkMacro. But in writing it, I realized I actually
want something different.
In trying to use my macro, I realized I don't want links relative to
the current tiddler, but links relative to a namespace. For example,
if I have a namespace called 'Foo' with several tiddlers within it
'T1', 'T2', 'T3', etc, then all links in those tiddlers should be
relative to the namespace ('Foo'), not themselves.
So the problem has two parts:
1. how to define a namespace
2. how to associate a tiddler with a namespace
Once I have these licked, it should be straightforward to modify my
macro to form links relative to the namespace.
My first thought (which I haven't tried yet) is to use tags. If a
given tiddler has tag 'Namespace:Foo', then any invocation of my macro
within that tiddler should be relative to 'Foo'. An alternate solution
would be to define namespaces externally (i.e. in an other tiddler
somewhere) and then simply use the tag 'Foo' on any tiddler in that
namespace. I think the first option is the simplest and the most clear
because the tags are self-documenting.
The technical question: How do I get the tags of the containing
tiddler? I've tried this:
var otherTiddler = story.findContainingTiddler(place);
var tags = otherTiddler.tags;
But this doesn't work.
Any ideas?
--
Bobman
Try this:
---------------
title = story.findContainingTiddler(place).getAttribute("tiddler");
tiddler = store.fetchTiddler(title);
var tags = tiddler.tags; // somewhat redundant
---------------
HTH.
-- F.
I've been playing with this more this morning, and I am waffling
between what syntax I should use for links and namespaces. I'd
appreciate some input or opinions.
Option 1:
Namespaces are identified with a 'Namespace:Foo' tag (where 'Foo' is
the namespace and 'Namespace:' is a keyword)
Links look like this: <<link [[:subheading]]>> (where 'subheading' is
the name of the tiddler within the namespace)
Option 2:
Namespaces are identified with 'Foo:' (where suffixing a tag with ':'
identifies it as a namespace)
Links look the same.
The issue I have with both approaches is that if I have a tiddler
'Foo', it is not identified with the namespace tags by TW. The second
option almost works, but then I need to name my tiddler 'Foo:', which
doesn't look natural. Ideally, I can just use 'Foo' anywhere, and the
macro knows it is a namespace. That way 'Foo' is both a tag and a
tiddler, and it looks natural when you are reading the page.
Thoughts?
--
Bobman
Maybe I am too pedantic?
--
Bobman
I added your suggestion to my macro, and it works great! Thanks again.
--
Bobman
My (unique?) situation is that we have many projects that are very
similar, with the same modules, etc, but in some cases there are
specific versions of those modules for a given project. My
thought/approach was to allow (virtually) multiple tiddlers with the
same name by using namespaces.
--
Bobman