Version 3.1
You can now use DEVONthink 3 icons in SuperTab which makes it easier to tell what kind of DEVONthink 3 record it is.
To use this download this command line tool (it’s Donationware), save it somewhere and set the path in the script.
As mentioned in earlier posts SuperTab supports splitting of rows and the usage of more than one tag in a row so don’t get the example screenshot wrong - it’s not that limited. You are not limited to use only groups in one row and smart groups in another, the screenshot is just a very basic example.
And, this could turn out to be very handy, SuperTab supports shortcuts to activate not only SuperTab but a specific row. However it does not seem to be possible at the moment to open the currently selected file when the shortcut is released. I wasn’t aware of this feature but can imagine that this could turn out to be something like an app switcher for DEVONthink records. This would be pretty cool
And this is worth mentioning, SuperTab seems to be able to run AppleScript files (but I didn’t test it).
To add inboxes or global smart groups (thanks @cgrunenberg!) just copy the Reference URL via the menu, create a new bookmark in the indexed group an assign a tag).
Hope it’s useful
-- Version 3.1
-- What:
-- Create bookmarks for selected DEVONthink records, ask for Tags, make tagged bookmarks available in SuperTab.
-- Delete selected bookmarks (if the indexed group is the current group).
-- Control which existing bookmarks are available in SuperTab by changing their flagged status. No need to delete.
-- Control which Tags (additionally to all Tags of flagged bookmarks) should be always prepopulated in choose from list by manually assigning Tags to any record that is not a bookmark - as long as this record is flagged and in the indexed group its Tags are used.
-- NEW: use DEVONthink 3 icons for group, smart group or document
-- Setup:
-- in Finder: Create a new folder in Finder (I’ve put mine in SuperTabs Application Support folder),
-- in DEVONthink: Index the new folder
-- in this script: Set the UUID of the indexed group
-- in SuperTab: Hover over the bottom of a row, click the plus sign, select "Tagged Items" from the drop-down menu, select a tag.
-- NEW: if you want to use the DEVONthink 3 icons in SuperTab download this tool https://www.hamsoftengineering.com/codeSharing/SetFileIcon/SetFileIcon.html (it's Donationware) and set the variable "SetFileIconPath"
-- Usage:
-- Run on selected records outside the indexed group to make them available in SuperTab.
-- Unflag records inside the indexed group to temporarily deactivate them.
-- Assign Tags to any record that is not a bookmark inside the indexed group to additionally prepopulate choose from list. Unflag this record to temporarily deactivate it.
-- Run on selected bookmarks inside the indexed group to delete them.
-- SuperTab supports multiple rows of Tagged Items and it supports multiple Tags in one row.
-- This script also supports multiple tags, so one bookmark, e.g. a database inbox, can be used in different SuperTab setups.
-- Choose existing Tags and create a new Tag in one script run.
-- Change properties as you like
-- NOTE that the default prefixTag has changed. Change it to the one you want.
-- Happy dashboarding!
property theUUID : "" -- UUID of the indexed group
property createNewTag : "Create new Tag ..." -- title of first choose from list item
property usePrefix : true -- if true they will have it even if overwritten in the dialog
property prefixTag : "." -- keeps the tags together and on top of the SuperTab Tag list
property showSuperTab : true -- if true SuperTab is right there to add or change a row
property SetFileIconPath : "" -- path where you've saved the command line tool "SetFileIcon" (the tool is only necessary if you want to see DEVONthink 3 icons in SuperTab. If you don't want to use them leave it as "")
tell application id "DNtp"
try
set windowClass to class of window 1
if {viewer window, «class srwi»} contains windowClass then
set currentRecord_s to selection of window 1
else if windowClass = document window then
set currentRecord_s to content record of window 1 as list
end if
set theGroup to (get record with uuid theUUID)
set theBookmarks to children of theGroup whose type is bookmark
repeat with thisBookmark in theBookmarks
if thisBookmark's state is false then
consolidate record thisBookmark
else
deconsolidate record thisBookmark
end if
end repeat
if current group = theGroup then
if currentRecord_s ≠ {} then
tell application "System Events" to set activeApp to name of first application process whose frontmost is true
tell application "SystemUIServer"
activate
set theDialog to display dialog "Delete selected bookmarks?" buttons {"Cancel", "Ok"} default button 2 with title "SuperTab Dashboard"
end tell
activate application activeApp
if button returned of theDialog = "Cancel" then return
repeat with thisRecord in currentRecord_s
if item 1 of parents of thisRecord = theGroup then
if thisRecord's type = bookmark then
try
consolidate record thisRecord
end try
delete record thisRecord in theGroup
end if
end if
end repeat
end if
else
if currentRecord_s = {} then
display notification "Updated indexed Folder!"
return
end if
set theChildren to children of theGroup whose state is true
set activeTagsList to {}
repeat with thisChild in theChildren
set thisTags to tags of thisChild
repeat with i from 1 to count of thisTags
set thisTag to item i of thisTags
if thisTag is not in activeTagsList then
set end of activeTagsList to thisTag
end if
end repeat
end repeat
set sortedActiveTagsList to my sort_list(activeTagsList)
set theTagList to (createNewTag as list) & sortedActiveTagsList
tell application "System Events" to set activeApp to name of first application process whose frontmost is true
tell application "SystemUIServer"
activate
set chooseTag to choose from list theTagList default items createNewTag with prompt "Create new and / or choose existing Tag(s):" with title "SuperTab Dashboard" with multiple selections allowed
end tell
activate application activeApp
if chooseTag is false then return
if item 1 of chooseTag = createNewTag then
tell application "System Events" to set activeApp to name of first application process whose frontmost is true
tell application "SystemUIServer"
activate
if usePrefix = false then set prefixTag to ""
set theDialog to display dialog "New Tag:" buttons {"Cancel", "Ok"} default button 2 default answer prefixTag with title "SuperTab Dashboard"
end tell
activate application activeApp
if button returned of theDialog = "Cancel" then return
set theTag to text returned of theDialog
if theTag = "" then return
if usePrefix = true and theTag does not start with prefixTag then set theTag to prefixTag & theTag
if (count of chooseTag) > 1 then
set chooseTag to items 2 thru -1 of chooseTag
set theTag to (theTag as list) & chooseTag
end if
else
set theTag to chooseTag
end if
set setDelay to false
tell application "Finder" to set DEVONthinkPath to POSIX path of (application file id "DNtp" as alias)
repeat with thisRecord in currentRecord_s
set theName to name of thisRecord
set theURL to reference URL of thisRecord
set theBookmark to create record with {name:theName, URL:theURL, type:bookmark, tags:theTag, state:true, exclude from classification:true, exclude from search:true, exclude from see also:true} in theGroup
deconsolidate record theBookmark
if SetFileIconPath ≠ "" then
set setDelay to true
set thePath to path of theBookmark
set theClass to class of thisRecord
if theClass is in {parent, smart group} then
if theClass = parent then set iconPath to DEVONthinkPath & "/Contents/Resources/Group.icns"
if theClass = smart group then set iconPath to DEVONthinkPath & "/Contents/Resources/Smart-Group.icns"
else
set iconPath to DEVONthinkPath & "/Contents/Resources/dtRecord.icns"
end if
do shell script quoted form of POSIX path of SetFileIconPath & " -image " & quoted form of POSIX path of iconPath & " -file " & quoted form of POSIX path of thePath
end if
end repeat
if SetFileIconPath ≠ "" then
tell application id "com.spritec.supertab"
quit
delay 0.5
activate
end tell
end if
if (count of chooseTag) = 1 then
display notification (item 1 of theTag) with title "Available in SuperTab Dashboard"
else
display notification (item 1 of theTag) & space & "and more..." with title "Available in SuperTab Dashboard"
end if
end if
set thePath to path of theGroup
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" & space & error_number message error_message as warning
end try
end tell
tell application "Finder"
set theFolder to (POSIX file thePath) as alias
set theFiles to files of theFolder
repeat with thisFile in theFiles
set extension hidden of thisFile to true
end repeat
end tell
if showSuperTab = true then
if setDelay = true then delay 1.5
tell application id "com.spritec.supertab"
presentInterface
end tell
end if
on sort_list(theTagList)
set old_delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ASCII character 10}
set list_string to (theTagList as string)
set new_string to do shell script "echo " & quoted form of list_string & " | sort -f"
set new_list to (paragraphs of new_string)
set AppleScript's text item delimiters to old_delims
return new_list
end sort_list