Work with Jamal MVC

14 views
Skip to first unread message

Guillermo Álvarez

unread,
Mar 18, 2009, 2:20:49 PM3/18/09
to Jamal MVC
Hello.

I was thinking about the future on the web, and think that a client
app based on MVC will be necesary. I start watching sproutcoure and it
was very ugly. By the other hand... I love jQuery.

I always want to make and jQuery based MVC, so it was very confortable
to found Jamal.

I start playing with jamal today. I forked it in github [1].

Now i working in a sample rails app, with a jamal plugin to make some
things:

a) Create a rake task to make the client app scaffold (aka install):

RAILS_ROOT/client/app/...
RAILS_ROOT/client/test/...
RAILS_ROOT/client/vendor/jamal

b) Create a rake task to update assets. For example:
Compile RAILS_ROOT/client/vendor/jamal in RAILS_ROOT/public/javascript/
jamal.js
Compile RAILS_ROOT/client/app/[controller|model|view]/*.js in
RAILS_ROOT/public/javascript/client.app.js

c) Some rails helpers
"include_jamal_core". The helper to make <script src...

d) Try to update assets live in development (ala Sass).

When I finish these. I want to work in JAMAL by improve some things
like
a) Model Post assumes /post restfull resource and can make find, new,
create, update and destroy.
b) View helpers. Typical view helpers in rails.


About restfull model, i read in the list that someout is working on
it, but i can't find any code.

I have a lot of work, but i think that in the future the actual
frameworks will be deprecated because all have to make two thing:
a) Serving stating assets (Ok, not the framework itself)
b) Restfull interface (Just for user sessions, or models)


These message is to ask for sugestions, because there is not a lot of
documentation.

Thanks.


[1] http://github.com/guillermo/jamal/tree/master

Guillermo

unread,
Mar 18, 2009, 4:35:41 PM3/18/09
to Jamal MVC


2009/3/18 Guillermo Álvarez <guil...@cientifico.net>

Now i working in a sample rails app, with a jamal plugin to make some
things:

The jamal rails jamal plugin is there:

Actually it includes 3 features

* A rake task to install jamal and generate a scaffold of a clients app
  The structure is:
    RAILS_ROOT/client/app
    RAILS_ROOT/client/vendor/jamal
    RAILS_ROOT/client/vendor/jquery

* A rake task to update assets
  These task update javascripts assets
  RAILS_ROOT/client/app will be RAILS_ROOT/public/javascripts/client.app.js
  RAILS_ROOT/client/vendor/jamal will be RAILS_ROOT/public/javascripts/jamal.js
  RAILS_ROOT/client/vendor/jquery will be RAILS_ROOT/public/javascript/jquery.js

* A view helper that include jquery, jamal and client.app
  If enviroment is development all assets are regenerate by request

Any feedback is welcome.

--
Guillermo Álvarez

Alex

unread,
Mar 18, 2009, 4:38:02 PM3/18/09
to jama...@googlegroups.com
Good Job!

Timo Derstappen

unread,
Mar 19, 2009, 5:19:06 AM3/19/09
to jama...@googlegroups.com
Hey Guillermo,

> I start playing with jamal today. I forked it in github [1].

Great!

> Now i working in a sample rails app, with a jamal plugin to make some
> things:

I'm no expert in rails, but Georg and Dennis are using Jamal with
rails. So maybe they have already some code/plugins/helper ... I'll
talk to them.

> a) Create a rake task to make the client app scaffold (aka install):
>
> RAILS_ROOT/client/app/...
> RAILS_ROOT/client/test/...
> RAILS_ROOT/client/vendor/jamal

The testsuite is also something that has to be worked on. qunit ftw!
It should be nicely integrated within jamal and its deployment tools.

http://docs.jquery.com/QUnit

> b) Create a rake task to update assets. For example:
> Compile RAILS_ROOT/client/vendor/jamal in RAILS_ROOT/public/javascript/
> jamal.js
> Compile RAILS_ROOT/client/app/[controller|model|view]/*.js in
> RAILS_ROOT/public/javascript/client.app.js

George wrote an air application to do that cross platform, but I guess
it's already outdated. In the Jamal repository I've build that with
ant, at work we are using phing to do the job. We switched from dean
edwards packer to the yui compressor lately.

To improve performance you can even concat jquery.js + jamal.js +
client.app.js. You save two requests and fetching javascript makes the
browser very slow. Be sure to add caching header (try to prevent 304
Not Modified) and a revision number in the compiled js file. So that
the browser recognizes any new version of the javascript.

> c) Some rails helpers
>  "include_jamal_core". The helper to make <script src...

Be sure to add the javascript at the very end of your body. This makes
your site render way faster ... YSlow ftw!

> d) Try to update assets live in development (ala Sass).

I don't know if I get this right. But I'm always working with the
original files within app, this means that there are lots of script
includes in the dev environment, but this is better for debugging. Be
sure to set debug: true in the jamal configuration.

> About restfull model, i read in the list that someout is working on
> it, but i can't find any code.

There isn't much but I already started to change the model:
http://jamal-mvc.com/browser/code/branches/sandboxes/teemow/

Thanks for your effort and have fun!

Cheers,
Timo

--
Timo Derstappen

http://teemow.com
mailto:tee...@gmail.com

Guillermo

unread,
Mar 19, 2009, 8:17:27 AM3/19/09
to jama...@googlegroups.com
On Thu, Mar 19, 2009 at 10:19 AM, Timo Derstappen <tee...@gmail.com> wrote:
The testsuite is also something that has to be worked on. qunit ftw!
It should be nicely integrated within jamal and its deployment tools.
http://docs.jquery.com/QUnit

Yes.
To improve performance you can even concat jquery.js + jamal.js +
client.app.js.

I know, but now i don't worry about performance. 

Anyway, [some spam] rails make so simply merge all with
stylesheet_tag 'jquery','jamal','client.app' :cacle => 'cache/app.js'
That will cache all files in 'cache/app' just for production.

In development i prefer have three files because debug.
  
You save two requests and fetching javascript makes the
browser very slow. Be sure to add caching header (try to prevent 304
Not Modified) and a revision number in the compiled js file. So that
the browser recognizes any new version of the javascript.

These work is just for apache, or nginx.
 


> c) Some rails helpers
>  "include_jamal_core". The helper to make <script src...

Be sure to add the javascript at the very end of your body. This makes
your site render way faster ... YSlow ftw!

It dependes. For hight intensive javascript apps, i prefer to just show a message for loading (like gmail does)

 
> About restfull model, i read in the list that someout is working on
> it, but i can't find any code.

There isn't much but I already started to change the model:
http://jamal-mvc.com/browser/code/branches/sandboxes/teemow/

Now i see.
I start by adding and inflector, and playing with something like these:

It works right now. 
It assumes that the url of the resource if the the pluralize name of the model. So Post model will go to /posts.

I also was working with form helpers.
The first attemp is here:

It's so funny doing things like these (it needs helper and restful branch):
     
$j.m({Post: {}});

 $('#post1').form_for('post').
             label('title','Post title').text_field('title').
             label('body', 'Body').text_area('body').
             submit_tag();

   $j.m.Post.find(1,function(data){
      $(#post1).set_model(data);
  }

And there is a form with files that soon, will update.

I uplad my test_app in wich i am working if some one wants to play with rails and jamal:


Thanks for your effort and have fun!

You're welcome.

--
Guillermo Álvarez

Alex

unread,
Mar 19, 2009, 9:53:28 AM3/19/09
to jama...@googlegroups.com
I use rails+jamal,  but i think i needn't a rails plugin.

of couse,   your job is great! 

Guillermo

unread,
Mar 19, 2009, 11:35:31 AM3/19/09
to jama...@googlegroups.com
On Thu, Mar 19, 2009 at 2:53 PM, Alex <blacka...@gmail.com> wrote:
I use rails+jamal,  but i think i needn't a rails plugin.

Of course. The plugin is not necesary at all.

The reason is that if you want to play with jamal code, it is easy for me an automatic system to compile jamal per request in development.

Other reason is that is easy to just type "rake jamal:install" to install all jamal and have a ready-to-work installation, than donwload jamal and lear how to set-up in a new application. At least, for me, take some time how to set up jamal from source code. The first thing when you see the code is: What files i have to use?, Where i have to put that files? and Who can i load that files? questions. These plugin solves these problem.


of couse,   your job is great! 

Thanks.


--
Guillermo Álvarez

Alex

unread,
Mar 19, 2009, 11:44:57 AM3/19/09
to jama...@googlegroups.com
  
I see ...  Thanks for your reply.
Reply all
Reply to author
Forward
0 new messages