Timeline/History with UserName?

6 views
Skip to first unread message

Gibson

unread,
Nov 6, 2009, 10:13:03 AM11/6/09
to TiddlyWiki
Hi all :)

At the minute I'm using the timeline macro in a tiddler to give me a
quick history of when things have been created but I'd also like
details of when they were modified and by which user, if that's
possible.

Is there some way I can do that?

Thanks,
-G-

Måns

unread,
Nov 6, 2009, 3:27:32 PM11/6/09
to TiddlyWiki
Hi Gibson

Try

<script>
var out=[]; var who='';
var tids=store.getTiddlers('modifier');
for (i=0; i<tids.length; i++) { var t=tids[i];
if (who!=t.modifier) {
who=t.modifier;
out.push('by '+who+':');
}
out.push('*[['+t.title+']]');
}
return out.join('\n');
</script>

Regards Måns Mårtensson

Gibson

unread,
Nov 9, 2009, 4:05:41 AM11/9/09
to TiddlyWiki
Hi,

Thanks for that - it's great for getting the "who" part :)

Can you tell me how I'd add the date at the side of the output line
out.push('*[['+t.title+']]'); ?

Thanks again,
-G-

Måns

unread,
Nov 9, 2009, 7:51:03 AM11/9/09
to TiddlyWiki
Hi Gibson

try:
out.push('*[['+t.title+']]'+t.modified+'');

regards Måns Mårtensson

Morris Gray

unread,
Nov 9, 2009, 11:46:31 PM11/9/09
to TiddlyWiki
You might like to try:

out.push('*[['+t.title+']] '+t.modified.formatString('YYYY.0MM.0DD -
DDD 0hh:0mm:0ss')+'');

This will make it a bit more tidy.

Morris

Måns

unread,
Nov 10, 2009, 4:01:21 AM11/10/09
to TiddlyWiki
Thanks Morris - I didn't know that..
So taught by Alex H's thread: (prevent wikification in a script)
http://groups.google.dk/group/tiddlywiki/browse_thread/thread/86dcc6f966aaf79a?hl=da
I've added three double quotes on each side of '+who+' to prevent
wikification of usernames:

out.push('by """'+who+'""":');
}
out.push('*[['+t.title+']] '+t.modified.formatString
('YYYY.0MM.0DD - DDD 0hh:0mm:0ss')+'');

The opposite solution (always to wikify/link to a tiddler with
username as title) would be something like:

out.push('by [['+who+']]:');
}
out.push('*[['+t.title+']] '+t.modified.formatString
('YYYY.0MM.0DD - DDD 0hh:0mm:0ss')+'');

Regards Måns Mårtensson

Morris Gray

unread,
Nov 10, 2009, 8:07:37 AM11/10/09
to TiddlyWiki
My last submission ;-) Next....
-------------------------------------
<script>
var out=['| !Script by Shulman, Mårtensson & Gray |\>|']; var
who='';
var tids=store.getTiddlers('modifier');
for (i=0; i<tids.length; i++) { var t=tids[i];
if (who!=t.modifier) {
who=t.modifier;
out.push('| modified by """'+who+'""": |
\>|');
}
out.push('|[['+t.title+']]|'+t.modified.formatString
('YYYY.0MM.0DD-DDD 0hh:0mm:0ss')+" |"+'');
}
return out.join('\n');
</script>
---------------------------------------

Morris

On Nov 10, 8:01 pm, Måns <humam...@gmail.com> wrote:
> Thanks Morris - I didn't know that..
> So taught by Alex H's thread: (prevent wikification in a script)http://groups.google.dk/group/tiddlywiki/browse_thread/thread/86dcc6f...

Måns

unread,
Nov 10, 2009, 4:19:44 PM11/10/09
to TiddlyWiki
Very neat Morris

On 10 Nov., 14:07, Morris Gray <msg...@symbex.net.au> wrote:
> My last submission ;-) Next....

One question though - Is it necessary to change it into a fET to make
use of TablesortingPlugin ( http://tw.lewcid.org/#TableSortingPlugin )
or is it possible to make the table sortable within the script?

YS Måns Mårtensson

Mike

unread,
Nov 10, 2009, 4:44:22 PM11/10/09
to TiddlyWiki
With some help from ELS I have replaced all of my fET calls to inline
JS :)
I think you are missing the header (hdr)
i.e.
var hdr="|sortable|k\n| !Brand | !Name | !Wrapper | !Recommended By | !
Purchased ||h"
out.push(hdr);

A Working Example:
<script>
var out=[];
var fmt='| %0 | %1 | %2 | %3 | %4 | {{fine{[[%5|%5]]}}} |';
var tids=store.getMatchingTiddlers("Cigar && ! excludeLists && !
Trash","created");
var hdr="|sortable|k\n| !Brand | !Name | !Wrapper | !Recommended By
| !Purchased ||h"

out.push(hdr);
if (!tids.length) out=["No Cigars found"];

for (var i=0; i<tids.length; i++) {
var val1=tids[i].title;
if (store.getTiddlerSlice(val1,"PersonalRank") != "Not Rated")
continue;
if (store.getTiddlerSlice(val1,"Purchased") != "Yes") continue;
var val2=store.getTiddlerSlice(val1,'Brand')
var val3=store.getTiddlerSlice(val1,'Name')
var val4=store.getTiddlerSlice(val1,'Wrapper')
var val5=store.getTiddlerSlice(val1,'RecommendedBy')
var val6=store.getTiddlerSlice(val1,'Purchased')
out.push(fmt.format([val2,val3,val4,val5,val6,val1]));
}
return out.join('\n');
</script>

Måns

unread,
Nov 10, 2009, 9:56:26 PM11/10/09
to TiddlyWiki
Hi Mike

Thanks for the hint..

I understand that I should write sth like (I know this is wrong
- ....:

var out=[];
var fmt='| %0 | %1 | %2 | %3 |';
for (var i=0; i<tids.length; i++) {
var val1=tids[i].title; if (2!=t.modifier)
var val2=t.modifier;
var val3=t.modified.formatString ('YYYY.0MM.0DD-DDD 0hh:0mm:0ss')+"
|"+'');
var hdr="|sortable|k\n| !Tiddler | !Modifier | !Modified|h"
out.push(hdr);

I know next script isn't right - but it is nevertheless usefull even
if made wrong - :
(It sorts Modifier and TiddlerTitles in the same column)

I think: If I could separate tiddlertitle t.modifier and t.modified
(in three parts/columns instead of two )- Then I would have a correct
sortable table

<script>
var out= ['| Script by Shulman, Mårtensson & Gray|c'];
var hdr="|sortable|k\n| !Tiddler&Modifier | !Modified |h"
out.push(hdr);
var who='';
var tids=store.getTiddlers('modifier');
for (i=0; i<tids.length; i++) { var t=tids[i];
if (who!=t.modifier) {
who=t.modifier;
out.push('| modified by @@"""'+who+'""":@@ |
\>|');
}
out.push('|[['+t.title+']]|'+t.modified.formatString
('YYYY.0MM.0DD-DDD 0hh:0mm:0ss')+" |"+'');
}
return out.join('\n');
</script>

Can you help me out?

YS Måns Mårtensson

Gibson

unread,
Nov 12, 2009, 3:34:06 AM11/12/09
to TiddlyWiki
Great :)

Thanks everyone!
> > > > On 6 Nov., 16:13, Gibson <kentucky.gib...@googlemail.com> wrote:- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages