TiddlerAlias Plugin (Beta 1) released

32 views
Skip to first unread message

Udo Borkowski

unread,
Sep 21, 2006, 9:55:42 AM9/21/06
to Tiddly...@googlegroups.com
I just released the first beta of the new TiddlerAlias plugin:
http://tiddlywiki.abego-software.de/Beta.html#%5B%5BTiddler%20Alias%20Example%5D%5D%20TiddlerAliasPlugin

With this plugin you can reference a tiddler through an alias (or even
through many aliases). E.g. a tiddler "William Shakespeare" may also be
referenced as {{{[[Shaxper]]}}}.

When editing a tiddler you may enter alternative names for the tiddler
in the "Alias" field (below the tags field), similar to the way you
enter tags. You may even specify multiple alias names, separated by
spaces. Alias names containing spaces must be written as {{{[[...]]}}}.


You find the plugin at the new "Beta Area" of abego Software:
http://tiddlywiki.abego-software.de/Beta.html

Feedback is highly appreciated.

Have fun,


Udo

----------
Udo Borkowski
http://www.abego-software.de


Saq Imtiaz

unread,
Sep 21, 2006, 10:06:10 AM9/21/06
to Tiddly...@googlegroups.com
On 9/21/06, Udo Borkowski <Udo.Bo...@gmx.de> wrote:

I just released the first beta of the new TiddlerAlias plugin:
http://tiddlywiki.abego-software.de/Beta.html#%5B%5BTiddler%20Alias%20Example%5D%5D%20TiddlerAliasPlugin

With this plugin you can reference a tiddler through an alias (or even
through many aliases). E.g. a tiddler "William Shakespeare" may also be
referenced as {{{[[Shaxper]]}}}.

When editing a tiddler you may enter alternative names for the tiddler
in the "Alias" field (below the tags field), similar to the way you
enter tags. You may even specify multiple alias names, separated by
spaces. Alias names containing spaces must be written as {{{[[...]]}}}.

Hey Udo,
Havent looked at the actual code but it looks good!
How about setting up a preferred alias, and then using that for the displayed title?

For example, if an alias is wrapped in  {{ }} it can be considered preferred, and if a preferred alias exists, its used for the title.

Just an idea....
Cheers,
Saq

Ken Girard

unread,
Sep 21, 2006, 12:15:42 PM9/21/06
to TiddlyWikiDev
Neat, but I get two "William Shakespeare" tiddlers when I click on both
links is a little odd.
Wait, problems are spotted.
OK, just realized it is even worse then I thought and I am guessing it
is an IE thing (as I think you would have seen it other wise). It lets
me open the "William Shakespeare" link and work that just fine, but the
"Shaxper" link I can not 'view' or 'close' in the normal fashion. When
I try to view it opens a different "William Shakespeare" tiddler. If I
then click close on the "Shaxper" version of the tiddler it closes the
other one.

Ken Girard

Udo Borkowski

unread,
Sep 21, 2006, 4:56:04 PM9/21/06
to Tiddly...@googlegroups.com
>
>
>Neat, but I get two "William Shakespeare" tiddlers when I click on both
>links is a little odd.
>
That is a bug. Will be fixed in the next "beta" ;-)

Udo

MilchFlasche

unread,
Sep 21, 2006, 7:19:22 PM9/21/06
to TiddlyWikiDev
Nice sharing! Udo! Yet another yearned feature! It can really be
helpful.

Udo Borkowski

