[TW5] How would I "register" a new tiddler type?

104 views
Skip to first unread message

Stephan Hradek

unread,
Apr 23, 2015, 4:06:10 AM4/23/15
to tiddly...@googlegroups.com
For documentation purposes I've put some Perl code in tiddlers.

At the moment I'm using "text/plain" as the tiddler type, but I'm wondering how I could register a new type "text/perl".

First it wouldn't be different from "text/plain", but maybe it's possible then, to change, for example, the font size or the font, when the "proper" mimetype is used?

Eric Shulman

unread,
Apr 23, 2015, 5:00:03 AM4/23/15
to tiddly...@googlegroups.com
Here's how you find the right place:

First, search by filter for [tag[$:/tags/EditTemplate]].... and you will find this tiddler:
    [[$:/core/ui/EditTemplate/type]

Next, examine the source of that tiddler, and you will find a <div> with
   class="tc-edit-type-down"

Within that <div>, there is a <$list> widget that uses the following filter to populate the dropdown list:
   [all[shadows+tiddlers]prefix[$:/language/Docs/Types/]each[group]sort[group]]

Then, search by filter for [prefix[$:/language/Docs/Types/]], and you will find this tiddler:
   [[$:/language/Docs/Types/text/plain]]

To make add your own type, start by cloning the above tiddler, and name it:
   [[$:/language/Docs/Types/text/perl]]

Then, set the "description" field to "Perl Source Code" and the "name" field to "text/perl".

That's it.  Your newly defined type will be automatically added to the droplist.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

PMario

unread,
Apr 23, 2015, 6:53:23 AM4/23/15
to tiddly...@googlegroups.com
On Thursday, April 23, 2015 at 10:06:10 AM UTC+2, Stephan Hradek wrote:
For documentation purposes I've put some Perl code in tiddlers.

At the moment I'm using "text/plain" as the tiddler type, but I'm wondering how I could register a new type "text/perl".

There is no official mime type "text/perl". See [1][2]

Since it would be a personal / experimental type you could use "text/x-perl". .. but you'd probably get in trouble with the perl community. If you do a google search, they may have there own interpretation, what "text/x-perl" is and how it should be interpreted. Same seems to be valid for "application/x-perl" ...

[1] http://www.sitepoint.com/web-foundations/mime-types-complete-list/
[2] http://www.iana.org/assignments/media-types/media-types.xhtml#text

 
First it wouldn't be different from "text/plain",

That's right, since it main element is "text" so the fallback for TW for unknown "text/xxxx" types imo is: "text/plain".
 
but maybe it's possible then, to change, for example, the font size or the font, when the "proper" mimetype is used?

You could implement a renderer plugin, that is aware of your text/x-plain or application/x-plain mime type.
You could use text/plain as an example. ...

but be aware, that you shouldn't use text/perl since this one would require the full standardisation process, described in http://tools.ietf.org/html/rfc6838#section-3.1

have fun!
mario



Stephan Hradek

unread,
Apr 23, 2015, 7:00:44 AM4/23/15
to tiddly...@googlegroups.com
So I'd go for "text/x.perl" as described in http://tools.ietf.org/html/rfc6838#section-3.4

Stephan Hradek

unread,
Apr 23, 2015, 7:12:26 AM4/23/15
to tiddly...@googlegroups.com
Thanks, Eric, but:


Am Donnerstag, 23. April 2015 11:00:03 UTC+2 schrieb Eric Shulman:

Here's how you find the right place:

First, search by filter for [tag[$:/tags/EditTemplate]].... and you will find this tiddler:
    [[$:/core/ui/EditTemplate/type]

Try this on tiddlywiki.com and it only gives you $:/ContributionBanner

Nevertheless: The rest helped in registring the mime type. Now I need to find out how to get it to render properly.

PMario

unread,
Apr 23, 2015, 7:18:51 AM4/23/15
to tiddly...@googlegroups.com
On Thursday, April 23, 2015 at 1:00:44 PM UTC+2, Stephan Hradek wrote:
So I'd go for "text/x.perl" as described in http://tools.ietf.org/html/rfc6838#section-3.4

or the personal tree: http://tools.ietf.org/html/rfc6838#section-3.3, since the experimental x- tree is strongly discouraged.

... and the word "vanity-tree" imo isn't very polite. So they should have stayed with name: "personal-tree"

-m


Eric Shulman

unread,
Apr 23, 2015, 11:39:39 AM4/23/15
to tiddly...@googlegroups.com
On Thursday, April 23, 2015 at 4:12:26 AM UTC-7, Stephan Hradek wrote:
Thanks, Eric, but:

Am Donnerstag, 23. April 2015 11:00:03 UTC+2 schrieb Eric Shulman:

Here's how you find the right place:

First, search by filter for [tag[$:/tags/EditTemplate]].... and you will find this tiddler:
    [[$:/core/ui/EditTemplate/type]

Try this on tiddlywiki.com and it only gives you $:/ContributionBanner

oops!  The TWCore default template tiddlers are shadows.  This will work better:
   [all[shadows]tag[$:/tags/EditTemplate]] 

-e

Stephan Hradek

unread,
Apr 26, 2015, 3:12:06 AM4/26/15
to tiddly...@googlegroups.com


Am Donnerstag, 23. April 2015 13:18:51 UTC+2 schrieb PMario:
On Thursday, April 23, 2015 at 1:00:44 PM UTC+2, Stephan Hradek wrote:
So I'd go for "text/x.perl" as described in http://tools.ietf.org/html/rfc6838#section-3.4

or the personal tree: http://tools.ietf.org/html/rfc6838#section-3.3, since the experimental x- tree is strongly discouraged.

That's why I didn't write "x-" but "x."

PMario

unread,
Apr 26, 2015, 6:22:56 AM4/26/15
to tiddly...@googlegroups.com
On Sunday, April 26, 2015 at 9:12:06 AM UTC+2, Stephan Hradek wrote:
That's why I didn't write "x-" but "x."

I think, there is no difference. They are both deprecated. see: http://tools.ietf.org/html/rfc6648
-m
Reply all
Reply to author
Forward
0 new messages