[Booki-dev] hello bookis

Aleksandar Erkalovic aerkalov at gmail.com
Tue Sep 14 15:14:56 PDT 2010


hi brendan,

nice to see you join the team :)

On Tue, Sep 14, 2010 at 10:46 PM, Brendan Howell
<brendan at howell-ersatz.com> wrote:
> The first thing I'm trying to sort out is where all the jquery magic lives.
>  Looking at the code, I see most everything seems to be in
> "/booki/lib/booki/editor/templates/editor/edit_book.html".  Is this where I
> would set up the actions for the ToDo list and Comments?

edit_book.html is django template file. some basic config parameters are setup
there (current book, current user and etc...). also, UI stuff like tabs, editor,
dialogs, xinha initialization.... not really sure dialog (and some
other html code) should be in that file,
but it is easier for now.

javascript code for editor is in site_media/js/editor.js file.
$.booki.editor.initEditor function is called at
initialization. everything that has to be done at moment of
initialization should go there. so editor.js
would be place where to put your code.

> From my brief reading of the code here it seems that most of the AJAX bits
> are all handled by calls to $.booki.sendToCurrentBook() with a JSON object
> inside.  Is this right?  Seems quite elegant and straightforward!

there is something called sputnik. it is abstraction for doing all
this ajax code. sputnik
let's you have channels. clients can subscribe and unsubscribe to
different channels.
you have channel for each book (being edited), chat and etc... so
server can send
message to book channel and it would be distributed to all web
browsers. from the
server side, all this code is in lib/booki/channels/editor.py (for
editor). from the
client side you use $.booki.sendToCurrentBook or
$.booki.sendToChannel. by default
you are subscribed to book channel so you don't have to think about
it. it is easy to
use sendToCurrentBook, you must specify argument "command" (that is name of
the remote function). everything else is optional. you can have
callback function and
also errback function (this does not work for now). whatever you
return on the server
side will be passed as result object to you callback. there are some magic
arguments that are also send, but nothing you should know at this stage.

the idea is that you get basic info at the initialization (when editor
page is loaded).
later you get changes as they happen or you loaded them when you want.
now, note tab
loads notes when you click on the note tab. with the TOC it is
different, every time someone
makes some kind of action it is send to all web clients and they sync
their current state with
new info (who is editing what, chapter status, new chapter and etc...)

> The HTML bits for the editor seem to live in
> /booki/lib/booki/editor/templates/editor/edit_book.html.  Is that right?

yes, html code is there.

> Thanks in advance for all your help and apologies for what will probably be
> a few stupid questions in the next few days.

nice to have you with us! i will try to answer all your questions and
will write you more,
but now i _must_ go watch latest episode of Weeds :)

aco

-- 
 http://www.binarni.net/



More information about the Booki-dev mailing list