Background
I’m creating a wiki to manage the chess club I help run at GigantiCorp, where I work. It’s going well, and I’m quite happy with the results. You can see a (somewhat anonymized1) version of it at http://scott.sauyet.com/Tiddlywiki/Demo/ClubDemo/v1/. I am proud to have been able to create this without asking a single question about it here. I’m clearly gaining deeper TW knowledge. But now it’s time for clean-up and optimization, and I’m ready to ask for help. This is the first of a few questions I expect to ask.
But I also would love other feedback on the wiki: Are there UI features that seem poorly done or ill-conceived? Are there implementation details that could be significantly simplified? I haven’t really tried for “pretty” yet, but can you suggest changes to improve the look?
1 I’ve cleaned up names, headshots, anything sensitive from GigantiCorp (such as ids, emails, etc,), and private email addresses. But the site connects users to Lichess, and I have left intact the user’s lichess ids, which, I suppose, could reveal other user details. Those ids are necessary for various functioning of the site.
Question
Is there a simple way to create a tiddler from a string of JSON (not a file) generated by another system and pasted in by the user.
I know I could ask the user to drop this to a file, something.json
, and drag that to the wiki, but I’m hoping to avoid that. I know that in JS there’s the $tw.Tiddler
constructor and $tw.wiki.addTiddler
, and I certainly can use that if nothing else is available. But I was wondering if this is already exposed through the wiki’s own tools.
I have a version, but it’s a little ridiculous, copying every property from the input JSON to a field in the new tiddler:
<$button>
<$action-sendmessage $message="tm-new-tiddler"
title={{{ [{$:/temp/create-member!!inside-profile}jsonget[title]] }}}
tags={{{ [{$:/temp/create-member{!!inside-profile}jsonget[tags]] }}}
avatar={{{ [{$:/temp/create-member!!inside-profile}jsonget[avatar]] }}}
coached-by={{{ [{$:/temp/create-member{!!inside-profile}jsonget[coached-by]] }}}
comments={{{ [{$:/temp/create-member!!inside-profile}jsonget[comments]] }}}
... plus 15 more fields ...
/>
Create member
</$button>
You can see this in http://scott.sauyet.com/Tiddlywiki/Demo/ClubDemo/v1/#Add%20Member.
(Yes, I know this could be cleaned up by caching a reference to [{$:/temp/create-member{!!inside-profile}]
but I’m hoping to eliminate this boilerplate altogether.)
Can I avoid those ridiculous shenanigans and somehow simply create a tiddler based on this JSON string?
Context
When I create a user, I want to fetch a number of tiddler fields from the corporate intranet directory. That directory is available as JSON, and I’ve already used it to batch-load the 90+ current members, converting that structure to my desired tiddler format, and then dragging a file with the result to my wiki.
I collected this data by running a script in the developer tools console on that intranet directory page, where I’m already logged in. This avoids having to deal with any authentication issues. To add a new member, I personally could just simply repeat this process, with a simpler script only designed to fetch one person’s data.
But I would rather that the other club administrators don’t have to do the whole file shuffle. I have a screen they can use, where they enter the person’s name, and get a script to run in the console on that intranet directory page, copy the resulting JSON, and paste that back in a second entry field and click a Create
button, which uses that JSON to build a tiddler. It’s a bit clunky, but workable. But I manually parse every field out of the input, and that seems ridiculous.
Obviously TW handles this every time we drag a JSON file onto the page. But I don’t know if that capability is exposed without descending into JS.
Other options
I don’t really like the process I’ve developed. I’m open to other ideas. The constraints are simple:
- The other administrators may have less technical backgrounds; I want the process to be reasonably simple for them
- I do not want – ever! – to try to integrate with company auth and single-sign-on. So, as far as I can tell, I can’t fetch the data through the new-ish HTTP capability in TW.
- I like having this as a stand-alone wiki, for all the usual reasons, so I wouldn’t want to try fetching this data dynamically (even if I could get through the auth issues); I really want a one-time import process to create the user.
Still, the current process does work, and the club administrator who adds most users to the current spreadsheet was able to use it. So unless someone has a brilliant alternative idea, I’m willing to stick with this. But I would feel so much better without all the JSON => field
manipulation.