Curious about field transclusions with formating

58 views
Skip to first unread message

TonyM

unread,
May 19, 2020, 9:40:43 AM5/19/20
to TiddlyWikiDev
Folks,

You may be aware if you transclude a few of the standard fields like
{{!!created}}
{{!!modified}}

What is returned is not the ugly date serial numbers, but

Tue May 19 2020 23:34:40 GMT+1000 (Australian Eastern Standard Time)

Tue May 19 2020 23:35:52 GMT+1000 (Australian Eastern Standard Time)


I believe this is a core mechanism, but since I am 90% of the way into building a tool to build field definitions I thought it important to ask if anyone knows how this is done?


I would like to know if I can hack this for other fields or possibly request a change to be able to do so. 


I have searched for it but do not know how to find it, since it uses a basic transclusion method, yet treats these fields differently.


Thank in advance for any insight.

TonyM


Joshua Fontany

unread,
May 19, 2020, 8:17:57 PM5/19/20
to TiddlyWikiDev
Hi Tony,

What you are looking for is declared in `boot.js`before the wiki is actually started, from line 994:

```
/*
Register and install the built in tiddler field modules
*/
$tw.modules.define("$:/boot/tiddlerfields/modified","tiddlerfield",{
name: "modified",
parse: $tw.utils.parseDate,
stringify: $tw.utils.stringifyDate
});
$tw.modules.define("$:/boot/tiddlerfields/created","tiddlerfield",{
name: "created",
parse: $tw.utils.parseDate,
stringify: $tw.utils.stringifyDate
});
$tw.modules.define("$:/boot/tiddlerfields/color","tiddlerfield",{
name: "color",
editTag: "input",
editType: "color"
});
$tw.modules.define("$:/boot/tiddlerfields/tags","tiddlerfield",{
name: "tags",
parse: $tw.utils.parseStringArray,
stringify: $tw.utils.stringifyList
});
$tw.modules.define("$:/boot/tiddlerfields/list","tiddlerfield",{
name: "list",
parse: $tw.utils.parseStringArray,
stringify: $tw.utils.stringifyList
});
```

I think this is worth exploring, but will have to think on it. You should be able to setup a startup module to define other parse/stringify definitions.

Best,
Joshua Fontany

TonyM

unread,
May 19, 2020, 10:19:03 PM5/19/20
to TiddlyWikiDev
Josua,

Thank you, this is what I was looking for not sure how far I can go from here, I have a way to mange and define fields with wikitext, macros and widgets so this may be best avoided, but it would be interesting to see if this could be made more hackable. I would need more guidance if I was to try my own startup module. Is there a way for us to have a template we can clone and edit for additional fields?, I am not sure then how to save it into a wiki, for load time.

Perhaps there is an argument that we have view and edit of system fields available on more fields.

My current method invokes a field macro `<<field fieldname>>` and what is displayed depends on a wiki or tiddler mode override eg display the field in View or Edit modes.

It sheds light on some of the behaviours we get, 
  • I did not realise list and tags were in this. 
  • I see that color is basically using the  editTag: "input", editType: "color", I was hoping to modify this to allow pasting colour numbers into the colour dialogue
  • This suggests to me it would be easy to define fields using other input/edit types available in html like date selectors, email address, numbers etc...
  • `{{!!color}}` returns the content only
Very interesting;

Regards
Tony

Saq Imtiaz

unread,
May 20, 2020, 4:47:26 AM5/20/20
to TiddlyWikiDev
A startup module defining extra fields works, I've done it in the past for a plugin for dates and fields I wanted treated as an array.
Eg:
$tw.modules.define("$:/boot/tiddlerfields/sq-duedate","tiddlerfield",{
	name: "sq-duedate",
	parse: $tw.utils.parseDate,
	stringify: $tw.utils.stringifyDate
});
Reply all
Reply to author
Forward
0 new messages