[TW5] Editor Toolbar - Adding a browse for files button ( [ext[...]] )

156 views
Skip to first unread message

The Bo

unread,
May 19, 2016, 4:18:29 AM5/19/16
to TiddlyWiki
Hey,

I was thinking about adding a button to the new editor toolbar where I can browse for local files to add them as an [ext[...|...]] link.

I would suggest a dropdown with a browse for file button and an editor field to name the link:

<input type="file">
<input type="text">



For the Javascript part I found this code:

function processSelectedFiles(fileInput) {
var files = fileInput.files;
for (var i = 0; i < files.length; i++) {
 alert
(files[i].name);
}
}


My problem is my lack of javascript skills and in fact I'm not deep enough in the tw core.
Does anyone have an idea how to implement this, maybe as a plugin?

Regards,
The BO

The Bo

unread,
Jul 25, 2016, 4:18:15 AM7/25/16
to TiddlyWiki
Any idea or is there already such a plugin?

Jeremy Ruston

unread,
Jul 25, 2016, 4:25:23 AM7/25/16
to tiddl...@googlegroups.com
Hi The Bo

I was thinking about adding a button to the new editor toolbar where I can browse for local files to add them as an [ext[...|...]] link.

For the Javascript part I found this code:
Unfortunately, for security reasons, browsers do not expose the full pathname of the selected file to JavaScript. Some browsers expose the filename portion, as in your example above, but even that is not consistent.

Best wishes

Jeremy


My problem is my lack of javascript skills and in fact I'm not deep enough in the tw core.
Does anyone have an idea how to implement this, maybe as a plugin?

Regards,
The BO

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/338c9fcd-4b73-44f1-838b-839ae8753ddf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dragon Cotterill

unread,
Jul 25, 2016, 6:04:13 AM7/25/16
to TiddlyWiki

Hi Bo,

On Monday, 25 July 2016 09:18:15 UTC+1, The Bo wrote:
Any idea or is there already such a plugin?

As Jeremy stated, it's almost impossible to get the details to external files from inside TW due to the security restrictions of the Browsers.

One of my TW's makes extensive use of external files (.PDFs and images) and the only way I could get them integrated was with external batch files.

This is one of my import routines:
@echo off
cd
Unsorted
for /f "Tokens=*" %%f in ('dir /l/b/a-d') do (rename "%%f" "%%f")
cd
..

FOR
%%A in (Unsorted/*.pdf) DO (
echo ^<div title="%%~nA" modifier="Imported" created="201001011200" tags="Unsorted" changecount="1"^> >> entries.div
echo ^<pre^>^|!Name: ^|%%~nA ^| >> entries.div
echo ^|!Author: ^| ^| >> entries.div
echo ^|!Date: ^| ^| >> entries.div
echo [img[./Images/Book.png][./Documents/%%A]] >> entries.div
echo ^</pre^>^</div^> >> entries.div
)

It is designed for TWC and has a specific layout, but it may suit your needs. But what it does is first switch everything in the "Unsorted" sub-directory into lowercase (this prevents loads of error where it tries to wikify the names of the .PDFs that are imported) before building a file with all the names of the PDFs as tiddler titles. The resulting file (entries.div) is then placed inside the TW file. When I go through and edit all the "Unsorted" tagged entries, TW handles the tidying up of the actual tiddlers.



 

The Bo

unread,
Jul 25, 2016, 7:09:13 AM7/25/16
to TiddlyWiki
Hey Jeremy,

I have a workaround for my purposes because the files are in directories named like this "01/011/0112/filename.pdf". My idea was to name the files for this example "0112 - filename.pdf" so I could create the fullpath by readout of the first 4 signs.

@ Dragon Cotterill
Thank you for your suggestion but I would really like to pass on batch files.

Regards
The Bo
Reply all
Reply to author
Forward
0 new messages