Inserting links to local files

Everything related to our flagship word processor.
Post Reply
Usable Thought
Posts: 11
Joined: 2009-08-05 03:03:05

Inserting links to local files

Post by Usable Thought » 2009-12-07 03:29:09

Just as background, I posted quite a while back that I had rejected Nisus Writer Pro as a word processor due to unresolvable issues with line height. However I am now evaluating it, and will probably buy it shortly, for a different purpose: editing RTF files, pure and simple. It's obviously far better than TextEdit; I can use it as my external editor in combination with DevonThink; etc.

Now for my questions:

1) Is there a way to create an alias to a file via the standard Mac operations for doing so, then insert or drag this alias into an RFT or RFTD file such that it becomes a link?

2) For hyperlinks to local files, is there a way to instruct a particular application to open a file? Otherwise what happens is just that Finder gets opened with a highlight on the file. So far in my playing around I have gotten Acrobat to open as an application by adding its name a hyperlink, but not to actually open a file. Haven't found any info yet on this question in the Acrobat forums.

These are not really Nisus questions - they relate more to OS X, the RFT standard, etc. But I'm hoping someone may know the answers from experience.

User avatar
martin
Official Nisus Person
Posts: 4251
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Inserting links to local files

Post by martin » 2009-12-09 12:33:53

Usable Thought wrote:1) Is there a way to create an alias to a file via the standard Mac operations for doing so, then insert or drag this alias into an RFT or RFTD file such that it becomes a link?
At this time no, but I don't see why we can't add such a thing. I'll file an enhancement request.

In the meantime you might use some kind of macro to help you. Here's a macro that inserts/adds a link in the topmost NWP document. That link points to the second document open in NWP.

Code: Select all

# gather documents we'll need
$docs = Document.openDocuments
If $docs.count < 2
	Prompt 'There must be at least two open documents to link between.'
	Exit
End

$applyDoc = $docs.valueAtIndex(0)
$targetDoc = $docs.valueAtIndex(1)
$filePath = $targetDoc.filePath
If ! $filePath
	$name = $targetDoc.displayName
	Prompt "The 2nd open document '$name' has not been saved, and thus cannot be linked to."
	Exit
End

# add link
$link = $filePath.expandedFilePath
$link = 'file://' & $link

Document.setActive($applyDoc)
If $applyDoc.textSelection.length == 0
	Insert Text $filePath.lastFilePathComponent
End
Set Link $link
Hopefully that's useful.
2) For hyperlinks to local files, is there a way to instruct a particular application to open a file? Otherwise what happens is just that Finder gets opened with a highlight on the file.
As far as I know, this isn't possible. What you want used to be the case prior to OSX 10.5 (Leopard), but Apple changed the behavior, likely for security reasons. However, NWP could help out here; I think we already have a request filed for this feature, but I'll make sure.

Usable Thought
Posts: 11
Joined: 2009-08-05 03:03:05

Re: Inserting links to local files

Post by Usable Thought » 2009-12-09 12:36:36

Thanks - I'll try the macro out.

I know some apps do manage to insert links that open to files they contain - e.g. Papers and DevonThink. But I don't know how they do it - I could look at the RFT code in plain text, but even then I assume the functionality that actually makes it work is in the app, not in the link.

User avatar
martin
Official Nisus Person
Posts: 4251
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Inserting links to local files

Post by martin » 2009-12-09 13:01:28

That's correct, the behavior of NWP would need to change, not the RTF. Currently NWP just punts the link/URL to OSX to handle, which is why the behavior is dependent on which version of OSX you're using. But we could check for URLs that point to local files, decide the proper application, and launch/open the file there.

User avatar
loulesko
Posts: 89
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: Inserting links to local files

Post by loulesko » 2009-12-09 18:08:38

How does one insert a hyper link to a local file? I know about the Hyperlink menu item, but how would you select a file with a dialog window?

thanks
Lou

Usable Thought
Posts: 11
Joined: 2009-08-05 03:03:05

Re: Inserting links to local files

Post by Usable Thought » 2009-12-09 18:19:07

How does one insert a hyper link to a local file? I know about the Hyperlink menu item, but how would you select a file with a dialog window?
Instead of

Code: Select all

http://
at the start of the URL you have

Code: Select all

file://
As for the path to the file, you could write a macro to get this. At the moment I am using Pathfinder, which has a nice context menu entry allowing you to manually copy various types of paths for a file.

User avatar
loulesko
Posts: 89
Joined: 2008-01-20 11:08:35
Location: California
Contact:

Re: Inserting links to local files

Post by loulesko » 2009-12-10 09:02:48

Fabulous. Thanks for the response.

-L

Post Reply