Connect: An experimental script that works like Hook

Connect script offers basic features of Hook app and some more. It creates two-way bondings between documents - whether or not their files are in DT initially. This script is experimental and it still has many rough edges.

There are three nonexclusive approaches to relate notes and documents by brute-force: by links, by tags and by groups. My Journal script is focused on notes. The script uses tags and keywords to establish the peer relationship of notes. Connect script is focused on documents. The script uses hidden groups and replicants to establish a connection between any format of documents. The script also finds connections among documents by searching for the owners and bearers of filenames and DT’s item links.

The script is built upon the infrastructure of my Stack V5 script and the design concept of Stacklink script. To understand what Connect does, you will need to (1) know briefly about how Hook app works, (2) know briefly about what is stack in the Stack script and link in Stacklink script, (3) know rather well about how replicant and item link work in DT.

The basic concept of Connect script:
AFAIK, @Bernardo_V is the only member who has offered a complete and effective workflow for tracing the two-way connection of editable documents in DT in his Return links/Back links script. I use a dual-approach in Connect script. The first approach (diagram 1) is to establish a connection by replicating a subject and a target into each other’s hidden group (stack). This approach overcomes the issue that a non-editable file can’t accept link as a means of connection. The second approach (diagram 2) is to identify the connection by tracing the owners of links within the content of a subject document and the bearers of the item link and filename of the subject document. Finally, the connect script can establish a connection (diagram 3), to a limited extent, with external webpages, Excel and Word documents, and in theory, any apps’ documents can be connected if they can use AppleScript to reference their opening documents.

Note: The script only supports the connection of items within the same database and files external to DT.


THERE ARE TWO VIEWS IN CONNECT SCRIPT: The list of CONNECT and the list of INSERT LINK AND CONNECT. When a user invokes the script in a markdown or rich text file, both views are available. For other formats of files, only the CONNECT view is available.

The CONNECT VIEW

There are eight sections in a CONNECT view. Each section has up to two actions - item action (â–Ľ) for individual items in the section and section action (â–·) for all items in the section (see B).

Note: Connect script is designed to perform multiple actions. Multiple items in different sections can be selected at once and all actions will be executed collectively.

  1. “:no_mouth: ME” shows the selected subject document (or documents). The item-action is to open the stack (hidden group) of one of ME to see all of the connected documents inside, the section-action is to pin all documents of ME to a documents holder for connection later. For example, a user may pin the main document and connect other documents to it on an ongoing basis.
  1. “:grinning::link:” shows all items in the stack of ME. The item-action is to open the selected files, the section-action is to create a new document and connected to ME. New documents will be saved under a group in the inbox of the database. The group can be defined in the script. This section will not be shown if ME contains more than one file.
  1. “:thinking::mag_right:” shows all items in the current database that contains the name or the item link of ME and the items that are the owners of the item links within the content of ME. The item-action is to connect the item to ME (put it in the stack of ME), the sction-action is to open all of them. For less than five items, individual document windows are opened. For more than five items, a viewer window that contains all items in this section will be opened. Noted that (1) This section will not be shown if ME contains more than one file. (2) For items that are already in the stack of ME, they will be hidden from this list.

Note: The “:thinking::mag_right:” section is meant to offer an option for the user to seek for connecting ME and items that may have been ignored previously, or to find related documents without having to make a relatively permanent connection between those documents and ME.

  1. “:open_file_folder: DT Active” shows all currently opened documents in the same database of ME. The item-action is to connect a selected item in this section to ME. Noted that the items under ME will be hidden from this list.
  1. “:pushpin: PINNED” shows all documents that are pinned in the current database. The item-action is to connect any of these pinned files to ME, the section-item is to unpin all documents from the list. Noted that (1) the items under ME will be hidden from this list even if it is/they are in the pinned list. (2) The script will keep 30 documents for each database and the number of pinned documents is defined in the script.
  1. “:tent: ACTIVE FILES OUTSIDE DT” shows all currently open Excel and Word documents outside DT. The item-action is to connect the selected item/s to ME. The script will search for the file path of the document. If the document is an existing externally opened index file in the current database, the script will connect ME to that index item. Else, the script will index the document into the inbox of the current database, then connect the index document to ME. Technically speaking, any app that allows AppleScript to extract its opening windows will be able to be added into the script.
  1. “:earth_asia: ACTIVE WEBPAGES OUTSIDE DT” shows all tabs of the frontmost window of Safari and Chrome. The item-action is to connect the selected item/s to ME. The script will search for the URL of the webpage. If the URL already exists as a bookmark, markdown, HTML, or formatted note item in the current database, the script will connect the item to ME. Else, the script will ask the user to convert the webpage into a preferred format and save the file in the inbox and connect it to ME.
  1. “:clock2: DT HISTORY” show all documents that have been opened before in the last 2 hours. The item-action is to connect the selected item/s to ME.

