The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Is there a script to simulate tagging somewhere? Thread Tools Search this Thread Display Modes
Hi!

I'm missing the ability to tag things and using a column with a dropbox at the moment, which isn't ideal, as the "tags" are document specific this way and aren't searchable.
I'd just need a script, which puts a selected word from a list into an outliner column, to simulate tagging. Is there anything like this out there?

Thanx!

Bye, Markus
 
For a couple of scripts which will search or filter on the values in pop-up list columns etc you could look at these threads:

http://forums.omnigroup.com/showthread.php?t=16396

http://forums.omnigroup.com/showthread.php?t=16392
 
To experiment with placing document-independent tags (from a list in a text file) you could start with a simple draft like the one below.
  • Allows placing of document-independent tags in a Tags column in OO3 documents
  • List of available tags is maintained in an external text file (TextEdit file).
  • One or more tags can be applied at a time.
  • Tags are attached to all rows selected in OO3.
  • The script will create the Tags column (and the tag-list text file, in the same folder as the script) if they are not initially present.

The script displays a simple menu, listing:
  1. The option to edit the tags file in TextEdit
  2. The list of available tags (multiple tags may be selected).

Any tags selected will be placed (avoiding duplication) in the Tags field of any rows selected in the front OO3 document.

Code:
property pVersion : "0.3"
property pTitle : "Place Tags in OO3" & space & "Ver. " & pVersion
property pTagFile : "TagSet.txt"
property pTagColumn : "Tags"
property pEditCommand : "[Edit Tag File]"

-- 	Copyright  2010, Robin Trew
--  All rights reserved.
-- 	
-- 	Redistribution and use in source and binary forms, with or without modification, 
-- 	are permitted provided that the following conditions are met:
-- 	
-- 		- Redistributions of source code must retain the above copyright notice, 
-- 		  this list of conditions and the following disclaimer.
-- 		- Redistributions in binary form must reproduce the above copyright notice, 
-- 		  this list of conditions and the following disclaimer in the documentation 
-- 		  and/or other materials provided with the distribution.
-- 		
-- 	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-- 	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
-- 	THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
-- 	IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
-- 	ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- 	 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-- 	 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-- 	 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
-- 	 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-- Allows placing of document-independent tags in a Tags column in OO3 documents
-- List of tags is maintained in an external text file (TextEdit file). One tag per line.
-- The script will create the Tags column (and the tags file) if they are not initially present.

-- The script displays a simple menu, listing:
-- 1. The option to edit the tags file in TextEdit
-- 2. The list of available tags (multiple tags may be selected).

-- Any tags selected will be placed in the Tags field of any rows selected in the front OO3 document.

on run
	tell application id "com.omnigroup.OmniOutlinerPro3"
		-- ensure that at least one row is selected
		try
			set oDoc to front document
		on error
			return
		end try
		tell oDoc
			set lstRows to selected rows
			if (count of lstRows) < 1 then
				display dialog "Select one or more rows, and try again." buttons {"OK"} with title pTitle
				return
			end if
			
			-- choose tag(s)
			set lstChosen to my ChooseTags()
			if (count of lstChosen) < 1 then return
			
			-- ensure that there is a tag column in the front document
			try
				set oCol to (first column where (name is pTagColumn) and (type is rich text))
			on error
				set oCol to make new column at end of columns with properties {name:pTagColumn, type:rich text}
			end try
			set idCol to id of oCol
		end tell
		
		-- add tag(s) to selected rows (avoiding any duplication of tags in a given row)
		repeat with oRow in lstRows
			set refText to (a reference to text of cell id idCol of oRow)
			set blnFirst to length of (refText as string) is 0
			repeat with oTag in lstChosen
				if blnFirst or (refText does not contain oTag) then
					set strData to oTag
					if blnFirst then
						set blnFirst to false
					else
						set strData to space & strData
					end if
					make new word at end of refText with data strData
				end if
			end repeat
		end repeat
	end tell
end run

on ChooseTags()
	set lstTags to GetTags()
	if (count of lstTags) < 1 then
		set strPath to GetPath()
		display dialog "No tags found in:" & return & return & strPath buttons {"OK"}
		tell application id "com.apple.TextEdit"
			open strPath as POSIX file
			activate
		end tell
		{}
	else
		set lstOptions to {pEditCommand} & lstTags
		set varChoice to choose from list lstOptions default items item 1 of lstTags with title my pTitle 
			with prompt "(Cmd-click for multiple selections)" & return & return & "Choose Tag(s):" with multiple selections allowed
		if varChoice is not false then
			if varChoice contains pEditCommand then
				set strPath to GetPath()
				tell application id "com.apple.TextEdit"
					open strPath as POSIX file
					activate
				end tell
				{}
			else
				varChoice
			end if
		else
			{}
		end if
	end if
end ChooseTags

on GetPath()
	set text item delimiters to ":"
	set strPath to (items 1 thru -2 of (text items of (path to me as string)) & {pTagFile}) as string
	set text item delimiters to space
	POSIX path of strPath
end GetPath

on GetTags()
	set strPath to GetPath()
	set lstTags to paragraphs of readFile(strPath)
end GetTags

on readFile(unixPath)
	set foo to (open for access (POSIX file unixPath))
	set txt to (read foo for (get eof foo))
	close access foo
	return txt
end readFile

Last edited by RobTrew; 2010-09-27 at 06:23 AM.. Reason: ver 0.3 checks that any tag column is of the right type
 
Wow, you've just given me exactly what I need, both ways! Many, many thanks!

Now I have to decide if I should work with the column data or use your tags script :-)

Just one little thing: I want to collect filtered columns from different documents into one. Is there a way to modify the filtered columns copy script, so it copies into a selected document and doesn't create a new one?

Markus

Last edited by Wobbly; 2010-09-28 at 04:24 AM..
 
I suppose the main limitation of the built-in pop-up list is that you can have only one 'tag' per row. (A useful discipline for some purposes and a pain for others).

The document-specific (in fact column-specific) character of the pop-up enumerations is not insurmountable: one can quite easily write a script to import a list of tags from an external text file, and make it (or add merge it with) the range of pop-up choices available in a particular column.
 