unread,
Sep 22, 2006, 3:35:34 AM9/22/06
to Tiddly...@googlegroups.com
As it turns out with the alias approach we have a nice to avoid doing all this stuff with displayTitle/preferedTitle etc that was suggested in another thread (http://groups.google.com/group/TiddlyWikiDev/browse_frm/thread/b4553cd61d271144/8c4d221586405f99#8c4d221586405f99, http://trac.tiddlywiki.org/tiddlywiki/ticket/176).

I.e. with the alias feature it is possible to "translate" tiddlers with "magic names" (like "AdvancedOptions" or "OptionsPanel").

Here the idea:

Assume you want to translate the tiddler "AdvancedOptions".

  • Rename the tiddler "AdvancedOptions" to the new name (e.g. "WeitereOptionen").
  • Add the alias "AdvancedOptions" to the tiddler.
  • Done.
This way also code that is referencing the "AdvancedOptions" tiddler will get the (renamed) tiddler, e.g. to add new options.

So it looks like once can avoid implementing this whole "displayTitle" idea and just fall back to the "alias" feature. The beauty of this is that we don't have to deal with the "title" field, a very central thing in TW. Changing things around these central things always have the danger of breaking old (plugin) code. E.g. plugins directly manipulating the title field may have problems when a "displayTitle" is defined. And for the end user things are simple again: the "title" is the stuff displayed as the "title".


But before we really can use this "alias" feature for translation we need a way to define fields for shadow tiddlers (not just their text) because in a translation of a shadow tiddler we want to set the "alias" field, too.



Udo

----------
Udo Borkowski
http://www.abego-software.de




Simon Baird

unread,
Sep 22, 2006, 9:53:26 AM9/22/06
to Tiddly...@googlegroups.com
On 9/22/06, Udo Borkowski <Udo.Bo...@gmx.de> wrote:

But before we really can use this "alias" feature for translation we need a way to define fields for shadow tiddlers (not just their text) because in a translation of a shadow tiddler we want to set the "alias" field, too.

I think also it might be useful to put tags on shadow tiddlers.

Simon.

Ps, what's the purpose of this for plugins:

(function() {

// plugin code here...

})();



--
Simon Baird <simon...@gmail.com>

Udo Borkowski

unread,
Sep 22, 2006, 10:54:32 AM9/22/06
to Tiddly...@googlegroups.com
I think also it might be useful to put tags on shadow tiddlers
That's what I thought, too. So I guess we should have a way to assign values to all kind of shadow tiddler fields, both standard and extended ones.



Ps, what's the purpose of this for plugins:

(function() {

// plugin code here...


})();

This defines an anonymous function and directly calls it (i.e. the functions body is executed). The main purpose is to "hide" variables and functions from the "global scope", to avoid poluting the "global namespace". This is mainly necessary because of the way JavaScripts handles "scoping".

In languages like Java or C if you define a variable in a block (something like "{....}"), e.g:

if (i > 10) {
    int n = 0;
    ...
}

the variable is defined "locally" in the block and is not visible outside of the block.

In JavaScript this is not the case. E.g.:

if (i > 10) {
    var n = 0;
    ...
}

The variable n is "global" even it is declared inside the {...}.

The only thing that opens a new scope is a function definition.

E.g.:
(function() {
var myVar = 123;

function myFunc(x) {
    return x*myVar;
}

window.globalFunc = function(y) {
    return 2*myFunc(y);
}
})();


Outside of the anonymous function you cannot see myVar nor myFunc, but you may call globalFunc.


Especially when writing plugins this is a useful approach since it reduces possible conflicts with other plugins. Also it avoids that someone accesses the "internals" of you code, making it easier for you to create compatible future versions, since you don't need to be afraid someone is using some "implementation detail" of you code.


Udo

----------
Udo Borkowski
http://www.abego-software.de




Saq Imtiaz

unread,
Sep 22, 2006, 11:03:24 AM9/22/06
to Tiddly...@googlegroups.com
On 9/22/06, Udo Borkowski <Udo.Bo...@gmx.de> wrote:
Ps, what's the purpose of this for plugins:

(function() {

// plugin code here...


})();

This defines an anonymous function and directly calls it (i.e. the functions body is executed). The main purpose is to "hide" variables and functions from the "global scope", to avoid poluting the "global namespace". This is mainly necessary because of the way JavaScripts handles "scoping".

Simon, an example is the error Clint reported with SelectThemePlugin and TW2.1, which I did a quick fix for not long ago. We have a for (var n in object) loop there that is globally declared, and was causing conflicts.... in a future rewrite it needs to be wrapped in a function.

Saq

Udo Borkowski

unread,
Sep 22, 2006, 3:10:37 PM9/22/06
to Tiddly...@googlegroups.com
I just released Beta 2 of the TiddlerAliasPlugin (http://tiddlywiki.abego-software.de/Beta.html#TiddlerAliasPlugin).

It fixes the bug reported by KenGirard. Thanks Ken.

About the Plugin

With the TiddlerAliasPlugin you can reference a tiddler through an alias (or even through many aliases). E.g. a tiddler "William Shakespeare" may also be referenced as [[Shaxper]].


When editing a tiddler you may enter alternative names for the tiddler in the "Alias" field (below the tags field), similar to the way you enter tags. You may even specify multiple alias names, separated by spaces. Alias names containing spaces must be written as [[...]]




Have fun,

Udo

----------
Udo Borkowski
http://www.abego-software.de



Udo Borkowski

unread,
Sep 24, 2006, 11:07:28 AM9/24/06
to Tiddly...@googlegroups.com
I think also it might be useful to put tags on shadow tiddlers

I just created a ticket "Support field values for shadow tiddlers" (http://trac.tiddlywiki.org/tiddlywiki/ticket/183) to cover this.

Udo

Simon Baird

unread,
Sep 24, 2006, 9:07:41 PM9/24/06
to Tiddly...@googlegroups.com
Okay that makes sense. I have a suggestion then:
 
line 6990 in function loadPlugins()
 
// window.eval(tiddler.text);
window.eval("function(){\n"+tiddler.text+"\n}();\n");
 
Would that break something?
 
Simon.
 
On 9/23/06, Saq Imtiaz <lew...@gmail.com> wrote:
On 9/22/06, Udo Borkowski <Udo.Bo...@gmx.de > wrote:
Ps, what's the purpose of this for plugins:

(function() {

// plugin code here...


})();

This defines an anonymous function and directly calls it ( i.e. the functions body is executed). The main purpose is to "hide" variables and functions from the "global scope", to avoid poluting the "global namespace". This is mainly necessary because of the way JavaScripts handles "scoping".

Simon, an example is the error Clint reported with SelectThemePlugin and TW2.1, which I did a quick fix for not long ago. We have a for (var n in object) loop there that is globally declared, and was causing conflicts.... in a future rewrite it needs to be wrapped in a function.

Saq

Udo Borkowski

unread,
Sep 24, 2006, 9:17:40 PM9/24/06
to Tiddly...@googlegroups.com
Would that break something?
I bet!

If I recall correctly Jeremy tried something similar in an attempt to pass some "parameter" to the plugin currently loaded. But this change broke some code and was rolled back. (Anyone got some details?)


Udo

----------
Udo Borkowski
http://www.abego-software.de



Simon Baird wrote:

Saq Imtiaz

unread,
Sep 25, 2006, 3:42:51 AM9/25/06
to Tiddly...@googlegroups.com
On 9/25/06, Udo Borkowski <Udo.Bo...@gmx.de> wrote:
Would that break something?
I bet!

If I recall correctly Jeremy tried something similar in an attempt to pass some "parameter" to the plugin currently loaded. But this change broke some code and was rolled back. (Anyone got some details?)

LostCreation

unread,
Oct 19, 2006, 12:50:46 AM10/19/06
to TiddlyWikiDev
Udo, this is a great plugin. Any idea if you can have the references to
[[TiddlerAlias]] merged with the references to [[Tiddler]]? Right now,
a tiddler that links to [[TiddlerAlias]] won't show up in the
references for [[Tiddler]]. So if we want to be able to track
references to [[TiddlerAlias]] we have to use pretty links (i.e.
[[TiddlerAlias|Tiddler]]).

Udo Borkowski wrote:
> I just released Beta 2 of the TiddlerAliasPlugin
> (http://tiddlywiki.abego-software.de/Beta.html#TiddlerAliasPlugin).
>
> It fixes the bug reported by KenGirard. Thanks Ken.
>

> *About the Plugin*

Udo Borkowski

unread,
Oct 19, 2006, 2:19:58 AM10/19/06
to Tiddly...@googlegroups.com
>> Any idea if you can have the references to
>> [[TiddlerAlias]] merged with the references to [[Tiddler]]?

Sounds like a good idea. I will check if I can introduce it in a new version of the plugin. Since not everybody will want this behaviour I will probably make it optional

Thanks,


Udo

----------
Udo Borkowski
http://www.abego-software.de




On 10/19/06, LostCreation <lostcr...@gmail.com> wrote:

Udo, this is a great plugin. Any idea if you can have the references to
[[TiddlerAlias]] merged with the references to [[Tiddler]]? Right now,
a tiddler that links to [[TiddlerAlias]] won't show up in the
references for [[Tiddler]]. So if we want to be able to track
references to [[TiddlerAlias]] we have to use pretty links (i.e.
[[TiddlerAlias|Tiddler]]).

Udo Borkowski wrote:
> I just released Beta 2 of the TiddlerAliasPlugin

LostCreation

unread,
Nov 19, 2006, 2:31:13 AM11/19/06
to TiddlyWikiDev
I've been playing around with this plugin a bit, and am curious if
anyone else is interested in the features I've added. I uploaded it on
tiddlyspot and it can be found here:
http://lostcreation.tiddlyspot.com/#TiddlerAliasPlugin
I started with Beta 3 on Udo's site (plug in still links there), and
made the following changes:

- I added a control panel to the plugin so you can change the default
options without editing the plugin itself.
- Made it so you can specify what character you want the non-space
alias to substitute. Defaults to "-".
- Added a "lazy auto plural" option. Disabled by default. It's "lazy"
because it only adds or subtracts an "s" from the end of words. Was
basically a merging with this plugin:
http://jackparke.googlepages.com/jtw.html#PluralAliasPlugin
- Added an "auto lower case" option. Disabled by default. Makes the
most sense if you're not using WikiWords for your links.
- Only tested changes on Firefox 2.0, though IE 7.0 appears to work ok.

Not sure how happy I am with the how I implemented everything.

First, I used some sudo-recursion for the new auto-alias options. Was
the only way I could think of to automatically make lower-case
lazy-plural aliases (for example), which is something I wanted for my
own project. While this seems like the "expected" behavior to me, it
creates a fair amount of overhead. (First option is repeated N times,
second N-1, etc.) I also haven't done anything to make these auto
options work on manually entered aliases. While I tend to think that
auto-aliasing the aliases would be the expected behavior, the
efficiency issue would double with every manually entered alias. I'm
not sure how comfortable I am with that.

Second, while I like being able to switch out the "-" with a "_" (or
even a ""!), I'm not sure how safe that is to allow. Should it be
escaped?

Udo Borkowski

unread,
Nov 19, 2006, 4:10:28 PM11/19/06
to Tiddly...@googlegroups.com
FYI: In the next release of TiddlyWiki the Alias feature will probably be in the core. This also includes the updating the "References" to include references done through Alias links.

Because of this I don't plan for any new releases of the Alias Plugin.

The build-in core feature will not include the "Auto Non-Space Alias" feature, but it provides the hook function

 TiddlyWiki.prototype.addMoreAliases

that can be used by plugins to implement this feature. Also your extensions like the "Auto Lower Case" or "'Lazy' Auto Plural" could be implementing by hijacking this function.


Udo

----------
Udo Borkowski
http://www.abego-software.de




Reply all
Reply to author
Forward
0 new messages