Automated summary creation linked with the source PDF file

One of the great characteristics of Skim highlights is that they capture automatically the highlighted text  in a newly created note.

Moreover you can export these notes in a separate txt or rtf file.

As a result an approximation of a summary is created if you highlight the appropriate text passages.

Additionally if you have created the Skim notes with the DevonThink links as I described in the post "DevonThink links in Skim notes and AppleScript" you can use another AppleScript in order to have a properly formatted hyperlink from every highlighted text to the exact pdf page of the paper or book.

When you copy this text to the respective wiki page of the paper or book you will have a nice hypertext between your summary and the source pdf file.

You can see the seamless integration between the summary and the pdf in the following YouTube video.

The AppleScript code is the following (updated):

 tell application "Skim"
    set pdfDevonThinkLink to (get text for note 4 of page 1 of document 1) as string
    set pdfDevonThinkLinkWihtoutZero to (text 1 thru ((length of pdfDevonThinkLink) - 1) of pdfDevonThinkLink) as string
    set allMyPages to pages of document 1
    set numberOfMyPages to length of allMyPages as integer
    tell application "TextMate"
        tell document 1
            insert "===Skim notes===
        end tell
    end tell
    repeat with currentPage from 0 to numberOfMyPages
        set pageNotes to notes of page currentPage of document 1
        set numberOfPageNotes to length of pageNotes as integer
        repeat with currentNoteNumber from 1 to numberOfPageNotes
            set pdfText to (get text for note currentNoteNumber of page currentPage of document 1) as string
            set pageForDevonThinkLink to currentPage - 1
            set the clipboard to pdfText
            tell application "TextMate"
                tell document 1
                    insert (the clipboard) & " [" & pdfDevonThinkLinkWihtoutZero & pageForDevonThinkLink & " p. " & currentPage & "]

                end tell
            end tell
        end repeat
    end repeat
end tell
In order for the script to work you need to have TextMate installed in your Mac and an empty txt file open.


How to put DevonThink links in Skim notes

