[TW5] Add ability to save/export other extensions

100 views
Skip to first unread message

TonyM

unread,
Dec 2, 2017, 8:26:21 PM12/2/17
to TiddlyWiki
Folks With a deep understanding of the core perhaps,

In $:/boot/boot.js various types and extensions are registered in lines like

	$tw.utils.registerFileType("text/plain","utf8",".txt");

How can I add another such as

	$tw.utils.registerFileType("text/cmd","utf8",".cmd");

So I can export with the cmd extension?

Regards
Tony

PMario

unread,
Dec 2, 2017, 8:43:06 PM12/2/17
to TiddlyWiki
Hi Tony, 

You can't, because there is no mime-type:
text/cmd

see: https://en.wikipedia.org/wiki/Media_type
and: https://www.iana.org/assignments/media-types/media-types.xhtml#text


It would be better, to describe, what you want to achieve.

-m

Eric Shulman

unread,
Dec 2, 2017, 9:16:24 PM12/2/17
to TiddlyWiki
On Saturday, December 2, 2017 at 5:43:06 PM UTC-8, PMario wrote:

Although it is not recommended, you can specify ANY string you like as a mime type, even if it is not included in any of the defined standards.  Thus, you can enter "text/cmd" into the "Type" field of a tiddler.  However, since that is not a standard type, it won't be recognized by any of the usual mechanisms.  Nonetheless, if you extend TiddlyWiki's registeredFileType definitions, you SHOULD be able to export tiddlers with "type/cmd" to files with a ".cmd" extension.  Note that I have NOT tried this myself, so there may be more involved in making it work.

-e

TonyM

unread,
Dec 2, 2017, 9:58:00 PM12/2/17
to tiddl...@googlegroups.com
Mario,

I know what you say, but as eric says we own the software here that can choose. 

I have asked this question in other requests to no response.  To me this would open a great deal of potential to store code, snipits, powershell scripts, terminal commands and more.

For example recently a Clients web host insisted on DNS Zone File updates being presented in a specific format and file standard, it would be easy to develop a standard tiddler one could edit some field values and generate the file for upload or email.

Additionally We can include a sentenal batch file, loaded on Windows (my expertise)  in start up that then monitors downloads (other exported tiddlers) and actions them. For example setting symbolic links, displaying the full download path, executing system commands sending them to an editor or SDK and much more. I also have some ways to ensure a degree of security on this.
 
One compelling example with a currently registered type is automating the generation of the settings.json for TiddlyServer in TiddlyWiki then export it to the right folder.

Of course we can write something that does not use the existing export features, but to me it makes sense using it because it also allows specific identification of such registered tiddler types.

Apart form my wanting to boost TW5 interaction with my desktop I see plenty of opportunity to use this to simplify install and integration tools, for example a tiddler could document and automate the whole install and execute process for newbies (by OS). We could even build HTML page builders, NodeJS command execution from inside tiddlywiki itself and a lot more.

Maybe I am dreaming?

Tony

PS Open edit and Export Oultlook *.msg files or ICS calendar files and more

TonyM

unread,
Dec 2, 2017, 10:01:56 PM12/2/17
to TiddlyWiki
Eric,

If you have no time to investigated this you self could you give some guidance?

It may only be a matter of being able to append to the existing table of registered file type after the tiddlywiki file has being opened.

Thanks either way

Tony

Jeremy Ruston

unread,
Dec 3, 2017, 4:27:03 PM12/3/17
to tiddl...@googlegroups.com
Hi Tony

How can I add another such as

Currently, file types can only be registered in boot.js. The problem is that the file types are needed early in the boot process in order to be able to read the files in the wiki folder.

It might be possible to engineer a way to add optional file extensions after bootup, but in the meantime I think it's reasonable to keep adding them to boot.js, as long as they are fairly general purpose.

So I can export with the cmd extension?

That should be possible without extending the core file extensions table. In exporter modules like $:/core/templates/exporters/CsvFile you'll see that the file extension is stored in a field; you can create an exporter for .cmd files that sets the correct file extension.

Best wishes

--
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 https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/1b7dc0f6-2282-4f89-bdcc-3d7dffc5d6d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TonyM

unread,
Dec 3, 2017, 5:35:07 PM12/3/17
to TiddlyWiki
Jeremy,

I will revisit the custom exporter but the last time I did that I ended up with files filename.cmd.html

Thanks
Tony
Reply all
Reply to author
Forward
0 new messages