Treating other file extensions as .tid

134 views
Skip to first unread message

Richard Baxter

unread,
Jun 12, 2014, 4:47:27 AM6/12/14
to tiddl...@googlegroups.com
Hello

I guess the subject line rather covers it ... is it possible for TW5 to treat files with other extensions (e.g .txt) as .tid files?  Or can setting the type: field in a file not be enough to trigger .tid like interpretation?

Well done with TW5 by the way - it looks terrific and is so easy to use.

Many thanks, Richard

PMario

unread,
Jun 12, 2014, 6:18:09 AM6/12/14
to tiddl...@googlegroups.com
Hi Richard,

Basically any file can be treated as a tiddler. ... see: https://github.com/Jermolene/TiddlyWiki5/tree/master/editions/tw5.com/tiddlers/images

you'll need a filename.txt.meta file, that defined the tiddler fields.

I think, the only field, that must exist is the title
eg:
title: Motovun Jack.jpg

The title inside the mata file can be different to the file name. ... Which can be confusing from time to time :)

hope this helps.
-mario

PMario

unread,
Jun 12, 2014, 6:20:19 AM6/12/14
to tiddl...@googlegroups.com

Rich

unread,
Jun 12, 2014, 8:03:34 AM6/12/14
to tiddl...@googlegroups.com
Thanks for that.  I had already gone through the link you've posted - and I appreciate the variety of ways to express metadata - but I suppose I just want one more ... But just to be clear, there's no way in TW5 to 'extend' the list of file extensions so they'd be interpreted as a .tid file?

Thanks, Rich 



On 12 June 2014 11:20, PMario <pmar...@gmail.com> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/HEqq8JZFCEI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Danielo Rodríguez

unread,
Jun 12, 2014, 10:29:06 AM6/12/14
to tiddl...@googlegroups.com
Hello rich,

I think the node version tries to interpret the files that it finds. At least it works with javascript files. Additionally you can specify how should each file be interpreted.

I'm which scenario are you doing test? How do you put those files inside tiddlywiky?

Rich

unread,
Jun 12, 2014, 11:05:27 AM6/12/14
to tiddl...@googlegroups.com
Hi

Thanks - I'll try the node version.

I'm trying to create a code snippet library with colleagues at work.  For our sins, we are SAS programmers (and therefore, not terribly computer literate ...).

Ideally, TW5 would live on a shared drive and people would copy their SAS programs there from which TW5 would pick them up automatically -or- people would import into TW5.  The SAS program header becomes the main text of the tiddler (using wikitext markup) and I can show/hide the SAS code itself using RevealWidget.  

All in all, it works very well: well presented documentation per program (with full program code), each one tagged (brilliant!) and full text searching of the code itself.  I'm hugely impressed and this, of all attempts, might gain traction at work.

The file extension question is from copying the SAS programs to the shared drive.  The programmer has to take the not-so-difficult step of changing the extension from .sas to .tid before importing.  Hardly awful, but I liked the idea of the folders being full of ready-to-go SAS programs - and TW5 sitting on top of them, providing all-in-one documentation.

My, now I've written this out, I seem awfully ungrateful... Forget I asked.

Cheers, Rich






Danielo Rodríguez

unread,
Jun 12, 2014, 3:35:53 PM6/12/14
to tiddl...@googlegroups.com
What you want works wonderfully with javascript.

Go to tiddlywiky5 github page. Enter in plugins and then check any of them. You will se there is no tid file, just regular javascript code. Inside each JS file there is a commented header. Field defined on that header are converted to tid files with that fields. You can ask your colleagues to include that header. Then use a custom view template based on, for example a particular tag.

Let my know if I explained myself.

Jeremy Ruston

unread,
Jun 13, 2014, 4:12:53 AM6/13/14
to TiddlyWiki
Hi Richard

