Jaws - coming soon - testers and advice wanted

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Jaws - coming soon - testers and advice wanted

Joe Armstrong (TN/EAB)
 
Hello,

Progress report - jaws (yaws + templates) is progressing nicely.
I have finally "made up my mind" (TM) and decided on a template syntax
(two years thought and half a dozen prototypes "down the drain") -
a compiler for this syntax has now been up and running for a few weeks
and I am finalising the Ajax support.

jaws is a template language for yaws (jaws is inspired by PHP, velocity
and AJAX)
- this posting contains a "first look" at the syntax. I'm not going to
describe the semantics - you have to *guess* - it's rather easy.
(Hints all webpages and templates get compiled to single functions)

A *single* jaws file contains templates for *many* webpages - so that an
entire application can be shipped as a single file.

Here's a simple example, assumed to be in the file foo.jaws

      @module foo
       
        @webPage test(_)
        <? N = 25, "" ?>

        <P>factorial <? N ?> is <? fac(N) ?>
       
        @erl
        fac(0) -> 1;
        fac(N) -> N * fac(N-1).

        @webPage form(A)
        <form method="post" action="./foo.jaws?page=posted">
       <input name="fac" size="20">
        </form>

        @webPage posted(A)
        <? {ok, X} = yaws_api:postvar(A, "fac"),
         N = list_to_integer(N), "" ?>

      <? banner([{"name","joe"},{"likes", "Erlang"}]) ?>

        <p>Fac <? N ?> is <? red(fac(N)) ?>

        @template red(X)
        <font color="red"><? X ?></font>

        @template banner(X)

        <p>Hello ${name:X} i hear you like ${likes:X}

      @webPage ajax(A)
        <div id="tag1">
        ...
        </div>

        <a href='javascript:erlcall'("foo", "myfunc", "")'>update</a>

        @webPage myfunc(A)
       
        myfunc(Args) ->
           [replace_contents("tag1", "<h1>Hi .... "].

        @webPage redirect(A)
        <? Headers = [{"redirect", "http:// ..."}], "" ?>

        <h1> You'll soon be redirected.

This defines eight webpages and two templates in one jaws file. It
gives examples of

        - template expansion
        - form handling
        - ajax
        - header manipulation (in the redirect example)

<< computationally <? fac(N) ?> is about 10-20 times faster than PHP
and it works for bignums :-) >>

It seems to me to be desirable to have the code which handles a form
*immediately after the code which defines the form* (and not in another
file) - it also seems desirable to be able to program HTML with
subroutines, like this:

        @webPage foo(A)

        Some html <? fancy_box(A) ?>
        ... <? fancy_box(B) ?> ...

        @template fancy_box(A)
        <table> .... <? A ?> ... </table>

Note also how the site of ajax call is lexically near to the code which
handles the call.

javascript:erlcall(M, F, A) allows javascript to call an arbitary Erlang
{M,F,A}
This is achieved with ajax and a JSON encoding. MFA returns a list
of actions that are to be performed on the webpage - ie
(replace_contents("tag1" , HTML))
sets the innerHTML field of tag1 to HTML.

At this stage I need two things:
        1) Testers - a few good people who are interested in this kind
of
           stuff
        2) javascript help - the result of myfunc(Args) is a list of
actions to be
           performed on a web page. A typical example is

           replace_contents(Tag, Html)

           When this is called in Erlang a JSON encoded term is sent
back to the
web page and after a little trickery

        jsReplaceContents(tag, html) is called

where

        function jsReplaceContents(tag, html) {
                document.getElementById(tag).innerHTML = html;
        }

