pseudo namespaces

166 views
Skip to first unread message

bopaige

unread,
Jan 30, 2008, 3:55:10 PM1/30/08
to TiddlyWiki
I have started a new job and am starting a new TW for notes on all the
new projects. I'm wondering if TW could be extended to support the
concept of namespaces for tiddlers. Perhaps there is even a plugin for
this already.

The new challenge in my new job is that we have many (say 10-15, but
growing) projects that are all very similar but not identical. Thus,
if I have a tiddler called "LoadData", I may need to specialize it for
a given project, i.e. "AA:LoadData". But I also may want to keep the
global one.

My idea (that I shamelessly stole from DokuWiki) is to use a ':' as a
namespace delimiter (like my example above). The only change required
to TW would be to *not* display the namespace qualifier when displayed
in the body of a tiddler. The namespace should be displayed in a
header, when editing, and in a tooltip, etc.

Is there some easy way to override how all tiddler links are built so
I can strip off the namespace, if it exists?

--
Bobman

Kashgarinn

unread,
Feb 1, 2008, 2:47:03 AM2/1/08
to TiddlyWiki
Check out monkeypirate tiddlywiki with its tagging system, should be
what you want.

wolfgang

unread,
Feb 1, 2008, 7:23:50 AM2/1/08
to TiddlyWiki
Hi,

> > ... I'm wondering if TW could be extended to support the
> > concept of namespaces for tiddlers. Perhaps there is even a plugin for
> > this already.

beside Kashgarinn's sound advise, an untested possibility: Maybe
RelativeLinkMacro would do that. Here its explanation:

> > It simply adds the current tiddler to the desired pretty link - think of
> > it as relative paths:
> > So if you put
> > <<relLink "_phone">>
> > into the tiddler "Bob", it will link you to "Bob_phone".
> > However, if you put it into the tiddler "John", the link will take you
> > to "Johne_phone".

http://devpad.tiddlyspot.com/#RelativeLinkMacro
http://groups.google.com/group/TiddlyWiki/browse_thread/thread/15b40b8b21af7120/ee02ea7780dba039?lnk=gst&q=RelativeLinkMacro#

> > ... The only change required
> > to TW would be to *not* display the namespace qualifier when displayed
> > in the body of a tiddler. The namespace should be displayed in a
> > header, when editing, and in a tooltip, etc.

Maybe ReplaceTiddlerTitle by TiddlyTools could help here? This
requires also InlineJavascriptPlugin

http://www.tiddlytools.com/#ReplaceTiddlerTitle
http://www.tiddlytools.com/#InlineJavascriptPlugin

W.

Bob Paige

unread,
Feb 1, 2008, 9:28:39 AM2/1/08
to Tiddl...@googlegroups.com
Thanks for the tips. It looks like I've recreated someone else's work
then. I think I will continue with my own macro as I have determined
my needs are different, but I do have one technical question about how
to accomplish it. My question is at the end of my post.

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

FND

unread,
Feb 1, 2008, 9:44:15 AM2/1/08
to Tiddl...@googlegroups.com
> How do I get the tags of the containing tiddler?

Try this:
---------------
title = story.findContainingTiddler(place).getAttribute("tiddler");
tiddler = store.fetchTiddler(title);
var tags = tiddler.tags; // somewhat redundant
---------------

HTH.


-- F.

Bob Paige

unread,
Feb 1, 2008, 10:08:18 AM2/1/08
to Tiddl...@googlegroups.com
Thanks! That works!

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

Eric Shulman

unread,
Feb 1, 2008, 1:00:27 PM2/1/08
to TiddlyWiki
> 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.

Perhaps you could use a technique common to TagglyTagging by creating
a tiddler, tagged with "Foo", and then creating the [[Foo]] tiddler
itself, and tag THAT with "namespace".

Then, to determine the namespace of a given tiddler object:

