Is there a simple timed way to refresh a Tiddler?

25 views
Skip to first unread message

kev

unread,
May 14, 2007, 8:58:51 AM5/14/07
to TiddlyWiki
This request could solve a lot of othe rproblems useing "include" but
right now I'm using the nice Tag Cloud Plugin here: www.keithrichardson.co.uk

The problem is that it is reading the tags of the home page file but
will only read the Included TiddlyWiki when I physically open and
close the tiddler.

I know there is a meta refresh command which I optimistically tried:
<html>
<head>
<meta http-equiv="refresh" content="5" />

</head>
<body>
</body>
</html>

And I noticed that some macros seem to have some kind of refresh
command built-in.

Is there a way of adding such refresh code to a particular tiddler or
to the actual plugin?

Thanks

Eric Shulman

unread,
May 14, 2007, 10:38:18 AM5/14/07
to TiddlyWiki
> will only read the Included TiddlyWiki when I physically open and
> close the tiddler.
> I know there is a meta refresh command which I optimistically tried:
> And I noticed that some macros seem to have some kind of refresh
> command built-in.
> Is there a way of adding such refresh code to a particular tiddler or
> to the actual plugin?

Try this inline script: (*)
http://www.TiddlyTools.com/#AutoRefresh

Usage:
<<tiddler AutoRefresh with: mode id>>
where 'mode' is one of:
off: prevent automatic refresh of this content when changes occur
on: enable automatic refresh of this content when underlying
tiddler is changed
force: enable automatic refresh of this content when ANY tiddler is
changed
and 'id' (optional) is the ID of the DOM element to act on, and
defaults to the containing tiddler (i.e., most of the time, you won't
need to use an ID)

so, for your purposes, try putting this:
<<tiddler AutoRefresh with: force>>
into the tiddler with the tag cloud. This should ensure that the tag
cloud display will be kept in sync as soon as new tiddlers are
included into the document (assuming, of course, that IncludingPlugin
triggers a "tiddlers have changed" notification event after it
includes the tiddlers from the remote document).

HTH,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

(*) reminder: all inline scripts require installation of
http://www.TiddlyTools.com/#InlineJavascriptPlugin

kev

unread,
May 14, 2007, 12:21:10 PM5/14/07
to TiddlyWiki
Thanks,

That seemed to work, once, when I edited a tiddler but then stopped
working (I cleared private data to test).

But I don't want it to refresh when I edit a tiddler. In some ways the
concept here is more simple: I want the tiddler to refresh once only
when the site is loaded and after a time delay of 2 or 3 minutes?


A pity TW does not recognise the META command!

Eric Shulman

unread,
May 14, 2007, 1:51:09 PM5/14/07
to TiddlyWiki
> But I don't want it to refresh when I edit a tiddler. In some ways the
> concept here is more simple: I want the tiddler to refresh once only
> when the site is loaded and after a time delay of 2 or 3 minutes?

Suppose you edit a tiddler and add/remove some tags... why would you
NOT want that change to be automatically reflected in the tag cloud
display? In any event, since the tag cloud content depends upon the
underlying tiddler data, refreshing it anytime that data is changed
would seem to make total sense.

If you are just wanting to delay long enough for the IncludePlugin to
load tiddlers from some remote server, then why not just use the
AutoRefresh script so that the tag cloud is refreshed as soon as the
IncludePlugin triggers a refresh notification event, rather than after
an arbitrary amount of time?

-e

Eric Shulman

unread,
May 14, 2007, 3:06:37 PM5/14/07
to TiddlyWiki
To make a displayed tiddler refresh itself on a timed basis, you can
embed a single line of inline script directly in the tiddler content.

For example, to display a tag cloud that automatically refreshes every
3 minutes, create a tiddler called [[TagCloud]], containing
----------
<<tagCloud>><script>
setTimeout("story.refreshTiddler('TagCloud',null,true)",180000);
</script>
----------
as long as the tiddler is open in the 'story' column, it will be re-
displayed on a timed basis.

Notes:
setTimeout() takes two params:
* the javascript to be invoked when wait time expires (passed as a
text string)
* the "wait time", in milliseconds (e.g., 3 minutes = 180000 msec)

and the code that is invoked, story.refreshTiddler(), takes three
params:
* the title of the tiddler you want to refresh
* the template to use (or null to use the default template)
* a 'force' flag (must be = true for this to work)

Each time the tiddler is refreshed it will re-render the script, and
therefore schedule *another* refresh to occur 3 minutes later... which
will render the script yet again, and schedule another refresh in 3
minutes... and so on.

Of course, this is OK if you *want* the tiddler display to be updated
on a period basis, but BE CAREFUL... it can make it difficult to edit
that tiddler, since you will have timed window in which to press
"edit", make changes, and press "done", before the tiddler gets
refreshed again! If you set the timer period too short, you may have
to be might not even have time enough to edit the tiddler to change
the timer to use a longer value!

Fortunately, there IS a way to avoid the whole 'never-ending periodic
refresh' issue by embedding the script into a *different* tiddler than
the one that you want refreshed, so that the timeout is only set when
*that* other tiddler is rendered. If you use a tiddler that is always
rendered at startup, such as MainMenu, it will ensure that the timer
code is invoked each time the document is loaded (and, of course, any
time the MainMenu is changed, and therefore re-rendered).

Thus, to produce the effect you asked for (i.e., to refresh a
<<tagCloud>> display 3 minutes after loading the document),
[[TagCloud]] would simply contain the <<tagCloud>> macro call, and
[[MainMenu]] would contain the inline script shown above. Note that
since the inline script only sets up a timer and doesn't actually
render any output, you can safely embed it in your [[MainMenu]]
without affecting the menu's appearance.

HTH,
-e

kev

unread,
May 14, 2007, 3:18:56 PM5/14/07
to TiddlyWiki
Yes, I would want to refresh the tags - but it would it be possible to
have a "delay" option like the Include Plugin itself has. Then all I
would need is set the delay so that the Autorefresh script would
create its tag cloud AFTER the Include had done its work?

Guessing, I tried
<<tiddler AutoRefresh with: on TabTags>>
<<tiddler AutoRefresh with: on IncludePlugin>>

kev

unread,
May 14, 2007, 3:50:29 PM5/14/07
to TiddlyWiki
That looks brilliant - I obviously won't be doing any programming!

While I play around with that I found a simple workaround using
another of your excellent useful scripts, namely the Refresh Tiddler
macro which provides the site visitor with the option of manually
refreshing the tags. That seems like an OK compromise - people usually
like pressing buttons anyway! It's online now and I'll test the new
way offline. I'm sure either solution is going to help get around the
Include problem.

Reply all
Reply to author
Forward
0 new messages