Thanks Simon.
Post by Simon GaeremynckHi Jacqueline,
You will have to create a backend module which will take care of
persisting/retrieving data to/from Cassandra.
I've started a document on our wiki [1] which outlines the anatomy of an
OAE backend module and where what code should go.
I will be expanding on it in the following days, but it should get you started.
I would suggest you go through the document first and then go through the
code that is creating a discussion. Start in the
node_modules/oae-discussions/lib/rest.js file with the create discussion
endpoint and work your way down from there. You can add `console.log("My
text");` if you want debug output, or if you're feeling adventurous, you
could use something like node-inspector [2] to step through the code.
I suspect that what you will have to do is very similar to
content/discussions?
1. Create an endpoint in your oae-meetings/lib/rest.js file at
/api/meetings/create which responds to POST requests
2. Export a function in your oae-meetings/lib/api.js file `createMeeting`
3. Export a function in your oae-meetings/lib/internal/dao.js file
`createMeeting` which persists the data to cassandra
When you have all of the above you can wire it up in your widget through
$.ajax({
'url': '/api/meetings/create',
'data': { .. },
'succes': function() { alert('Meeting has been created!'); },
'error': function() { alert('Meeting has not been created! :('; }
});
Kind regards,
Simon
[1]
https://github.com/oaeproject/Hilary/wiki/Anatomy-of-an-OAE-backend-module
[2] https://github.com/node-inspector/node-inspector
Post by Jacqueline RamosHi Simon.
I wanted to do all the logic in my own widget, but I have to write in a
columnfamily I created in cassandra. I see that the module is in the Hilary
side. So my question is: how can I do this if I don't have the files that
for example "creatediscussion" has?
Post by Jacqueline RamosHope you can help me
Jacqueline
On Mon, Mar 31, 2014 at 1:21 PM, Simon Gaeremynck <gaeremyncks at gmail.com>
Hi Jacqueline,
The frontend (3akai-ux) and the backend (Hilary) talk to each other over
REST (more specifically, HTTP).
Post by Jacqueline RamosThis means that if the frontend needs some data (e.g.: discussion
profile data) it will perform a GET request to an api that is provided by
Hilary.
Post by Jacqueline RamosHave a look in the network tab of your browser's developer tools when
loading a page.
Post by Jacqueline RamosYou'll see a lot of requests fly by. Among those, there should be a
couple of requests to `/api/...`
Post by Jacqueline RamosIn the frontend, we use jQuery's excellent ajax function [1] to achieve
this. As you said, this logic is located
Post by Jacqueline Ramosin the `oae.api.discussion.js` [2] file under `/shared/oae/api`.
If you're writing your own widget however, it's probably not necessary
to add your own API, you can place that logic in your own
Post by Jacqueline Ramoswidget and use jQuery's ajax method directly.
On the backend we expose a set of REST endpoints (all under `/api`) that
the UI can consume via jQuery's ajax method.
Post by Jacqueline RamosEach `oae-*` module will have a `/lib/rest.js` file that plugs the
endpoint in the expressjs [3] webserver.
Post by Jacqueline RamosHave a look at the discussion rest endpoints [4] for how this might work.
Hope that helps,
Simon
[1] http://api.jquery.com/jQuery.ajax/
[2]
https://github.com/oaeproject/3akai-ux/blob/master/shared/oae/api/oae.api.discussion.js#L32
Post by Jacqueline Ramos[3] http://expressjs.com/3x/api.html
[4]
https://github.com/oaeproject/Hilary/blob/master/node_modules/oae-discussions/lib/rest.js#L114
Post by Jacqueline RamosOn 31 Mar 2014, at 18:25, Jacqueline Ramos <jackie.ljrm at gmail.com>
Post by Jacqueline RamosHi, I am trying to understand how the widget "creatediscussion"
connects with the module in Hilary "oae-discussion" to create a new
discussion and insert into cassandra
Post by Jacqueline RamosPost by Jacqueline RamosI see that this code does it.
oae.api.discussion.createDiscussion(displayName, discussionTopic,
visibility, [], members, function (err, data) {
discussion profile
Post by Jacqueline RamosPost by Jacqueline Ramosif (!err) {
window.location = data.profilePath;
} else {
oae.api.util.notification(
oae.api.i18n.translate('__MSG__DISCUSSION_NOT_CREATED__',
'creatediscussion'),
oae.api.i18n.translate('__MSG__DISCUSSION_COULD_NOT_BE_CREATED__', 'creatediscussion'),
Post by Jacqueline RamosPost by Jacqueline Ramos'error');
}
});
and there is a oae.api.discussion.js in 3akai-ux/shared/oae/api that I
assume is the file that connects with Hilary. Am I wrong?
Post by Jacqueline RamosPost by Jacqueline RamosAlso I am trying to create a "oae.api.meeting.js" and place it in the
oae.api,js file. It says there that the file is a plugin so I guess I have
to do something else for it work, right?
Post by Jacqueline RamosPost by Jacqueline RamosCould you please help me?
Jacqueline
_______________________________________________
oae-dev mailing list
oae-dev at collab.sakaiproject.org
http://collab.sakaiproject.org/mailman/listinfo/oae-dev
--
Liliana Ramos