Suggested workflow for integrating with TiddlyWiki (nodejs) through external apps

482 views
Skip to first unread message

Dan L.

unread,
Apr 2, 2017, 6:29:14 PM4/2/17
to tiddly...@googlegroups.com
My goal is to use TidyWiki as a repository for personal notes and
journals (i.e. Evernote). I'm new to using TiddlyWiki, but comfortable
with scripting and development. I'd like to get some input from more
experienced users on how they approach creating and editing tiddler
content (or integrating in general) outside of manually creating
tiddlers.

The two approaches I could find were editing files directly, and using
the REST API.

* Directly creating/editing files in the tiddlers directory requires a
restart of the nodejs server, followed by a refresh of the browser
window, for any changes to go through.
* Using the REST API (GET/PUT/DELETE) seems straight forward enough for
getting, editing, or creating text based tiddlers. However, it's
undocumented so I'm not sure if there's steps I might be missing
(updating indexes, etc.) and I'd have to check into how to handle any
new content such as images. Also, it seems a browser refresh is also
necessary to render any changes.

Some examples of things I'd like to do:

* Append entries to a day specific tiddler, either automatically (i.e. I
have a simple script to connect/disconnect from my work VPN and open
related applications, it could also add lines that have the time and
connection/disconnection for time tracking) or manually through the
command line.
* Poll my Pinboard account for new bookmarks, then create corresponding
Tiddlers in TiddlyWiki, which I may later use for annotations/notes on
resources.
* Have a daemon watching a directory so if I put a photo in Dropbox from
my phone, it will import it.

Douglas Counts

unread,
Apr 4, 2017, 6:41:43 AM4/4/17
to TiddlyWikiDev, prude...@warpmail.net
Directly creating/editing files in the tiddlers directory requires a 
restart of the nodejs server, followed by a refresh of the browser 
window, for any changes to go through

You said that you are new to TiddlyWiki, so firstly TiddlyWiki runs as a SPA (Single Page Application) within the browser.

The server merely constructs the application and sends it as a solitary HTML file to the browser. All the tiddlers are included within that solitary file. All your content is already contained there. So, the application will not see the changes you directly made to the server under normal circumstances. You would need to fully reload the page anew, thus forcing the server to create it anew.  But some browsers will cache the page, so you may need to force the browser to do a full refresh.  If a user saves the page to their local file system, they don't even need the server at all unless there are specific links to content there, such as images. Again, the entire app/website is contained within that single file that was served up to the browser.

Lastly, the server and the App both cache things, so if you are using a text editor to directly edit the tiddlers externally on the server, then there is a good chance that some of these changes will not be visible to the server while it is running.

Using the REST API (GET/PUT/DELETE) seems straight forward enough for 
getting, editing, or creating text based tiddlers. However, it's undocumented

This server.js page and this libraryserver.js page should give you all the information you need if you wish to write your own mini-client for the server.

Regarding the examples you provided discussing some of your ideas, if you know how to write JavaScript inside your browser to do what you want, then you can do the same within TiddlyWiki.  You can either write a plugin, or simply save the JavaScript making sure you select the `application/javascript` content type when you save that tiddler.  The JavaScript will then be executable within the browser. 

TiddlyWiki has its own Domain Specific Language comprised largely of what it calls Widgets, Macros, Actions, Buttons, Messages and more.  You can find detailed information on the internals of TiddlyWiki by referencing the developer wiki here.

Best regards,

Doug

Dan L.

unread,
Apr 4, 2017, 7:18:26 PM4/4/17
to Douglas Counts, TiddlyWikiDev
I'm trying to understand how I should go about manipulating tiddlywiki
separate from a browser -- for example, through a command line script or
a cronjob. There doesn't seem an obvious/clean way to do it, so I was
hoping that there might be some advice. I can dream up a couple
approaches (such as using a web browser plugin which lets me trigger
reloads via a network request, or run TiddlyWiki's server with a process
manager that I can restart with a network request), but better to rely
on collective wisdom instead :)

From what you're saying, though, it sounds like I might be better off
rethinking how I'd build integrations into something that fits into
TiddlyWiki's plugin architecture a bit better?


