I have a Published google document embedded in a tiddlywiki
<iframe style="width: 100%; height: 80vh;" src="https://docs.google.com/document/d/e/2PACX-1vS-tWnWyKzRAyAUT-IkR12Iw8VYqfPYLCGKyofsQIJa_WqCLKu73ZjRj5Z1DydTagCKklV-vmbchxNv/pub?embedded=true"></iframe>
When you make changes to the underlying document the changes are published within 5 minutes. This is fine for most applications. As it will “refresh” when you open the tiddler containing the iframe.
Except when you are writing and embedding documents
Google suggests using a meta tag inside the iframe tag
<meta http-equiv="refresh" content="300">
However this is not refreshing as advertised.
Is there a way to address this?
I Imagin tiddlywiki may be sanitising this or some other factor.
Alternatively can we get tiddlywiki to do a timed refresh on our own tiddler.
buggyj
September 14, 2023, 10:02am
2
here a js macro to do this
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "freshiframe";
exports.params = [
{name: "url"}
];
/*
Run the macro
*/
exports.run = function(url) {
var text = `<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="5">
</head>
<body>
<iframe src=${url} frameborder="0"></iframe>
</body>
</html>`
return "data:text/html;charset=utf-8," + encodeURIComponent(text);
};
})();
remember to set module-type to macro and type to application/javascript
call it like this
<iframe src=<<freshiframe "https://docs.google.com/document/d/e/2PACX-1vS-tWnWyKzRAyAUT-IkR12Iw8VYqfPYLCGKyofsQIJa_WqCLKu73ZjRj5Z1DydTagCKklV-vmbchxNv/pub?embedded=true">> frameborder="0"/>
Thanks @buggyj I will check it out.
buggyj:
content="5"
Is this the seconds before refresh?, I can make it minutes.
JanJo
September 14, 2023, 11:27am
4
Great. Could you turn the seconds to refresh into a param that can be changed?
buggyj
September 14, 2023, 1:06pm
5
one without the js
\define refreshdoctmpl(url,period)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="$period$">
</head>
<body>
<iframe src=$url$ frameborder="0"></iframe>
</body>
</html>
\end
\define refreshiframe(url)
<iframe src=<<makedatauri """$url$""" "text/html">> frameborder="0"/>
\end
<$vars x=<<refreshdoctmpl "https://docs.google.com/document/d/e/2PACX-1vS-tWnWyKzRAyAUT-IkR12Iw8VYqfPYLCGKyofsQIJa_WqCLKu73ZjRj5Z1DydTagCKklV-vmbchxNv/pub?embedded=true" "15">>>
<$macrocall $name="refreshiframe" url=<<x>>/>
</$vars>
JanJo
September 14, 2023, 11:05pm
6
Thanks @buggyj
In the wiki I tested it in I had quit a small frame , and adding height and width did not help.
I would like to scale the frame by dragging. Is something like that possible.
buggyj
September 15, 2023, 6:30am
7
\define refreshdoctmpl(url,period)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="$period$">
</head>
<body>
<iframe src=$url$ frameborder="0" width="100%" height="1000px"></iframe>
</body>
</html>
\end
\define refreshiframe(url)
<iframe src=<<makedatauri """$url$""" "text/html">> frameborder="0" width="100%" height="1000px">
\end
<$vars x=<<refreshdoctmpl "https://tiddlywiki.com/" "15">>>
<div style="height:1000px">
<$macrocall $name="refreshiframe" url=<<x>>/>
JanJo
September 15, 2023, 10:08am
8
Thanks @buggyj
I added an extra macro-step to be able to use it with a shorter spell,
perhaps we could also add the heigt to this an add something to remove at least one of the nested scrollbars
\define refreshdoctmpl(url,period)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="$period$">
</head>
<body>
<iframe src=$url$ frameborder="0" width="100%" height="1000px"></iframe>
</body>
</html>
\end
\define refreshiframe(url)
<iframe src=<<makedatauri """$url$""" "text/html">> frameborder="0" width="100%" height="1000px">
\end
\define reframe(url, time:"60")
<$vars x=<<refreshdoctmpl "$url$" "$time$">>>
<div style="height:1020px">
<$macrocall $name="refreshiframe" url=<<x>>/>
</div>
</vars>
\end
<<reframe "https://example.com/" "10">>