Snapshot Plugin not working

145 views
Skip to first unread message

Stephan Hradek

unread,
Mar 18, 2013, 10:52:43 AM3/18/13
to tiddly...@googlegroups.com
Hi!

I didn't test before :( I upgraded to FF19 and TiddlyWiki 2.7.1. Now I tried the snapshot plugin and it fails with:

error during local file access: TypeError: netscape.security.PrivilegeManager is undefined

Is there anything I can do about it?

Eric Shulman

unread,
Mar 18, 2013, 3:15:23 PM3/18/13
to TiddlyWikiDev
FireFox has removed support for privileged filesystem I/O functions.
In this case, it is the "file picker" interface. As a work-around,
you could overlay the SnapshotPlugin definition of "askforfilename",
so that it uses a simple 'prompt' for input (which doesn't require any
security).

Create a new tiddler called [[SnapshotPluginTweak]], tagged with
'systemConfig', containing:
----------------------
config.macros.snapshot.askforfilename=function(msg,path,file){
return prompt(msg,path+file);
}
----------------------

When you open your document, plugins are loaded in alphanumeric order,
based on tiddler title, so the SnapshotPluginTweak is applied after
SnapshotPlugin, replacing the errant function with the above
simplification.

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

Stephan Hradek

unread,
Mar 18, 2013, 3:49:20 PM3/18/13
to tiddly...@googlegroups.com
Thanks Eric!

Will you update the plugin?

Did you also see my ListBoxPlugin enhancement?

Stephan Hradek

unread,
Mar 18, 2013, 3:57:51 PM3/18/13
to tiddly...@googlegroups.com
Small typo. It's not "askforfilename" but "askForFilename".

But with that fix it worked.

cmari

unread,
Mar 18, 2013, 5:56:02 PM3/18/13
to tiddly...@googlegroups.com
Thanks for this tip, Eric!  Could something similar be done for other plugins? 
I'm most especially missing the ability to use ExportTiddlersPlugin (or even SaveAsPlugin, as a second-best alternative), but QuickEdit_image would be awfully nice to have again, too.
Thanks!
cmari

Stephan Hradek

unread,
Mar 19, 2013, 3:31:10 PM3/19/13
to tiddly...@googlegroups.com
Hi cmari!

Why don't you try?

I lloked at the export  plugin and found a "askForFilename" in "config.macros.exportTiddlers". So simply adding a "tweak"-tiddler should be a valid approach.

cmari

unread,
Mar 19, 2013, 4:18:57 PM3/19/13
to tiddly...@googlegroups.com
Hi Stephan,
I did try to tweak QuickEdit before posting and had no success.  That's why I asked the question.

However, now that you have prompted me, I tried ExportTiddlers again and discovered that with all the recent updates, it seems to be working already, with no additional tweaking required (TW 2.7.1 and the updated TiddlyFox extension in Firefox).  So thanks!
cmari

Majou Nexian

unread,
Nov 24, 2015, 11:03:09 AM11/24/15
to tiddly...@googlegroups.com
Hello.

First of all, I would like to thank Mr. Shulman for the wonderful and powerful editor!
While being somewhat bigger than WikiBar, QuickEdit - correctly handles applying foreground and background to text and has much richer functionality.

This problem indeed still exist today!

One image may say more than million of words: http://imgur.com/vJlygOj
Perhaps Mr. Shulman could find a slice of his time to update his marvelous (without exaggeration) plugins. That would be wonderful.

