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...)

On Friday, June 22, 2012 1:40:07 AM UTC+10, Meta wrote:
>
> 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.
>
> On Thursday, June 21, 2012 11:14:38 PM UTC+10, whatever wrote:
>>
>> 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 
>>
>> On Jun 20, 3:48 pm, Meta <[email protected]> wrote: 
>> > 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
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/tiddlywiki/-/tTPnVdh75ZAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to