Can't write a plugin

105 views
Skip to first unread message

andrewg_oz

unread,
Jan 7, 2020, 8:37:55 AM1/7/20
to TiddlyWikiDev
I'm trying to learn how plugins work and been reading the dev wiki:


I've followed the instructions, created a plugin tiddler and a payload tiddler for the javascript. So far my payload tiddler just contains:

console.log('Hello, world!');

but nothing appears in the console. I have set the type of the payload tiddler to be 'application/javascript', which isn't mentioned in the instructions, but seems the right thing to do.

What have I missed?

Thanks.

Ton Gerner

unread,
Jan 7, 2020, 10:42:34 AM1/7/20
to TiddlyWikiDev
Hi,

A long time ago I did make a few plugins this way, but since Andreas Hahn published his Tinka plugin it is much more easier to make plugins.

See:
Repo: https://github.com/TinkaPlugin/Tinka
Wiki: https://tinkaplugin.github.io/

Cheers,

Ton

andrewg_oz

unread,
Jan 8, 2020, 9:35:31 AM1/8/20
to TiddlyWikiDev
Thanks. That Tinka plugin looks like it will save a lot of mucking about packaging and re-packaging plugins. However, it doesn't explain why my plugin code is being ignored.

Ton Gerner

unread,
Jan 8, 2020, 3:24:19 PM1/8/20
to TiddlyWikiDev
Hi,


On Wednesday, January 8, 2020 at 3:35:31 PM UTC+1, andrewg_oz wrote:
Thanks. That Tinka plugin looks like it will save a lot of mucking about packaging and re-packaging plugins. However, it doesn't explain why my plugin code is being ignored.


Sorry I can't help further; I'am not a developer and don't know anything about javascript.

Cheers,

Ton
 

andrewg_oz

unread,
Feb 2, 2020, 9:44:58 AM2/2/20
to TiddlyWikiDev
Thanks anyway. Just in case anyone finds this, I've found that plugin tiddlers need a module-type property set to either parser or widget in order for their code to be executed. Small steps...

Joshua Fontany

unread,
Feb 2, 2020, 9:04:44 PM2/2/20
to TiddlyWikiDev
Module type is important. One of the biggest things to realizing about developing in javascript with tiddlywiki is how to call other "libraries". For example, in order to call the "json-pointer" library, I created a tiddler the following metadata & the library in the text field (actually a seperate *.js.meta file next to the lib a I'm serving node-js style, but they are equivalent).

module-type: library
tags: 
title: $:/plugins/joshuafontany/jsonmangler/modules/libs/json-pointer.js
type: application/javascript


Then, in order to reference it in other widget/filter/etc script tiddlers, you do:

var pointer = require("$:/plugins/joshuafontany/jsonmangler/modules/libs/json-pointer.js");

I can then access the various "exports" by calling `pointer.whatever()`, etc, etc.

Best,
Joshua F
Reply all
Reply to author
Forward
0 new messages