On Tue, Apr 4, 2017, at 03:41, Douglas Counts wrote:
>
> >
> > Directly creating/editing files in the tiddlers directory requires a
> > restart of the nodejs server, followed by a refresh of the browser
> > window, for any changes to go through
> >
>
> You said that you are new to TiddlyWiki, so firstly TiddlyWiki runs as a
> SPA (Single Page Application) within the browser.
>
> The server merely constructs the application and sends it as a solitary
> HTML file to the browser. *All the tiddlers are included* within that
> solitary file. All your content is already contained there. So, the
> application will not see the changes you directly made to the server
> under
> normal circumstances. You would need to fully reload the page anew, thus
> forcing the server to create it anew. But some browsers will cache the
> page, so you may need to force the browser to do a full refresh. If a
> user
> saves the page to their local file system, they don't even need the
> server
> at all unless there are specific links to content there, such as images.
> Again, the entire app/website is contained within that single file that
> was
> served up to the browser.
>
> Lastly, the server and the App both cache things, so if you are using a
> text editor to directly edit the tiddlers externally on the server, then
> there is a good chance that some of these changes will not be visible to
> the server while it is running.
>
> Using the REST API (GET/PUT/DELETE) seems straight forward enough for
> > getting, editing, or creating text based tiddlers. However,
> > it's undocumented
> >
>
> This server.js
> <https://github.com/Jermolene/TiddlyWiki5/blob/1530b3e2d8d76f39caed56024e7a0d1ecc260354/core/modules/commands/server.js>
> page
> and this libraryserver.js
> <https://github.com/Jermolene/TiddlyWiki5/blob/ffc0899f52b45ba2b5a5a20fb909dcc587e80b3e/plugins/tiddlywiki/pluginlibrary/libraryserver.js>
> page
> should give you all the information you need if you wish to write your
> own
> mini-client for the server.
>
> Regarding the examples you provided discussing some of your ideas, if you
> know how to write JavaScript inside your browser to do what you want,
> then
> you can do the same within TiddlyWiki. You can either write a plugin, or
> simply save the JavaScript making sure you select the
> `application/javascript` content type when you save that tiddler. The
> JavaScript will then be executable within the browser.
>
> TiddlyWiki has its own Domain Specific Language comprised largely of what
> it calls Widgets, Macros, Actions, Buttons, Messages and more. You can
> find detailed information on the internals of TiddlyWiki by referencing
> the
> developer wiki here <http://tiddlywiki.com/dev/>.

Douglas Counts

unread,
Apr 5, 2017, 12:50:11 AM4/5/17
to TiddlyWikiDev, dougla...@gmail.com, prude...@warpmail.net
If you are wanting to manipulate TiddlyWiki from the command line, that should be possible as there are a number of commands built into TiddlyWiki.  

Those run to completion and then exit. For example, the command to build a single html file, builds the file, and then exits.

The commands available inside a browser's developer tools console are much more interactive.  You can create tiddlers there and do just about anything else you would ever want to.

There are also a number of headless browsers available for Node development, that is the direction that I would recommend.

Most of those are included as part of a node testing strategy:
There are many other headless browsers out there that even use other languages like python or C#.

Anything that you would want to do through a browser, you can do with one of these instead.  You simply have to pick one that meets your needs the best among the many that are out there. I have used PhantomJS and Selenium in several projects and they work great.  Their websites have examples on their use, you can find YouTube videos on their use, and if you search GitHub, you will find that many projects use them in various ways.

-Doug

PMario

unread,
Apr 5, 2017, 8:26:47 AM4/5/17
to tiddly...@googlegroups.com, prude...@warpmail.net
On Monday, April 3, 2017 at 12:29:14 AM UTC+2, Dan L. wrote:
My goal is to use TidyWiki as a repository for personal notes and
journals (i.e. Evernote). I'm new to using TiddlyWiki, but comfortable
with scripting and development.

Welcome to the club!
 
I'd like to get some input from more
experienced users on how they approach creating and editing tiddler
content (or integrating in general) outside of manually creating
tiddlers.

That's possible. Tiddlers are just text files with a .tid extension and some special formatting.

eg:

created: 20170405135712000
modified: 20170405135712000
title: New Tiddler
tags: tagA tabB [[tag with spaces]]
field-x: optional field
field-y: an other optional field

The empty line above separates the meta data section form this text area.

