<erl>
out(A) -> {ssi, "HEAD.inc","%%",[{"add", "choosen"}]}.
</erl>

<h3>Add yapp</h3>

<erl>

get_value(K,P) ->
        case proplists:get_value(K,P) of
           undefined -> "";
           V -> string:strip(V)
        end.

format(P) ->
        SrvId = get_value("srvid",P),
        AppName = get_value("appname",P),
        Path = get_value("path",P),
        format(SrvId,AppName,Path).

format([],_,_) -> error(no_srv_id);
format(_,[],_) -> error(no_appname);
format(S,A,[]) -> format(S,A,"/" ++ A);
format(S,A,P) ->
        case (catch yapp_handler:add(yapp_handler, S, P, list_to_atom(A))) of
           ok ->
                ["Added Server Id: ", S,", AppName: ", A, ", Path: ", P];
           Error ->
             error(Error)
        end.

error(no_srv_id) ->   "<p>No Server Id selected!</p>";
error(no_appname) ->   "<p>No AppName given!</p>";
error(E) ->       ["<p>Error adding yapp<pre>", io:format("~p",[E]),"</pre></p>"].

out(A) ->

    P = yaws_api:parse_post(A),

   {html, ["<p>",format(P),"</p>"] }.

</erl>

<p><a href="add.yaws">Return to add page</a></p>

<erl>
out(A) -> {ssi,"END.inc",[],[]}.
</erl>
