Name
    YOTE

Summary
    Yote is a platform for creating web based applications by bridging
    client side javascript with server side, automatically persistent perl
    objects. Yote provides javascript objects with methods that map to their
    server side counterparts.

    See http://fenowyn.com/yote for more information.

Note
    As of this writing Yote is on version 0.072. 
    It is not yet stable and is in pre-alpha mode.
    Consider this alpha software once version 0.100 is reached.
    Please email coyocanid@gmail.com to report bugs or issues or 
    feature requests.

Requirements
    *   perl version 5.10

    *   A webserver that can run perl cgi files

    *   jquery (provided with this distribution, or from
        http://docs.jquery.com/Downloading_jQuery)

    *   Some sort of server-side storage (MySQL or a writable file)

Install Yote
        $ perl Build.PL
        $ ./Build
        $ ./Build test
        $ ./Build install

Changing Ports
      If you want to change the port once yote has been installed, 

Verify by running html test
      $ yote_server
      open http://<myhost>/yote/unit_tests.html

Using Yote
  Start the Web App Server
    Starting the Web App Server from the command line:

           $ yote_server

    This starts the server on the default port (8008), using SQLiteIO, and
    writing to file ~/.yote/SQLite.yote.db.

    Starting the Web App Server from a package:

           use Yote::WebAppServer;

           my $server = new Yote::WebAppServer();

           $server->start_server( port => 8008,
                      datastore  => 'Yote::SQLiteIO',
                      sqlitefile => 'yote.database' );

  Coding with Yote
   Client Side
           <script src="./js/jquery-latest.js"></script>
           <script src="./js/jquery.dumper.js"></script>
           <script src="./js/jquery.base64.min.js"></script>
           <script src="./js/json2.js"></script>
           <script src="./js/yote.js"></script>
           <script>
	       /* Get the account root singleton object. */
               var hello_app = $.gServ.get_app( 'Yote::Hello' );

	       /* Returns a string. If the method results in changes in other
	          javascript objects, those objects will automatically be updated. */
               var result = hello_app.hello({ name:"fred" } );

	       /* Returns a counter object */
               var counter = hello_app.get_counter();
           </script>

   Server Side
        package Yote::Hello;

        use strict;
        use Yote::Obj;

	#
	# A singleton of this class is created and accessed by the 
	# client with get_app.
	#
        use base 'Yote::AppRoot';

	#
	# Init is called only the very first time an Yote::AppRoot
	# is instantiated.
	#
        sub init {
            my $self = shift;

	    #
	    # 'get_counter' does not need an explicit definition. 
	    # A get_ method passed an argument will use that as a default.
	    #
            my $counter = $self->get_counter( new Yote::Obj() );
        }

	#
	# The client object can call this directly.
	#   hello_app.hello({ name:"wilma" });
	#   The argument { name => "wilma" } is passed to the $data parameter of the method.
	#   If a user is logged in on the client, that user will have an account root container
	#    object associated with the approot singleton. This container will be used to store
	#    user data specific to this app, like documents, stats and the like.
 	#
        sub hello {
            my( $self, $data, $acct_root, $acct ) = @_;
            my $name = $data->{name};
            my $counter = $self->get_counter();

	    #
	    # 'set_count' does not need an explicit definition.
	    #
            $counter->set_count( $counter->get_count() + 1 );

	    #
	    # The return value is a string in this case.
	    # var msg = hello_app.hello({name:"foo"}); 
	    # msg will be the string "hello there 'foo'. I have said hello 1 times."
	    #
            return "hello there '$name'. I have said hello ". $counter->get_count() . " times.";
        }

        1;