All fields are optional except title. If you want to see the tiddlers in the "latest" sidebar created and modified are mandatory.

There is a second format, that uses 2 files. eg:

test.txt

The test.txt file contains just the "text" area from above and the meta data file looks like this

text.txt.meta

created: 20170405135712000
modified: 20170405135712000
title: New Tiddler
tags: tagA tabB [[tag with spaces]]
field-x: optional field
field-y: an other optional field

The latest / upcomming TW nodejs version 5.1.14 will create files like this by default.


The two approaches I could find were editing files directly, and using
the REST API.

yes
 
* Directly creating/editing files in the tiddlers directory requires a
restart of the nodejs server, followed by a refresh of the browser
window, for any changes to go through.

that's right. ... but its relatively straight forward to create an external watch-task that restarts the server for you. It's a bit hacky, but works for a dev workflow
 
* Using the REST API (GET/PUT/DELETE) seems straight forward enough for
getting, editing, or creating text based tiddlers. However, it's
undocumented so I'm not sure if there's steps I might be missing
(updating indexes, etc.) and I'd have to check into how to handle any
new content such as images. Also, it seems a browser refresh is also
necessary to render any changes.

That's right!
 
Some examples of things I'd like to do:

* Append entries to a day specific tiddler, either automatically (i.e. I
have a simple script to connect/disconnect from my work VPN and open
related applications, it could also add lines that have the time and
connection/disconnection for time tracking) or manually through the
command line.

As I wrote above. As long as you keep the general directory and file structure it's simple to create single file TWs from the "tiddlywiki" command line interface. .. That's how the whole development workflow works.

From your OP I suppose you installed nodejs already. I'm using the latest stable branch 6.x which works well.

You also should install tiddlywiki CLI with npm install -g tiddlywiki ... version 5.1.13 is fine!

eg:

[mario:~] $
-> tiddlywiki --version
5.1.13

tiddlywiki without any params will show you the possible commands. See: http://tiddlywiki.com/#Commands

tiddlywiki --help editions will list all the available editions

One of the is the server edition. Which you can initialize like this:

cd tmp
tiddlywiki test-server --init server

and start with:

tiddlywiki test-server --server


Have a look at the directory structure!

There also is a configuration file named tiddlywiki.info

It contains infos about the plugins, that should be used and some general buidl instructions, to make the --build command easier.
  • create some tiddlers
  • stop the server
  • try: tiddlywiki test-server --build index

You'll see, that a index.html has been built in the default output directory, of your edition folder.
You can also try: tiddlywiki test-server --build static
It will use the parameters from tiddlywiki.info. So you don't need to remember many parameters


 
* Poll my Pinboard account for new bookmarks, then create corresponding
Tiddlers in TiddlyWiki, which I may later use for annotations/notes on
resources.

With the above info you should be able to create bash scripts, that get you going.

 
* Have a daemon watching a directory so if I put a photo in Dropbox from
my phone, it will import it.

The "watch-stuff" is a bit more work. We'll discuss this later.

have fun!
mario

vijayvithal jahagirdar

unread,
Nov 6, 2019, 7:39:09 AM11/6/19
to TiddlyWikiDev
I am in the same boat, Opening up Chrome's `developer tools` I can see

1. http://<DOMAIN>/recipes/default/tiddlers.json gives me a json file with the list of tiddlers
2. I am trying to identify the URL Targets which will allow me to do basic CRUD operations on a tiddler selected from the list. But am not able to identify standard method of doing so.

Document this as a standard API would help in creation of scripts which integrate TW with other systems(Bug/Issue tracking,CMS etc.)

Jeremy Ruston

unread,
Nov 6, 2019, 7:55:27 AM11/6/19
to TiddlyWikiDev
I am in the same boat, Opening up Chrome's `developer tools` I can see

1. http://<DOMAIN>/recipes/default/tiddlers.json gives me a json file with the list of tiddlers
2. I am trying to identify the URL Targets which will allow me to do basic CRUD operations on a tiddler selected from the list. But am not able to identify standard method of doing so.

Document this as a standard API would help in creation of scripts which integrate TW with other systems(Bug/Issue tracking,CMS etc.)

The API is documented here:


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 view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/25695e18-3120-4ddb-9842-2d868dc5350c%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages