My favorites | Sign in
Project Logo
                
Search
for
Updated Sep 10, 2007 by steve.yen
TrimJunction  

Junction

The open source Junction framework is a conventions-over-configuration, synchronizing web MVC framework for JavaScript.

  • '''TrimPath Junction''' is a clone or port of the terrific Ruby on Rails web MVC framework into JavaScript.
  • '''TrimPath Junction''' is also sometimes referred to as TrimJunction, or as just Junction.

Show me some code: here are some code snippets comparing Ruby on Rails versus JavaScript on Junction.

Junction is your best bet if you want to build single page applications using tried-and-true web MVC paradigms, while letting you leverage new technologies like Google Gears.

More

News

Vision

In a nutshell: copy Rails when possible, because it's a great web MVC framework. Next, riff on Rails to allow for doing cool, non-Rails maneuvers that are only possible with JavaScript.

The result should be a web MVC framework that runs in either the client AND the server (Rhino). While we're at it, explore and push the edges of occasionally connected web applications, providing easy synchronization between distributed code and data.

Long version:

With an eye towards Don't Repeat Yourself, spiced with a little Ajax, the grand vision of the TrimPath Junction project is to be able to write web application logic just once, in familiar languages like JavaScript.

A Junction-based web application should run, validate input, process data, generate output and do its thing on both the server AND the client. We use the Rhino JavaScript runtime for the server and use your favorite, modern web browser for the client.

If you know Rails, then Junction will be very familiar stuff. Maybe you can help the Junction project to grow up.

If you know JavaScript, then all the good things you've been hearing about Rails is now becoming available to you through the Junction project. Except, you don't need to learn yet another programming language.

With Junction, you still need to know HTML/DHTML, DOM, CSS, and SQL. You still need to know about HTTP, cookies, and sessions. Junction doesn't hide these things from you and magically turn your web browser into the next Visual Basic IDE. Junction believes in fealty to web standards.

But, you will probably need to learn about offline, occasionally connected databases and application design. Junction deviates from its Rails roots in pushing on this feature area. Think synchronization and poor (really destitute) man's Notes or Groove. Junction aims to provide a web-standards-based reincarnation of Notes or Groove. This is the key new area that Junction explores and aspires to push forward.

Junction, like Rails, also stays out of your way. If you need to specify HTML down to the Nth degree, you can. If you want to bring in more web GUI widgets (like from Dojo Toolkit or htmlArea or Flash or Prototype), you can. Junction is a web Model-View-Controller (MVC) framework, not about hiding JavaScript or the DOM model.

Model - View - Controller

Here's how the web MVC paradigm appears in Junction.

  • '''Model''' - in the Junction world, these are just a plain old JavaScript 'classes'. Actually, that means these are just plain old JavaScript functions, and they follow the Active Record pattern of object-relational mapping. Fancy queries are done using SQL, even when offline or disconnected from the server. We use the TrimQuery project and Google Gears RDBMS to allow SQL to run in a (possibly disconnected) web browser data cache.
  • BlogPost = function() {}
    
    modelInit('BlogPost');
    
    BlogPost.hasMany('Comments);
    
    BlogPost.findByShortName = function(shortName) {
        return BlogPost.find("first", { conditions: ["BlogPost.shortName = ?", shortName] });
    }
  • '''View''' - these are JavaScript Templates (JST). The JST engine is another project of the TrimPath effort. JST templates should be familiar to anyone who knows other HTML templating markup syntax, like PHP, FreeMarker, Velocity, Smarty.
  • <div>
      Comments...
      <ul>
        {for comment in blogPost.getComments()}
          <li><span>${comment.author} says...</span>
              <div>${comment.body}</div></li>
        {/for}
      </ul>
    </div>
  • Alternatively, if you like rhtml/ERb/JSP style syntax, Junction can also use EcmaScriptTemplates. For example...
  • <div>
      Comments...
      <ul>
        <% for (var comments = blogPost.getComments(),
                    i = 0; i < comments.length; i++) { %>
          <li><span><%= comments[i].author %> says...</span>
              <div><%= comments[i].body %></div></li>
        <% } %>
      </ul>
    </div>
  • '''Controller''' - these are also just plain old JavaScript functions. Notice that Junction supports scaffolding, just like with Rails...
  • BlogPostController = function() {}
    
    scaffold(BlogPostController, 'BlogPost')

It's all hooked together through convention, not configuration. That is, if you just follow the naming conventions, there are no configuration files. The Junction framework favors reflection and late-bound dynamic object decorations and extensions. The result is less code, no recompilation steps, and faster development.

Links

  • External Resources
    • Ruby on Rails
      • Learning Ruby and Rails is a good thing, whether or not you dig Junction or not. Rails and Ruby are very interesting technologies that show off the power of dynamic languages. Plus, since Junction suffers from a newborn project's lack of documentation, the best way to understand Junction right now is to know a little bit of its parent, Rails.
      • Ruby on Rails versus JavaScript on Junction code comparison.
    • Solving The Back Button
    • Prototype
      • Junction uses the Prototype library from Sam Stephenson for Ajax and DOM animation effects.
    • Groove Networks
    • JSON

{ Junction home | documentation | download }


Comment by dusan.maliarik, Jul 27, 2007

It would be nice to have some docs about deployment and performance.

Comment by steve.yen, Jul 30, 2007
Comment by Remember.Objective, Aug 06, 2007

Awesome...thanks for the continued development of trimpath.

Comment by Remember.Objective, Aug 06, 2007

Awesome...thanks for the continued development of trimpath.

Comment by Remember.Objective, Aug 06, 2007

Awesome, thanks for the continued development of trimpath.

Comment by newdongyuwei, Aug 25, 2007

great job!

Comment by pnigme...@yahoo.gr, Sep 18, 2007

Is it possible to use just the browser part of the framework without the helma (or any other) webserver? If yes, how should the various files be organized?

Thanks for any pointers.

Comment by robbie.wilhelm, Sep 26, 2007

soso lala

Comment by dreamflasher, Oct 01, 2007

WOW, this is such a great work!

Comment by flares, Oct 04, 2007

TrimJunction looks great. There's a very simple alternative called jMVC at http://blog.codeville.net/2007/10/04/rich-javascript-mvc-user-interfaces-with-jmvc/

TrimJunction is much more sophisticated but jMVC may be easier in simple cases.

Comment by flares, Nov 05, 2007

Update: if you're using ASP.NET, check out how easily you can use client-side MVC with jMVC.NET. http://blog.codeville.net/2007/10/18/jmvcnet-neat-client-side-mvc-for-aspnet/

Hosted by Google Code