The INSERT LINK AND CONNECT VIEW

This view is only available if ME is a single markdown or rich text file. The purpose of this view is to both insert an item link of the selected items and connect to ME. The default view is still CONNECT but can be switched to this view by double-clicking the top title.


A DEMO

The demo is based on an earlier version of the script. Therefore the displayed sections aren’t exactly the same.

  1. While reviewing the paper from Besharvo and Brickson (2015), I come across the major citation Kraatz & Block (2008) of this paper. 2. I find the article in my library and invoke the script. 3. I select the article’s name in “:open_file_folder: DT Active” and double-click.

Now the two documents are connected. I can continue my current review and review Kraatz & Block (2008) later. I can also continue to connect other related documents.


THE SETUP OF CONNECT

Step 1: the user needs to create three custom metadata fields. These fields are compatible with the Stack V5 script.

property mdStackLink : "stacklink" -- type "URL",  used by source document to hold the link to the theSourceStack
property mdHasStack : "hasstack" -- type boolean, value=1 if a document has as stack 
property mdSourceLink : "sourcelink" -- type "URL",  used by notes to hold the link to the source document

Step 2: The user needs to save their favourite templates for new documents in a folder defined by the property newDocTemplateLoc. These templates are for creating new files in section “:grinning::link:”. Newly created file (“:grinning::link:”) and import and index file (":tent: " and ":earth_asia: ") will be saved under the group defined by the property newFileLoc.

property newFileLoc : "/Inbox/Files created by Connect"
property newDocTemplateLoc : "~/Library/Application Support/DEVONthink 3/Templates.noindex/Favorites"

Step 3: The user may want to adjust these preferences.

  • p_inclAlaisesInFindRelatedDocs== true is to include aliases as one of the predicates in the search of potentially connected items of ME in “:thinking::mag_right:”. However, the script only supports an aliases field with only a single entry (at the moment).
  • p_extensionToOpenExternally. The action of “open” in the section “:grinning::link:” will open some formats of files externally. In my script, I open Excel (xl), Word (do), Scapple (sc), and bookmark (we) externally.
  • p_pinNDocForEachDB. The maximum number of pinned files in each database.
  • p_defaultViewForNoteIsCONNECT. If the user wants the default view of Connect script, when ME is a markdown or rich text file, to be the “INSERT LINK AND CONNECT” view, set this to false.
property p_inclAlaisesInFindRelatedDocs : true
property p_extensionToOpenExternally : {"xl", "do", "sc", "we"} -- only the first 2 letters of extension
property p_pinNDocForEachDB : 30
property p_defaultViewForNoteIsCONNECT : true

Step 4: The first time the script is invoked in each database, the script will ask the user to select a “Top Stack” to hold all the hidden stacks. All stacks will be excluded from classification when it is created.


The Connect Script

If you intend to use the script, test it thoroughly with a testing database. The script is experimental!

Updated version v1b12 on 2020.07.20
Connect v1b12.scpt.zip (176.3 KB)

2 Likes

v1b12 update:

  • Add a new section ":fearful::x: " for disconnection. The item-action is to disconnect the selected items from ME, the section-action is to disconnect all items from ME. Technically speaking, the script is removing the related replicants from each other’s stack.

2 Likes