[PLUGIN] Firebase

Post your completed addons to share with the community

Post » Mon Nov 11, 2013 9:46 pm

Firebase v0.5

contribute github

download plugin only

run LIVE multi-user demo

Real time database-as-a-service integration. Have a real-time database without owning a server!

So far, you can:
- Set String, Numbers, Objects (as JSONs)
- Register for updates of String, Numbers, Objects
- Create (concurrency safe) lists of objects
- Register for list updates

Authenticate users securely using:
- email/password
- Facebook logins

Use the webgui (firebase) to:
-View/edit data
-set read/write access
-add consistency rules to be verified by firebase (stop cheating)

A capx is included in the repo for testing. All communication is encrypted and compressed. Tested on static HTML export, preview and minification. It will NEVER work with Cocoon, but Firebase does provide APIs for native iOS, and Android, so you can possibly get to your data in a complicated post process operation if you want native.

The project is hosted on github so if you need a feature and can add it yourself, add it yourself and send me a pull request! I have tried to comment my code to make it fairly obvious what the design is.

Tomtlarkworthy2013-11-15 11:09:27
B
14
S
5
G
1
Posts: 60
Reputation: 1,052

Post » Mon Nov 11, 2013 10:11 pm

Sounds like a nice idea.
What different auths does it support?
Is the plug going to do encryption/ decryption?
Image ImageImage
B
171
S
50
G
179
Posts: 8,392
Reputation: 113,478

Post » Mon Nov 11, 2013 10:37 pm

The technical details of firebase are at
https://www.firebase.com/

Firebase is a *very* capable serverless database.

Authentication supports
Facebook
Twitter
Github
Persona
Email & Password

You can set validation rules via a web gui, which firebase checks. So you can prevent certain types of cheating (e.g. you can't buy X unless you have Y cash in the bank). More complex logic won't fit in its validation rules (e.g. the rules of a game of cards), but you can add your own server with different permissions onto the firebase for those cases.

Firebase supports SSL (by default), so data is encrypted on the wire, its also compressed effeciently.

Oh and transaction support, which is a pretty neat technical feat on a real time over-the-web store. The database caches all data locally, so local data writes are fast, and they sync global writes in the background (a bit like dropbox). This avoids slow downs during poor connectivity situations (remember transactions!). Its very smart.

I have no idea if half these features can be mapped to construct 2. But just as a non-server database with validation rules its pretty hand.


tlarkworthy2013-11-11 22:44:01
B
14
S
5
G
1
Posts: 60
Reputation: 1,052

Post » Tue Nov 12, 2013 9:21 pm

The basic API is now in place. Your Actions are

(set, update, push*, remove) to (String, Number, JSON)

*push is for lists

you can register for real time updates of all event types:-
("value", "child_added", "child_removed", "child_updated", "child_moved")

You associate a tag on registration like AJAX, so then your tagged conditions trigger when data is received from firebase.

You can then use the expressions to get the data and URL references out

(ValString, ValNumber, ValJSON, Ref)

There is a capx demoing this functionality in github. A screen shot of the real-time database demo is at
https://github.com/tomlarkworthy/construct2_firebase_plugin/blob/master/demo/firebase_ui.png

MISSING FUNCTIONALITY from Firebase API:
error callbacks
transactions
authentication
filter queries
list order priorities

I probably won't implement all the missing parts, but I am quite keen to get my mits on authentication and transactions at some point (not massively urgent though)


tlarkworthy2013-11-12 21:23:48
B
14
S
5
G
1
Posts: 60
Reputation: 1,052

Post » Tue Nov 12, 2013 10:40 pm

I hope you can get it up and running.
As is its crashing C2 on preview.
I wouldn't think that was possible.
Image ImageImage
B
171
S
50
G
179
Posts: 8,392
Reputation: 113,478

Post » Tue Nov 12, 2013 10:52 pm

works on mine. Any clues in the javascript console? (CTRL + J)

EDIT: just tested preview on Firefox, Chrome on Linux over network and fine. Does it boot the preview and die on the webpage or does C2 refuse to preview it (the later being a plugin install problem)? ***


*** wait whats the directory the plugin is installed as??? on my machine its "firebase" but that might have got screwed when you cloned from github...tlarkworthy2013-11-12 23:01:17
B
14
S
5
G
1
Posts: 60
Reputation: 1,052

Post » Tue Nov 12, 2013 11:04 pm



Abort Crashes C2, retry, and ignore launches the browser.
Image ImageImage
B
171
S
50
G
179
Posts: 8,392
Reputation: 113,478

Post » Tue Nov 12, 2013 11:12 pm

Oh ok. I think thats because I said the plugin depends on "https://cdn.firebase.com/v0/firebase.js", a remote file, which I did so it would insert
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
in the HTML. I think it expects that file to be in the plugin directory though locally.

I don't have a debug version of C2 so it does not pop that up for me. Ignore it until I find another method for altering the HTML? Does it work in the browser afterwards?tlarkworthy2013-11-12 23:13:44
B
14
S
5
G
1
Posts: 60
Reputation: 1,052

Post » Tue Nov 12, 2013 11:28 pm

Yeah, looks like it runs fine.

Well if its a call to an external file, then it probably shouldn't be run in preview mode.
Image ImageImage
B
171
S
50
G
179
Posts: 8,392
Reputation: 113,478

Post » Tue Nov 12, 2013 11:43 pm

Great!

Firebase needs to be an external API so you can get around the same origin policy and actually do database like things. There does not seem to be way of adding remote JS libraries in a nice way but I will ask elsewhere.

I appreciate you giving it a spin and your debugging help a lot.


tlarkworthy2013-11-12 23:43:51
B
14
S
5
G
1
Posts: 60
Reputation: 1,052

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 3 guests