OpenTaggedTiddlers with MatchTags' boolean select

108 views
Skip to first unread message

HansBKK

unread,
Jun 12, 2011, 1:35:59 AM6/12/11
to TiddlyWiki
This is related to my recent post, but I thought different enough to
warrant a separate thread.

I am trying to use OpenTaggedTiddlers in combination with
MatchTagsPlugin

This works fine:

<<tiddler OpenTaggedTiddlers with: "Open all" journal modified reverse
close 100>>

Regarding the "tagToMatch" variable (above = "journal"), the plugin's
doc states:

when MatchTagsPlugin is installed, you can also use a boolean tag
expression, enclosed in "..."

But I haven't been able to get any of the below to work:

<<tiddler OpenTaggedTiddlers with: "Open all" "journal AND NOT
Archived" modified reverse close 100>>
<<tiddler OpenTaggedTiddlers with: "Open all" "(journal AND NOT
Archived)" modified reverse close 100>>
<<tiddler OpenTaggedTiddlers with: "Open all" "[journal AND NOT
Archived]" modified reverse close 100>>
<<tiddler OpenTaggedTiddlers with: "Open all" "[[journal AND NOT
Archived]]" modified reverse close 100>>


While I'm here, is there any way to trigger this behavior
automatically, either when a tiddler is opened, or at document load
time?

Thanks very much in advance.

http://www.tiddlytools.com/#OpenTaggedTiddlers
http://www.tiddlytools.com/#MatchTagsPlugin

HansBKK

unread,
Jun 12, 2011, 1:59:32 AM6/12/11
to TiddlyWiki
I found a couple of posts by Eric that seem like they'd allow a
solution, but I'm a total newbie to JS coding, both generally and in
TW, so please don't just reply "create a plugin" or something 8-)

Assuming the below would work, where would I put it to make it work at
document load time?

config.shadowTiddlers["DefaultTiddlers"] = "[["
+ store.getTaggedTiddlers("sticky","modified").reverse()[0].title
+ "]] [["
+ store.getTaggedTiddlers("journal AND NOT
Archived","modified").reverse()[0].title
+ "]]";
Message has been deleted

Tobias Beer

unread,
Jun 12, 2011, 5:52:16 AM6/12/11
to TiddlyWiki
Try...

1. create a tiddler
2. give it a name, e.g. DefaultTiddlersHack
3. paste the code
4. tag it "systemConfig"
5. save and reload
6. post back if your code worked the way you wanted / expected it to

Alternatively, if you are using a zzConfig tiddler or the likes,
simply put the code in there and prepend a little comment, e.g.

//code to invoke custom default tiddlers
...

However, I am not sure if the TiddlyWiki loading sequence allows to
set shadow tiddlers during load time and to actually have them being
used right after. But, I guess, it does ...since you probalby didn't
come up with that code all by yourself.

Cheers, Tobias.

HansBKK

unread,
Jun 12, 2011, 9:12:39 AM6/12/11
to tiddl...@googlegroups.com
No joy. "Error: SyntaxError: unterminated string literal"


Here's the sum total of my zzConfig

config.shadowTiddlers["DefaultTiddlers"] = "[["
+ store.getMatchingTiddlers("journal AND NOT
archived","modified").reverse()[0].title
+ "]]";


Previously my zzConfig looked like this:

/***
|''Description:''|Configure options for this ~TiddlyWiki|
***/
//{{{
//}}}

and I don't know from brackets or slashes, so I'm hoping a minor syntax error?


And of course I didn't write this code myself, got it here and here

Your help is greatly appreciated.

HansBKK

unread,
Jun 12, 2011, 9:25:45 AM6/12/11
to tiddl...@googlegroups.com
That error did come from a syntax error - I guess JS doesn't like line breaks in the middle of its code?


The second reference link in my previous message apparently didn't make it:

http://groups.google.com/group/tiddlywiki/browse_thread/thread/1d6caa42c883b8d0/5fea2d03581b99d8

I noticed that the two snippets use different commands, and the more recent one is "getMatchingTiddlers", and I've just upgraded to MatchTags v2.0.5 which uses that.


The new zzConfig tiddler looks like this

config.shadowTiddlers["DefaultTiddlers"] = "[["+ store.getMatchingTiddlers("journal AND NOT archived","modified").reverse()[0].title + "]]";
And returns exactly nothing

Tobias Beer

unread,
Jun 13, 2011, 6:56:58 AM6/13/11
to TiddlyWiki
Hi Hans,

I just...

1. downloaded a blank TiddlyWiki
2. imported MatchTagsPlugin from TiddlyTools
3. created a couple of journal entries
4. added a zzConfig, containing http://pastebin.com/mk3zFL8Y
5. hit reload and it worked

You can see it work here: http://goo.gl/wEjkW

Now, have you perhaps been overriding the DefaultTiddlers shadow
tiddler so that the shadow doesn't even get applied? Otherwise, try
the code exactly as it is above and make sure your tags are matching
in a case-sensitive manner.

Cheers, Tobias.

HansBKK

unread,
Jun 13, 2011, 9:09:05 AM6/13/11
to TiddlyWiki
Tobias,

You were exactly correct about my leaving a non-shadow DefaultTiddlers
in place - I had just emptied its contents, not deleted it entirely
(duh! 8-)

So this code works fine, except - it only displays a single tiddler!

I really appreciate your taking so much trouble to pursue this, and
while I really would like TW to have additional flexibility in auto-
launching tiddlers, I completely understand if it's just not doable at
this time - I am in the meantime using (to me) acceptable workarounds
- a combination of an explicit "default" tag and using
OpenTaggedTiddlers as it was designed, where the user can click on a
link to open all the unarchived journal entries.

Thanks,

Hans


On Jun 13, 5:56 pm, Tobias Beer <beertob...@googlemail.com> wrote:
> Hi Hans,
>
> I just...
>
> 1. downloaded a blank TiddlyWiki
> 2. imported MatchTagsPlugin from TiddlyTools
> 3. created a couple of journal entries
> 4. added a zzConfig, containinghttp://pastebin.com/mk3zFL8Y

PMario

unread,
Jun 13, 2011, 12:29:50 PM6/13/11
to TiddlyWiki
Tested this one in firebug only.

http://pastebin.com/9XBk18NQ

-m

HansBKK

unread,
Jun 13, 2011, 11:37:12 PM6/13/11
to tiddl...@googlegroups.com
Very cool, we're getting there. Now to be able to create multiple sets and control the ordering. . .

Neither of the below work, because (obviously) me have no JS.

vvar tids1 = store.getMatchingTiddlers("default","modified").reverse()
var tids2 = store.getMatchingTiddlers("journal AND NOT archived","title").reverse()
var tids = tids1+tids2
tids = tids.map(function(elem){return elem.title})
config.shadowTiddlers["DefaultTiddlers"] = '[[' + tids.join(']] [[') + ']]'

===============================

var tids = store.getMatchingTiddlers("default","modified").reverse()+store.getMatchingTiddlers("journal AND NOT archived","title").reverse()
tids = tids.map(function(elem){return elem.title})
config.shadowTiddlers["DefaultTiddlers"] = '[[' + tids.join(']] [[') + ']]'

Tobias Beer

unread,
Jun 14, 2011, 4:58:10 AM6/14/11
to TiddlyWiki

PMario

unread,
Jun 14, 2011, 7:55:50 AM6/14/11
to TiddlyWiki
On Jun 14, 5:37 am, HansBKK <hans...@gmail.com> wrote:
> Very cool, we're getting there. Now to be able to create multiple sets and
> control the ordering. . .
>
> Neither of the below work, because (obviously) me have no JS.
but the spirit :)

try this.
http://pastebin.com/ihKjWYgY

If you are interested, what's going on, read the following.
Otherwise just have fun! :)

