Is there a way to generate a set of dynamical variables?

195 visualizzazioni
Passa al primo messaggio da leggere

Stephan Hradek

da leggere,
30 ott 2019, 05:04:0330/10/19
a TiddlyWiki
Background of my question: For a colleague who often needs to write standard mails I've created a TiddlyWiki where one can create 2 tiddlers. One with the standard mailtext using place holders. The placeholders are also defined in the template. Example below. The other tiddler is simply one piping the mailtemplate-tiddler through a tiddler which will generate the form to fill in the placeholders.

Example for the mailtemplate:

[[subject:Request for offer {{!!company}}]]
[[recipients:offerman@my.company]]
[[company:Company Name]]
[[due_date:Due date]]
[[revenue:Annual revenue]]
[[known_cb,not,already:Company known]]

Dear Mr. Offerman

The company {{!!company}} asked for an offer.

Their annual revenue is {{!!revenue}}.

The due date is {{!!due_date]].

{{!!company}} is {{known_cb}} known to us.

Best regards

The tiddler showing the form is then just something like this:

{{
   Mailtemplate:Request for offer -- Generate Mail
||
   Create Mail
}}

and the resulting form will look something like this:

+----------------+---------------------------------+
| Recipients     | offerman@my.company             |
+----------------+---------------------------------+
| Subject        | Request for offer {{!!company}} |
+----------------+---------------------------------+
| Company
        | [_____________]                 |
+----------------+---------------------------------+
| Due date       | 
[_____________] [cal]           |
+----------------+---------------------------------+
| Annual revenue | 
[_____________]                 |
+----------------+---------------------------------+
|Company known   | 
[_] already                     |
+----------------+---------------------------------+


This already works quite well, but I do not really like the notation of the placeholders {{!!placeholder}}. This is due to the fact that the generated form simply stores the values in fields in the mailtemplate.

Since I had difficulties with the recipients and the subject, they are not editable and are not in fields. I first wanted to make them editable but this did not work as the defaults won't appear unless the tiddler, where the fields are located, does not exist. Moreover the defaults are not stored unless you explicitly go into the fields. As a result these 2 values are stored in variables.

So my next idea was: Wouldn't it be nice, placeholders could be written in the form <<placeholder>>?

Unfortunately I am not able to generate a set of variables dynamically. You see: I do not know beforehand which placeholders will be used in a mailtemplate. So I go through the mailtemplate with the ListWidget, finding the placeholders from the top part, generating the input elements. Creating variables by this is of course not possible.

But maybe someone here has an idea how to do this?




Mark S.

da leggere,
30 ott 2019, 10:16:3230/10/19
a TiddlyWiki
I've read your post several times now, but I'm still unsure what you want.

Perhaps you could show the list code you are using, and then highlight the output, indicating
what you would desire the output to be.

Good luck!

Xavier Cazin

da leggere,
30 ott 2019, 10:21:3530/10/19
a tiddl...@googlegroups.com
Hi Stefan,

I'm almost certain that filters hold the answer to your questions. Especially since they include operators like subfilter[], then[] and else[] —and also ~run constructs. Here is an example of what you can write with recent TW5 releases:

\define default_subject() My default subject
\define subject-filter() [[My form]get[subject]else<default_subject>]

Subject : <$text text={{{ [subfilter<subject-filter>] }}}/>

Does it sound usable for your use case?

Cheers,
-- Xavier Cazin


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f472935c-703f-40ff-b8fc-dbfffd3148a6%40googlegroups.com.

TonyM

da leggere,
30 ott 2019, 21:37:1130/10/19
a TiddlyWiki
Stephan,

I am a little confused about you question as well.

I do not really like the notation of the placeholders

This is not helpful, the notation should not be the problem, perhaps its you use of it, I think your issue is with the concept of templates

Have you tried {{||templatename}} in a tiddler?
or {{||mailtemplate}} in a new email message

This will display the current template in your currenttiddler using the values in the current tiddler not the template. ie {{!!fieldname)) is a fieldname in the current tiddler not the template.

The edit text widget https://tiddlywiki.com/prerelease/#EditTextWidget has a placeholder parameter
To use a variable in this widget its a simple matter of placeholder=<<placeholder>>

By the way
You original post has the following  which is incorrect.
The due date is {{!!due_date]].

Regards
Tony

Stephan Hradek

da leggere,
4 nov 2019, 07:24:1204/11/19
a tiddl...@googlegroups.com
@all who answered - Thanks for your time.

What I did now is to provide a working example at https://github.com/Skeeve/mailtemplates-made-easy/tree/master/wiki

If you're interested you can download from there.

The only questions I have are:

  1. How can I make sure, the default values are set. In this case not touching the checkbox will set no value for the placeholder known_cb and will thus give wrong results.
  2. Is there a way I could use Tiddlywiki's variable-notation <<variable>> instead of the transclude-a-field notation {{!!fieldname}}
