You could hijack the saveTiddler method, automatically adding this
custom field (presumably determining the latest ID on startup):
http://trac.tiddlywiki.org/browser/Trunk/core/js/TiddlyWiki.js?rev=12238#L309
That might look something like this:
(function() {
// assumes SERIALID has been initialized
var _saveTiddler = TiddlyWiki.prototype.saveTiddler;
TiddlyWiki.prototype.saveTiddler = function() {
var tiddler = _saveTiddler.apply(this, arguments);
if(!tiddler.fields.serialid) {
SERIALID++;
tiddler.fields.serialid = SERIALID.toString();
}
};
})();
(Note that field names must be lower case and values are strings.)
> Better if this field is not user-editable.
There's no access control in regular TiddlyWikis, as it's all happening
client-side.
So unless you're using some server-side, that's not really enforceable -
however, it might be sufficient to not make it easy for users to change
this data.
> 2. Optionally display tiddlers as rows, with a "preview" column that
> displays the first few lines of the content.
Shouldn't be hard to create a macro for this.
In fact, there are probably ForEachTiddler scripts out there that do
very similar things - you might wanna search the group archives.
HTH.
-- F.
But I suppose that you could make the tiddler.title the ID and
automatically generate that starting from 001. Then use a custom field
for the content that would go in the tiddler's title field. That way
you'd enforce uniqueness on the title, and be allowed to have more
than one tiddler of the same "title".
just some thoughts coming off the top of my head right now - not sure
if i make sense. Always get confused when i start thinking about
messing with tiddlers - that MPTW fealing all over again.
Alex
> --
> You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
> To post to this group, send email to tiddl...@googlegroups.com.
> To unsubscribe from this group, send email to tiddlywiki+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
>
>
Well, the hash will be calculated from the tiddler body, so tiddlers
with the same content but different metadata (e.g. tags) will have the
same hash.
> I don't know, if the new .revision counter is unique?
You mean the revision numbers of tiddlers in TiddlySpace? While those
are indeed unique, that is an artifact of the store implementation being
used on the server (a MySQL database) - so I wouldn't rely on it.
-- F.
alex
The hashing will be just produced from the tiddler text, and therefore
the same tiddler content in a different space, or on a different
server, would carry the same hash identifier.
This means that it should be possible to use the hashes to track
tiddlers that are copied between tiddlywikis/spaces.
Cheers
Jeremy
--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com
To expand on what Jeremy has already said, TiddlySpace's hashing is not
meant to be used as unique identifier[1][2] for individual tiddlers, but
is gonna be a checksum[3] of the contents.
-- F.
[1] http://en.wikipedia.org/wiki/Universally_unique_identifier
[2] http://en.wikipedia.org/wiki/Globally_unique_identifier
[3] http://en.wikipedia.org/wiki/Checksum
out.push("|!Title|!Date|!Keyword|h"); // create tabel header
[...]
out.push( "|[[" + tids[i].title + "]] " + "|" + tids[i].created +"|" +
tids[i].fields.keyword +"|");
(Personally, I'd construct the table using the DOM rather than
wikification, but that's not directly relevant here.)
HTH.
-- F.
Using CouchDB as backend would indeed be awesome.
There has been some interest in this before[1][2] - personally, I think
it'd be great if there was a couch app providing (a subset of) the
TiddlyWeb API, as that would mean a lot of existing code (e.g. the
adaptor) could simply be reused.
-- F.
[1] http://groups.google.com/group/tiddlywiki/t/f331501c09e10549
[2] http://groups.google.com/group/tiddlywiki/t/125feda2eae813a4
tids[i].created.formatString("YYYY-0MM-0DD 0hh:0mm");
see http://tiddlywiki.org/wiki/Timestamps
-- F.
Sure:
---------------
(function($) { // use "$" as local alias for jQuery
var table = $("<table />");
$("<tr />").
append("<th>Title</th>").
append("<th>Date</th>").
appendTo(table);
var tiddlers = store.getTaggedTiddlers("foo");
for(var i = 0; i < tiddlers.length; i++) {
var tiddler = tiddlers[i];
var link = createTiddlyLink(null, tiddler.title, true);
var timestamp = tiddler.created.
formatString("YYYY-0MM-0DD 0hh:0mm");
var row = $("<tr />").appendTo(table);
$("<td />").append(link).appendTo(row);
$("<td />").append(timestamp).appendTo(row);
}
table.appendTo(place); // assumes "place" is a DOM element
})(jQuery);
---------------
(I've kept it basic - there are ways to optimize this and to make it
more elegant, but would have made this example more complex.)
-- F.
Actually, why don't we combine our efforts? I don't have a whole lot of
experience with CouchDB, but wanted to get back to playing with it
anyway - and having worked on the TiddlyWiki<->TiddlyWeb side of things
a lot, I could probably help move things along.
If you could provide some guidance on design documents, views and such,
I could quickly come up with some exemplary code to store and retrieve
tiddlers (preferably over on [twdev] to keep the noise down).
-- F.
Oh, good to know.
> So to port TW on couch, we have 2 solutions ,the port the tiddlyweb
> concept on another db backend like it was done with mysql for Tspace
> (i think), or the build of a new TW adaptator who's more couch specific
> And i think the second one is my first path
I agree an adaptor is the right approach, as TiddlyWiki is perfectly
capable of interacting with CouchDB by itself. We can worry about
compatibility with TiddlyWeb's HTTP API (or a subset thereof) later.
(TiddlyWeb's MySQL store is just an extension of the server-side's
storage layer, with no impact on the HTTP API. I had experimented with
such a store implementation using CouchDB a while back*.)
> Another thing is to know if we do the port " a la couchapp" (splitting
> of the code & more elegant in the couch world) or "a la TW" everything
> in one file and the data outside
The way TiddlyWebWiky handles this is to store each tiddler individually
and populating an empty TiddlyWiki template by adding the appropriate
HTML representation for each tiddler to the HTML document (above the
"<!--POST-STOREAREA-->" marker present in each TiddlyWiki).
I'm not sure which facilities CouchDB offers for such server-side
processing though.
-- F.