Here's where I'm at in my version of the FileDropPlugin Config ...
might not get back to it until tomorrow. Linking not quite right,
doesn't know about un*x, not discriminating by file type ... oh well.
-- Mark
config.macros.fileDrop.addEventListener("application/x-moz-
file",function(nsiFile)
{
var t = nsiFile.path.replace(/\\/g,"_") ;
var newDate = new Date();
/* Given file path or url, convert into standard local path */
function normalizedPathArray(str) {
var idx = str.lastIndexOf(":") ;
if (idx != -1) str = str.substring(idx-1) ;
str = str.replace(/\\/g,"/") ;
var ret = str.split("/") ;
ret[0] = ret[0].toLowerCase() ;
return ret ;
}
var localPathArray = normalizedPathArray(document.URL) ;
var droppedPathArray = normalizedPathArray(nsiFile.path) ;
var sharedPath = [] ;
for(var i=0;i<localPathArray.length;i++) {
if(localPathArray[i] != droppedPathArray[i]) break ;
sharedPath[i] = localPathArray[i] ;
}
var filePath = droppedPathArray.join("/") ;
if (sharedPath.length) {
filePath = "" ;
for(i=0;i<localPathArray.length - sharedPath.length-1;i++)
filePath += "../" ;
filePath += droppedPathArray.slice(sharedPath.length).join("/") ;
filePath = "../" + sharedPath.join("/") ;
}
var fileLink = "" + droppedPathArray[droppedPathArray.length-1] +
"|" + filePath + "]]" ;
store.saveTiddler(null,t,fileLink,config.options.txtUserName,newDate,
[]);
story.displayTiddler(null,t)
})
On Feb 9, 11:34 am, "Mark S." <[email protected]> wrote:
> Hi Eric,
>
> Is there an easy way to set FileDropPluginConfig, so that it always
> links and never embeds -- even for text files? Basically, I just want
> to drag and drop links to files (preferably with a relative path so
> that it will work anywhere.) I guess having intelligent drag-and-drop
> links (e.g. formatted as links for files but as images for images)
> would be cool, but even just having not to type the path by hand would
> be a good start.
>
> The concept of embedding files is really cool, but the only benefit
> over file linking is that its a bit simpler to carry everything as one
> file on your thumbdrive. Without a synchronization tool (e.g. rsync)
> it might be a bit tedious to carry along a set of files rather than
> one file.
>
> So .... thinking out loud. What about dragging and dropping a file,
> which creates a batch file script in the tiddler? Then the actual
> human being could copy the tiddler out to a bat file (or sh, depending
> on system), and run the code which would set up directories, copy the
> files, etc. This would bypass the sensible security limitations on
> javascript, handing-off the responsibility to a human who, hopefully,
> knows that its OK to copy file "B" to new location "Z".
>
> -- Mark
>
> On Feb 9, 8:57 am, Eric Shulman <[email protected]> wrote:
>
> > > moderate sized image and got a new tiddler with the following info:
>
> > > plot2.jpg type=image/jpeg, size=128810 bytes, encoded=174431 bytes
>
> > > But every time when I try to open that tiddler, there will be a long
> > > delay and FF3 will report a unresponsive script. The tiddler will
> > > eventually open and the full size image show in the tiddler. But this
> > > is not so usable with even larger size image.
>
> > > Did I missed anything? I read some people also have issues with
> > > several MB video file. So I guess the embedding process slow it
> > > down.
>
> > In general, photos and other media files are, for practical use, too
> > big to embed as base64-encoded content, primarily due to performance
> > issues. Encoded images are best used for relatively small graphics,
> > such as icons, logos, and background textures.
>
> > > I wonder if it is possible to NOT embedded the file into a tiddler but
>
> > AttachFilePlugin supports *three* different ways to attach a file:
> > * embedded base64-encoded data
> > * a local file/path reference
> > * a URL
>
> > If there is no embedded data in the attachment tiddler, then the local
> > path/file is used (if any). If there is no local file information (or
> > the file does not actually exist), then the attachment falls back to
> > using a remote URL (if specified).
>
> > There is a Configuration section in FileDropPluginConfig that you can
> > use to control whether or not *encoded* data will be included in the
> > attachment tiddler.
>
> > > Since the main headache of using external file are maintaining the
> > > relative link and file storage.
>
> > Using TiddlyWiki to automatically copy/create new directories and
> > files in your filesystem is not a good idea: file and directory I/O
> > functions from javascript are subject to security restrictions
> > (especially for writing *binary* files), and there are significant
> > browser-specific and OS-specific limitations that make reliable
> > implementation extremely difficult. At best, it's a large, complex
> > chunk of code... at worst, there's just too many ways that the
> > functions can fail, with the potential for filesystem corruption
> > (badly formed directories/files) or loss of data (from deleting the
> > wrong file).
>
> > However, even without automatic manipulation of the external
> > filesystem, you can still use AttachFilePlugin/FileDropPlugin much as
> > you have described... except that you will still have to manually
> > create and maintain the external folder of images, rather than having
> > the plugin do it for you.
>
> > enjoy,
> > -e
> > Eric Shulman
> > TiddlyTools / ELS Design Studios
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---