The Question at 1. is the more important one. The Question at 2. is just that I personally find it more understandable for non-TiddlyWiki-users (and that's what the system should be for) to use <<something>> than {{!!something}}. It's just that the 2 exclamation marks do not make sense to people not knowning about TiddlyWiki.

BTW: I couldn't save to tiddlyspot. It simply fails without any hint about what's wrong. Just pops up "Started saving".

Mark S.

da leggere,
4 nov 2019, 15:21:5704/11/19
a TiddlyWiki


BTW: I couldn't save to tiddlyspot. It simply fails without any hint about what's wrong. Just pops up "Started saving".

What browser? You have to save from Chrome the first time.

Stephan Hradek

da leggere,
5 nov 2019, 01:26:5505/11/19
a TiddlyWiki


Am Montag, 4. November 2019 21:21:57 UTC+1 schrieb Mark S.:

What browser? You have to save from Chrome the first time.
Firefox… So thanks for the hint.

Mark S.

da leggere,
5 nov 2019, 11:16:4805/11/19
a TiddlyWiki
You're doing some amazing stuff there, BTW.

I may not understand, but perhaps for #1 you should create a template editor for the user. This editor would, for instance,
contain the instructions re the fields and format, so the user didn't have to look them up. Then, when the user clicked
a "save" or "finalize" button, the template tiddler would be created including any necessary fields.

For #2, since you are doing your own parsing, perhaps you could substitute {{!! for << and }} for >> before processing the text.
You might be able to do this with a split/join sequence, e.g. split<startchevron>join<leftbrackets> where startchevron and leftbrackets are previously defined values << and {{!! respectively.
This would allow the user to use "<<name>>" and not have to know that they are actually referencing a field.

Although, to me {{!!field}} is just fine ;-)

Good luck!

TonyM

da leggere,
6 nov 2019, 00:21:0406/11/19
a TiddlyWiki
Stephan,

I have had so much trouble building email composition and send tools thanks for sharing. Your use of [[something:value]] is interesting. I am yet to understand fully how it works.

My dream is to be able to attach a json file of tiddlers to an email as well, any idea if this may be possible?

Regards
Tony

Stephan Hradek

da leggere,
6 nov 2019, 02:54:1906/11/19
a TiddlyWiki


Am Mittwoch, 6. November 2019 06:21:04 UTC+1 schrieb TonyM:
My dream is to be able to attach a json file of tiddlers to an email as well, any idea if this may be possible?
 
As far as I know it's not possible to add attachments with a mailto-link. You could "paste" the JSON content into the mail body.

Stephan Hradek

da leggere,
6 nov 2019, 03:04:4606/11/19
a TiddlyWiki


Am Dienstag, 5. November 2019 17:16:48 UTC+1 schrieb Mark S.:
You're doing some amazing stuff there, BTW.

Thanks.

I may not understand, but perhaps for #1 you should create a template editor for the user.

That's a great idea!

 
For #2, since you are doing your own parsing, perhaps you could substitute {{!! for << and }} for >> before processing the text.

I do not like that idea too much. It will introduce ambiguities because {{!!…}} still would have the special meaning while the user would only know about <<…>>

TonyM

da leggere,
6 nov 2019, 20:34:2206/11/19
a TiddlyWiki
Stephan,

I believe attachments are handled as mime types inside the body text. We know other emailers or inbox software can do this we just need to work out how to do the same in tiddlywiki. Unfortunately I have found the email methods so fragile I waste a lot of time with them, so I am keen to explore your solution. Thanks for sharing.

Regards
Tony

Stephan Hradek

da leggere,
7 nov 2019, 05:40:4007/11/19
a TiddlyWiki


Am Donnerstag, 7. November 2019 02:34:22 UTC+1 schrieb TonyM:
Stephan,

I believe attachments are handled as mime types inside the body text.

Of course. Looking at the pure ASCII file of a mail it's trivial. The content type is multipart mixed. A boundary string is defined and then the whole body looks something like this:

Mail text here
--BOUNDARY
HTML text here
--BOUNDARY
attachment
1 here
--BOUNDARY
attachment
2 here
--BOUNDARY--

But you cannot pass that using a mailto-link.




TonyM

da leggere,
7 nov 2019, 05:55:4007/11/19
a TiddlyWiki
Stephan

Ah so what I want is currently impossible. I hope someone may work a way to install a mapi or other email service into tiddlywiki even if it demanded a login to an external mail router. I would love to be able to attach tiddlers containing an attachment with a bundle of tiddlers. It would be a way to submit surveys or updates from a read only wiki that can then be imported to a master wiki.

Thanks for your effort though

Tony

Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi