Sign up | Lost password? | Help

[ advanced search ]

Monday, 16. May 2005, 15:26:16

kln

avatar

Posts: 46

Norway

GTDTiddlyWiki

The problem is not the website ([url]http://shared.snapgrid.com/gtd_tiddlywiki.html), but the html-file you store on your local machine.

This is a GTD (getting things done) "application" consisting of one html-file (including some javascript). Everything seems to work fine, except that when you've done changes to the file, you're not allowed to save. Instead a javascript error window pops up saying
"It's not possible to save changes using this browser. Use FireFox if you can"

Identifying Opera as IE or Mozilla does not help.

Ketil

Tuesday, 17. May 2005, 05:32:08

The load/save code is very browser-specific, in fact the code specific to IE uses ActiveX, and the Mozilla/Firefox code appears to delve into the internals of the browser.

Unsurprisingly, neither of those techniques will work for any other browser. What works for Opera is using LiveConnect to access Java:
function operaSaveFile(filePath, content)
{
  try{
    var s = new java.io.PrintStream(new java.io.FileOutputStream(filePath));
    s.print(content);
    s.close();
  } catch(e) {
    opera.postError(e);
    return null;
  }
  return true;
}

function operaLoadFile(filePath)
{
  var content = '';
  try {
    var r = new java.io.BufferedReader(new java.io.FileReader(filePath));
    var line;
    while ((line = r.readLine()) != null) content += line + '\n';
    r.close();
  } catch(e) {
    opera.postError(e);
    return null;
  }
  return content;
}
You also need to modify your Java security policy, "C:\Documents and Settings\your-name\.java.policy":
grant codeBase "file:/c:/gtd_tiddlywiki.html" {
  permission java.io.FilePermission "c:\\gtd_tiddlywiki.html", "read,write";
  permission java.io.FilePermission "c:\\gtd_tiddlywiki_backup.html", "read,write";
};
setting the names appropriate to wherever the wiki file is.

Feel free to get in touch with the developer of the wiki and pass this info on.

Wednesday, 18. May 2005, 16:59:04

Sorry, i cannot understand. That means we need install Java for Opera and make some modifications to let it run?

Thursday, 19. May 2005, 03:36:37

Yes. The Javascript modifications are best made by the tiddlywiki developer. The loadFile and saveFile wiki functions also need to be modified, but it's pretty obvious:
function saveFile(fileUrl, content)
{
    var r = mozillaSaveFile(fileUrl, content);
    if((r == null) || (r == false))
        r = ieSaveFile(fileUrl, content);
[color=red]    if((r == null) || (r == false))
        r = operaSaveFile(fileUrl, content);[/color]
    return(r);
}

function loadFile(fileUrl)
{
    var r = mozillaLoadFile(fileUrl);
    if((r == null) || (r == false))
        r = ieLoadFile(fileUrl);
[color=red]    if((r == null) || (r == false))
        r = operaLoadFile(fileUrl);[/color]
    return(r);
}
You'll need to install Java, and modify/create the policy file.

Thursday, 19. May 2005, 04:48:36

Dear Andrew, More thanks for your instruction. It works definitely. Great news.

Thursday, 19. May 2005, 09:23:20

kln

avatar

Posts: 46

Norway

hmmmm...

I've added the changes to the code and updated the policy (I think...), but I keep getting "javascript error while saving":

[Error:
name: TypeError
message: Statement on line 1430: The Object does not implement [[Construct]]
Backtrace:
Line 1430 of inline#1 script in file://localhost/.../TiddlyWiki/gtd_tiddlywiki.html
var s = java.io.PrintStream(java.io.FileOutputStream(filePath));
Line 1461 of inline#1 script in file://localhost/.../TiddlyWiki/gtd_tiddlywiki.html
r = operaSaveFile(fileUrl, content);
Line 1338 of inline#1 script in file://localhost/.../TiddlyWiki/gtd_tiddlywiki.html
backup = saveFile(backupPath, original);
Line 1747 of inline#1 script in file://localhost/...TiddlyWiki/gtd_tiddlywiki.html
saveChanges();
At unknown location
[statement source code not available]

]

Thursday, 19. May 2005, 11:13:44

kln

avatar

Posts: 46

Norway

Restarting Opera did the trick.
Now it actually works!

Thank you very much for your help Andrew!

kln

Tuesday, 14. June 2005, 18:22:53

hage1

avatar

Posts: 2

Just found this info - but as I have not got any idea on how to do it.
Must I insert the script(s) into the tiddlywiki?
If not where do I put it?
More questions than answers.
I hope someone can help.
Thank you in advance

Thursday, 16. June 2005, 02:51:40

You need to edit the tiddlywiki file, adding the two Opera load/save functions from my first post, then modifying the existing load/save functions as shown in my second post.

Thursday, 16. June 2005, 21:01:46

hage1

avatar

Posts: 2

Thank you, Andrew.
Is there a particular line where to insert the functions from your first post?

Friday, 17. June 2005, 08:35:55

If you search for "loadFile" and "saveFile" (which you'll need to modify anyway) you'll see other functions for loading and saving in IE and Mozilla/Firefox. Anywhere around there will do, nowhere special.

Monday, 22. August 2005, 11:41:41

bigmusic

avatar

Posts: 17

Also make sure your java is up to date. I had been screwing around with this for a week trying to get it to work but after I updated java and it works now sorta. It seems to hang sometimes though. There are some java errors that occur as well. Seeing as how I am not a coder I thought if somebody could tell me what these mean I would appreciate it:

java.security.PrivilegedActionException: java.lang.ClassNotFoundException: java.io
at java.security.AccessController.doPrivileged(Native Method)
at com.opera.PrivilegedThread.run(LiveConnectPrivilegedActions.java:285)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: java.io
at com.opera.PluginClassLoader.findClass(PluginClassLoader.java:325)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.opera.PluginClassLoader.loadClass(PluginClassLoader.java:387)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.opera.PrivilegedFindClass.run(LiveConnectPrivilegedActions.java:261)
... 3 more
Caused by: java.io.FileNotFoundException: C:\java\io.class (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at com.opera.PluginClassLoader.readClassFile(PluginClassLoader.java:336)
at com.opera.PluginClassLoader.access$100(PluginClassLoader.java:35)
at com.opera.PluginClassLoader$4.run(PluginClassLoader.java:315)
at java.security.AccessController.doPrivileged(Native Method)
at com.opera.PluginClassLoader.findClass(PluginClassLoader.java:312)
... 7 more

Monday, 22. August 2005, 15:48:23

The error messages indicate a typo somewhere around where "java.io" is mentioned. Check that your code matches the code I gave above, both in the HTML file and the policy file. "java.io" must have a dot immediately after it, as in "java.io.something".

Monday, 22. August 2005, 16:44:08

bigmusic

avatar

Posts: 17

Thanks for your reply Andrew.

It's a straight cut and paste from your code to the files themselves. I even saved the wiki at the root of my C drive so that I would make sure I had the syntax correct for policy file.

Just so you know it does save, and you can write to the HTML file. It's just takes a few seconds for it to write to file. While it is writing none of the other functionality of the wiki is responsive to clicks. Just to see if there was anything going on in the java i opened up the console to watch and those errors above popped up. Javascript errors happned as well, but those stopped once I turned off the animation.

Monday, 22. August 2005, 16:45:16

bigmusic

avatar

Posts: 17

Oh, and I did do a word for word look over of the files and I couldn't find a bit of difference between the code on the site and the code in my files.

Tuesday, 23. August 2005, 04:18:51

Well, if the files are saving, then I guess the error messages are from some internal Java processing that's figuring out the various classes. Ignore them. I can't comment on the slowness, sorry. I don't use GTDTW myself.

Friday, 7. October 2005, 22:15:30

checketts

avatar

Posts: 3

The TiddlyWiki developer (Jeremy) has incorporated this code into the main TW code. However, I haven't been able to find anyone who could get Opera to save.

I've taken the code posted here and replaced Jeremy's functions with this (there were a few differences) and still no luck. I also performed the change to the .java.policy

Currently when I save Opera throws the following error:

=======================================================================
localhost:

[Error:
name: TypeError
message: Statement on line 2699: The Object does not implement [[Construct]]
Backtrace:
Line 2699 of inline#2 script in file://localhost/C:/tiddlywiki.htm
var r = new java.io.BufferedReader(new java.io.FileReader(filePath));
Line 2589 of inline#2 script in file://localhost/C:/tiddlywiki.htm
r = operaLoadFile(fileUrl);
Line 2389 of inline#2 script in file://localhost/C:/tiddlywiki.htm
var original = loadFile(localPath);
Line 1086 of inline#2 script in file://localhost/C:/tiddlywiki.htm
saveChanges();
return false;
At unknown location
[statement source code not available]

]
=================================================================================

I would really love to help get Opera saving working for all TW users. Any idea on what I'm missing? I realize that kln stated he had the same error (http://my.opera.com/community/forums/findpost.pl?id=935167) and it went away when he restarted Opera. Sadly it is still here for me. :frown:

-Clint

Friday, 14. October 2005, 19:36:58

mchean

avatar

Posts: 6

Has anyone had any luck with this yet on WinXP, I keep getting a message that it can't save on
localhost, and that I should use Firefox :mad:

Saturday, 15. October 2005, 07:45:33

I've emailed the developer of Tiddlywiki with the changes required to get Opera going.

[color=red]function operaUrlToFilename(url)
{
  var i = url.indexOf(':');
  if (i > 0) url = url.substring(i - 1);
  return url;
}[/color]

function operaSaveFile(filePath, content)
{
  try
    {
    var s = new java.io.PrintStream(new java.io.FileOutputStream([color=red]operaUrlToFilename([/color]filePath[color=red])[/color]));
    s.print(content);
    s.close();
    }
  catch(e)
    {
    if(opera)
      opera.postError(e);
    return null;
    }
  return true;
}

function operaLoadFile(filePath)
{
  var content = [];
  try
    {
    var r = new java.io.BufferedReader(new java.io.FileReader([color=red]operaUrlToFilename([/color]filePath[color=red])[/color]));
    var line;
    while ((line = r.readLine()) != null)
      content.push([color=red]new String([/color]line[color=red])[/color]);
    r.close();
    }
  catch(e)
    {
    if(opera)
      opera.postError(e);
    return null;
    }
  return content.join("\n");
}
New .java.policy file, which requires you place your Tiddlywiki into its own folder:
grant codeBase "file:/c:/tiddlywiki-folder/tiddlywiki.html" {
  permission java.io.FilePermission "c:\\tiddlywiki-folder\\*", "read,write";
};
Edit: it's possible that Jeremy may make some small alterations to this for his final version.

Monday, 17. October 2005, 14:21:31

checketts

avatar

Posts: 3

Thanks, those fixes now allow Opera to save. I really appreciate your help.

I noticed that it took Opera about 58 seconds to save an almost empty TW file. Does it take this long for your version of Opera? (I'm using Opera 8.5 on Windows XP SP2, Java Version 1.5.0_04) Are there any tweaks I can make to improve the saving speed?

-Clint

Monday, 17. October 2005, 14:22:07

checketts

avatar

Posts: 3

(Pardon the double post) -Server Error

Tuesday, 18. October 2005, 15:27:24

As expected, the code I gave above will be changing slightly, mostly for Apple Mac support. I'm still discussing things with the author - we're running into some security-related problems (.java.policy).

Yes, saving takes an age. I've been meaning to look into that. I suspect it's the line-by-line loading rather than the actual saving that's the problem. BTW, an "empty" TiddlyWiki is 124KB and has over 4500 lines!

Thursday, 23. March 2006, 17:32:16

rsperberg

avatar

Posts: 6

NYC

I have a Nokia 770, which includes Opera for devices.

The 770 weighs 8 oz and has an 800-pixel wide screen, which means I carry it around all the time in my hip bag and it's perfect for viewing a full web page.

So I'd like to use TiddlyWiki (or rather GTDTiddlyWiki) to take notes and keep reminders for myself, using Opera as the access program and keeping my gtd-wiki.html page on the 770's memory card. I really like TW's micro-content approach and the wiki method of linking notes (aka pages or, here, tiddlies). Much more natural than note-taking programs I've tried. Plus it's platform agnostic.

The Java workaround that permits Opera to save an html file locally doesn't work for me -- the 770 doesn't include Java.

I have, however, installed Python. And Ruby is available, as is Perl.

Can your fix be adapted to use one of these languages?

The combo of TiddlyWiki, Opera and the 770 could be extremely potent.

Thanks,

Roger

Monday, 31. July 2006, 03:37:02

I've been fooling with TiddlyWiki all weekend (see my blog) and made a much faster saver. Still requires Java, no getting away from that.

As for access to Python, Ruby or Perl, well I don't know anything about the Nokia 770, but I'd guess they won't be usable from Opera via JavaScript.

IMO, Java on the 770 is only a matter of time...

Wednesday, 8. November 2006, 19:59:36

@Andrew Gregory:
The version available of GTDTiddlyWiki at http://shared.snapgrid.com/index.html ( 1.0.6 Sept 3rd, 2005 )no longer have your code.
So, GTDTiddlyWiki no works anymore with Opera :frown:

Then I tried NextAction ( http://trimpath.com/project/wiki/NextAction ), a GTDTiddlyWiki-like "application".
But it also don´t works on Opera! :frown:
Try the demo at http://trimpath.com/demos/nextaction_static1/nextaction.htm

Any ideas?
TIA

Thursday, 9. November 2006, 01:09:44

The original TiddlyWiki has full Opera support.

GTDTiddlyWiki is a derivative project that I don't believe has ever incorporated the Opera saving code I've outlined in this thread. If you want to use GTDTiddlyWiki, you need to make the changes yourself.

Thursday, 9. November 2006, 10:24:10

OK, thanks for reply!
How about NextAction?

Friday, 10. November 2006, 10:48:14 (edited)

NextAction needs some fixes to even start working:

nextaction.htm:
Line 673: Delete extra comma at end of line

nextaction_files/query:
Lines 451, 461, 501, 530, 544: change "theEval" to "eval"

The following are also bugs, but they don't prevent it working:

nextaction.htm:
Line 64: delete extra illegal colon ( : )
Line 99: change "text-weight" to "font-weight"

... And now that I see how they save things - it won't work in Opera because Opera doesn't save the page from the version that's been modified in memory. Opera saves the file originally downloaded that is in the cache.

Friday, 10. November 2006, 10:56:50

Thanks, Andrew! I´ll pass this to the author.
I don't use GTDTW nor NextAction myself.
I´m just learning about GTD.

BTW, I support your "Formatted Email Composition" page! Count on me!
:up:

Friday, 10. November 2006, 12:19:18

I don't think NextAction will ever work on anything other than Firefox, not without them writing a load/save system like TiddlyWiki's. I know the TiddlyWiki guys found lots of issues with IE saving webpages, to the point where it just broke things.

Tuesday, 19. June 2007, 20:59:44

I think I've found an interesting replacement for [GTD]TiddlyWiki!
It's a Widget named MyWiki.
Take a look at http://widgets.opera.com/widget/4861

:cool:

Forums » Opera Community » Opera Community and other Opera services » Open the Web & Take Action