If I understand correctly, the problem here is that you've got a pile of text files with the extension .sas that you'd like to be able to easily import into TW5. Would you like them to be treated as if they were .txt files or .tid files? If so, we can create a very simple module that plugs .sas in as an alternative extension. If you need to massage the files in some non-standard way as they are imported, then we'd need a more complex module.

TW5 has the concept of deserializer modules that extract tiddlers from different file formats. The mechanism starts by looking up the file extension within the JavaScript hashmap $tw.config.fileExtensionInfo. For example, open tiddlywiki.com and try this in the browser JS console:

$tw.config.fileExtensionInfo[".tid"]

You should see Object {type: "application/x-tiddler"}, which tells us that .tid files should be interpreted as being of the type application/x-tiddler.

That type is then looked up in another hashmap:

$tw.config.contentTypeInfo["application/x-tiddler"]

For this example you should see:

{encoding: "utf8", extension: ".tid", flags: Array[0], deserializerType: "application/x-tiddler"}

The field "deserializerType" is then looked up amongst the module definitions for modules of type "tiddlerdeserializer". You can see the available deserializers listed:

$tw.modules.types.tiddlerdeserializer

Finally, the actual deserializer for application/x-tiddler is created by boot.js:


Most other deserialisers live in this file:


So, we can plug in .sas so that it is treated as .txt with this single line of JavaScript:

$tw.config.fileExtensionInfo[".sas"] = $tw.config.fileExtensionInfo[".txt"];

Try running that line in your browsers JS console and then drag in a .sas file and see if it behaves as you expect. If so, we can look at baking that tweak into a module tiddler so that it runs each time you restart your wiki.

Best wishes

Jeremy




--
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 post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Rich

unread,
Jun 13, 2014, 5:33:13 AM6/13/14
to tiddl...@googlegroups.com
Hi Jeremy

Thanks for the explanation.  I thought there'd be some way of determining behaviour based on file extension or type: field.

As I would like SAS files to be interpreted as .tid, I added the following in Chrome JS console:-

$tw.config.fileExtensionInfo[".sas"] = $tw.config.fileExtensionInfo[".tid"];

I checked it with:- 

$tw.config.fileExtensionInfo[".sas"]

and got 'Object {type: "application/x-tiddler"}'

This is what I'm after, I believe.  However, importing the SAS file made no difference with TW5 according a type of 'application/x-sas'.

If it's any help, the text I'm inserting is as follows (saved in a file called 'tmp.sas'):-

    /*: Win/Unix
    title: Table for non-mutually exclusive groups
    caption: Non-mut excl grps
    type: application/x-tiddler
    tags: Output Table Percentages Test_Data
    sas: 9.3

    ! Purpose 

    A simple way to output figures ....
    */

Thanks, Rich






--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/HEqq8JZFCEI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.

Jeremy Ruston

unread,
Jun 13, 2014, 5:39:57 AM6/13/14
to TiddlyWiki
Hi Rich

I think part of the problem is that you don't need the /* and */ lines; can you prepare content to look like this:

    title: Table for non-mutually exclusive groups
    caption: Non-mut excl grps
    type: application/x-tiddler
    tags: Output Table Percentages Test_Data
    sas: 9.3

    ! Purpose 

    A simple way to output figures ....

Best wishes

Jeremy


Rich

unread,
Jun 13, 2014, 5:46:12 AM6/13/14
to tiddl...@googlegroups.com
Hi

I've just tried it without the /*...*/ comments but still no joy.  I'm using tiddlywiki.com if that's any help.

I appreciate the comments part isn't needed for TW5 - but it's needed by SAS so the file remains a SAS program (if you know what I mean).

Honestly though, don't worry about it.  Given how good TW5 is and how it will be helpful to us, it's no bother to get folk to change the file extension.

Thanks, Richard

Jeremy Ruston

unread,
Jun 13, 2014, 6:00:47 AM6/13/14
to TiddlyWiki
Hi Richard

No problem, keep the feedback coming,

Best wishes

Jeremy
Reply all
Reply to author
Forward
0 new messages