Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Note Tags! (Read 10723 times)
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Note Tags!
May 27th, 2009, 7:25pm
 
Enjoy this fun little thing that answers a question I've been mulling on the TBX Forum in a couple of places. Here's a Ruby script and a demonstration TBX file that enables you to do text tagging at the note level:

http://www.vze26m98.net/tbx/NoteTags.zip

Requirements: presumably your Mac has Ruby 1.8.6 or thereabouts in /usr/bin. Most Tiger and Leopard installs should have this.

Running the demo: Download the Zip to your Desktop and unpack. Double-click on the "NoteTags.tbx" file inside the folder ("NoteTags") that was created.

There should be an Outline view open, and one of the "TEMPLATES" children: "single". Open a new Nakajoji view on the first note in the outline: "Juilliard Performance...". Select "entire document" for your Nakajoji view.

You should see two items with "Babbit," a date, and some quoted text. From the Nakajoji export template drop-down menu, select the other two "TEMPLATES" children in turn: "multiple" and "overlap". You should see different chunks of text from the two content notes displayed.

OK, so what's going on and what's the big deal?

Open up the "Juiliard..." note and look at the text. It's been marked up with html-like tags:

<single></single>
<multiple></multiple>
<overlap></overlap>

These demonstrate that you can tag text in a note for display in a Nakajoji view. Furthermore, and this is the even cooler part, you can multiply tag the text and the tags can overlap!

Multiple tags are concatenated, overlapping tags are deleted in the Nakajoji view.

If you look at the "single" template that's open, you'll see lots that you're familiar with. The ^action^ command sets the user attribute $TagString to the result of passing the note $Text to the Ruby script, along with an argument that tells the Ruby script which tag you want to scan on. In this case "single." If you look at the other templates you'll see they pass the other tags to the Ruby script.

I'm curious for any reactions. I've just built this, so haven't had much time to play with it myself. If you have trouble running the demo, please let me know.

If this proves useful, I'll put together a small application that will automate tagging in Tinderbox.

Wow! Tinderbox is fantastic. (Special thanks to Mark A. for all his help and encouragement...)

Best, Charles

Back to top
 
 
WWW   IP Logged
Paul Walters
Ex Member




Re: Note Tags!
Reply #1 - May 27th, 2009, 9:35pm
 
Very impressive.  I'm interested to see how you develop this concept further. Good work solving the problem you posed.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Note Tags!
Reply #2 - May 28th, 2009, 4:59am
 
Interesting! Some continuation thoughts. If TagString were a set data type instead of a string, it could store all* the quotes. The * reservation is that string/set attributes probably have a finite size; I don't know what limit is but I suspect it will be less than that allowed for $Text.

As in the demo the TagString is primarily being used to hold data ready for the text export view, you might consider adding a Stamp for clearing TagString.  I called mine "Clear TagString" and used the code "$TagString=;", without the enclosing quotes (what does set to semi-colon do?). Now just select notes as necessary, go the the Stamps menu and cliick the name of your stamp.  Job done. You could use a Quick Stamp but then you have to select the right target attribute, etc. A saved stamp wins when you know you'll want that exact action again later on. FWIW, I did try adding an action to the end of a template (e.g. ^action($TagString=;)^) so as to clear the attribute as soon as it's been used but that seemed not to work.

One last code point, in post-TB v4.6 preferred syntax, attribute references use a $ prefix in action code - though not in export codes (confusing, I agree!). Thus your:

^action(TagString=runCommand(

...ideally should be:

^action($TagString=runCommand(

Both work now, but in due course the former will stop working as code syntax tightens. At present Eastgate is working hard not to break old stuff while building out the new usage but at some point supporting both will become untenable so better to start out with the 'new' syntax.  Elements of the latter are covered in aTbRef, albeit inline within pertinent articles.
Back to top
 
« Last Edit: May 29th, 2009, 1:17pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Charles Turner
Full Member
*
Offline



Posts: 180
New York, USA
Re: Note Tags!
Reply #3 - May 28th, 2009, 7:21am
 
Quote:
If TagString were a set data type instead of a string, it could store all* the quotes. The * reservation is that string/set attributes probably have a finite size; I don't know what limit is but I suspect it will be less than that allowed for $Text.


Hi Mark A.-

I copied text into a String data attribute until it beeped at me. Looks like a TBX string attribute will hold around 8K chars. I don't think I have any notes near that size.

I am a bit unclear what you're saying here, though. Does a Set data attribute have a larger maximum size?

Thanks for the syntax reminder!

Best, Charles

Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Note Tags!
Reply #4 - May 28th, 2009, 8:55am
 
The point of a set is that it is 'multi-value' - viewed in a key attribute (using short value!) you'll see it is a semi-colon delimited set of strings, e.g. "ant;bee;cow;dog" being a set holding 4 values*. Thus, your TagStrings might - if pertinent to your needs- be used to store the result of more than one template; if you viewed all 3 templates in your demo and the TagString was a set you'd have several discrete strings generated by the different template.

Assuming you've made a new set attribute called "TagStrings" try changing the second line of your template to code like this (example here for 'single' template):

^action($TagStrings=$TagStrings+runCommand("ruby ~/Desktop/NoteTags/notetags.rb 'single'", $Text))^"^get(TagStrings)^"

* IIRC, TB doesn't escape semicolons in sets so adding a value containing a semicolon will result in the value being treated as 2 discrete values; I don't believe a backslash prefix (\;) will escape the character.  This might be an issue in the above context.

I don't  know the max 'size' of a set vs. a string attribute - I suspect it's the same as the set is only a semicolon delimited string when saved.
Back to top
 
« Last Edit: May 28th, 2009, 8:57am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Johnnie Wilcox - mistersquid
Full Member
*
Offline



Posts: 84
San Francisco, CA
Re: Note Tags!
Reply #5 - May 29th, 2009, 1:12pm
 
This sounds really exciting and I appreciate the write up. Is there any chance you can make a quick screencast of how this works?

===========

Looking downthread: thank you, Mark, for the video.
Back to top
 
« Last Edit: May 29th, 2009, 8:49pm by Johnnie Wilcox - mistersquid »  
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Note Tags!
Reply #6 - May 29th, 2009, 1:49pm
 
I've taken the liberty of doing a quick movie (via iShowU HD) of Charles 'NoteTags' demo TBX.  Oops, the MOV is about 35Mb and the sound is a bit quiet, but it gives the effect. (No time to re-record now - I'll see if I get a change later on). Movie:

http://www.acrobatfaq.com/tbdemos/notetags.mov

Enjoy.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print