var ns=""; // assume no namespace
for (var t=0;t<tiddler.tags.length;t++)
if (store.getTiddler(tiddler.tags[t]).isTagged("namespace")
{ ns=tiddler.tags[t]; break; }


HTH,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

Bob Paige

unread,
Feb 1, 2008, 2:00:02 PM2/1/08
to Tiddl...@googlegroups.com
I considered something like this (thanks for the sample code) but I
thought it would be too expensive to constantly look up the tiddlers
and the tags.

Maybe I am too pedantic?

--
Bobman

Bob Paige

unread,
Feb 1, 2008, 2:22:23 PM2/1/08
to Tiddl...@googlegroups.com
Eric,

I added your suggestion to my macro, and it works great! Thanks again.


--
Bobman

Eric Shulman

unread,
Feb 1, 2008, 2:27:06 PM2/1/08
to TiddlyWiki
> > var ns=""; // assume no namespace
> > for (var t=0;t<tiddler.tags.length;t++)
> > if (store.getTiddler(tiddler.tags[t]).isTagged("namespace")
> > { ns=tiddler.tags[t]; break; }


> I considered something like this (thanks for the sample code) but I
> thought it would be too expensive to constantly look up the tiddlers
> and the tags.
>
> Maybe I am too pedantic?

It's ALWAYS good to be mindful of the computational overhead...

Here's another way to do the namespace lookup that should be more
efficient:

var ns=""; // assume no namespace
var tids=store.getTaggedTiddlers("namespace");
for (var t=0;t<tids.length;t++)
if (tiddler.tags.contains(tids[t].title) { ns=tiddler.tags[t];
break; }

and, if that is still too costly, there's a different approach
entirely:

Define the namespaces in a single tiddler, using a whitespace-
separated list, e.g.:

[[NameSpaces]]
Foo Bar Baz

Then, read that tiddler content instead of doing a lookup to find all
the tagged tiddlers:

var ns=""; // assume no namespace
var spaces=store.getTiddlerText("NameSpaces").readBracketedList();
for (var s=0;s<spaces.length;s++) if (tiddler.isTagged(s)) { ns=s;

Eric Shulman

unread,
Feb 1, 2008, 2:29:14 PM2/1/08
to TiddlyWiki
errata:

In the first alternative code example,

if (tiddler.tags.contains(tids[t].title) { ns=tiddler.tags[t];

should be:

if (tiddler.tags.contains(tids[t].title) { ns=tids[t].title;

-e

Eric Shulman

unread,
Feb 1, 2008, 2:31:01 PM2/1/08
to TiddlyWiki
errata #2:

in the 2nd alternative code example:

for (var s=0;s<spaces.length;s++) if (tiddler.isTagged(s)) { ns=s;

should be:

for (var s=0;s<spaces.length;s++) if (tiddler.isTagged(s))
{ ns=spaces[s];

-e

Kashgarinn

unread,
Feb 12, 2008, 5:36:40 AM2/12/08
to TiddlyWiki
I still think you could have saved yourself alot of work and used the
tagglytagging plugin.

Basically each tag can be a tiddler as well as a tag, so any kind of
tree structure can be created, and the information regarding placement
in the structure stays with the tiddler itself.

I recommend checking it out.

K.

Bob Paige

unread,
Feb 12, 2008, 8:44:00 AM2/12/08
to Tiddl...@googlegroups.com
I have (and still do) use TagglyTagging. But this does not resolve the
problem of multiple tiddlers with the same name.

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

Kashgarinn

unread,
Feb 12, 2008, 9:50:36 AM2/12/08
to TiddlyWiki
ah, I see.

I wouldn't have tried to solve it like that though, I'd have done it
differently. Basically, I'd have "module1" tiddler tagged with the
projects they belong to, and then I'd tag "default contents of
module1" - "module1 for project X" - "module1 for project Y" with the
"module1" tag

Both giving you an easily linkable "mofule1" for the projects and an
overview of the different module1 types, that is, if I'm understanding
you correctly.

K.

On Feb 12, 1:44 pm, "Bob Paige" <bobpa...@gmail.com> wrote:
> I have (and still do) use TagglyTagging. But this does not resolve the
> problem of multiple tiddlers with the same name.
>
> 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
>

Nailson

unread,
May 2, 2012, 6:22:00 PM5/2/12
to tiddl...@googlegroups.com
Hi there.

I was researching about how to have multiples tiddlers with same name and I found your post (I know, it's a little bit old).
I'm facing the same problem as yours.
Is there any plugin for that?
Did you find a solution? If so, would you mind to share?

P.S.? In www.wikimatrix.org is saying that is possible to have namespaces in TiddlyWiki using plugin, but I couldn't find any.

Thanks a lot.
Nailson
Reply all
Reply to author
Forward
0 new messages