The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
How do I create a hyperlink Thread Tools Search this Thread Display Modes
Quote:
Originally Posted by Sébastien View Post
Any idea to perform this action ? (Using an applescript maybe ? I have checked the applescript dictionary of OO, but i did not found the "link" keyword...)
For fairly deep and intractable architectural reasons Applescript can not really manipulate RTF text. If it were something that I really needed to do, and performance were not an issue, I might explore something like:
  • Capturing the RTF data from the OO row by placing its text in the clipboard, and extracting the raw rtf data from there.
    Code:
    set dataRTF to the clipboard as «class RTF »
  • Writing the RTF data out to a file
  • Converting the RTF file to HTML with a textutil command line
  • Performing some string operations on the HTML to wrap potential links with <a HREF tags
  • Converting the HTML back to RTF, again with textutil
  • Capturing the TextEdit RTF version (now with clickable links) into the clipboard
  • Replacing the OO row contents with the clipboard contents.

Maybe the OO mouse operation doesn't seem so bad now :-)

--

Last edited by RobTrew; 2010-10-31 at 12:43 PM..
 
Or, I might process an .oo3 file directly:
  • gunzip the XML in the package (if necessary)
  • process the XML strings (regex ? XSLT transform ?)
  • rezip the XML (if necessary)
 
Quote:
Originally Posted by Sébastien View Post
when I select this kind of URL, I can transform it into a link, using "Make Link". But it forces me to use a mouse to do this
Not sure if others are seeing this, but if I make a link in this way, (Ctrl-click, Make Link) it works ...

BUT the link is lost if I save and close the document and then open it again ...

(Under Preferences > General > Attachments I have unchecked automatically create ...)

--
 
Thank you so much for your answer, I have found a solution with your tips ;)

Crafting a RTF link and capturing it into the clipboard worked very well. I use the following script for this :

#! /bin/bash
echo "{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf3 20
{\fonttbl\f0\fswiss\fcharset0 Optima-Regular;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3 920\tx4480\tx5040\tx5600\tx6160\tx6720\fi560\sl288 \slmult1\sb160\ql\qnatural\pardirnatural
{\field{\*\fldinst{HYPERLINK \"$2\"}}{\fldrslt*
\f0\fs26 \cf0 $1}}}" | pbcopy -Prefer rtf


Let's say this script is named "make-rtf-link", I just call it like this :
make-rtf-link <the link I want to use> <title of the link>*

And then I obtain a RTF link in my clipboard, which can be pasted into OO.

WIN *\o/


"Maybe the OO mouse operation doesn't seem so bad now :-)"
Ha ha ! Well... I just feel really better when I don't have to use a mouse when I work ^^
 
Good solution.

One could assign a keystroke to an analogous applescript.

A variant which uses HTML (for those of us who are not native RTF speakers):

Code:
set {strURL, strTitle} to {"", ""}

set strURL to text returned of (display dialog "Enter a URL:" default answer "http://" with title "Make Link")
set strTitle to text returned of (display dialog "Enter a title for the link:" default answer strURL with title "Make Link")

if (strURL is not "") and (strTitle is not "") then
	set strHTML to quoted form of ("<font face=\"helvetica\"><a href=\"" & strURL & "\">" & strTitle & "</a></font>")
	do shell script "echo " & strHTML & "  | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
end if
But, I am still finding that links made this way cease to work after the file has been saved, closed and reopened ...
(tho they work fine when first created)

(I have filed a bug under Help > Send Feedback ... )

--

Last edited by RobTrew; 2010-11-01 at 11:04 AM.. Reason: Added simple specification of font face
 
Quote:
But, I am still finding that links made this way cease to work after the file has been saved, closed and reopened ...
(tho they work fine when first created)
With my script I have no problem of this kind.
 
Quote:
Originally Posted by Sébastien View Post
With my script I have no problem of this kind.
Interesting. On my system, all three approaches (Ctrl-click Make Link, your script and mine) all have this problem. (I think they are all doing the same thing).

After reopening the file, Ctrl-click Open URL still works, but mouse-over no longer causes a cursor change, and simple dbl-clicking no longer launches the link
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink to external info stmind OmniPlan General 5 2010-03-04 07:29 AM
Create date Laucha OmniFocus 1 for Mac 2 2010-02-21 06:50 AM
Create own polygon jochen OmniGraffle General 3 2009-06-30 10:32 AM
Getting a Hyperlink of the Last Sent Message from Mail.app using Applescript DataGazetteer OmniFocus Extras 1 2008-05-22 04:48 AM
Can't create new Folder catxtwo OmniFocus 1 for Mac 2 2007-11-21 09:26 AM


All times are GMT -8. The time now is 10:28 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.