Experimental TiddlyWiki with MetaData, XHTML compliant store etc. release

5 views
Skip to first unread message

Udo Borkowski

unread,
Apr 23, 2006, 5:57:53 PM4/23/06
to Tiddly...@googlegroups.com
I digested the very valuable input from the discussion in this forum and came up with another experimental adaption of the TiddlyWiki 2.0.8 at

 http://tiddlywiki.abego-software.de/metadata/

Its major features are:
You find more documentation in the TiddlyWiki (in Tiddlers and source code).


Again feedback is highly appreciated.

And many thanks for all your support and input.

Udo


P.S.: this is not a "supported extension" or so, but just an "experiment". It
must not be used for productive systems. You may loose your data. This
experimental version can be dropped at any time (e.g. with the release
of TiddlyWiki 2.1).

P.P.S.: A unified diff of the JavaScript changes can be found here:
http://tiddlywiki.abego-software.de/patch/metadata2.diff.txt

Saq Imtiaz

unread,
Apr 24, 2006, 12:13:38 AM4/24/06
to Tiddly...@googlegroups.com
Has any concensus been reached on whether or not we will allow for nesting of EMD?

Saq

PS: great work once again Udo!

Udo Borkowski

unread,
Apr 24, 2006, 2:53:56 AM4/24/06
to Tiddly...@googlegroups.com
Has any concensus been reached on whether or not we will allow for nesting of EMD?

Nesting is supported through the "dot notation" and the namespaces.

E.g.
store.setValue("Preferences", "abego.yoursearch.lastSearchText", "tiddly");
store.setValue("JoeBrown", "ContactManager.street", "Washington St"); store.setValue("JoeBrown", "ContactManager.zip", "12345"); store.setValue("JoeBrown", "ContactManager.phone", "555-1234");

Beside this you can also assign compound objects to the metadata fields, giving you another way to structure you data.


In the HTML file the nesting is represented through nested "div" elements.


Udo


Saq Imtiaz

unread,
Apr 24, 2006, 3:03:31 AM4/24/06
to Tiddly...@googlegroups.com
On 4/24/06, Udo Borkowski <Udo.Bo...@gmx.de> wrote:
Has any concensus been reached on whether or not we will allow for nesting of EMD?

Nesting is supported through the "dot notation" and the namespaces.

E.g.
store.setValue("Preferences", "abego.yoursearch.lastSearchText", "tiddly");
store.setValue ("JoeBrown", "ContactManager.street", "Washington St");
store.setValue("JoeBrown", "ContactManager.zip", "12345");
store.setValue("JoeBrown", " ContactManager.phone", "555-1234");

Thanks for the info Udo, I wasn't sure which way we had decided to go. Dot notation will do if it has to. :)

One query, from someone not a coding genius like yourself.... in the above example, whats the easiest way to 'run through' or retrieve all ContactManager.*  metadata? Eg get the values for all ContactManager metadata for that tiddler in an array. Or check to see if the tiddler has any ContactManager metadata.

Thanks again,

Saq

Udo Borkowski

unread,
Apr 24, 2006, 3:46:04 AM4/24/06
to Tiddly...@googlegroups.com
whats the easiest way to 'run through' or retrieve all ContactManager.*  metadata? Eg get the values for all ContactManager metadata for that tiddler in an array. Or check to see if the tiddler has any ContactManager metadata.

Good question. For this the "forEachField" function is introduced.

Here two examples:

Get all metadata fields of the ContactManager namespace of a tiddler

function getAllContactManagerData(tiddler) {
    var result = {};
    store.forEachField(tiddler,
        function(tiddler, namespacePath, fieldName, value) {
            if (namespacePath == "ContactManager") {
                result[fieldName] = value;
            }
        });    
    return result;   
}



Check if a tiddler has any ContactManager metadata:

function hasAnyContactManagerData(tiddler) {
    return store.forEachField(tiddler,
        function(tiddler, namespacePath, fieldName, value) {
            if (namespacePath == "ContactManager") {
                return true;
            }
        });    
}


Usage:
if (hasAnyContactManagerData("JoeBrown")) 
    result += "JoeBrown has ContactManagerData\n";
else 
    result += "JoeBrown has no ContactManagerData\n";

if (hasAnyContactManagerData("HelloThere")) 
    result += "HelloThere has ContactManagerData\n";
else 
    result += "HelloThere has no ContactManagerData\n";


Instead of this kind of check you may also just access a required ContactManager field. If it does not exist undefined is returned.


Udo


Saq Imtiaz

unread,
Apr 24, 2006, 3:59:37 AM4/24/06
to Tiddly...@googlegroups.com
Brilliant Udo!

I had seen the forEachField function, but I didn't realize that I could use the namespacePath variable in this way. Thank you for taking the time to elaborate. :) I daresay I'll be more than happy if this makes it way into the core as is, without any further work.

One quick observation, which might be wrong, but in:

function getAllContactManagerData(tiddler) {
    var result = {};
    store.forEachField(tiddler,
        function(tiddler, namespacePath, fieldName, value) {
            if (namespacePath == "ContactManager") {
                result[fieldName] = value;
            }
        });    
    return result;   
}

Shouldnt the second line be:
 var result= [];
since result is supposed to be an array?

I'm still learning JS so maybe there's a more than likely chance that I'm missing something, but I figured I'd ask.

Saq

On 4/24/06, Udo Borkowski <Udo.Bo...@gmx.de> wrote:

Udo Borkowski

unread,
Apr 24, 2006, 4:38:39 AM4/24/06
to Tiddly...@googlegroups.com
Shouldnt the second line be:
 var result= [];
since result is supposed to be an array?

I didn't know that you an array. I think the {} object variant is nicer. Using the {} you can add "named" properties to the object, with the array you can just access the items per index. I choose the object variant because I wanted to return named fields with values.

It is still very easy to iterate over all fields of the result. Just do:

for (var n in result) {
    alert("found field %0 with value %1".format([n, result[n]]);
}

If you just want the names of the ContactManager fields an array would probably be the better result. The code may look like this (not tested):

function getContactManagerFieldNames(tiddler) {

    var result = [];
    store.forEachField(tiddler,
        function(tiddler, namespacePath, fieldName, value) {
            if (namespacePath == "ContactManager") {
                result.push(fieldName]);
            }
        });    
    return result;   
}

Udo


Saq Imtiaz

unread,
Apr 24, 2006, 4:43:51 AM4/24/06
to Tiddly...@googlegroups.com
Objects..... yes, never really used them before. Now it makes sense why you werent using push, since it wasnt an array.
Thanks Udo, as usual, you have taught me something new. I've moslty limited myself to using arrays and strings until now, but I can definitely see the attraction of objects.

Cheers,

Saq

On 4/24/06, Udo Borkowski <Udo.Bo...@gmx.de> wrote:
Reply all
Reply to author
Forward
0 new messages