Hi Jon

Great progress.


> The next step was to trigger sync. This happens when I edit the
> GettingStarted page. And here it wasn't enough to point
> CouchDBAdaptor.prototype.saveTiddler at the tw5.com-server. When I did that
> and triggered sync, the browser's GET request mysteriously became an
> OPTIONS request which is unsupported in modules/commands/server.js. What's
> up with that? More CORS voodoo. As per
> http://metajack.im/2010/01/19/crossdomain-ajax-for-xmpp-http-binding-made-easy/,
> I added this to server.js:
>

I think it would make sense to fold this into the core of TW; there could
be a few situations where CORS support would be useful.


> Meanwhile, I add the following to the app.html generated by tankbld:
>


>
> <script src="pouchdb-nightly.js"></script>
>
> <script>
>  var global_couchdb = new PouchDB('http://localhost:5984/tiddly/');
> </script>
>

Existing TW5 plugins that encapsulate external libraries do so by
statically importing the library as a tiddler that can then be required.
See the CodeMirror plugin for an example. It would mean rebuilding your
base wiki each time there's a new pouchdb nightly, but you'll probably be
wanting to incorporate the wiki build process into your own build process
anyway.


> I can see, for example, that the CouchApp is polling tiddlers.json.
> Presumably it's looking for changes?
>

Yes, that's right - tiddlers.json returns a JSON snapshot of the visible
"skinny" tiddlers - which is to say that they are missing a "text" field
but are otherwise ordinary tiddlers.


> At the moment it won't find any, because that is only a static doc. I can
> also see that when the browser app saves to the server, the server updates
> its own instance of the wiki. Presumably those updates are then reflected
> in the next tiddlers.json sent back to the browser?
>

Yes that's right.


> My best guess at this point is that I now need to:
>
> - at startup, externalize all the tiddlers in the app.html image as
> CouchDB docs
>

That step is optional - the TiddlyWeb and Tank editions both ship with an
empty app.html, and then they load their content via the sync process.

However, that extra asynchronous step during startup does cause some issues
that we haven't resolved yet, so baking the tiddlers into the HTML file
would be best.


> - make CouchDBAdaptor's saveTiddler save to CouchDB and also update the
> CouchDB instance of tiddlers.json
>

Yes - although I'd maybe have expected tiddlers.json to be generated
dynamically when required.


>
> - redirect CouchDBAdaptor's loadTiddler and deleteTiddler to CouchDB
>

Yes.


> That's the plan, but please let me know what concepts I'm still missing.
>

The broad plan sounds correct, and I don't see any significant obstacles.


> Also I'd love to hear what strategies you use to debug, especially in the
> browser. The way in which modules are loaded makes it an interesting
> challenge to debug!
>

If I need to debug in the browser I generally use Chrome, which seems to
have far and away the best dev tools. My technique for debugging is
unsophisticated: I place "debugger" statements in the code, recompile
(usually with qbld.sh, which is fast), and reload in the browser.

