Tiddler digest

71 views
Skip to first unread message

Meta

unread,
Jun 20, 2012, 9:48:47 AM6/20/12
to tiddl...@googlegroups.com
Hi guys,

I'm currently using ForEachTiddler plugin to display a list of recently edited tiddlers along with the first line of each. Here is my code:

<<forEachTiddler
    sortBy
        tiddler.modified
    descending

    script '
        function lastDays(tiddler) {
            var compareDate = new Date();
            compareDate.setDate(compareDate.getDate() - 5); 
            if (tiddler.modified > compareDate && !tiddler.tags.contains("excludeLists") && !tiddler.tags.contains("systemConfig") && tiddler.tags.contains("bookfile")){
                var previewText = tiddler.text.substring(0,150).replace(/(\r\n|\n|\r)/gm," ") + "...";
                return "[[" + tiddler.title + "]]\n{{small borderleft{" + previewText + "}}}\n\n";}
            else
                return "";
        }
    '

    write 'context.output+= lastDays(tiddler) , ""'

        begin 'context.output = ""'

        end 'context.output
                ? context.output
                : "<<tiddler [[List the 4 most recently modified tiddlers]]\>\>"       
        '
>>

The problem is that tiddlywiki evidently runs the wikify command after all the content has been written, resulting in a number of markup errors (e.g. unclosed //, @@, etc.)

How can I modify this code so that it displays correctly?

Thanks,
Meta

whatever

unread,
Jun 21, 2012, 9:14:38 AM6/21/12
to TiddlyWiki
Hi!

Udo has the following two examples for fET on his site:

(1) http://tiddlywiki.abego-software.de/#[[List%20the%20first%20line%20of%20all%20tiddlers%20with%20the%20tag%20%22basic%22]]
- List the first line of all tiddlers with the tag "basic"
(2) http://tiddlywiki.abego-software.de/#[[List%20the%2010%20most%20recently%20modified%20tiddlers]]
- List the 10 most recently modified tiddlers

From them, I put together the following code, which works nicely
(beware googlewrap):

<<forEachTiddler
where
'tiddler.tags.contains("booklist")'
sortBy tiddler.modified descending
script
'
function getFirstLine(s) {
var m = s.match(/\s*(.*)/);
return m != null && m.length >= 1 ? m[1] : "";
}
'
write
'(index < 10) ? "* [["+tiddler.title+"]]\n{{small
borderleft{"+getFirstLine(tiddler.text)+"}}}\n\n" : ""'
>>

HTH
w
> The problem is that tiddlywiki evidently runs the wikify command *after *all

Meta

unread,
Jun 21, 2012, 11:40:07 AM6/21/12
to tiddl...@googlegroups.com
Great, thanks, works a charm! My next challenge is to make this display in a nice table rather than a vertical list, but I think I can tackle that one.

Meta

unread,
Jun 21, 2012, 12:04:16 PM6/21/12
to tiddl...@googlegroups.com
This works just like I want it to:

<<forEachTiddler
 where
 'tiddler.tags.contains("bookfile")'

     sortBy tiddler.modified descending

 script
 '
 function getFirstLine(s) {
 var m = s.match(/\s*(.*)/);
 return m != null && m.length >= 1 ? m[1] : "";
 count++;
 alert(count);
}
 '

 write
 '(index < 12) ? "|[["+tiddler.title+"]] {{small{(<<view modified date$)))<br>{{borderleft{"+getFirstLine(tiddler.text)+"}}}}}}" + ((index==3||index==7||index==11) ? "|\n" : "") + ((index==11) ? "|widetable|k" : "") : ""'
>>

(okay, maybe it could be a bit prettier...)
Reply all
Reply to author
Forward
0 new messages