Commits

Anonymous committed 3ba51c5 Merge

merged

  • Participants
  • Parent commits fe18608, aa95acf

Comments (0)

Files changed (38)

-daad7d38fb258ef4789fc865f17b3d31cad8c9af 0.1
+daad7d38fb258ef4789fc865f17b3d31cad8c9af 0.2
+5377cf4aa39777dfb59c9e3b1b03310a58375c8a 0.1
+5377cf4aa39777dfb59c9e3b1b03310a58375c8a 0.1
+0000000000000000000000000000000000000000 0.1
+daad7d38fb258ef4789fc865f17b3d31cad8c9af 0.2
+a9d33964db8785a465687f0357799173ed806582 0.2

File Mnesia.nonode@nohost/LATEST.LOG

Binary file modified.

File Mnesia.nonode@nohost/schema.DAT

Binary file modified.

File deps/webmachine/ebin/webmachine.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_app.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_decision_core.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_deps.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_dispatcher.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_error_handler.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_logger.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_mochiweb.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_multipart.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_perf_logger.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_request.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_request_srv.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_resource.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_skel.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_sup.beam

Binary file modified.

File deps/webmachine/ebin/webmachine_util.beam

Binary file modified.

File deps/webmachine/ebin/wmtrace_resource.beam

Binary file modified.

File deps/webmachine/ebin/wrq.beam

Binary file modified.

File deps/webmachine/src/wrq.erl~