I have defined a few simple functions (replace_contents(tag, HTML),
delete_tag(Tag) etc.

But I am really stretching my knowledge of javascript here.

If any javascript guru wants to help please contact me.

In particular does anybody have any ideas how to do this?

If I have this

         <div id="foo">
          ....
          ...  <a href="javascript:bar()">click</a>

         </div>

 I want bar() to compute the id if the nearest containing div - in this
case "foo" any ideas how to do this? - do I really have to "walk the
tree" from the root of the DOM tree?

/Joe
Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

bryan rasmussen
I might be able to do testing, dependent on figuring out my schedule
which for the next 4 months is pretty hairy.

A propos the javascript: http://mcc.id.au/xpathjs/
xpath in javascript.

So perhaps it would be able to run an xpath, assuming that one gave
the a element an id :

//div[a[@id='myid']]

Cheers,
Bryan Rasmussen





On 2/20/06, Joe Armstrong (AL/EAB) <[hidden email]> wrote:

>
> Hello,
>
> Progress report - jaws (yaws + templates) is progressing nicely.
> I have finally "made up my mind" (TM) and decided on a template syntax
> (two years thought and half a dozen prototypes "down the drain") -
> a compiler for this syntax has now been up and running for a few weeks
> and I am finalising the Ajax support.
>
> jaws is a template language for yaws (jaws is inspired by PHP, velocity
> and AJAX)
> - this posting contains a "first look" at the syntax. I'm not going to
> describe the semantics - you have to *guess* - it's rather easy.
> (Hints all webpages and templates get compiled to single functions)
>
> A *single* jaws file contains templates for *many* webpages - so that an
> entire application can be shipped as a single file.
>
> Here's a simple example, assumed to be in the file foo.jaws
>
>      @module foo
>
>        @webPage test(_)
>        <? N = 25, "" ?>
>
>        <P>factorial <? N ?> is <? fac(N) ?>
>
>        @erl
>        fac(0) -> 1;
>        fac(N) -> N * fac(N-1).
>
>        @webPage form(A)
>        <form method="post" action="./foo.jaws?page=posted">
>       <input name="fac" size="20">
>        </form>
>
>        @webPage posted(A)
>        <? {ok, X} = yaws_api:postvar(A, "fac"),
>         N = list_to_integer(N), "" ?>
>
>      <? banner([{"name","joe"},{"likes", "Erlang"}]) ?>
>
>        <p>Fac <? N ?> is <? red(fac(N)) ?>
>
>        @template red(X)
>        <font color="red"><? X ?></font>
>
>        @template banner(X)
>
>        <p>Hello ${name:X} i hear you like ${likes:X}
>
>      @webPage ajax(A)
>        <div id="tag1">
>        ...
>        </div>
>
>        <a href='javascript:erlcall'("foo", "myfunc", "")'>update</a>
>
>        @webPage myfunc(A)
>
>        myfunc(Args) ->
>           [replace_contents("tag1", "<h1>Hi .... "].
>
>        @webPage redirect(A)
>        <? Headers = [{"redirect", "http:// ..."}], "" ?>
>
>        <h1> You'll soon be redirected.
>
> This defines eight webpages and two templates in one jaws file. It
> gives examples of
>
>        - template expansion
>        - form handling
>        - ajax
>        - header manipulation (in the redirect example)
>
> << computationally <? fac(N) ?> is about 10-20 times faster than PHP
> and it works for bignums :-) >>
>
> It seems to me to be desirable to have the code which handles a form
> *immediately after the code which defines the form* (and not in another
> file) - it also seems desirable to be able to program HTML with
> subroutines, like this:
>
>        @webPage foo(A)
>
>        Some html <? fancy_box(A) ?>
>        ... <? fancy_box(B) ?> ...
>
>        @template fancy_box(A)
>        <table> .... <? A ?> ... </table>
>
> Note also how the site of ajax call is lexically near to the code which
> handles the call.
>
> javascript:erlcall(M, F, A) allows javascript to call an arbitary Erlang
> {M,F,A}
> This is achieved with ajax and a JSON encoding. MFA returns a list
> of actions that are to be performed on the webpage - ie
> (replace_contents("tag1" , HTML))
> sets the innerHTML field of tag1 to HTML.
>
> At this stage I need two things:
>        1) Testers - a few good people who are interested in this kind
> of
>           stuff
>        2) javascript help - the result of myfunc(Args) is a list of
> actions to be
>           performed on a web page. A typical example is
>
>           replace_contents(Tag, Html)
>
>           When this is called in Erlang a JSON encoded term is sent
> back to the
> web page and after a little trickery
>
>        jsReplaceContents(tag, html) is called
>
> where
>
>        function jsReplaceContents(tag, html) {
>                document.getElementById(tag).innerHTML = html;
>        }
>
> I have defined a few simple functions (replace_contents(tag, HTML),
> delete_tag(Tag) etc.
>
> But I am really stretching my knowledge of javascript here.
>
> If any javascript guru wants to help please contact me.
>
> In particular does anybody have any ideas how to do this?
>
> If I have this
>
>         <div id="foo">
>          ....
>          ...  <a href="javascript:bar()">click</a>
>
>         </div>
>
>  I want bar() to compute the id if the nearest containing div - in this
> case "foo" any ideas how to do this? - do I really have to "walk the
> tree" from the root of the DOM tree?
>
> /Joe
>
Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

Matthias Lang
In reply to this post by Joe Armstrong (TN/EAB)
Joe Armstrong (AL/EAB) writes:

 > Here's a simple example, assumed to be in the file foo.jaws

 > <form method="post" action="./foo.jaws?page=posted">
 >        <input name="fac" size="20">
 > </form>
...
 > <p>Fac <? N ?> is <? red(fac(N)) ?>
...
 > << computationally <? fac(N) ?> is about 10-20 times faster than PHP
 > and it works for bignums :-) >>

