Book Image

Learning JavaScriptMVC

By : Wojciech Bednarski
Book Image

Learning JavaScriptMVC

By: Wojciech Bednarski

Overview of this book

<p>JavaScriptMVC is a client-side, JavaScript framework that builds maintainable, error-free, lightweight applications as quickly as possible. As it does not depend on server components, it can be combined with any web service interface and server-side language.<br /><br />"Learning JavaScriptMVC" will guide you through all the framework aspects and show you how to build small- to mid-size well-structured and documented client-side applications you will love to work on.<br /><br />This book starts from JavaScriptMVC installation and all its components are explained with practical examples. It finishes with an example of building a web application. You will learn what the JavaScriptMVC framework is, how to install it, and how to use it efficiently.<br /><br />This book will guide you on how to build a sample application from scratch, test its codebase using unit testing, as well as test the whole application using functional testing, document it, and deploy the same. After reading Learning JavaScriptMVC you will learn how to install the framework and create a well-structured, documented and maintainable client-side application.</p>
Table of Contents (13 chapters)

Installing JavaScriptMVC


Installing JavaScriptMVC is as easy as making tea, but faster.

Choosing your method

There are three methods.

The last two methods are the preferred way, for the following reasons:

The third method seems to be the best one, because it contains all the advantages from the second one, plus it creates an encapsulated environment, which we can easily and quickly create or delete without affecting our current development environment setup.

Which method is right for me?

For a fast tryout library, choose the first method. For the actual development, definitely choose the second one.

The first method – download the package

In this method, we will use a web interface on the JavaScriptMVC web page to configure and download the package:

  1. Download the complete package from http://javascriptmvc.com and unpack its content.

  2. Create a folder named Todo under the local web server working directory.

  3. Copy all files from javascriptmvc-3.2.2 to the Todo folder and start the web server.

    $ mkdir Todo && cp -r javascriptmvc-3.2.2/* Todo && cd Todo
    

That is it; we are all set and ready to go.

The second method – pull the code from Git repositories

We assume that the reader knows and has installed Git.

If not, the following resources might be helpful:

In the following steps, we are going to install JavaScriptMVC for our Todo example project:

  1. Under local web server directory, create new folder named Todo:

    $ mkdir Todo && cd Todo
  2. Inside the Todo folder, create a new Git repository:

    $ git init
  3. Add JavaScriptMVC components as submodules to the project:

    $ git submodule add git://github.com/bitovi/steal.git
    $ git submodule add git://github.com/bitovi/documentjs.git
    $ git submodule add git://github.com/bitovi/funcunit.git
    $ git submodule add git://github.com/jupiterjs/jquerymx jquery
  4. Install and update the submodules:

    $ git submodule init
    $ git submodule update
  5. The last module we need to install is Syn. Since it is already a submodule to the FuncUnit project, all we need to do is initialize and update it:

    $ cd funcunit
    $ git submodule init
    $ git submodule update
  6. Switch Syn to the master branch:

    $ cd syn/
    $ git checkout master
  7. Go back to the root directory of the project:

    $ cd ../..
  8. Move the js command to the root directory of the project:

    $ ./steal/js steal/make.js
Verifying Installation

The project directory should have following folder structure:

.git
.gitmodules
documentjs
funcunit
jquery
js
js.bat
steal

That is it; we are all set and ready to go.

Note

More about submodules in Git: http://git-scm.com/book/en/Git-Tools-Submodules

The third method – Vagrant

To install JavaScriptMVC using this method, we need to install Vagrant, which is a virtualized development tool wrapper around Oracle VM VirtualBox, an x86 and AMD64/Intel64 virtualization software package.

  1. Download and install Oracle VM VirtualBox (https://www.virtualbox.org).

  2. Download and install Vagrant (http://downloads.vagrantup.com).

  3. Download an unpack the JavaScriptMVC kick-starter (https://github.com/wbednarski/JavaScriptMVC_kick-starter/archive/master.zip).

  4. Inside JavaScriptMVC kick-starter folder type vagrant up.

    This command creates a virtual environment and a projects directory. It also installs the web server. JavaScriptMVC framework will be placed in the Todo directory.

Any changes we make inside the projects directory are immediately visible in web browser at http://192.168.111.111/.