====
some info, what's going on.

store.getMatchingTiddlers() returns an array of objects
eg:
[ {title: "New Tiddler", modified: 20110614120000, created ...},
{title: "New Tiddler1", modified: 20110614120000, created ...} ]

====
.reverse(); .. reverses the sort order

store.getMatchingTiddlers("default","-modified") .. does the same :)
see the minus in front of "-modified".

====
so tids1 and tids2 are arrays of objects
we can combine two arrays with concat().

var tids = []
tids = tids.concat(tids1,tids2);

====

map() function can manipulate arrays. In our case it returns the title
of the tids objects.

The following line is very hacky, because it converts the "object
tids" into an "array tids". Sorry for this, but it saves a variable.

tids = tids.map(function(elem){return elem.title})
====

join() can take arrays and create a string

["text 1", "text 2"].join(']] [[') creates
"text 1]] [[text 2"

'[[' + join() + ']]' ... fixes the front and the end of the string


et voila:
config.shadowTiddlers["DefaultTiddlers"] = '[[' + tids.join(']] [[') +
']]';

hope this helps
-m

PMario

unread,
Jun 14, 2011, 7:57:30 AM6/14/11
to TiddlyWiki

HansBKK

unread,
Jun 15, 2011, 3:32:49 AM6/15/11
to TiddlyWiki
PMario, you da man!

For posterity - the purpose of this exercise is to allow a TW to act/
look like a blog at startup - it may have all kinds of other tiddler
types, but the standard "journal" entries will now appear on the front
page at startup. Any type of tiddler can be tagged "default" and it
will appear at the top of the list - like a blog or forum's "sticky"
tag, and all the rest of the unarchived journal entries sort in
reverse date order below.

So my workflow is to use a GTD-style project/action TW, combined with
journaling - unstructured notes about various things - tagged by
project, progress on habit control/formation routines etc.

Every once in a while I parse the recent journal entries for new
projects/actions, extract important notes to structured reference
files etc - when I've finished extracting everything important from
that journal entry I tag it "archived" and it no longer shows up on
the home page.

A thing of beauty, thank you PMario!

And thanks also for the JS reference links; I hope one day I'm in a
position to start learning programming - my understanding is that JS
isn't the best first language though?

On Jun 14, 6:55 pm, PMario <pmari...@gmail.com> wrote:
> On Jun 14, 5:37 am, HansBKK <hans...@gmail.com> wrote:> Very cool, we're getting there. Now to be able to create multiple sets and
> > control the ordering. . .
>
> > Neither of the below work, because (obviously) me have no JS.
>
> but the spirit :)
>
> try this.http://pastebin.com/ihKjWYgY

HansBKK

unread,
Jun 22, 2011, 12:44:52 AM6/22/11
to tiddl...@googlegroups.com
PMario,

Sorry, but my zzConfigOption with your code in place is doing something wierd. When this tiddler matches

title=[G] GTD HF - Redmine in place
My opening screen contains a whole series of non-existent tiddlers broken out at the spaces - "GTD" and "HF" and "Redmine" etc

I assume that my starting the tiddler title with the square brackets in that TW is causing the problem? If this isn't an easy fix I can do some search-and-replacing, but I've got a bunch of other functionality that's keyed off that naming convention. . .

Thanks in advance.


Here's the code, only slightly adapted:

var tids1 = store.getMatchingTiddlers("#default","modified").reverse()
var tids2 = store.getMatchingTiddlers("#journal AND NOT #archived","title").reverse()
 
var tids = []
tids = tids.concat(tids1,tids2);
 
tids = tids.map(function(elem){return elem.title})
Reply all
Reply to author
Forward
0 new messages