What happens if someone enters N=123456789?

Does the whole erlang node crash and burn, dumping out _all_ users on
the site?

Matthias
Reply | Threaded
Open this post in threaded view
|

RE: Jaws - coming soon - testers and advice wanted

Joe Armstrong (TN/EAB)
In reply to this post by Joe Armstrong (TN/EAB)
 



> From: Matthias Lang
> Sent: den 20 februari 2006 11:08
> To: [hidden email]
> Subject: Re: Jaws - coming soon - testers and advice wanted
>
> Joe Armstrong (AL/EAB) writes:
>
>  > Here's a simple example, assumed to be in the file foo.jaws
>
>  > <form method="post" action="./foo.jaws?page=posted">
>  >        <input name="fac" size="20">
>  > </form>
> ...
>  > <p>Fac <? N ?> is <? red(fac(N)) ?>
> ...
>  > << computationally <? fac(N) ?> is about 10-20 times
> faster than PHP  > and it works for bignums :-) >>
>
> What happens if someone enters N=123456789?
>
> Does the whole erlang node crash and burn, dumping out _all_
> users on the site?

Yes :-) -- but I have also made a version which wraps all functions
in a safety wrapper. ie M:F(A) gets compiled as safe:apply(N, F, A)
safe:apply is a restrictive safety wrapper where I am extremely
restrictive in what you can do. Here you can call your own stuff
but calling external modules and BIFs is restricted, the safety
wrapper allow spawning processes (but not to many)
and restricts the maximum number of reductions that a process
may perform in delivering a web page.

Hopefully this can be used to make a "enterprise yaws" - where
many different users can safely run their code within one yaws server.

Approved applications (ie without the safety wrappers compiled in)
could be run
in the same system with no performance degradation.

/Joe

BTW - does Microsoft dislike Erlang? - the spelling checker
in Microsoft Outlook suggest that M:F(A) is a typo
and suggests the replacement text "MAFIA"



> Matthias
>
Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

Vlad Dumitrescu
Hi,

> BTW - does Microsoft dislike Erlang? - the spelling checker
> in Microsoft Outlook suggest that M:F(A) is a typo
> and suggests the replacement text "MAFIA"

Well, if you reformulate the question as "*why* does MS disike Erlang", you
get a question that is much easier to answer :-) because Erlang gets into
the same category as Google or Linux.

/Vlad
Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

Chandru-4
In reply to this post by Matthias Lang
On 20/02/06, Matthias Lang <[hidden email]> wrote:

> Joe Armstrong (AL/EAB) writes:
>
>  > Here's a simple example, assumed to be in the file foo.jaws
>
>  >      <form method="post" action="./foo.jaws?page=posted">
>  >        <input name="fac" size="20">
>  >      </form>
> ...
>  >      <p>Fac <? N ?> is <? red(fac(N)) ?>
> ...
>  > << computationally <? fac(N) ?> is about 10-20 times faster than PHP
>  > and it works for bignums :-) >>
>
> What happens if someone enters N=123456789?
>
> Does the whole erlang node crash and burn, dumping out _all_ users on
> the site?

This isn't a "problem" with Jaws though. Even if  you had a plain web
form which submitted this value, you'd still run into the same problem
if your factorial function naively accepted this value.

       fac(N) when is_integer(N) and (N > 1000) -> {error, nice_try};
       fac(0) -> 1;
       fac(N) -> N * fac(N-1).

