I was wondering if I could ask you how to change the [[file.xls]] tag,
of course in the ease and comfort of a plugin so that I can import it
into a new wiki when I upgrade it in the future :D
There are two things I'd like it to do.. I'd like it to accept
general windows links to files, like [[C:\program files\user\my
documents\test.xls]] or links to network drives: [[o:\office\documents
\2007\test.xls]] or if the file has been uploaded to a file directory
on the server it could link to there like this: [[documents\test.xls]]
This would be so that people who are used to the windows links can
just copy/paste from an explorer window instead of having to use
[[file:///o:/silly/stupid/test.xls]]
Of course, being able to drag and drop the file from an explorer
window into the edit window, and it would automatically copy the whole
link location to the edit window where the pointer is would be just..
brilliant.. not sure if that's at all possible though.
I'll try to investigate it myself, but if you know of a simple way to
do this (in a plugin), that'd be great.
K.
This would be so that people who are used to the windows links can just copy/paste from an explorer window instead of having to use [[file:///o:/silly/stupid/test.xls]]
//{{{Paste that code into a new tiddler (e.g. "FileLinkMacro") and tag it with "systemConfig", then reload your TiddlyWiki.
config.macros.fileLink = {};
config.macros.fileLink.handler = function(place, macroName, params) {
var filePath = params[0].replace("\\", "/") // convert path separators to Unix format
wikify("[[" + params[1] + "|file:///" + filePath + "]]", place);
};
//}}}
I changed the macro name to FL instead of fileLink, the macro is too
hard to use though in my humble opinion.
I would rather want to change the [[]] to suit my needs, is that not
possible as a plugin?
[[file description|file link]] is just alot easier than :
<<FL "file link" "file decription">> because instead of 5 things
screwing up, you got 10 things screwing up, if you're confused about
what I mean, I'll "" all the things I mean:
[[file description|file link]] = 5 things:
1) "[["
2) "file description"
3) "|"
4) "file link"
5) "]]"
<<FL "file link" "file description">>
1) "<<"
2) "FL"
3) """
4) "file link"
5) """
6) """
7) "file description"
8) """
9) ">>"
10) the spaces between the commands
I will use the filelink macro though, as it does do what I want it to
do (and maybe it's just a matter of getting used to it), so again
thanks alot for your input :)
K.
I get your point - but I'm afraid there's not much I can do about that.
Nevertheless, the macro syntax is quite straightforward; you have the
<<macroDelimiters>> (corresponding to [[linkBrackets]]) and simply need
to add the macro name and parameters (enclosed in quotes if there's a
space in the parameter value):
<<name "parameter 1" "parameter 2">>
vs.
[[parameter 1|parameter 2]]
So it's not really much different from the PrettyLinks syntax, actually.
What you could do, though, is change the way the parameters are handled,
so you'd use something like
<<name parameter 1|parameter 2>>
You'd just have to untangle the parameter string accordingly.
Of course you could also try hijacking the prettyLink function and
adding some sort of pattern recognition - e.g. something like (in
pseudo-code):
if(URL like /^\w:\\/) { // paths starting with a drive, like "C:\"
URL = "file:///" + URL;)
}
In fact, if you pull that off and it works without any issues or risks,
JR *might* even be willing to include it in the core...
-- F.
Nice idea. Get going on that, Kashgarinn :)
;D
--
Daniel Baird
http://tiddlyspot.com (free, effortless TiddlyWiki hosting)
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog ::
Things That Suck)
He might not have to:
In config.formatters, there's a section "name: 'prettyLink'".
Below the following lines:
// Pretty bracketted link
var link = lookaheadMatch[3];
I've added (in the actual source code, as I'm not sure how to
hijack/overwrite this):
// check for Windows file path (e.g. "C:\")
if(link.search(/^\w:\\/) != -1) {
link = "file:///" + link;
}
That should do it (though the RegEx is not heavily tested, so this
*might* be incomplete or even buggy).
Maybe I should move this to [twdev]...
-- F.
I added the code into my TW just below the var link =
lookaheadMatch[3]; , and it works.
a bit off-topic, I can only verify that it works in Internet explorer,
not firefox as I somehow was able to kill external links working in
firefox (mozilla as well.. somehow just a blank page pops up.. I'll
reinstall CCTW when it has been upgraded to the new version)
Thanks for that btw, not the solution I was looking for, but it works,
so I hope it'll get added to the core code.
K.
On Jun 6, 11:03 am, Kashgarinn <steint...@gmail.com> wrote:
> Of course, being able to drag and drop the file from an explorer
> window into the edit window, and it would automatically copy the whole
> link location to the edit window where the pointer is would be just..
> brilliant.. not sure if that's at all possible though.
>
-Xavier
Yup, that should be it.
I've posted this issue on [twdev]; I'll get back to you if/when there's
news to report.
> not the solution I was looking for, but it works
It's not the solution you were looking for?
what did you have in mind then, short of the drag&drop thing (which
won't work with a simple text box)!?
> I can only verify that it works in Internet explorer, not firefox
Works fine for me in FF - not sure how you could have messed that up
though, sorry...
-- F.
http://www.autohotkey.com/forum/viewtopic.php?t=19907
-- F.
Cheers
Jeremy
--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com
Done: ticket #348 (http://trac.tiddlywiki.org/ticket/348)
That patch will also convert network paths ("\\MyServer\MyFile.txt").
Please note that the regular expressions used here are not heavily
tested, so this *might* be incomplete or even buggy.
-- F.
Cheers
Jeremy
This was an easy one - and I'm glad I could give something back...
(... which I'm working on in the "Suppress an empty tags panel?" thread,
though I'm unsure whether that's core-worthy.)
-- F.
-Xavier