Updated scripts for stack, stacklink, and tagger (V4)

NOTE: Run the script with a test database first. The script doesn’t delete or change any current items in the database, but it is best practice to back up the database before testing the script.

You need to set up five custom meta fields and one tag group (under /Tags) before running the script.

--(1) location to be created or specified and cmd fields to be created -------------
property topTagGpLocation : "/Tags" -- the tag group that contains all tags
property theNewTagsLocation : "/Tags/New Tags/" -- for gathering new tags created when using the script
property mdCardNum : "cardnum" -- data type is "Integer", used by the source document to keep the numbering of cards created in each doc-stack 
property mdStackLink : "stacklink" -- data type is "URL",  used by the source document to hold the link to the doc-stack
property mdSourceLink : "sourcelink" -- data type is "URL",  used by cards and main annotation file to hold the link to theDoc
property mdHasStack : "hasstack" -- data type is boolean, value=1 if a document has as stack 
property mdIsCard : "iscard" -- data type is boolean, value=1 if a doument is the card of a document
--End of (1) -------------

This is how a document holds its stack info: the “stacklink” cmd points to the stack, the “cardnum” cmd keep track of the number of cards created in the stack, and the “hasstack” cmd indicates that the document has a stack.
cmd1

For a card: the “sourcelink” points to the source document of the card.
cmd2

WHY “iscard” is needed. I can create a smart group to consolidate all cards of all documents with a simple filter.

WHY “sourcelink” is needed. That cmd is more an experiment of mine. In theory, each card can have one parent (the source) and its many children (the stack of cards of a card). Don’t go there for multi-level stack …

The “/Tags/New Tags” must be created to hold the newly created tags during the tagging process. When “Add New Tags” is chosen together with the other tags, the script will ask for the names of the new tags. “Recently Created Tags” shows the tags in the group “/Tags/New Tags”.

NOTED: you do not “have to” create new tags by this manner but must create this group for the functioning of Stack. I use this function to manage the ad hoc creation of new tags and compare their necessity with the existing tags. I usually move the newly created tags from the group “New Tags” into the relevant tags group at the end of each day.

Configuration for the “Stack”.
(1) This update consolidates the setup script and the main script. To configure(re-configure) the stack, make sure that (1) you are in a viewer window, and the current database is where you need to set up the stack, and (2) DO NOT select any item in the window. Each database has its own topstack, and each topstack has its own configuration. So u’ll need to run configuration for each database for which you want to use stack.
NOTED: a file “StackAndTaggerV4.plist” will be created under the DT’s script menu when the configuration is finished. Just leave it there. The file is used by both the Stack and the Tagger scripts.

(2) Activate the configuration function of “Stack” script. When no item is selected and the script is activated, the script will enter into configuration mode. User should choose “Use a New TopStack” even they have used the previous script - the existing topstack and document stacks will remain the same after the configuration.
NOTE: Check the description of the list box, make sure that the database is the one you need. Don’t worry, the script won’t mess up your database even you have chosen the wrong one.

(3) Choose a location for the TopStack. The gorup “TopStack” is used for holding all document stacks.
NOTED: you cab pick any name for the stack or change its name later. It is because the script only save the uuid of the group that is used as the topStack.

(4) Choose the option to create the card in rich text format (RT) or markdown format (MD).

(5) Choose the option to display backlink in full filename (LF) or just showing the page/paragraph info (LS). If u have other idea on naming, pass it on to me.

(6) Choose how to mark the cited text by the last used highlight colour (MH) or underline the text (MU). If a custom highlight colour is wanted, pick the colour in DT3 preference and setup shortcut key for that colour in macOS preference, the shortcut key must be “shift-control-7”. If no marking is needed, choose (MC), but don’t define the shortcut key “shift-control-7” in macOS.

(7) Choose the option to add a comment to the card (or not) at the time of its creation.

(8) Choose which font to use in the card. If Markdown format (MD) is used, choose any font coz markdown is plain text.

(9) Options for tagging. Choose (TN) for no tagging(tag later). Choose (TP) to show the tags of the source document at the time of a card’s creation. (9.1) You can only use (TT) when “Tagger” script is also used. I will post the “Tagger” script in the near future. (9.2) if (TC) or (TT) are picked, the script will ask the user to update the tag list when they run the script for the first time in each day.

If you choose (TC):


The script will ask for which current tags group under “/Tags” are to be used for choosing the tags when a card is created. However, if there are more than two to three hundred tags under the tags group, it will take a while to load and display the tags after a card is created.
NOTED: I don’t use (TC) coz it’s too slow. I have a powerful iMac and it still takes 6-8 secs to pull a list of 300 tags. It’s better to use (TN) and (TP), or try using (TT). I will post the script in the next few days (it takes time to write).

(10) If you are like me and always have many windows on the screen, you may want to specify a fixed location to place the card when it is created. Else you can pick “none” to let DT deciding where to place the newly created card.

(11) You need to input the resolution of your main screen.

The main script “Stack”.

StackV4b5 (public)____Shift-Ctrl-Alt-K.scpt.zip (239.3 KB)

I will post the info and supplement scripts of “openstack” and “stacklink” tomorrow.

1 Like