Chandru
Reply | Threaded
Open this post in threaded view
|

RE: Jaws - coming soon - testers and advice wanted

Corrado Santoro
In reply to this post by Joe Armstrong (TN/EAB)
Quoting "Joe Armstrong (AL/EAB)" <[hidden email]>:
> BTW - does Microsoft dislike Erlang? - the spelling checker
> in Microsoft Outlook suggest that M:F(A) is a typo  
> and suggests the replacement text "MAFIA"
Wow!!! Could it possibile that Outlook has been written by a sicilian
programmer??? Or maybe Microsoft in this cases reveals what it really is.... a
"MAFIA"! :-))
 
Cheers,
--Corrado
 
--  
======================================================  
Eng. Corrado Santoro, Ph.D.  
 
University of Catania - Engineering Faculty  
Department of Computer Science and  
Telecommunications Engineering  
Viale A. Doria, 6 - 95125 CATANIA (ITALY)  
 
Tel: +39 095 7382380           Fax: +39 095 338280  
     +39 095 7382365  
     +39 095 7382364  
 
EMail: [hidden email]  
Personal Home Page:  
            http://www.diit.unict.it/users/csanto 
 
NUXI Home Page:  
            http://nuxi.iit.unict.it 
======================================================

-------------------------------------------------
This mail sent through IMP: http://www.cdc.unict.it/
Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

Alex Arnon
In reply to this post by Chandru-4
Could the Javascript apply(...) binding cause new atoms to be created? In that case, wouldn't that constitute a security hazard?

Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

Matthias Lang
In reply to this post by Chandru-4
chandru writes:

 > This isn't a "problem" with Jaws though. Even if  you had a plain web
 > form which submitted this value, you'd still run into the same problem
 > if your factorial function naively accepted this value.

The point I wanted to make was that, in this particular case, it is
easier to shoot yourself in the foot using jaws than PHP. Or, more
graphically, in PHP you shoot one person's foot, whereas in jaws you
shoot thousands of people's feet all at the same time in a fabulous
concurrent out-of-memory splatterfest.

I didn't mean to imply that inets or yaws were any less splattersome.

Matthias
Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

Filippo Pacini (S.G. Consulting)
In reply to this post by Joe Armstrong (TN/EAB)
Hi,
I might be able to do some testing, and maybe help a little with
javascript, though I'm an Erlang newbie.

Regarding the javascript below something like this should work:

elRef is a reference to the a element, so instead of bar() you call the
function as
bar(this);

function bar(elRef) {
    while (elRef) {
       var elRef = elRef.parentNode;
       if (elRef.nodeName.toLowerCase() == 'div') {
          alert(elRef.getAttribute('id'));
          return
       }
    }
}

Tested on firefox: it works if you write the link as
<a href="javascript:;" onclick="return bar(this);">click</a>

Not if you call bar directly in the href. I have no idea why.

Filippo Pacini


Joe Armstrong (AL/EAB) wrote:

>  
>
> In particular does anybody have any ideas how to do this?
>
> If I have this
>
>          <div id="foo">
>           ....
>           ...  <a href="javascript:bar()">click</a>
>
>          </div>
>
>  I want bar() to compute the id if the nearest containing div - in this
> case "foo" any ideas how to do this? - do I really have to "walk the
> tree" from the root of the DOM tree?
>
> /Joe
>


Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

Chris Double
In reply to this post by Joe Armstrong (TN/EAB)
On 2/20/06, Joe Armstrong (AL/EAB) <[hidden email]> wrote:
>  I want bar() to compute the id if the nearest containing div - in this
> case "foo" any ideas how to do this? - do I really have to "walk the
> tree" from the root of the DOM tree?

Some javascript code to do this:

---------------8<-------------------
<script>
function enclosingDiv(node) {
  while(node && node.nodeName != "DIV") {
    node = node.parentNode;
  }
  return node;
}

function bar(self) {
  var node = enclosingDiv(self);
  if(node)
    alert(node.id);
  else
    alert("No Div node");
  return false;
}

</script>
<div id="foo">
    <div id="baz">
        <a onclick="bar(this);" href="#"><div>click</div></a>
    </div>
