How to generate JSON for a plugin for a Library

89 views
Skip to first unread message

Andrew

unread,
Apr 12, 2020, 5:00:09 PM4/12/20
to TiddlyWikiDev
Hey everyone, it has been awhile since I worked on anything. Trying to pick up were I left off but there has been a lot of changes. I have moved my work fully to GitHub from Tiddlyspot because Tiddlyspot doesn't do https. Anyway, I am now at t5a.github.io.

I started back up my work on my plugintools plugin but I am running into problems getting my Library JSON text generator to work. In particular it was supposed to automatically escape using the \ anytime it came to a quote mark. I have a tiddler called $:/plugins/ajh/plugintools/libraryformat and I thought it used to work but now it doesn't. Any suggestions would help. Sorry, it has been a couple years and I am not sure what all has changed. Thanks.

LinOnetwo

unread,
Apr 12, 2020, 8:56:13 PM4/12/20
to TiddlyWikiDev
I see TodlIist plugin  https://kookma.github.io/TW-Todolist/ from KooKma is using JSON in $__todolist_data_base_tasks.json

Maybe you can take a look

在 2020年4月13日星期一 UTC+8上午5:00:09,Andrew写道:

Jed Carty

unread,
Apr 13, 2020, 5:38:35 PM4/13/20
to TiddlyWikiDev
I think that the jsontiddler macro is what you want, or at least a good place to start. https://tiddlywiki.com/#jsontiddlers%20Macro

Jed Carty

unread,
Apr 13, 2020, 5:50:17 PM4/13/20
to TiddlyWikiDev
I think what you need is something like this:

{
<$list filter=<<somefilter>>>
"<$view field=title format= jsencoded/>": <$text text=<<jsontiddler "jsontiddlers Macro">>/>,
</
$list>
}

the $view widget with format=jsencoded is the part that actually answers your question, I think.

Jed Carty

unread,
Apr 13, 2020, 7:27:43 PM4/13/20
to TiddlyWikiDev
I am having a really hard time reading anything on your site (I am dyslexic, the colors and lines are more than I can do), so I am not sure what state your work is in, but this is a thing I was playing around with when trying to see if I could make a simpler way to make plugin libraries, it is one tiddler that packages plugins in the browser and one that puts it all into a format for the plugin library files, I never got around to seeing if I could make an exporter taht would export the plugin library files in bulk, there is probably some way to do it.

\define plugintext()
{
"tiddlers": {<$list filter='[subfilter{$:/state/MakePlugin!!filter}]+[bl[]]'>
"<$view field=title format=jsencoded/>": <$text text=<<jsontiddler "jsontiddlers Macro">>/>,
</$list>
<$list filter='[subfilter{$:/state/MakePlugin!!filter}]+[last[]]'>
"<$view field=title format=jsencoded/>": <$text text=<<jsontiddler "jsontiddlers Macro">>/></$list>
}
}
\end

Name: <$edit-text tiddler='$:/state/MakePlugin' field='name' class='tc-edit-texteditor'/>
Filter: <$edit-text tiddler='$:/state/MakePlugin' field='filter' class='tc-edit-texteditor'/>
Description: <$edit-text tiddler='$:/state/MakePlugin' field='description' class='tc-edit-texteditor'/>
List: <$edit-text tiddler='$:/state/MakePlugin' field='list' class='tc-edit-texteditor'/>
Version: <$edit-text tiddler='$:/state/MakePlugin' field='version' class='tc-edit-texteditor'/>

<$button>
Make Plugin
<$wikify name=pluginText text="<<plugintext>>">
<$action-setfield $tiddler={{$:/state/MakePlugin!!name}} text=<<pluginText>> type='application/json' description={{$:/state/MakePlugin!!description}} core-version=">=5.0.0" dependents="" list={{$:/state/MakePlugin!!list}} plugin-type="plugin" version={{$:/state/MakePlugin!!version}}/>
</$wikify>
</$button>

and then to get the plugins formatted for the files used by a plugin library:

title: Make Plugin Library

\define oneTiddler()
  <$list
    filter='[<theTiddler>fields[]] -text +[bl[]]'
  >
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp;"<$view field='title' jsencoded/>": "<$view tiddler=<<theTiddler>> field=<<currentTiddler>> format=jsencoded/>",
  </$list>
  <$list
    filter='[<theTiddler>fields[]] -text +[bl[]]'
  >
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp;"<$view field='title' jsencoded/>": "<$view tiddler=<<theTiddler>> field=<<currentTiddler>> format=jsencoded/>"
  </$list>
\end

\define jsonListing()
[<br>
<$list
  filter='[subfilter{$:/state/PluginLibrary!!filter}] +[bl[]]'
  variable=theTiddler
>
  &nbsp;&nbsp;{
  <<oneTiddler>>
  <br>
  &nbsp;&nbsp;},
  <br>
</$list>
<$list
  filter='[subfilter{$:/state/PluginLibrary!!filter}] +[last[]]'
  variable=theTiddler
>
  &nbsp;&nbsp;{
  <<oneTiddler>>
  <br>
  &nbsp;&nbsp;}
  <br>
</$list>
]
\end

This packages the plugins returned by this filter into the format needed by a plugin library.

The file structure needs to be:

*Library Folder
** recipes
*** library
**** tiddlers
***** //individual tiddler json files//
**** tiddlers.json
** index.html

filter: <$edit-text tiddler='$:/state/PluginLibrary' field=filter/>


!! tiddlers.json

''filename:'' tiddlers.json

''contents:''

<<jsonListing>>

!! Tiddler JSON files:

<$list filter={{$:/state/PluginLibrary!!filter}}>

---
''filename:'' <$view field='title' format='urlencoded'/>.json

''contents:''

<<jsontiddler>>
</$list>


Mohammad

unread,
Apr 15, 2020, 8:52:09 AM4/15/20
to TiddlyWikiDev
Hi Andrew,
 welcome back!

--Mohammad
Reply all
Reply to author
Forward
0 new messages