-%% @author Justin Sheehy <justin@basho.com>
-%% @copyright 2007-2009 Basho Technologies
-%%
-%%    Licensed under the Apache License, Version 2.0 (the "License");
-%%    you may not use this file except in compliance with the License.
-%%    You may obtain a copy of the License at
-%%
-%%        http://www.apache.org/licenses/LICENSE-2.0
-%%
-%%    Unless required by applicable law or agreed to in writing, software
-%%    distributed under the License is distributed on an "AS IS" BASIS,
-%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-%%    See the License for the specific language governing permissions and
-%%    limitations under the License.
-
--module(wrq).
--author('Justin Sheehy <justin@basho.com>').
-
--export([create/4,load_dispatch_data/6]).
--export([method/1,version/1,peer/1,disp_path/1,path/1,raw_path/1,path_info/1,
-         response_code/1,req_cookie/1,req_qs/1,req_headers/1,req_body/1,
-         stream_req_body/2,resp_redirect/1,resp_headers/1,resp_body/1,
-        app_root/1,path_tokens/1]).
--export([path_info/2,get_req_header/2,do_redirect/2,fresh_resp_headers/2,
-         get_resp_header/2,set_resp_header/3,set_resp_headers/2,
-         set_disp_path/2,set_req_body/2,set_resp_body/2,set_response_code/2,
-         merge_resp_headers/2,remove_resp_header/2,
-         append_to_resp_body/2,append_to_response_body/2,
-         max_recv_body/1,set_max_recv_body/2,
-         get_cookie_value/2,get_qs_value/2,get_qs_value/3,set_peer/2]).
-
--include_lib("include/wm_reqdata.hrl").
-
-create(Method,Version,RawPath,Headers) ->
-    create(#wm_reqdata{method=Method,version=Version,
-                       raw_path=RawPath,req_headers=Headers,
-      wmreq=defined_in_load_dispatch_data,
-      path="defined_in_create",
-      req_cookie=defined_in_create,
-      req_qs=defined_in_create,
-      peer="defined_in_wm_req_srv_init",
-      req_body=not_fetched_yet,
-      max_recv_body=(50*(1024*1024)),
-      app_root="defined_in_load_dispatch_data",
-      path_info=dict:new(),
-      path_tokens=defined_in_load_dispatch_data,
-      disp_path=defined_in_load_dispatch_data,
-      resp_redirect=false, resp_headers=mochiweb_headers:empty(),
-      resp_body = <<>>, response_code=500}).
-create(RD = #wm_reqdata{raw_path=RawPath}) ->
-    {Path, _, _} = mochiweb_util:urlsplit_path(RawPath),
-    Cookie = case get_req_header("cookie", RD) of
-	undefined -> [];
-	Value -> mochiweb_cookies:parse_cookie(Value)
-    end,
-    {_, QueryString, _} = mochiweb_util:urlsplit_path(RawPath),
-    ReqQS = mochiweb_util:parse_qs(QueryString),
-    RD#wm_reqdata{path=Path,req_cookie=Cookie,req_qs=ReqQS}.
-load_dispatch_data(PathInfo, PathTokens, AppRoot, DispPath, WMReq, RD) ->
-    RD#wm_reqdata{path_info=PathInfo,path_tokens=PathTokens,
-                 app_root=AppRoot,disp_path=DispPath,wmreq=WMReq}.
-
-method(_RD = #wm_reqdata{method=Method}) -> Method.
-
-version(_RD = #wm_reqdata{version=Version})
-  when is_tuple(Version), size(Version) == 2,
-     is_integer(element(1,Version)), is_integer(element(2,Version)) -> Version.
-
-peer(_RD = #wm_reqdata{peer=Peer}) when is_list(Peer) -> Peer.
-
-app_root(_RD = #wm_reqdata{app_root=AR}) when is_list(AR) -> AR.
-
-% all three paths below are strings
-disp_path(_RD = #wm_reqdata{disp_path=DP}) when is_list(DP) -> DP.
-
-path(_RD = #wm_reqdata{path=Path}) when is_list(Path) -> Path.
-
-raw_path(_RD = #wm_reqdata{raw_path=RawPath}) when is_list(RawPath) -> RawPath.
-
-path_info(_RD = #wm_reqdata{path_info=PathInfo}) -> PathInfo. % dict
-
-path_tokens(_RD = #wm_reqdata{path_tokens=PathT}) -> PathT. % list of strings
-
-response_code(_RD = #wm_reqdata{response_code=C}) when is_integer(C) -> C.
-
-req_cookie(_RD = #wm_reqdata{req_cookie=C}) when is_list(C) -> C. % string
-
-req_qs(_RD = #wm_reqdata{req_qs=QS}) when is_list(QS) -> QS. % string
-
-req_headers(_RD = #wm_reqdata{req_headers=ReqH}) -> ReqH. % mochiheaders
-
-req_body(_RD = #wm_reqdata{wmreq=WMReq,max_recv_body=MRB}) ->
-    maybe_conflict_body(WMReq:req_body(MRB)).
-
-stream_req_body(_RD = #wm_reqdata{wmreq=WMReq}, MaxHunk) ->
-    maybe_conflict_body(WMReq:stream_req_body(MaxHunk)).
-
-max_recv_body(_RD = #wm_reqdata{max_recv_body=X}) when is_integer(X) -> X.
-
-set_max_recv_body(X, RD) when is_integer(X) -> RD#wm_reqdata{max_recv_body=X}.
-
-maybe_conflict_body(BodyResponse) ->
-    case BodyResponse of
-        stream_conflict ->
-            exit("wrq:req_body and wrq:stream_req_body conflict");
-        {error, req_body_too_large} ->
-            exit("request body too large");
-        _ ->
-            BodyResponse
-    end.
-
-resp_redirect(_RD = #wm_reqdata{resp_redirect=true}) -> true;
-resp_redirect(_RD = #wm_reqdata{resp_redirect=false}) -> false.
-
-resp_headers(_RD = #wm_reqdata{resp_headers=RespH}) -> RespH. % mochiheaders
-
-resp_body(_RD = #wm_reqdata{resp_body=undefined}) -> undefined;
-resp_body(_RD = #wm_reqdata{resp_body={stream,X}}) -> {stream,X};
-resp_body(_RD = #wm_reqdata{resp_body=RespB}) when is_binary(RespB) -> RespB;
-resp_body(_RD = #wm_reqdata{resp_body=RespB}) -> iolist_to_binary(RespB).
-
-%% --
-
-path_info(Key, RD) when is_atom(Key) ->
-    case dict:find(Key, path_info(RD)) of
-        {ok, Value} when is_list(Value) -> Value; % string
-        error -> undefined
-    end.
-
-get_req_header(HdrName, RD) -> % string->string
-    mochiweb_headers:get_value(HdrName, req_headers(RD)).
-
-do_redirect(true, RD) ->  RD#wm_reqdata{resp_redirect=true};
-do_redirect(false, RD) -> RD#wm_reqdata{resp_redirect=false}.
-
-set_peer(P, RD) when is_list(P) -> RD#wm_reqdata{peer=P}. % string
-
-set_disp_path(P, RD) when is_list(P) -> RD#wm_reqdata{disp_path=P}. % string
-
-set_req_body(Body, RD) -> RD#wm_reqdata{req_body=Body}.
-
-set_resp_body(Body, RD) -> RD#wm_reqdata{resp_body=Body}.
-
-set_response_code(Code, RD) when is_integer(Code) ->
-    RD#wm_reqdata{response_code=Code}.
-
-get_resp_header(HdrName, _RD=#wm_reqdata{resp_headers=RespH}) ->
-    mochiweb_headers:get_value(HdrName, RespH).
-set_resp_header(K, V, RD=#wm_reqdata{resp_headers=RespH})
-  when is_list(K),is_list(V) ->
-    RD#wm_reqdata{resp_headers=mochiweb_headers:enter(K, V, RespH)}.
-set_resp_headers(Hdrs, RD=#wm_reqdata{resp_headers=RespH}) ->
-    F = fun({K, V}, Acc) -> mochiweb_headers:enter(K, V, Acc) end,
-    RD#wm_reqdata{resp_headers=lists:foldl(F, RespH, Hdrs)}.
-fresh_resp_headers(Hdrs, RD) ->
-    F = fun({K, V}, Acc) -> mochiweb_headers:enter(K, V, Acc) end,
-    RD#wm_reqdata{resp_headers=lists:foldl(F, mochiweb_headers:empty(), Hdrs)}.
-remove_resp_header(K, RD=#wm_reqdata{resp_headers=RespH}) when is_list(K) ->
-    RD#wm_reqdata{resp_headers=mochiweb_headers:from_list(
-                                 proplists:delete(K,
-                                     mochiweb_headers:to_list(RespH)))}.
-
-merge_resp_headers(Hdrs, RD=#wm_reqdata{resp_headers=RespH}) ->
-    F = fun({K, V}, Acc) -> mochiweb_headers:insert(K, V, Acc) end,
-    NewHdrs = lists:foldl(F, RespH, Hdrs),
-    RD#wm_reqdata{resp_headers=NewHdrs}.
-
-append_to_resp_body(Data, RD) -> append_to_response_body(Data, RD).
-append_to_response_body(Data, RD=#wm_reqdata{resp_body=RespB}) ->
-    case is_binary(Data) of
-	true ->
-	    Data0 = RespB,
-	    Data1 = <<Data0/binary,Data/binary>>,
-            io:format("appending ~p to ~p:~n~p~n~p~n",[Data,Data0,Data1,RD]), 
-	    io:format("result:~p~n",[RD#wm_reqdata{resp_body=Data1}]),
-	    RD#wm_reqdata{resp_body=Data1};
-	false -> % MUST BE an iolist! else, fail.
-	    append_to_response_body(iolist_to_binary(Data), RD)
-    end.
-
-get_cookie_value(Key, RD) when is_list(Key) -> % string
-    proplists:get_value(Key, req_cookie(RD)).
-
-get_qs_value(Key, RD) when is_list(Key) -> % string
-    proplists:get_value(Key, req_qs(RD)).
-
-get_qs_value(Key, Default, RD) when is_list(Key) ->
-    proplists:get_value(Key, req_qs(RD), Default).
-
-

File ebin/webmstn.beam

Binary file modified.

File ebin/webmstn_app.beam

Binary file modified.

File ebin/webmstn_deps.beam

Binary file modified.

File ebin/webmstn_dynamic_resource.beam

Binary file removed.

File ebin/webmstn_notes_resource.beam

Binary file modified.

File ebin/webmstn_resource.beam

Binary file removed.

File ebin/webmstn_static_resource.beam

Binary file modified.

File ebin/webmstn_sup.beam

Binary file modified.

File priv/dispatch.conf

-{["notes"], webmstn_dynamic_resource, []}.
-{['*'], webmstn_static_resource, ['PATHTOWWW']}.
-
+{["wmtrace",'*'],wmtrace_resource,[{trace_dir,"priv/traces"}]}.
+{["notes",act], webmstn_notes_resource,[{trace_dir,"priv/traces"}]}.
+{["notes"], webmstn_notes_resource,[{trace_dir,"priv/traces"}]}.
+{['*'], webmstn_static_resource,[{trace_dir,"priv/traces"},"priv/www"]}.

File priv/log/access.log.2009_09_27_23

Empty file removed.

File priv/www/index.html

 
 <body>
    <h1>Sticky Notest - MochiWeb - WebMachine test</h1>
-   <a href="stickynotes.html" target="new">Go directly to Sticky Notes!</a><hr>
+   <a href="stickynotes.html" target="new">Go directly to Sticky Notes</a>
+   &nbsp;
+   &nbsp;
+   <a href="wmtrace" target="new">Last Trace</a>
+   &nbsp;
+   &nbsp;
+   <a href="wmtrace" target="new">All Traces</a>
+   <hr>
    <form name="myForm" action="javascript:ajaxFunction()">
    <table id="tt">
      <tr><td>URL:          </td><td><input id="url" type="text" size="90" value='/notes'></td></tr>

File priv/www/js/application.js

 	$.post( url, {"json": data}, callback, "json");
 }
 
+function get(json, url, callback){
+	var data = JSON.stringify(json);
+	$.get( url, {"json": data}, callback, "json");
+}
+
 function attachEvent(note){
 	note.children("textarea").focus(function(){
 		zTop($(this).parent("div.note"));	
 		"action" : "read_all",
 	}
 
-	post(json, "/notes", cbAll);	
+	get(json, "/notes/all", cbAll);	
 }
 
 $(document).ready(function(){

File src/webmstn_notes_resource.erl

 
 -include_lib("webmachine/include/webmachine.hrl").
 
-init([]) -> {ok, undefined}.
+init([]) -> {ok, undefined};
+init([Cfg]) -> 
+    {trace_dir,Dir} = Cfg,
+	AbsDir =filename:absname(Dir), 
+	io:format("= = = = = = ~nnotes_resource Cfg=~p,  absdir=~p~n",[Cfg,AbsDir]),
+	{{trace,AbsDir}, Cfg}.
 
 content_types_provided(RD,Ctx) ->
     {[{"application/json",to_json}],RD,Ctx}.
     {true, RD, Ctx}.
 
 process_post(RD,Ctx) ->
-    io:format("--> process_post~n"),
+%   io:format("--> process_post~n"),
     Data = mochiweb_util:parse_qs(wrq:req_body(RD)),
     io:format("--> process_post Data:~n~p~n",[Data]),
     Struct = mochijson2:decode(proplists:get_value("json", Data)),
 %    io:format("--> process_post Act:~n~p~n",[Act]),
     RD1 = wrq:set_resp_header("Content-Type", "application/json",RD),
     Ans = mochijson2:encode(notes:Act(Struct)),
+    io:format("--> process_post DB Response:~p~n",[Ans]),
 %    io:format("--> process_post DB Response:~p~nbefore~n~p~n",[Ans,RD]),
     RD2 = wrq:append_to_resp_body(Ans,RD1),
 %    RD1 = wrq:append_to_response_body(<<"body here">>,RD1),
 %    io:format("--> process_post RD~n~p~n",[RD2]),
     {true,RD2,Ctx}.
-  
+  

File src/webmstn_static_resource.erl

 
 -record(context, {docroot,fullpath}).
 
-init([DocRoot]) -> {ok, #context{docroot=DocRoot}}.
+init([DocRoot]) -> {ok, #context{docroot=DocRoot}};
+init([Cfg,DocRoot]) -> 
+    {trace_dir,Dir} = Cfg,
+	AbsDir =filename:absname(Dir), 
+	io:format("= = = = = = ~nstatic_resource Cfg=~p,  AbsDir=~p~nDocRoot =~p~n",
+			[Cfg,AbsDir,DocRoot]),
+	{{trace,AbsDir}, #context{docroot=DocRoot}}.
 
 content_types_provided(ReqProps, Context) ->
 %    io:format("content_types_provided: ctx: ~p~n~nreq:~p~n~n",[Context,ReqProps]),

File src/webmstn_sup.erl

     [supervisor:start_child(?MODULE, Spec) || Spec <- Specs],
     ok.
 
-%% @spec prep_dispatch(DispatchTemplate) -> Dispatch
-%% @doc replace 'PATHTOWWW' -> absolute path to "./priv/www" in the Dispatch
-%% @doc Example: {['*',webmstn_static_resource,['PATHTOWWW']}
-%% @doc becomes {['*',webmstn_static_resource,["c:/tmp/webcandy/priv/www"]}
-%% @doc if the app was cloned into c:/tmp/webcandy
-prep_dispatch(DispatchTemplate) -> 
-	WWWPath = filename:absname("priv/www"),
-	lists:map(fun({Pattern,Resource,Paths})->
-				{Pattern, Resource,
-				        lists:map(fun(Code) ->
-									if 
-										Code =:= 'PATHTOWWW' -> WWWPath;
-										true                 -> Code
-									end
-								end, Paths)} 
-				end, DispatchTemplate ).
-
-
-
 %% @spec init([]) -> SupervisorTree
 %% @doc supervisor callback.
 init([]) ->
     Ip = case os:getenv("WEBMACHINE_IP") of false -> "0.0.0.0"; Any -> Any end,   
-	{ok, DispatchTemplate} = file:consult("priv/dispatch.conf"),
-    io:format("************************************DispatchTmpl: ~p~n",[DispatchTemplate]),
-	Dispatch = prep_dispatch(DispatchTemplate),
+	{ok, Dispatch} = file:consult("priv/dispatch.conf"),
     io:format("Dispatch: ~p~n",[Dispatch]),
     WebConfig = [
 		 {ip, Ip},
-erl -pa ebin deps/*/ebin deps/*/deps/*/ebin -boot start_sasl -s webmstn
+werl -pa ebin deps/*/ebin deps/*/deps/*/ebin -boot start_sasl -s webmstn