</div>
---------------8<-------------------

This should alert with 'baz', the nearest enclosing div.

Chris.
--
http://www.bluishcoder.co.nz
Reply | Threaded
Open this post in threaded view
|

RE: Jaws - coming soon - testers and advice wanted

Joe Armstrong (TN/EAB)
In reply to this post by Joe Armstrong (TN/EAB)
No - javascript is executed on the client - never the server. Nothing you can do on the client can damange the sever
*provided* the server code is safely compiled.
 
I guess I omitted to say that in my "safe" mode of compilation *everything* is compiled with a safety wrapper (ie including
BIFs) - thus
 
    apply(M, F, A) is transformed to safe:do(erlang, apply, [M,F,A])
 
and
   
   list_to_atom(X) to safe:do(erlang, list_to_atom, [X])
   
   Then safe:do/3 can be written with any policy you like - to enable or disable more or less risky operations
 
/Joe
 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Alex Arnon
Sent: den 20 februari 2006 12:49
To: [hidden email]
Subject: Re: Jaws - coming soon - testers and advice wanted

Could the Javascript apply(...) binding cause new atoms to be created? In that case, wouldn't that constitute a security hazard?

Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

Alex Arnon


On 2/20/06, Joe Armstrong (AL/EAB) <[hidden email]> wrote:
No - javascript is executed on the client - never the server. Nothing you can do on the client can damange the sever
*provided* the server code is safely compiled.
 
I guess I omitted to say that in my "safe" mode of compilation *everything* is compiled with a safety wrapper (ie including
BIFs) - thus
 
    apply(M, F, A) is transformed to safe:do(erlang, apply, [M,F,A])
 
and
   
   list_to_atom(X) to safe:do(erlang, list_to_atom, [X])
   
   Then safe:do/3 can be written with any policy you like - to enable or disable more or less risky operations
 
/Joe
 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Alex Arnon
Sent: den 20 februari 2006 12:49
To: [hidden email]
Subject: Re: Jaws - coming soon - testers and advice wanted

Could the Javascript apply(...) binding cause new atoms to be created? In that case, wouldn't that constitute a security hazard?

So this would enable me to define explicit "bindings" to server-side functionality - excellent!
BTW, how can one check if a string represents an existing atom or not?

Reply | Threaded
Open this post in threaded view
|

RE: Jaws - coming soon - testers and advice wanted

Ulf Wiger (TN/EAB)
In reply to this post by Joe Armstrong (TN/EAB)
Alex Arnon wrote:
>
> BTW, how can one check if a string represents an
> existing atom or not?

list_to_existing_atom(Str)

/Ulf W
Reply | Threaded
Open this post in threaded view
|

Re: Jaws - coming soon - testers and advice wanted

ke han
In reply to this post by Joe Armstrong (TN/EAB)
Sounds great Joe!!! gotta have a copy when your ready.
I am just starting a process of building a framework based on the
experience of a just finished mid-sized ajax/json/yaws/erlang/mnesia app.
I am in the design phase of pulling together all the utils and
fragmented metadata I wrote for the app into a cohesive and simple MVC
framework.
I am canvasing all the latest erlang code base for inclusion and
influence...including Ulf's plain_fsm and (awaiting) rdbms and various
ajax andf json patterns.
My primary goal is to build a high level framework which formalizes the
interaction of injecting a controller into a view and having the view
contain metadata of the client/server interaction separate from the view
layout/content.  The idea is that the controller and domain objects
(referenced via the controller and metadata interactions) are each
plain_fsm "objects" that use "receive parse transforms" to allow the
domain and controllers to "inherit" accessor, event and other framework
behaviors.
If this ramble makes no sense, hopefully, my first few sets of example
code will ;-).
But the important thing is I would love to study how to include your
ideas with an open mind to transform my own into something better.
These next 4 weeks are crucial for me as its my only time to spend 100%
of my energy on getting this framework bootstrapped. (yes, I plan to
open source the whole thing).
thanks for the heads up!!
ke han


Joe Armstrong (AL/EAB) wrote:

