Search

John Sidiropoulos

How to Create RTF Links to Files in DEVONthink

DEVONthink assigns a custom Uniform Resource Locator ( URL) to every file that is in a DEVONthink database. An example of this URL is the following:

x-devonthink-item://F860B6A7–2AF7–4938–9C64-FFA0CC59036E

These URLs are extremely useful because you can use them to create links to the respective files of any type (e.g. RTF, HTML, Markdown). Moreover, they have some distinct advantages compared to links based on file paths. Specifically, the URL does not change if you rename the file or move it to another database or group/folder. You can even sync the file with a DEVONthink database on another device (iOS or macOS), and its URL remains the same. As a result, you can be confident that the links will not break in the future.

Moreover, in the case of a PDF file, a different URL is assigned to every single page of it. Consequently, you can link to a specific PDF page which is extremely useful for scholarly purposes. An example of such URL is the following:

x-devonthink-item://F860B6A7–2AF7–4938–9C64-FFA0CC59036E?page=10

The index base for the page numbers is zero. As a result, the above URL links to the eleventh page of the document and not to the tenth page as someone could expect.

You can get this URL on the clipboard by using the menu command “Copy Item Link”


or by using the contextual menu (right-clicking on any page).


Then you can just paste the page link in any program that supports RTF (Nisus Writer Pro, Skim notes, Tinderbox notes) and you will get automatically a nicely formatted link.


If you paste the link in Microsoft Word or any plain text editor, you get just the raw link. However, you can create the link manually using either a markup language (Markdown, LaTeX, HTML) or the command “Hyperlink…” in Word.

2017-04-28_17-04-41.jpg
2017–04–28_17–04–41.jpg

The automatically generated link is nice, but it does not contain the linked page number. Also, you cannot get the link to only one file at a time. These limitations can be overcome as usually by using AppleScript.

My preferred link style for non-academic purposes is (Title – Author: Referred Page) or (Title – Author).


The script for creating a link to a PDF page formatted as above is the following:

(*
johnsidi.com
Title: DEVONthink - clipboard - Create RTF link for selected file
Version: 1.0
Date: 28 April 2017
// REQUIREMENTS
--one and only one item should be selected in DEVONthink
*)
set the clipboard to ""
tell application "DEVONthink Pro"
    activate
    set theSelection to the selection
    if theSelection is {} then error "Please select one file."
    set selectedItems to count theSelection
    if selectedItems > 1 then error "Please select only one file"
    set fileType to kind of content record of window 1
    set fileLink to the reference URL of content record of window 1
    set nameFile to name of content record of window 1
    if fileType is equal to "PDF+Text" or fileType is equal to "PDF" then
        set DEVONthinkPageNum to current page of window 1
        set realCurrentPageNum to DEVONthinkPageNum + 1
        set HTMLlink to "(" & nameFile & ": " & realCurrentPageNum & ")"
        set the clipboard to HTMLlink
        do shell script "pbpaste | textutil -stdin -format html -convert rtf -stdout | pbcopy -Prefer rtf"
    else
        set HTMLlink to "(" & nameFile & ")"
        set the clipboard to HTMLlink
        do shell script "pbpaste | textutil -stdin -format html -convert rtf -stdout | pbcopy -Prefer rtf"
    end if
end tell

The script for creating links to the selected items in DEVONthink is the following:

(*
johnsidi.com
Title: DEVONthink - clipboard - Create RTF links for selected files
Version: 1.0
Date: 28 April 2017
// REQUIREMENTS
--at least one file should be selected in DEVONthink
*)
set the clipboard to ""
tell application "DEVONthink Pro"
    activate
    set theSelection to the selection
    if theSelection is {} then error "Please select at least one file."
    repeat with anItem in theSelection     
        set fileType to kind of anItem
        set fileLink to the reference URL of anItem
        set nameFile to name of anItem
        set HTMLlink to "(" & nameFile & ")
" set the clipboard to (the clipboard) & HTMLlink & return end repeat do shell script "pbpaste | textutil -stdin -format html -convert rtf -stdout | pbcopy -Prefer rtf" end tell

