Hi,
I have some tiny problems with TM's HTML output window.
I have a tmcommand which generates HTML code on basis on a shell script. Fine, after invoking it I see my result. In addition I added a button called 'Refresh' to that HTML page. I want to use it to start that shell script again (which writes the HTML code to a file) using TextMate.system and then via JavaScript 'location.href' or 'location.replace()' to refresh the HTML output window.
Well, this only works if I press the button at least twice or three times(?). After pressing the refresh button I had a look at the new generated html file and the content is correct, but TM'S HTML output window displays still the 'old' version. I tried the meta tags no-cache and expire with '0'. No success. I also changed the actual html code a bit to be sure that TM recognizes it's a new document.
Is there a built-in cache for the HTML ouptut? Or can someone advice me? How can force TM to refresh the HTML output?
Many thanks in advance,
--Hans
On Mar 4, 2008, at 3:32 PM, Hans-Jörg Bibiko wrote:
Hi,
I have some tiny problems with TM's HTML output window.
I have a tmcommand which generates HTML code on basis on a shell script. Fine, after invoking it I see my result. In addition I added a button called 'Refresh' to that HTML page. I want to use it to start that shell script again (which writes the HTML code to a file) using TextMate.system and then via JavaScript 'location.href' or 'location.replace()' to refresh the HTML output window.
Well, this only works if I press the button at least twice or three times(?). After pressing the refresh button I had a look at the new generated html file and the content is correct, but TM'S HTML output window displays still the 'old' version. I tried the meta tags no-cache and expire with '0'. No success. I also changed the actual html code a bit to be sure that TM recognizes it's a new document.
Is there a built-in cache for the HTML ouptut? Or can someone advice me? How can force TM to refresh the HTML output?
Many thanks in advance,
--Hans
I'd suggest replacing the html of the current window instead of changing the url. But if you're dead set on just changing the url, add a unique get string to the end EG: myfile.html?342739847923 to force the caching system to assume it's a different file.
Replacing the html with innerHTML or something would be a lot faster and bugfree.
I was actually thinking of writing something that would let me do this, but I never got around to it. Just making sure everything is properly escaped for javascript and html and the shell and then whatever script you have is enough to drive the lazy coders like me mad.
—Thomas Aylott – subtleGradient—
On 6 Mar 2008, at 00:17, Thomas Aylott - subtleGradient wrote:
On Mar 4, 2008, at 3:32 PM, Hans-Jörg Bibiko wrote:
I have a tmcommand which generates HTML code on basis on a shell script. Fine, after invoking it I see my result. In addition I added a button called 'Refresh' to that HTML page. I want to use it to start that shell script again (which writes the HTML code to a file) using TextMate.system and then via JavaScript 'location.href' or 'location.replace()' to refresh the HTML output window.
Well, this only works if I press the button at least twice or three times(?). After pressing the refresh button I had a look at the new generated html file and the content is correct, but TM'S HTML output window displays still the 'old' version. I tried the meta tags no-cache and expire with '0'. No success. I also changed the actual html code a bit to be sure that TM recognizes it's a new document.
Is there a built-in cache for the HTML ouptut? Or can someone advice me? How can force TM to refresh the HTML output?
I'd suggest replacing the html of the current window instead of changing the url. But if you're dead set on just changing the url, add a unique get string to the end EG: myfile.html?342739847923 to force the caching system to assume it's a different file.
Replacing the html with innerHTML or something would be a lot faster and bugfree.
Thanks. Finally I went that way using innerHTML. The idea using myfile.html?342739847923 also works but unfortunately I also have to deal with images which have the same URL but I change the content of these images with a script.
There is also an other issue. If I press a button within an HTML output window very slowly - meaning press the button down, wait a second, and release it - works sometimes better than a 'fast' click. I don't know whether this is an issue of TM's internal event loop in conjunction with TextMate.system().
But anyway, it would be nice to have an option to force the HTML window to avoid caching the content.
--Hans
On 6 Mar 2008, at 08:56, Hans-Joerg Bibiko wrote:
[...] There is also an other issue. If I press a button within an HTML output window very slowly - meaning press the button down, wait a second, and release it - works sometimes better than a 'fast' click. I don't know whether this is an issue of TM's internal event loop in conjunction with TextMate.system().
Try to make the button do something else than TextMate.system() (and maybe try the same in Safari). I don’t see how TM’s event loop should be able to affect this.
Sounds more like WebKit’s buttons start a local event loop on mouse down which has a timeout to prevent getting stuck e.g. in case of a missed “application lost focus”-event or similar.
But anyway, it would be nice to have an option to force the HTML window to avoid caching the content.
I am not aware of anything I can do here -- I already use all the WebKit settings which exist for disabling caching.
On 6 Mar 2008, at 09:14, Allan Odgaard wrote:
On 6 Mar 2008, at 08:56, Hans-Joerg Bibiko wrote:
[...] There is also an other issue. If I press a button within an HTML output window very slowly - meaning press the button down, wait a second, and release it - works sometimes better than a 'fast' click. I don't know whether this is an issue of TM's internal event loop in conjunction with TextMate.system().
Try to make the button do something else than TextMate.system() (and maybe try the same in Safari). I don’t see how TM’s event loop should be able to affect this.
Sounds more like WebKit’s buttons start a local event loop on mouse down which has a timeout to prevent getting stuck e.g. in case of a missed “application lost focus”-event or similar.
But anyway, it would be nice to have an option to force the HTML window to avoid caching the content.
I am not aware of anything I can do here -- I already use all the WebKit settings which exist for disabling caching.
Thanks. I see.
I tried several things. I wrote an HTML doc /bla.html containing a button which does javascript "location.replace(file:///bla.html)" and the meta tags for no-cache, expires=0 etc.
I opened that file via a tmcommand cat /bla.html in an HTML output window. Then I changed the content of /bla.html and pressed the button. Nothing happens. If I do this in Safari it works. If I do this within the HTML Preview window (no refreshing) it also works.
--Hans
On 6 Mar 2008, at 11:37, Hans-Joerg Bibiko wrote:
[...] I wrote an HTML doc /bla.html containing a button which does javascript "location.replace(file:///bla.html)" and the meta tags for no-cache, expires=0 etc.
Try use tm-file: instead. Quoting the manual:
Due to a (presumed) security restriction with WebKit it is not possible to have the HTML output redirect, link or reference files on your disk via the file: URL scheme. Instead you can use the tm-file: URL scheme, which works exactly like file:, but does not have this cross-scheme restriction.
On 6 Mar 2008, at 13:11, Allan Odgaard wrote:
On 6 Mar 2008, at 11:37, Hans-Joerg Bibiko wrote:
[...] I wrote an HTML doc /bla.html containing a button which does javascript "location.replace(file:///bla.html)" and the meta tags for no-cache, expires=0 etc.
Try use tm-file: instead. Quoting the manual:
OF COURSE! With tm-file it works. Thanks!! (Actually I should know this ;)
--Hans