> No - javascript is executed on the client - never the server. Nothing
> you can do on the client can damange the sever
> *provided* the server code is safely compiled.
>  
> I guess I omitted to say that in my "safe" mode of compilation
> *everything* is compiled with a safety wrapper (ie including
> BIFs) - thus
>  
>     apply(M, F, A) is transformed to safe:do(erlang, apply, [M,F,A])
>  
> and
>    
>    list_to_atom(X) to safe:do(erlang, list_to_atom, [X])
>    
>    Then safe:do/3 can be written with any policy you like - to enable or
> disable more or less risky operations
>  
> /Joe
>  
>
>     ------------------------------------------------------------------------
>     *From:* [hidden email]
>     [mailto:[hidden email]] *On Behalf Of *Alex Arnon
>     *Sent:* den 20 februari 2006 12:49
>     *To:* [hidden email]
>     *Subject:* Re: Jaws - coming soon - testers and advice wanted
>
>     Could the Javascript apply(...) binding cause new atoms to be
>     created? In that case, wouldn't that constitute a security hazard?
>

Reply | Threaded
Open this post in threaded view
|

RE: Jaws - coming soon - testers and advice wanted

Martin Logan
In reply to this post by Joe Armstrong (TN/EAB)
I can do testing.  It is quite serendipitous that you release this now.
I am in the process of moving to yaws after spending time with php and
ruby on rails.  I am willing to take a shot at writing an application of
my choice with jaws and providing feedback if it would be helpful to
you.  Do you have an example app already written that I could look at?

Cheers,
Martin

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Joe Armstrong
(AL/EAB)
Sent: Monday, February 20, 2006 3:14 AM
To: [hidden email]
Subject: Jaws - coming soon - testers and advice wanted

 
Hello,

Progress report - jaws (yaws + templates) is progressing nicely.
I have finally "made up my mind" (TM) and decided on a template syntax
(two years thought and half a dozen prototypes "down the drain") -
a compiler for this syntax has now been up and running for a few weeks
and I am finalising the Ajax support.

jaws is a template language for yaws (jaws is inspired by PHP, velocity
and AJAX)
- this posting contains a "first look" at the syntax. I'm not going to
describe the semantics - you have to *guess* - it's rather easy.
(Hints all webpages and templates get compiled to single functions)

A *single* jaws file contains templates for *many* webpages - so that an
entire application can be shipped as a single file.

Here's a simple example, assumed to be in the file foo.jaws

      @module foo
       
        @webPage test(_)
        <? N = 25, "" ?>

        <P>factorial <? N ?> is <? fac(N) ?>
       
        @erl
        fac(0) -> 1;
        fac(N) -> N * fac(N-1).

        @webPage form(A)
        <form method="post" action="./foo.jaws?page=posted">
       <input name="fac" size="20">
        </form>

        @webPage posted(A)
        <? {ok, X} = yaws_api:postvar(A, "fac"),
         N = list_to_integer(N), "" ?>

      <? banner([{"name","joe"},{"likes", "Erlang"}]) ?>

        <p>Fac <? N ?> is <? red(fac(N)) ?>

        @template red(X)
        <font color="red"><? X ?></font>

        @template banner(X)

        <p>Hello ${name:X} i hear you like ${likes:X}

      @webPage ajax(A)
        <div id="tag1">
        ...
        </div>

        <a href='javascript:erlcall'("foo", "myfunc", "")'>update</a>

        @webPage myfunc(A)
       
        myfunc(Args) ->
           [replace_contents("tag1", "<h1>Hi .... "].

        @webPage redirect(A)
        <? Headers = [{"redirect", "http:// ..."}], "" ?>

        <h1> You'll soon be redirected.

This defines eight webpages and two templates in one jaws file. It
gives examples of

        - template expansion
        - form handling
        - ajax
        - header manipulation (in the redirect example)

<< computationally <? fac(N) ?> is about 10-20 times faster than PHP
and it works for bignums :-) >>

It seems to me to be desirable to have the code which handles a form
*immediately after the code which defines the form* (and not in another
file) - it also seems desirable to be able to program HTML with
subroutines, like this:

        @webPage foo(A)

        Some html <? fancy_box(A) ?>
        ... <? fancy_box(B) ?> ...

        @template fancy_box(A)
        <table> .... <? A ?> ... </table>

Note also how the site of ajax call is lexically near to the code which
handles the call.

javascript:erlcall(M, F, A) allows javascript to call an arbitary Erlang
{M,F,A}
This is achieved with ajax and a JSON encoding. MFA returns a list
of actions that are to be performed on the webpage - ie
(replace_contents("tag1" , HTML))
sets the innerHTML field of tag1 to HTML.

At this stage I need two things:
        1) Testers - a few good people who are interested in this kind
of
           stuff
        2) javascript help - the result of myfunc(Args) is a list of
actions to be
           performed on a web page. A typical example is

           replace_contents(Tag, Html)

           When this is called in Erlang a JSON encoded term is sent
back to the
web page and after a little trickery

        jsReplaceContents(tag, html) is called

where

        function jsReplaceContents(tag, html) {
                document.getElementById(tag).innerHTML = html;
        }

I have defined a few simple functions (replace_contents(tag, HTML),
delete_tag(Tag) etc.

But I am really stretching my knowledge of javascript here.

If any javascript guru wants to help please contact me.

In particular does anybody have any ideas how to do this?

If I have this

         <div id="foo">
          ....
          ...  <a href="javascript:bar()">click</a>

         </div>

 I want bar() to compute the id if the nearest containing div - in this
case "foo" any ideas how to do this? - do I really have to "walk the
tree" from the root of the DOM tree?

/Joe
Reply | Threaded
Open this post in threaded view
|

RE: Jaws - coming soon - testers and advice wanted

Martin Logan
In reply to this post by Joe Armstrong (TN/EAB)
Please keep me up to date on your progress, or if you are looking for
help I am willing join up and pitch in.  I have just finished writing a
few largish web apps in php and ruby on rails and was about to start
writing an MVC framework of my own.  No need to have 50 frameworks if we
can have one good one.

Cheers,
Martin

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On ehalf Of ke.han
Sent: Monday, February 20, 2006 8:21 AM
To: Joe Armstrong (AL/EAB)
Cc: Alex Arnon; [hidden email]
Subject: Re: Jaws - coming soon - testers and advice wanted

Sounds great Joe!!! gotta have a copy when your ready.
I am just starting a process of building a framework based on the
experience of a just finished mid-sized ajax/json/yaws/erlang/mnesia
app.
I am in the design phase of pulling together all the utils and
fragmented metadata I wrote for the app into a cohesive and simple MVC
framework.
I am canvasing all the latest erlang code base for inclusion and
influence...including Ulf's plain_fsm and (awaiting) rdbms and various
ajax andf json patterns.
My primary goal is to build a high level framework which formalizes the
interaction of injecting a controller into a view and having the view
contain metadata of the client/server interaction separate from the view

layout/content.  The idea is that the controller and domain objects
(referenced via the controller and metadata interactions) are each
plain_fsm "objects" that use "receive parse transforms" to allow the
domain and controllers to "inherit" accessor, event and other framework
behaviors.
If this ramble makes no sense, hopefully, my first few sets of example
code will ;-).
But the important thing is I would love to study how to include your
ideas with an open mind to transform my own into something better.
These next 4 weeks are crucial for me as its my only time to spend 100%
of my energy on getting this framework bootstrapped. (yes, I plan to
open source the whole thing).
thanks for the heads up!!
ke han


Joe Armstrong (AL/EAB) wrote:

> No - javascript is executed on the client - never the server. Nothing
> you can do on the client can damange the sever
> *provided* the server code is safely compiled.
>  
> I guess I omitted to say that in my "safe" mode of compilation
> *everything* is compiled with a safety wrapper (ie including
> BIFs) - thus
>  
>     apply(M, F, A) is transformed to safe:do(erlang, apply, [M,F,A])
>  
> and
>    
>    list_to_atom(X) to safe:do(erlang, list_to_atom, [X])
>    
>    Then safe:do/3 can be written with any policy you like - to enable
or
> disable more or less risky operations
>  
> /Joe
>  
>
>
------------------------------------------------------------------------
>     *From:* [hidden email]
>     [mailto:[hidden email]] *On Behalf Of *Alex
Arnon
>     *Sent:* den 20 februari 2006 12:49
>     *To:* [hidden email]
>     *Subject:* Re: Jaws - coming soon - testers and advice wanted
>
>     Could the Javascript apply(...) binding cause new atoms to be
>     created? In that case, wouldn't that constitute a security hazard?
>