Action

AddToTinderbox

Posted by webline, Last update 8 months ago

UPDATES

8 months ago

minor improvements

show all updates...

8 months ago

minor improvements

10 months ago

some minor adjustments

This action copies the current note into Tinderbox (TBX). After finishing the job the note in Drafts will be copied to the Archive.
The new note in TBX will be added to a container called „inbox“ (just create an empty note with this name in TBX).
You have to set the path to your TBX file in the „theTBXFile“ variable first. That’s all it needs.

If you find this useful you can Buy Me A Coffee

Steps

  • runAppleScript (macOS only)

    -- The action must be initiated from a note in Drafts.app while the title of the note will become the $Name of the TBX note. 
    -- the script is based on the work of midas0441 (TBX forum)
    
    on execute(draft)
    	-- adjust filename and path to your needs
    	set theTBXFile to "/Users/yourname/Documents/Tinderbox/ideas.tbx"
    
    	set theTitle to title of the draft
    	set theFullBody to the content of the draft
        set theCleanBody to returnContentWithoutFirstLine(theFullBody)
     	set theCreateDate to ("" & createdAt of the draft)
    	set theModifyDate to ("" & modifiedAt of the draft)
    	set theTags to (tags of the draft)
    	set theListOfTags to convertListToString(theTags, "; ")
        set theLinkToDrafts to the permalink of the draft
    
    	set theDialogText to "Store to your default file or the frontmost file?"
    	display dialog theDialogText buttons {"Frontmost", "Default"} default button "Default" with icon caution giving up after 5
    	
    	if the button returned of the result is "Frontmost" then
    		set theTarget to false
    	else
    		set theTarget to true
    	end if
    
    	tell application id "Cere"
    		if theTarget then
    			open theTBXFile
    		end if
    		
    		tell front document
    			if not (exists note "Inbox") then make new note with properties {name:"Inbox"}
    			set theContainer to note "inbox"
    			set myNote to make new note with properties {name:theTitle} at theContainer
    			tell myNote
    				set value of attribute "Text" to theCleanBody
    				set value of attribute "Created" to theCreateDate
    				set value of attribute "Modified" to theModifyDate
    				set value of attribute "Tags" to theListOfTags
    				set value of attribute "Prototype" to "pNotiz aus Drafts"
    				set value of attribute "URL" to theLinkToDrafts
    				set value of attribute "DisplayedAttributes" to "Created;Modified;Tags;URL"
    			end tell
    		end tell
    	end tell
    end execute
    
    on convertListToString(theList, theDelimiter)
    	set AppleScript's text item delimiters to theDelimiter
    	set theString to theList as string
    	set AppleScript's text item delimiters to ""
    	return theString
    end convertListToString
    
    on returnContentWithoutFirstLine(allContent)
    	set theResult to ""
    	set theFirstNonEmptyLine to returnTheFirstNonEmptyLine(allContent)
    	set text item delimiters to return
    	set theResult to (paragraphs theFirstNonEmptyLine thru -1) of allContent as string
    	set text item delimiters to ""
    
    	return theResult
    end returnContentWithoutFirstLine
    
    on returnTheFirstNonEmptyLine(allContent)
    	set theResult to 2
    	repeat with i from 2 to the number of paragraphs in allContent
    		if paragraph i of allContent is not "" then
    			set theResult to i
    			exit repeat
    		end if
    	end repeat
    
    	return theResult
    end returnTheFirstNonEmptyLine
    
  • script

    // Drafts - Archive
    // move draft into the Archive
    draft.isArchived = true;
    draft.update();
    script.complete();

Options

  • After Success Default , Tags: tbx
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.