How to Create Bookmarks to Tinderbox Notes

There are some notes/containers in my Tinderbox files (e.g. Inbox, Actions for Today) which I want to visit in the fastest possible way, using just the keyboard or the trackpad.

A solution to this challenge is to create a stamp which opens this note using its URL (e.g. tinderbox://demo/?view=map+select=1493125917;). First, you need to take the URL of the note for which you would like to create in effect a bookmark as is shown in the following image and then create the stamp.


Then you need to open the Document Inspector (Stamps > Inspect stamps…) and create the stamp/bookmark. There are two versions of its action.

When the note is a simple note the action is just the command to open the URL, for example

runCommand("open tinderbox://demo/?view=map+select=1493125917;");

However when the note is a container I prefer the view to be focused automatically on the contents of the container. This can be accomplished if you create a code note (titled FocusViews) somewhere in your Tinderbox file (in the “code notes” container for example ), and add in its body the AppleScript code

tell application "System Events"
    key code 125 using {command down, shift down} --arrow down
end tell

This simple script activates the keyboard shortcut for the “Focus View” Tinderbox menu command.


The action of the “Go to Inbox” stamp is the following:

runCommand("open tinderbox://demo/?view=outline+select=1492694214;");runCommand("osascript -e '"
+$Text("FocusView") + "'" );

Some comments:

  • If no note is selected on a view the stamps are greyed out. However, a stamp/bookmark does not use any information from the currently selected note. As a result, it would be nice if it could be executed without this precondition.

  • On my demo project the Inbox URL (tinderbox://demo/?view=map+select=1492694214;). You can manually change the parameter “map” to one of the other Tinderbox views (outline, chart, attributeBrowser). For more details about the Tinderbox URL scheme, you can read this page: http://www.acrobatfaq.com/atbref7/index/ObjectsConcepts/Concepts/TinderboxURLschema.html.

  • Each time you activate a bookmark for a container (but not for a simple note) a new tab is created. This is somewhat burdensome especially because there is not at the moment a menu command for closing tabs created from Tinderbox (2nd level tabs – see this forum thread for more information) and you need to use the mouse.

Finally, you can assign to the stamp/bookmark a custom keyboard shortcut or even a gesture, and you are just one press away from any Tinderbox note.

How to Create an Inbox in Tinderbox

I am a new user of Tinderbox, and I use it mainly for task management at the moment (for note management I use a MediaWiki wiki). I think I have finally found a “task manager” which I can adapt to my needs and not be depended on any or task management app in which I have no degree of control. For example, OmniFocus still does not support tags, Todoist does not really support start dates, and I can do nothing about it. With Tinderbox I can just create a new user attribute and create in effect my own task manager.

Of course, Tinderbox is not perfect, and some useful functionality, especially for task management, is missing. For example, it does not have an Inbox or a scratchpad for quickly writing down an idea while working on something else on Tinderbox or on a different app as Plato65 pointed out on the Tinderbox forum. However, this can be done using an AppleScript!

First, you need to create a Tinderbox note/container in which all your new ideas will be collected. You can name the note “Inbox” or any other way you like. Then you need to copy the URL of the note and adjust the value of the property inboxURL at the start of my script.


After executing the script, a window is shown in which you can write the new Inbox item.

The default option is to just enter the title of the note. If you want to add extra info on the body of the note, after writing the title, you can click on the “Enter additionally the body of the note” button.

If you executed the script while working on another app, at the end this app would become again active.

Some additional comments:

  • The Tinderbox file in which the Inbox note has been created should always be open.
  • The URL (e.g. tinderbox://demo/?view=map+select=1492694214;) of a Tinderbox note is quite fragile because the note’s path is embedded on the URL. As a result, you should not change the position of the Inbox or if you do, then you will need to adjust the value of the inboxURL property.

The AppleScript code is the following:

(*
johnsidi.com

Title: Add a note to Tinderbox's inbox
Version: 1.1 
Changes: Added multi-line text fields
Date: 21 April 2017
 
// REQUIREMENTS
--replace the value of the property inboxURL with that of your own Inbox (Note > Copy Note URL)

*)


property inboxURL : "tinderbox://demo/?view=map+select=1492694214;"

set the clipboard to ""
tell application "System Events"
 set frontmostProcess to first process where it is frontmost
end tell

display dialog "Enter the title of the note:" default answer linefeed buttons {"Enter additionally the body of the note", "OK", "Cancel"} default button 2

copy the result as list to {titleBody, theTitle}

if titleBody is equal to "Enter additionally the body of the note" then
  set theText to text returned of (display dialog "Enter the body of the note." default answer (linefeed & linefeed & linefeed & linefeed & linefeed))
   set the clipboard to theTitle & return & theText
else
  set the clipboard to theTitle
end if

tell application "Tinderbox 7"
   activate
   --open the Inbox container
 do shell script "open " & inboxURL
 delay 0.5
  
   tell application "System Events"
       key code 125 using {shift down, command down} --arrow down
 end tell
end tell

tell application "System Events"
    keystroke "v" using {command down}
 delay 0.5
  key code 53 --Esc 
end tell
delay 1
-- return to the previous app
tell application "System Events"
 set frontmost of frontmostProcess to true
end tell

Finally, in the same spirit, you can change the AppleScript which is embedded in the excellent clip-to-Tinderbox service/workflow from Mark Anderson for all the clippings to be sent to the Inbox.

on run {input}
--replace the value of the property inboxURL with that of your own Inbox (Note > Copy Note URL)

    set the clipboard to input as Unicode text
    
    set inboxURL to "tinderbox://demo/?view=map+select=1492694214;"
    
    tell application "System Events"
        set frontmostProcess to first process where it is frontmost
    end tell
    
    tell application "Tinderbox 7"
        activate
        --open the Inbox container
        do shell script "open " & inboxURL
        delay 0.5
        
        tell application "System Events"
            key code 125 using {shift down, command down} --arrow down
        end tell
    end tell
    
    tell application "System Events"
        keystroke "v" using {command down}
        delay 0.5
        key code 53 --Esc 
    end tell
    delay 1
    -- return to the previous app
    tell application "System Events"
        set frontmost of frontmostProcess to true
    end tell
    
end run

Any comments or improvements are welcome!

Alexa, Todoist and nothing is lost in voice recognition!

I like the integration of Alexa with Todoist (the task manager of my preference), and I use the command “Alexa remind me …” several times per day.

Unfortunately the voice recognition accuracy of these free form utterances many times is not good to the effect that when Alexa repeats my request, sometimes it is incomprehensible! In the latter case, I have found out that the accuracy does not improve if you just try to repeat your request. But instead of just stopping using Alexa for recognising complicated utterances there is an alternative hacky and somewhat inconvenient solution.

Specifically, you can review all your voice interactions with Alexa by visiting History in Settings in the Alexa App or in the Alexa web page.

alexa-settings

There you can see a list of the transcriptions of all your interactions arranged chronologically and by clicking on the left side you can see the details for each one.

screen_shot_2017-01-02_at_19_41_23

Now the important thing is that you can listen to the audio clip which was wrongly transcribed by clicking on the transcription.

alexa-click-on-audio-clip

As a result, you can hear back the request and remember what you wanted to do. Nothing is lost!

Additionally, you can provide feedback on inaccurate translations which hopefully will improve the voice recognition accuracy in the future.

Bill Gates on Knowledge

“The old saying knowledge is power sometimes makes people hoard knowledge. They believe that knowledge hoarding makes them indispensable. Power comes not from knowledge kept but from knowledge shared. A company’s values and reward system should reflect that idea.” (Bill Gates, 1999)

An Apple Watch and its charger, an unexpected configuration

A nice unexpected feature of the Apple Watch is that it can be charged while you are wearing it! Additionally the Milanese loop makes the process of temporarily adjusting the strap extremely easy and fast. I have bought also a charger with relative long cable (2m) which permits a sufficient range of movement while I am sitting at a desk.
apple-watch-charging-1

 

Some tools of the trade

I currently use the following hardware:

This is my new virtual home!

At the moment everything is under construction!

under-construction

A WordPress.com Website.

Up ↑