[TW5] TiddlyWiki as an Application Platform for a Powershell GUI/IDE

173 views
Skip to first unread message

Marc J. Cawood

unread,
Oct 16, 2016, 8:03:07 AM10/16/16
to TiddlyWikiDev
So I've been learning Powershell and it's pretty, well, powerful and, since August, open-source and cross platform. And it's not only for server operators. But enough asides...

Powershell is command-line-based and I like making a GUI on top of useful command-lines (as I have done with AWK and WGET) because I am forgetful about syntax and a UI, with built-in reference, which builds and runs commands from a few clicks is just better than typing (and mistyping) a lot.

My preference for the presentation would be HTML and my preference for the logic would be JavaScript. However, I need access directly to the operating system (no browser sandbox).

I could use NW.js but then I'd have to build my own UI. My thinking is: could/should I use TW5 Desktop? Can TW be leveraged as an application platform which is not necessarily a wiki (i.e. info platform).

I think TiddlyWiki would be a great platform for a rich/hypertext version of the Powershell Help System/Reference. But I want to add on top of that and have, in addition to the cmdlet reference, a kind of builder UI. So I can search or navigate to a cmdlet, read it's syntax, see some examples AND run those examples AND build my own execution of that cmdlet.

Ideally the UI will allow a preview of the output objects of cmdlets (using the `ConvertTo-JSON` cmdlet) as tables or trees and piping these outputs to other cmdlets. Even more betterer would be a kind of flowchart drag and drop like snaplogic but that's a way down the line.

So, in addition to the questions above, can plugins within TW Desktop work like standard node modules and require modules like `node-powershell` and just execute OS commands?

Jeremy Ruston

unread,
Oct 16, 2016, 8:50:47 AM10/16/16
to tiddly...@googlegroups.com
Hi Marc

I could use NW.js but then I'd have to build my own UI. My thinking is: could/should I use TW5 Desktop?

If you wish to build a native app based on TiddlyWiki then TiddlyDesktop might be a reasonable place to start. Alternately, you could consider just adding the enhancements you need as TiddlyDesktop plugins - it’s very extensible, like TiddlyWiki itself.

Can TW be leveraged as an application platform which is not necessarily a wiki (i.e. info platform).

It’ll still be a wiki, at least in the sense that TW uses the term (roughly, an application for composing hypertext). But it doesn’t need to look like a wiki to the end user; by replacing $:/core/ui/PageTemplate one can have an entirely custom user interface.

I think TiddlyWiki would be a great platform for a rich/hypertext version of the Powershell Help System/Reference. But I want to add on top of that and have, in addition to the cmdlet reference, a kind of builder UI. So I can search or navigate to a cmdlet, read it's syntax, see some examples AND run those examples AND build my own execution of that cmdlet.

Ideally the UI will allow a preview of the output objects of cmdlets (using the `ConvertTo-JSON` cmdlet) as tables or trees and piping these outputs to other cmdlets. Even more betterer would be a kind of flowchart drag and drop like snaplogic but that's a way down the line.

So, in addition to the questions above, can plugins within TW Desktop work like standard node modules and require modules like `node-powershell` and just execute OS commands?

Yes, TiddlyDesktop plugins have access to Node.js APIs.

Best wishes

Jeremy


--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/e0439414-f8c9-4d8f-aadd-6157332381d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marc J. Cawood

unread,
Oct 16, 2016, 11:10:10 AM10/16/16
to TiddlyWikiDev
Thanks Jeremy. I'm looking at using the `child_process` module but I don't see any node_modules/ folder in TW Desktop. Could you give me a leg up on how to import a module?

Bonus Question: If you could hack a small plugin which shows a button which execs say `ls` and returns (alerts) the string that would be awesome.

 const exec = require('child_process').exec;
 
exec('ls', (err, stdout, stderr) => {
 
if (err) {
   console
.error(err);
   
return;
 
}
  console
.log(stdout);
 
});

Jeremy Ruston

unread,
Oct 16, 2016, 11:19:56 AM10/16/16
to tiddly...@googlegroups.com
Hi Marc

Thanks Jeremy. I'm looking at using the `child_process` module but I don't see any node_modules/ folder in TW Desktop. Could you give me a leg up on how to import a module?

TiddlyDesktop doesn’t use node_modules at the moment. You’ll need to research the details of how nw.js handles node_modules, but it definitely works.

Bonus Question: If you could hack a small plugin which shows a button which execs say `ls` and returns (alerts) the string that would be awesome.

It’s not a trivial amount of work, I’m afraid. There is no direct access between the TiddlyDesktop main process and the content of a wiki. To devise a way for the wiki to request that the main process executes a code fragment, you might want to to look at how saving is handled using the DOM for message transfer. You’d need to rig up something similar so that a hosted wiki can request that a code fragment be executed.

Just to be clear, your goals here are ambitious and unusual. I don’t know of anyone else who’s done the same thing. So there’s going to be quite a lot of slog to get there: you’ll need to learn a lot of the details of how things work so that you can copy/extend things. As a programmer, I’d say that it’s the recipe for absorbing entertainment, but it’s not for everyone :)

Best wishes

Jeremy


 const exec = require('child_process').exec;
 
exec('ls', (err, stdout, stderr) => {
 
if (err) {
   console
.error(err);
   
return;
 
}
  console
.log(stdout);
 
});


--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.

Marc J. Cawood

unread,
Oct 16, 2016, 12:14:30 PM10/16/16
to TiddlyWikiDev
Well... naivety is one of my only virtues.

The following code works fine in standard nw.js and shows how the runtime is just browser+node:

<button onclick="console.log(process.version)">Click Me!</button>

I can even get `require('child_process').exec()` working without requiring any modules.

So why shouldn't this code run inside TiddlyDesktop?

Marc J. Cawood

unread,
Oct 16, 2016, 12:18:35 PM10/16/16
to TiddlyWikiDev
Oh dear!
process is not defined

I see the wikis are not running as normal nw.js applications. How are you launching them?

Jeremy Ruston

unread,
Oct 16, 2016, 12:22:39 PM10/16/16
to tiddly...@googlegroups.com
Hi Marc

I see the wikis are not running as normal nw.js applications. How are you launching them?

Wiki files are loaded in sandboxed iframes; they don't have access to Node.js features. The main process runs the backstage wiki, a privileged TiddlyWiki that runs in the background and provides the TiddlyDesktop user interface. That dichotomy lies behind my comment about needing to figure out a way to communicate between the two parts of the system.

Best wishes

Jeremy.

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.

Marc J. Cawood

unread,
Oct 16, 2016, 2:07:45 PM10/16/16
to TiddlyWikiDev
Ahhhh! The old security-kills-functionality. get's me every time. Sniff.
Reply all
Reply to author
Forward
0 new messages