I experimented with Node.js debuggers when TW5 started and couldn't find an
approach I liked (it was early in 2012). So far I've managed to get by with
console.log statements. (It's probably beneficial that I've never been a
huge enthusiast for the big '90s IDEs).

Best wishes

Jeremy



>
> Thanks!
>
> Jon
>
>
>
>
>
> On Monday, March 3, 2014 5:10:43 PM UTC-5, Jon Udell wrote:
>>
>> "Does that make sense?"
>>
>> Yep, that's the plan. Was curious what SkinnyTiddlers and recipes and
>> etc. are all about, but if I can safely ignore that and just do
>> load/save/delete that's what I'll do.
>>
>> Thanks!
>>
>> On Monday, March 3, 2014 4:36:16 PM UTC-5, Jeremy Ruston wrote:
>>>
>>> Hi Jon
>>>
>>> I've run tankbld which created app.html, from which emanate (via the
>>>> adaptor) Ajax calls to a server that knows about things like /status
>>>> and recipes. Should I look to https://github.com/cdent/tank for that
>>>> knowledge?
>>>>
>>>
>>> Sorry if it wasn't clear, I'm suggesting that you fork the existing
>>> tiddlyweb adaptor. The specifics of the present implementation are very
>>> TiddlyWeb-specific. So your next step would be to replace the
>>> implementations of the methods like getTiddlerInfo, saveTiddler,
>>> loadTiddler and deleteTiddler with new implementations that call the couch
>>> APIs. Does that make sense?
>>>
>>> Best wishes
>>>
>>> Jeremy
>>>
>>>
>>>
>>>
>>>>
>>>> Thanks,
>>>>
>>>> Jon
>>>>
>>>>  3, 2014 3:06:26 PM UTC-5, Jeremy Ruston wrote:
>>>>
>>>>>  > The editions I explored were server and tw5.com-server. It appears
>>>>> that they are using the filesystem adaptor
>>>>>
>>>>> Both those editions use both the filesystem adaptor and the tiddlyweb
>>>>> adaptor. The latter is active in the browser, and handles syncing changes
>>>>> back to the server with HTTP. The file system adaptor runs on the server
>>>>> and handles syncing back to the file system via the Node.js file APIs.
>>>>>
>>>>> The tw5tank edition is more like your situation; it just uses the
>>>>> tiddlyweb adaptor, because it doesn't run on the server.
>>>>>
>>>>> > At the hangout #21 we briefly talked about the inclusion of pouchdb
>>>>> as a TiddlyWiki store [1]. Which would need to "hide the existing tiddler
>>>>> hashmap" behind an api. Do you remember?
>>>>>
>>>>> Yes, I didn't bring it up here to keep things simple. For
>>>>> completeness, the idea is that an alternative way of integrating PouchDB
>>>>> would be to replace the existing $tw.Wiki object class with a new class
>>>>> that backs to PouchDB for tiddler storage instead of a native JS hashmap.
>>>>> The advantage of this approach would be that it would then be possible to
>>>>> have native PouchDB implementations of wiki store methods like wiki.
>>>>> getTiddlersWithTag().
>>>>>
>>>>> Best wishes
>>>>>
>>>>> Jeremy
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Mar 3, 2014 at 7:24 PM, Jon Udell <[email protected]> wrote:
>>>>>
>>>>>> @PMario: In Thali, CouchDB/Couchbase is an embedded system service
>>>>>> used both for users' data and for apps. Both data and apps can replicate
>>>>>> among peers directly. By the way, Yaron actually started prototyping with
>>>>>> PouchDB, and a PouchDB adapter for CouchDB/Couchbase would meet my need.
>>>>>> That's because it works in two modes: as its own database (writing to the
>>>>>> browser's IndexedDB) or as a client of a CouchDB server (which in Thali,
>>>>>> again, is embedded on the client device as a system service.)
>>>>>>
>>>>>> Jon
>>>>>>
>>>>>>
>>>>>> On Monday, March 3, 2014 2:12:51 PM UTC-5, PMario wrote:
>>>>>>>
>>>>>>> @Jeremy,
>>>>>>> At the hangout #21 we briefly talked about the inclusion of pouchdb
>>>>>>> as a TiddlyWiki store [1]. Which would need to "hide the existing 
>>>>>>> tiddler
>>>>>>> hashmap" behind an api. Do you remember?
>>>>>>>
>>>>>>> Reading the discussion of Jon and Yaron at
>>>>>>> http://thali.codeplex.com/discussions/537194. makes me think, using
>>>>>>> pouchdb as an optional internal TW store, would be even better.
>>>>>>>
>>>>>>> It would be needed to create an API, discussed at [1], but this
>>>>>>> would also allow us to have more options as tw stores.
>>>>>>> What do you think?
>>>>>>>
>>>>>>> @Jon,
>>>>>>> I'm not sure, if I get the purpose of your Thali project. .. Do you
>>>>>>> provide a server side backend for users, where they can store there 
>>>>>>> data.
>>>>>>> ... But imo this wouldn't fit to the P2P goal. Or is this just the
>>>>>>> plattform to store apps?
>>>>>>>
>>>>>>> -m
>>>>>>>
>>>>>>> [1] http://www.youtube.com/watch?feature=player_detailpage&v=Sqj
>>>>>>> PSqQySc0#t=2565
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Jeremy Ruston
>>>>> mailto:[email protected]
>>>>>
>>>>
>>>
>>>
>>> --
>>> Jeremy Ruston
>>> mailto:[email protected]
>>>
>>


-- 
Jeremy Ruston
mailto:[email protected]

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to