As I have many documents where I would have to add many pop-up items that came up later (I'm working on a thesis and tried to do the categorization with this "tags".) I would have to edit these for every old document to update the "tags". So I think I will go for the tags script, as these tags aren't document specific.

Is there a way to edit the font size of the tags box? As I have many tags, I'd like to reduce scrolling.
 
Quote:
Originally Posted by Wobbly View Post
Is there a way to edit the font size of the tags box? As I have many tags, I'd like to reduce scrolling.
The standard Applescript choose from list dialog doesn't offer us any access to its fonts.

In principle (if the list is sorted) you should be able to tap a letter key to scroll straight to the first entry that begins with that letter.

Otherwise, if the lists are very long, but are alphabetically sorted, all I can immediately think of is introducing some nesting - a first list that chooses one of 3/4 alphabetic ranges, and a second list that is filtered in this way ... not ideal ...
 
On second thoughts, it might work better to get one or more characters through Launchbar or a dialog, and then show a choose list only displaying those tags which began with the typed characters ...

(ie primitive type-ahead)
 
An alternative version which asks for one or more initial letters, and then displays only tags which start with those letters.

The initial characters can be given straight to LaunchBar (preceded by a tap on the space bar, once the script has been selected).

If the script is not launched from LaunchBar, it will put up a text dialog and request the starting characters.

[This version probably only helpful if the tag list is very large]

Code:
property pVersion : "0.4"
property pTitle : "Place Tags in OO3" & space & "Ver. " & pVersion
property pTagFile : "TagSet.txt"
property pTagColumn : "Tags"
property pEditCommand : "[Edit Tag File]"

-- 	Copyright  2010, Robin Trew
--  All rights reserved.
-- 	
-- 	Redistribution and use in source and binary forms, with or without modification, 
-- 	are permitted provided that the following conditions are met:
-- 	
-- 		- Redistributions of source code must retain the above copyright notice, 
-- 		  this list of conditions and the following disclaimer.
-- 		- Redistributions in binary form must reproduce the above copyright notice, 
-- 		  this list of conditions and the following disclaimer in the documentation 
-- 		  and/or other materials provided with the distribution.
-- 		
-- 	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-- 	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
-- 	THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
-- 	IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
-- 	ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- 	 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-- 	 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-- 	 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
-- 	 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-- Allows placing of document-independent tags in a Tags column in OO3 documents
-- List of tags is maintained in an external text file (TextEdit file). One tag per line.
-- The script will create the Tags column (and the tags file) if they are not initially present.

-- The script displays a simple menu, listing:
-- 1. The option to edit the tags file in TextEdit
-- 2. The list of available tags (multiple tags may be selected).

-- Any tags selected will be placed in the Tags field of any rows selected in the front OO3 document.

on handle_string(strChars)
	set lstTags to GetTags()
	if (count of lstTags) < 1 then
		set strPath to GetPath()
		display dialog "No tags found in:" & return & return & strPath buttons {"OK"}
		tell application id "com.apple.TextEdit"
			open strPath as POSIX file
			activate
		end tell
		return
	else
		set lstTags to FilterList(lstTags, strChars)
		
		-- DISPLAY THE MENU
		set lstOptions to {pEditCommand} & lstTags
		if length of lstTags > 0 then
			set strDefault to item 1 of lstTags
		else
			set strDefault to pEditCommand
		end if
		set varChoice to choose from list lstOptions default items strDefault with title my pTitle 
			with prompt "(Cmd-click for multiple selections)" & return & return & "Choose tag(s) starting with " & quote & strChars & quote with multiple selections allowed
		if varChoice is not false then
			if varChoice contains pEditCommand then
				set strPath to GetPath()
				tell application id "com.apple.TextEdit"
					open strPath as POSIX file
					activate
				end tell
				set lstChosen to {}
			else
				set lstChosen to varChoice
			end if
		else
			set lstChosen to {}
		end if
		
		if lstChosen is not {} then AddTags(lstChosen)
	end if
end handle_string

on run
	set var to display dialog "Tag(s) starting with:" default answer ""
	set strChars to text returned of var
	handle_string(strChars)
end run

on AddTags(lstChosen)
	tell application id "com.omnigroup.OmniOutlinerPro3"
		-- ensure that at least one row is selected
		try
			set oDoc to front document
		on error
			return
		end try
		tell oDoc
			set lstRows to selected rows
			if (count of lstRows) < 1 then
				display dialog "Select one or more rows, and try again." buttons {"OK"} with title pTitle
				return
			end if
			
			-- ensure that there is a tag column in the front document
			try
				set oCol to (first column where (name is pTagColumn) and (type is rich text))
			on error
				set oCol to make new column at end of columns with properties {name:pTagColumn, type:rich text}
			end try
			set idCol to id of oCol
		end tell
		
		-- add tag(s) to selected rows (avoiding any duplication of tags in a given row)
		repeat with oRow in lstRows
			set refText to (a reference to text of cell id idCol of oRow)
			set blnFirst to length of (refText as string) is 0
			repeat with oTag in lstChosen
				if blnFirst or (refText does not contain oTag) then
					set strData to oTag
					if blnFirst then
						set blnFirst to false
					else
						set strData to space & strData
					end if
					make new word at end of refText with data strData
				end if
			end repeat
		end repeat
	end tell
end AddTags


on GetPath()
	set text item delimiters to ":"
	set strPath to (items 1 thru -2 of (text items of (path to me as string)) & {pTagFile}) as string
	set text item delimiters to space
	POSIX path of strPath
end GetPath

on GetTags()
	set strPath to GetPath()
	set lstTags to paragraphs of readFile(strPath)
end GetTags

on readFile(unixPath)
	set foo to (open for access (POSIX file unixPath))
	set txt to (read foo for (get eof foo))
	close access foo
	return txt
end readFile

on FilterList(lstTags, strChars)
	if strChars is "" then return lstTags
	set lst to {}
	repeat with oTag in lstTags
		if oTag begins with strChars then set end of lst to oTag as string
	end repeat
	lst
end FilterList

Last edited by RobTrew; 2010-09-28 at 10:52 AM.. Reason: Mention that string parameters can be fed to Launchbar
 
Many thanx again for this modification!

I am working the whole day with the tags script and the workflow is wonderful. I just needed to get fastscript, to key commandize the script. It also eliminates the 1-2 second pause til the tags window appears when using the normal applescript menu.

I wonder if there'll ever be a native implementation of tags...

Is there a way to modify the "filtering values of columns copy"- script to always copy into a specified window instead creating a new one?

Markus
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tagging marcussommer@mac.com OmniOutliner 3 for Mac 0 2010-08-06 06:59 AM
tagging outlines mrglsmrc OmniOutliner 3 for Mac 0 2009-06-26 07:27 PM
Tagging System ptone OmniFocus Extras 1 2008-11-24 03:15 AM
Bookmark tagging hardcoreUFO OmniWeb Feature Requests 0 2007-07-11 05:43 AM
Tagging Searchbox SpiralOcean OmniFocus Extras 2 2007-07-10 09:07 PM


All times are GMT -8. The time now is 04:00 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.