TaskPaperExtendedNotes

Introduction

WHile TaskPaper's notes are great, there are times when I feel I need more. That is where Extended Notes comes into play. The concept is a rather simple one. Have a tag that defines a certain type of file. An outline file in opml format, a text file, a scrivener file etc. The value of said tag would be the file name. You can see it in action here.

Usage and Setup

Tags and Paths
This is where you need to be careful. The variable is a list in the manner of:

set workList to {{"note", "outline"}, {docPath:"/Users/pedro/Dropbox/Notes/", ext:"txt",appname:"nvALT"}, {docPath:"/Users/pedro/Dropbox/Outliner/", ext:"opml",appname:"Mindnode Lite"}}

Breaking it down we have:

  1. Item 1 is a list of your tags. In my case I have "Note" and "Outline"
  2. Item 2 onwards is a list of records pertaining to each tag.

So in the above example, item 2 is a list of the path where you place docs related to your Note tag and the extension of your Note tag (some may prefer txt, md, mmd etc.) and finally the app with which you want to open the note (Must be exactly named). Item 3 pertains to tag outline.
If you prefer more tags/document types then just expand on this.

NOTE:
If a document with the specified name doesn't exist it will be created (Text file types only so far...)

Tips and Use Cases

Not to sure how this could benefit you or why you may need extra notes? Let me give you a scenario I stated in an earlier post.

You're a Web Developer with a task list similar to (forgive me if it's silly but hey, I'm no WebDev) :

With this simple list you can easily see how quickly you can get things done. Used in conjunction with my previous extension you could, without leaving your task list, toggle the timer on and open the project file you need to work on. The added benefit is of course that you can have extensive notes without cluttering your task list.

What's to Come

I've got a few more things planned for this and other extensions. This is far from perfect so if you find any bugs or would like to request a feature, please do so on the GitHub page I've setup.

The Script

            --  TaskPaper Actions | Extra Info
    -- 
    --  For use with TaskPaper and Alfred
    --  For further instructions read the README.md or visit http://palobo.tumblr.com
    --
    --  Copyright (C) 2012  Pedro Lobo <palobo@gmail.com>
    --

    -- Set your variables here
    set workList to {{"note", "outline"}, {docPath:"/Users/pedro/Dropbox/Notes/", ext:"txt", appname:"nvALT"}, {docPath:"/Users/pedro/Dropbox/Outliner/", ext:"opml", appname:"MindNode Lite"}}


    -- Change nothing bellow this point unless you know what you're doing. Magic starts here.

    tell application "TaskPaper"
        tell selected entry
            set marker to 0
            set tagList to name of tags
            set watchList to list 1 of workList
            set propList to rest of workList
            repeat with _item in watchList
                set marker to marker + 1
                repeat with _tag in tagList
                    if _tag as rich text = _item as rich text then
                        set _name to value of tag named _tag
                        set rec to record marker of propList
                        my accessInfo(_name, docPath of rec, ext of rec, appname of rec)
                    end if
                end repeat
            end repeat
        end tell
    end tell



    to accessInfo(_name, _path, _ext, _appname)

        set extraInfo to _path & _name & "." & _ext
        set extraAlias to extraInfo as POSIX file

        tell application "Finder"

            if exists extraAlias then
                try
                    do shell script "open -a " & quoted form of _appname & " " & quoted form of extraInfo
                    my displayMessage("Operations", "Opened File", "Successfully opened " & _name & "." & _ext)
                on error
                    my displayMessage("Errors", "Error", "Propblem Opening " & _name & "." & _ext)
                end try
            else
                try
                    do shell script "touch " & quoted form of extraInfo
                    do shell script "open -a " & quoted form of _appname & " " & quoted form of extraInfo
                    my displayMessage("Operations", "Created New File", "Successfully Created and Opened " & _name & "." & _ext)
                on error
                    my displayMessage("Errors", "Error", "Propblem Creating/Opening " & _name & "." & _ext)
                end try

            end if
        end tell

    end accessInfo

    to displayMessage(msgName, msgTitle, msgText)
        -- Check to see if it's running
        tell application "System Events"
            set growlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
        end tell

        -- Register Growl
        if growlRunning then
            tell application id "com.Growl.GrowlHelperApp"
                -- Make a list of all the notification types 
                -- that this script will ever send:
                set the allNotificationsList to ¬
                    {"Operations", "Errors"}

                -- Make a list of the notifications 
                -- that will be enabled by default.      
                -- Those not enabled by default can be enabled later 
                -- in the 'Applications' tab of the Growl preferences.
                set the enabledNotificationsList to ¬
                    {"Operations", "Errors"}

                -- Register our script with growl.
                -- You can optionally (as here) set a default icon 
                -- for this script's notifications.
                register as application ¬
                    "TaskPaper Extended Notes" all notifications allNotificationsList ¬
                    default notifications enabledNotificationsList ¬
                    icon of application "TaskPaper"
            end tell
        end if

        -- Display the Message
        if growlRunning then
            tell application id "com.Growl.GrowlHelperApp"
                notify with name ¬
                    msgName title ¬
                    msgTitle description ¬
                    msgText application name ¬
                    "TaskPaper Extended Notes"
            end tell
        else
            display dialog msgText
        end if

    end displayMessage

    --  This program is free software: you can redistribute it and/or modify
    --  it under the terms of the GNU General Public License as published by
    --  the Free Software Foundation, either version 3 of the License, or
    --  (at your option) any later version.
    --
    --  This program is distributed in the hope that it will be useful,
    --  but WITHOUT ANY WARRANTY; without even the implied warranty of
    --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    --  GNU General Public License for more details.
    --
    --  You should have received a copy of the GNU General Public License
    --  along with this program.  If not, see <http://www.gnu.org/licenses/>.