Juzu Day 3: The Coolness

Today is the last of my three days on Juzu and I want to show some nice features you can find inside.

If you want to start from Day 1, you can take a look in the previous posts:
Three Days with Juzu: Write a Killer App;
Juzu Day 2: Real Web Apps as well.

So, if you want to see some nice gems, it’s here.

All the Coolness

We know how to write an app, but do we know how to write something cool, something you say “it’s fucking great, man!” when you look at it? Of course, there are a number of other gems in Juzu.

Ajax + jQuery

The first one, and it’s a big one, is about Ajax calls. We saw at the beginning of this “quite long” article that you can declare a resource with @Ajax annotation, like here in maintainSession:

It’s about Ajax, right? So, we added jQuery as an asset in the packaging-info:

Thanks to the amazing stuff that is done under the hood by Julien, Juzu will detect you’re using jQuery and will generate specific jQuery objects so you can call your method very easily from within the JavaScript. Let’s take a look inside chat.js to see this:

There’s also $.jzLoad and $.jzAjax methods if you want a shortcut to jQuery $.ajax() method, like:

For me, it’s a killer feature because it makes your code so much easier to read.


I already talked a little bit about Less integration but here is a quick example about how great this is to write CSS.

The fact is I like Less but without this integration, I could certainly not use it. But now, since it’s part of Juzu, I have no excuse since it takes just a line to use Less.

So, let’s say you want to define emoticons in your CSS. Usually, you will do this:

One thing I hate is copy/pasting the some code; same thing goes for CSS, I hate it like that. 1) It’s ugly. 2) It’s hard to read. With Less integration in Juzu, you just need to do this in emoticons.less:

Now, take a look at that, it’s far better, isn’t it? 🙂

You can even do more tricky stuff with Less like, for example, in the panels.less:

Here, you declare a class with arguments and you can even do some math with your params (like @height – 51). I can’t thank enough all the developers out there who provide jQuery, Bootstrap, Less and all these kinds of life savers.

Responsive Design

There’s a big trend on responsive design. If you don’t really know what it is, I invite you to spend even more time watching a video on this:

Responsive Design from Benjamin Paillereau on Vimeo.

To make it simpler, it’s about developing one app to rule them all! You write once and it will adapt automatically depending on whether accessing your site or app from a desktop, a small notebook, an iPad, an iPhone; you name it.

All you need to do is two things:

  • Manage viewport with a viewport metatag in your html header;
  • Create multiple CSS for each media (small screen, large screens, print, etc).

Viewport metatag

Again, thanks to Juzu’s coolness, it will only take 10 seconds for this step. Just add the right withMetaTag in your render and you’re done – like in the chat:

It’s that easy!

Media in CSS

Well, this is where Less integration is a killer and why you should really use it!

It may be a pain in the *** to manage this but not with Less. Again, thanks to Less integration in Juzu, it’s just a few lines of code and thinking your CSS the right way – like for the Chat app:

As all my CSS uses @height and @width to manage sizable elements, I can import the Less files with new parameters for each media size and I’m done. Here’s the same for big desktops:

So, writing a responsive CSS is not that hard, you have no excuse not to make them responsive! 🙂 (well, at least if you’re using Juzu… If you’re using one of the usual suspects, good luck with this). Here’s what the Chat app looks like on iPhone:

Fluid App, why not?

I’ll end with something a little off topic, but I think we have a final great gem here. It’s also so simple to add it into a Juzu app, so I wanted to add a note about it.

As I wrote a Chat, the thought popped into my head: hummm, it would be great to use it like any regular app… Luckily, I’m a Macbook Pro user, which means I’m running Max OS X. And we have a great app called Fluid App.

It’s great because it allows you to convert a website to an app and that’s exactly what I did in this Juzu app.

It looks like this:

And basically, what you need to do is not that hard since Juzu allows you to do what you want, right?
As I’m using extensively jQuery, which is well integrated in Juzu, I just added a few calls to make my app Fluid Aware.

Maintain session if loaded as a Fluid App

We need first to maintain the session as it’s part of the real app User Experience.

Update the notification badge

Then, we can add a badge on the Dock icon.

Send growl notification if available

We can also send notifications in the Notification Center.

Add change status menu item in the Dock app

Finally, we can even change our status right from the Dock 🙂

Nothing more is needed; from this point on, the application can be added as a real app in my Applications folder.

What’s Next?

So, you did it, you read these three posts to the end. I want first to give you a big thank for your reading time.

I hope they helped you to discover this new web framework that is Juzu.

You will find some documentation on its official website: http://juzuweb.org/
If you have questions about Juzu, you can go to the Google group to ask them: http://groups.google.com/group/juzu.

And if you want to contribute, it’s on GitHub: https://github.com/juzu/juzu.

Again, thousand kudos to Julien and his great work on Juzu!

Finally, a small word about the Chat application: you want to know more or help me to build an even better Chat application? Contact me or simply fork the Chat GitHub project, I’ll be more than happy to integrate new cool ideas in the Chat (or bug fixes).

Thus, if you want to take a deeper look at the code, it’s Open Source and available on eXo Addons Repositories: https://github.com/exo-addons/chat-application« Again, thanks for watching and stay tuned – more things are coming, Benjamin. »

Related Posts

1 Comment

    Speak your mind

    Your email address will not be published.

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">