For every book or paper that I read I create a new page in my wiki. The name of this page is created under the following template: Title - Author, for example "Deconstructing the Laws of Logic - Clark". In this page I keep all my notes and my thoughts concerning this paper. The pdf file is inside a DevonThink database. When I am reading a pdf I want to be able to use the DevonThink link without leaving Skim. To this end I wrote an AppleScript, which creates in the first page of a pdf four Skim notes, containing four different ways of constructing references using DevonThink links.
The fourth note is the simplest and contains the DevonThink url (x-devonthink-item://CDEC17B7-1EEE-42E1-B8C9-86A24C172BF3?page=0). Its extended text contains the title of the wiki page. 

The third note contains a MediaWIki internal link to the wiki page of this pdf followed by an external link to the pdf file itself.

The second note contains the necessary Latex code for creating a proper bibliography reference and a link to the exact pdf page using the hyperref package. The only things that are missing from the above code are the cite key (between the opening parenthesis and the colon) and the page numbers. As an example the complete second note is the following: 

(\cite{Deconstructing-the-Laws-of-Logic-Clark-2008a}: \href{x-devonthink-item://CDEC17B7-1EEE-42E1-B8C9-86A24C172BF3?page=}{})

As you can notice the cite key "Deconstructing-the-Laws-of-Logic-Clark-2008a" is quite long. I have chosen this because I want to recognize the reference just by looking in its cite key and not by trying to remember for example which paper Clark wrote on 2008...

The code for a bibliography reference to the third page of this paper which is in the 27th page of the Philosophy Journal is the following:

(\cite{Deconstructing-the-Laws-of-Logic-Clark-2008a}: \href{x-devonthink-item://CDEC17B7-1EEE-42E1-B8C9-86A24C172BF3?page=2}{27})

The first note contains the necessary MediaWiki code for creating a link to the excact pdf page which is compatible with LaTeX whenever you want to export the wiki text to Latex (more about this in a quite distant in time post...)

Now every time I want to create a link to a pdf file everything is at hand in one of these notes! 

The AppleScript code which makes all the above possible is the following: 
tell application id "com.devon-technologies.thinkpro2"
    set these_items to the selection
    if these_items is {} then error "Please select some contents."
    repeat with this_item in these_items
        set RecordLink to the reference URL of this_item
        set DevonThinkLink to RecordLink & "?page=0"
        set PdfPath to get the path of this_item
        set PdfName to the name of this_item
        tell application "Skim"
            open PdfPath
            tell page 1 of document 1
                make note with properties {type:anchored note, bounds:{523, 820, 540, 820}, text:"(<rawtex></rawtex>: [" & RecordLink & "?page=])", extended text:DevonThinkLink}
                delay 0.1
                make note with properties {type:anchored note, bounds:{523, 800, 540, 800}, text:"(: \\href{" & RecordLink & "?page=}{})"}
                delay 0.1
                make note with properties {type:anchored note, bounds:{523, 780, 540, 780}, text:"([[" & PdfName & "]]: [" & RecordLink & "?page=])"}
                delay 0.1
                make note with properties {type:anchored note, bounds:{523, 760, 540, 760}, text:DevonThinkLink, extended text:PdfName}
            end tell
            save document 1
            delay 1
            close document 1
        end tell
    end repeat
end tell
In my post "How to create correctly the Skim notes which have the DEVONthink links, when you have already annotated the first page of the PDF document" there is an improved version of the above AppleScript. The newer one solves a problem which appears when you want a third AppleScript to use the aforementioned Skim notes like the AppleScript in my post "Automated creation of a LaTeX compatible citation only from Skim! (with hyperlink included)". Moreover it creates a fifth note for which there is detailed information in my post "Latin page numbers, Arabic page numbers and the fifth Skim note".


A road map for my blog - The many faces of links

In the following mind map you can see the various kinds of links that I am able to use and the respective programs that are required in order to create each of them. Moreover I have added some hyperlinks in the nodes for which I have posted relevant information.

From A Digital Workflow for Academic Research

You can download this mind map in its native Mind Manager file format from here  and as a PDF from here (right click + Save as).

Finally, you can view this mind map as a roadmap for my blogspots... post by post I will try to present how you can create and use these different ways of cross-linking your thoughts, notes, writings and also your sources into an integrated whole!  


How to use DevonThink links in a MediaWiki page

MediaWiki supports out of the box a number of protocols for external linking such as HTTP, HTTPS, mailto, IRC. Additionally it gives you the possibility to add your own protocols by modifing the LocalSettings.php file under the root folder.

I have installed MAMP in order to use MediaWiki and lets say that my wiki is named "MyWiki". Then the path for this file in my file structure is (I use Snow Leopard):
So in order for MediaWiki to be able to understand DevonThink links you need to add the following line to the LocalSettings.php file:
$wgUrlProtocols[] = 'x-devonthink-item://';    

Then when you write in the edit mode of a MediaWiki page:

you just see

a nice hyperlink after saving. 

Now MediaWiki and DevonThink are perfectly integrated! See a short demonstration in the following video.

If you want to learn how the wiki text in the above video can be created automatically using Skim, AppleScript and Textmate read the following posts:


It's all about hyperlinks!

If I was forced to choose the single most important element of my workflow then my answer would be the creation and usage of hyperlinks. We are all accustomed of using hyperlinks in the World Wide Web but I have observed that the usage of them in the personal mode of working is quite rare.

A classic but somewhat outdated form of link is the bibliography reference that is commonly used in academic texts. Its main disadvantage is that you need a lot of time and energy to actually find and use the referred passage. Nowadays a different situation is possible by using hyperlinks.  

I chose to use MediaWiki, DevonThink and Latex because they make the cross-linkage of my notes, my sources and my writings very easy and fast.

Specifically lets say you have A and B wiki pages. If you want to create a hyperlink from A to B you just have to write [[B]] in the wiki text. The whole process is very well documented in the MediaWiki help page about links.

The respective linking process with DevonThink is not well known and I think it is quite important. I even believe this capability of DevonThink to be a reason for academic researchers to switch to Mac computers!

The DevonThink program assigns a custom Uniform Resource Locator (URL) for every file that is imported or indexed to it. An example of this URL is the following:


Moreover, in the case of a pdf file, a different URL is assigned to every single page of it. This URL takes the form:


As a result when you want to refer to the twenty fifth page of a pdf document you just have to use the URL:


Notice that the page number in the URL is 24 and not 25 as the index base that is used by DevonThink is zero and not one.

You can send this URL to the clipboard by clicking "Copy Page Link" in the contextual menu.

Then you can use this link in order to create a hyperlink to the exact pdf page! As a result all your bibliography references can be transformed to live links to the respective pages. No more you have to hunt down the source of a quotation!

There is only one but...

Not every word processor accepts the DevonThink links, the most prominent of them... Word.  This is an additional reason that I do not use Word...

Some programs that are fully compatible with the DevonThink links are the following:
In the above programs after you paste a DevonThink link you do not see the raw URL but the name of the linked file!
Then you can edit the link as you like...
Be careful only not to start the editing from the first or the last character of the file name.
You can even edit the DevonThink link if you want to refer to a different page of the same pdf file.

But the best thing is that you can use DevonThink link inside MediaWiki pages and Latex. If you want to learn how read my next post...

Some tools of the trade

I use the following hardware:
  • a MacBook Pro 17in
  • a MacMini (as a server for my wikis and my ebooks library)
  • an iPad
  • a Time Capsule
  • an iPhone 3G
  • several external hard drives (for backup)
  • a 27in LG monitor

In my academic workflow I use the following programs:
  • Skim: for reading papers and books (in pdf format)
  • Calibre: for organizing all my ebooks (read and unread)
  • DevonThink: for organizing everything that I have read
  • BibDesk: for reference management and automated bibliography creation
  • MediaWIki: for notes management
  • TextMate and LaTex: for writing my papers
  • AppleScript: for automating my workflow