The solution which works is indeed in updating the tiddler. This works and here is how:
Edit: QuickEditPlugin

        if(window.Components) { // moz
            try {
-               netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-               var nsIFilePicker = window.Components.interfaces.nsIFilePicker;
-               var picker = Components.classes['@mozilla.org/filepicker;1'].createInstance(nsIFilePicker);
-               picker.init(window, msg, nsIFilePicker.modeOpen);
-               var thispath = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
-               thispath.initWithPath(path);
-               picker.displayDirectory=thispath;
-               picker.defaultExtension='jpg';
-               picker.defaultString=file;
-               picker.appendFilters(nsIFilePicker.filterAll|nsIFilePicker.filterImages);
-               if (picker.show()!=nsIFilePicker.returnCancel)
-                   var result="file:///"+picker.file.path.replace(/\\/g,'/');
+                  var result=prompt(msg,path+file);
            }
            catch(e) { alert('error during local file access: '+e.toString()) }

Thats it. Just as stated by Stephan Hradek.

Image of it working:   http://imgur.com/OJZX489

This is for anyone who strikes in finding the solution, as TW5 is still very lacking in WYSIWYG- (editor requires external dependency, making it unportable) and markup- editors.

Tobias Beer

unread,
Nov 24, 2015, 1:45:46 PM11/24/15
to TiddlyWikiDev
Hi Majou,

Thanks for posting.
While tiddlytools.com says it hasn't been updated in two years,
perhaps Eric picks up on it.

Best wishes,

— tb

Eric Shulman

unread,
Nov 24, 2015, 2:58:24 PM11/24/15
to TiddlyWikiDev
On Tuesday, November 24, 2015 at 8:03:09 AM UTC-8, Majou Nexian wrote:
The solution which works is indeed in updating the tiddler. This works and here is how:
Edit: QuickEditPlugin

        if(window.Components) { // moz
            try {
-               netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-               var nsIFilePicker = window.Components.interfaces.nsIFilePicker;
-               var picker = Components.classes['@mozilla.org/filepicker;1'].createInstance(nsIFilePicker);
-               picker.init(window, msg, nsIFilePicker.modeOpen);
-               var thispath = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
-               thispath.initWithPath(path);
-               picker.displayDirectory=thispath;
-               picker.defaultExtension='jpg';
-               picker.defaultString=file;
-               picker.appendFilters(nsIFilePicker.filterAll|nsIFilePicker.filterImages);
-               if (picker.show()!=nsIFilePicker.returnCancel)
-                   var result="file:///"+picker.file.path.replace(/\\/g,'/');
+                  var result=prompt(msg,path+file);
            }
            catch(e) { alert('error during local file access: '+e.toString()) }

Thats it. Just as stated by Stephan Hradek.


You should NOT modify the plugin itself.  Rather, create a separate "plugin" tiddler, similar to the one described in an earlier post in this thread (see https://groups.google.com/forum/#!original/tiddlywikidev/sGjHBRn7OJA/Zal9VOY1Mk4J)

Create a new tiddler called [[QuickEditPluginTweak]], tagged with 'systemConfig', containing: 
config.quickEdit.promptForFilename=function(msg,path,file){
   
return prompt(msg,path+file);
}

Because plugins are loaded in alphabetical order by title, QuickEditPluginTweak will be loaded after QuickEditPlugin, thus replacing the default 'promptForFilename()' function that attempts to show a system file-picker dialog with a simple function that just invokes "prompt()" to display a text input popup to enter a path/filename.

enjoy,
-e

Majou Nexian

unread,
Nov 24, 2015, 6:47:02 PM11/24/15
to TiddlyWikiDev

Well, few things:
- its TWC, so I understand that Eric would probably want to work on TW5 and abadon TWC altogether. Which is favorable from perspective of efficient time management.
- it was broken with latest post in 2013, in fact I googled this discussion while having this problem.
- because I found the working "hack", I decided to post it, because a working hack is better than not-working clean code.

Of course, an updated plugin or correctly created patch is far better solution, but due to the reasons just above, my intention was to fix somewhat this problem for others in similar need.
I am not expecting anyone to do a proper fix, perhaps this may even turn counter-productive and could lead to chain patching.

All the best!

Majou Nexian

unread,
Nov 24, 2015, 6:47:58 PM11/24/15
to TiddlyWikiDev

I see. thank you very much!!

 
Reply all
Reply to author
Forward
0 new messages