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
Export Key Attributes and Text (Read 7905 times)
steve harf
Full Member
*
Offline



Posts: 76
Cleveland, Ohio
Export Key Attributes and Text
Oct 07th, 2007, 11:58am
 
Is there a simple export script that can export the key attributes of a note and its text without explicitly naming each member of the key attributes set? My idea is to have the script examine the contents of KeyAttributes and then export the label and value of each attribute found there, then append the note text.
Back to top
 
 

- Steve Harf
WWW steveharf   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Export Key Attributes and Text
Reply #1 - Oct 8th, 2007, 12:32pm
 
I don't see a clean way to do this.

But often, key attributes are used to define a class of things: a BOOK has KeyAttributes of "author;title.publisher".  If that's your situation, and if you aren't exporting *too* many classes, you might just assign a different export template to each class.

Author: ^get(Author)
Title: ^get(Title)
Publisher: ^get(Publisher)

^text
Back to top
 
 
WWW   IP Logged
Lew Friedland
Full Member
*
Offline



Posts: 50

Re: Export Key Attributes and Text
Reply #2 - Jan 13th, 2008, 11:55am
 
I just tried creating this template, which answers my earlier request about a bibliographic template. When I try to choose it, the selection does not stick. It was created in TextEdit, saved as plain text, and placed in the same file as other Text Export templates. Any ideas?

Also, can this template be assigned to a prototype, e.g. the book prototype so that all notes inheriting the book proto also inherit the template? I'm pretty sure it can, but not sure how to assign it.
Thanks.
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Export Key Attributes and Text
Reply #3 - Jan 13th, 2008, 12:57pm
 
I'm not sure what you mean by "the selection does not stick".  If the template is disabled/greyed out. Tinderbox isn't sure it's a text file.  If the template is not in the menu, perhaps it's not stored in the right folder.  If the template changes after you have set it, perhaps an agent is trying to set it, too?

Yes, templates inherited from prototypes.
Back to top
 
« Last Edit: Jan 13th, 2008, 2:52pm by Mark Anderson »  
WWW   IP Logged
Ioa Petra-ka
Full Member
*
Offline



Posts: 103
Portland, Oregon, USA
Re: Export Key Attributes and Text
Reply #4 - Feb 27th, 2008, 11:48am
 
The solution to this one requires only an action and a macro. First you need a macro that will print out the name of an attribute and then the value of an attribute:

Macro: printSetPair
Code:
$1: ^get($1)^<br /> 



Next you need an action. This can be a rule attached to the note which will be displaying these values, an agent, or event a stamp. Depends on how you want this data to be updated. Since KeyAttributes will probably not be changing a lot, I would suggest something low-impact. Once the template string is generated and stored in the note's attribute, it probably won't change often.

So the next step is getting every attribute and its value, listed in KeyAttributes, stored into another attribute as template code. Let's call this attribute HTMLExportKeyAttributes. Insert this expression into the action of your choice (to play around with it, try using a Rule, as that will update constantly and you can tweak the behaviour as you see fit).

Example note: Rule
Code:
HTMLExportKeyAttributes=format($KeyAttributes, "", "^do(printSetPair, '", "')^\n", "") 



The format() function allows you to create a "pretty" list generated from a set. First you specify the set attribute KeyAttributes, and then four strings to determine what the list will look like. But we are going to use this function to create Tinderbox code! For simple explanation purposes, we do not need to delimit the whole list, so the first and last strings have been left empty, but if you want to wrap this section in a DIV or something, that would be where you put it. The important ones are the two strings that get inserted around the name of each value in the set. Here we are just creating the template code for a macro call around where Tinderbox will stick the set variable.

This will generate a text string of valid template export code, looking something like:

Code:
^do(printSetPair, 'Created')^
^do(printSetPair, 'Name')^
^do(printSetPair, 'WordCount')^ 



Note the carriage returns ("\n") will look funny in Tinderbox if you look at it in the attribute inspector, but they will export fine. At this point, you are pretty much done. All you need to do now is put this template call in your export template:

Code:
^get(HTMLExportKeyAttributes) 


Back to top
 
« Last Edit: Feb 27th, 2008, 12:05pm by Ioa Petra-ka »  

Av
  IP Logged
Pages: 1
Send Topic Print