The DefaultTiddlers is processed as a filter line [1]: for instance, 
instead of just some [[tiddler 1]] [[tiddler 2]] you can put there smth 
like this:

[[tiddler 1]]
[tag[tag 1]]
[limit[10]]

So, alternatively to what Eric have suggested, you can create ifOffline 
filter (which adds a tiddler only if you opened your TW offline) and use 
only one DefaultTiddlers:

[[tiddler 1 to open anyway]]
...
[ifOffline[tiddler 1 to open if offline]]
...

So, the question is -- how to create such a filter? First, let's create a 
duplicate of the "tiddler" filter which works in the [ifOffline[tiddler]] 
syntax:

config.filters.ifOffline = function(results,match) {
    results.pushUnique(match[3]);
    return results;
};

(create a tiddler with such code and systemConfig tag -- and the plugin is 
ready, but test it first -- put [ifOffline[some existing tiddler]] into the 
DefaultTiddlers)
Now, this one adds the tiddler anyway, but we need smth like this:

config.filters.ifOffline = function(results,match) {
    if(we_are_offline)
        results.pushUnique(match[3]);
    return results;
};

the only thing is how to calc this pseudo-coded we_are_offline thing. As 
far as I can see from the core code, that should be !readOnly:

config.filters.ifOffline = function(results,match) {
    if(!readOnly)
        results.pushUnique(match[3]);
    return results;
};

Best regards,
Yakov.

[1] http://tiddlywiki.org/#Filters

четверг, 6 июня 2013 г., 9:12:49 UTC+4 пользователь Eric Shulman написал:
>
> > you could just put this script as the text of your DefaultTiddlers: 
> > <script> 
> > if (!readOnly) 
> >   wikify("[[GettingStarted]]",place); 
> > else 
> >   wikify("[[OnlineHomeTiddler]]",place); 
> > endif 
> > </script> 
>
> Regrettably, it's not quite that simple.  The contents of 
> DefaultTiddlers are expected to be actual names of  tiddlers to 
> display, as opposed to "rendered" links to tiddlers.  The TWCore 
> doesn't apply any wiki parsing to the contents... it simply chops it 
> up into white-space separated parts. 
>
> The above script should *not* be placed as text in the 
> DefaultTiddlers.  Rather, you should do this: 
>
> First create a plugin tiddler called [[SetDefaultTiddlers]], tagged 
> with "systemConfig",  containing the following script: 
> ---------- 
> //{{{ 
>    if (!readOnly) 
>       config.shadowTiddlers.DefaultTiddlers="[[GettingStarted]]"; 
>    else 
>       config.shadowTiddlers.DefaultTiddlers="[[OnlineHomeTiddler]]"); 
> //}}} 
> ---------- 
> During startup, the [[SetDefaultTiddlers]] plugin will be invoked, 
> assigning the shadow content of [[DefaultTiddlers]] based on the 
> current status of the readOnly flag (which generally defaults to TRUE 
> when online). 
>
> Then, **DELETE** your existing [[DefaultTiddlers]] so that the 
> *shadow* [[DefaultTiddlers]] definition will be applied next time you 
> reload the document. 
>
> enjoy, 
> -e 
> Eric Shulman 
> TiddlyTools / ELS Design Studios 
>
> HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"... 
>    http://www.TiddlyTools.com/#Donations 
>
> Professional TiddlyWiki Consulting Services... 
> Analysis, Design, and Custom Solutions: 
>    http://www.TiddlyTools.com/#Contact 
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to