3 | It Worked
4 |
5 |
6 | MochiWeb running.
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | include ../support/include.mk
2 |
3 | all: $(EBIN_FILES)
4 |
5 | debug:
6 | $(MAKE) DEBUG=-DDEBUG
7 |
8 | clean:
9 | rm -rf $(EBIN_FILES)
10 |
--------------------------------------------------------------------------------
/src/erlwsh.app:
--------------------------------------------------------------------------------
1 | {application, erlwsh,
2 | [{description, "erlwsh"},
3 | {vsn, "0.01"},
4 | {modules, [
5 | erlwsh,
6 | erlwsh_app,
7 | erlwsh_sup,
8 | erlwsh_web,
9 | erlwsh_deps
10 | ]},
11 | {registered, []},
12 | {mod, {erlwsh_app, []}},
13 | {env, []},
14 | {applications, [kernel, stdlib, crypto]}]}.
15 |
--------------------------------------------------------------------------------
/src/eshell.erl:
--------------------------------------------------------------------------------
1 | -module(eshell).
2 | -export([eval/2]).
3 | eval(Str,Binding) ->
4 | {ok,Ts,_} = erl_scan:string(Str),
5 | Ts1 = case lists:reverse(Ts) of
6 | [{dot,_}|_] -> Ts;
7 | TsR -> lists:reverse([{dot,1} | TsR])
8 | end,
9 | {ok,Expr} = erl_parse:parse_exprs(Ts1),
10 | erl_eval:exprs(Expr, Binding).
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #Erlwsh -- Erlang Web Shell
2 |
3 | Author: dennis (killme2008@gmail.com)
4 |
5 | Erlwsh is an erlang web shell,you can program erlang on web browser.
6 |
7 | #Install:
8 | First,you have to install mochiweb:
9 |
10 | cd erlwsh
11 | chmod u+x scripts/install_mochiweb.sh
12 | scripts/install_mochiweb.sh
13 |
14 | Then,compile all sources:
15 |
16 | make
17 |
18 | At last,you can start erlwsh by start.sh
19 |
20 | chmod u+x start.sh
21 | ./start.sh
22 |
23 | Erlwsh is online:
24 |
25 | http://localhost:8000/shell
26 |
--------------------------------------------------------------------------------
/src/erlwsh_app.erl:
--------------------------------------------------------------------------------
1 | %% @author author
2 | %% @copyright YYYY author.
3 |
4 | %% @doc Callbacks for the erlwsh application.
5 |
6 | -module(erlwsh_app).
7 | -author('author ').
8 |
9 | -behaviour(application).
10 | -export([start/2,stop/1]).
11 |
12 |
13 | %% @spec start(_Type, _StartArgs) -> ServerRet
14 | %% @doc application start callback for erlwsh.
15 | start(_Type, _StartArgs) ->
16 | erlwsh_deps:ensure(),
17 | erlwsh_sup:start_link().
18 |
19 | %% @spec stop(_State) -> ServerRet
20 | %% @doc application stop callback for erlwsh.
21 | stop(_State) ->
22 | ok.
23 |
--------------------------------------------------------------------------------
/src/erlwsh.erl:
--------------------------------------------------------------------------------
1 | %% @author author
2 | %% @copyright YYYY author.
3 |
4 | %% @doc TEMPLATE.
5 |
6 | -module(erlwsh).
7 | -author('author ').
8 | -export([start/0, stop/0]).
9 |
10 | ensure_started(App) ->
11 | case application:start(App) of
12 | ok ->
13 | ok;
14 | {error, {already_started, App}} ->
15 | ok
16 | end.
17 |
18 | %% @spec start() -> ok
19 | %% @doc Start the erlwsh server.
20 | start() ->
21 | erlwsh_deps:ensure(),
22 | ensure_started(crypto),
23 | application:start(erlwsh).
24 |
25 | %% @spec stop() -> ok
26 | %% @doc Stop the erlwsh server.
27 | stop() ->
28 | Res = application:stop(erlwsh),
29 | application:stop(crypto),
30 | Res.
31 |
--------------------------------------------------------------------------------
/support/include.mk:
--------------------------------------------------------------------------------
1 | ## -*- makefile -*-
2 |
3 | ######################################################################
4 | ## Erlang
5 |
6 | ERL := erl
7 | ERLC := $(ERL)c
8 |
9 | INCLUDE_DIRS := ../include $(wildcard ../deps/*/include)
10 | EBIN_DIRS := $(wildcard ../deps/*/ebin)
11 | ERLC_FLAGS := -W $(INCLUDE_DIRS:../%=-I ../%) $(EBIN_DIRS:%=-pa %)
12 |
13 | ifndef no_debug_info
14 | ERLC_FLAGS += +debug_info
15 | endif
16 |
17 | ifdef debug
18 | ERLC_FLAGS += -Ddebug
19 | endif
20 |
21 | EBIN_DIR := ../ebin
22 | DOC_DIR := ../doc
23 | EMULATOR := beam
24 |
25 | ERL_SOURCES := $(wildcard *.erl)
26 | ERL_HEADERS := $(wildcard *.hrl) $(wildcard ../include/*.hrl)
27 | ERL_OBJECTS := $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.$(EMULATOR))
28 | ERL_DOCUMENTS := $(ERL_SOURCES:%.erl=$(DOC_DIR)/%.html)
29 | ERL_OBJECTS_LOCAL := $(ERL_SOURCES:%.erl=./%.$(EMULATOR))
30 | APP_FILES := $(wildcard *.app)
31 | EBIN_FILES = $(ERL_OBJECTS) $(ERL_DOCUMENTS) $(APP_FILES:%.app=../ebin/%.app)
32 | EBIN_FILES_NO_DOCS = $(ERL_OBJECTS) $(APP_FILES:%.app=../ebin/%.app)
33 | MODULES = $(ERL_SOURCES:%.erl=%)
34 |
35 | ../ebin/%.app: %.app
36 | cp $< $@
37 |
38 | $(EBIN_DIR)/%.$(EMULATOR): %.erl
39 | $(ERLC) $(ERLC_FLAGS) -o $(EBIN_DIR) $<
40 |
41 | ./%.$(EMULATOR): %.erl
42 | $(ERLC) $(ERLC_FLAGS) -o . $<
43 |
44 | $(DOC_DIR)/%.html: %.erl
45 | $(ERL) -noshell -noinput -eval 'edoc:file("$<")' -s init stop
46 | mv *.html $(DOC_DIR)
47 |
--------------------------------------------------------------------------------
/scripts/install_mochiweb.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 | # author: litaocheng@gmail.com
3 | # date: 2009.10.16
4 | # desc: get the mochiweb from the google code svn, and install
5 | # it to the erlang otp lib directory(makesure you have install
6 | # the erlang otp).
7 | # 1, get the erlang otp lib dir
8 | # 2, check out the code from svn
9 | # 3, compile the code
10 |
11 |
12 | erl_exists()
13 | {
14 | echo -n "check if Erlang/OTP exists... "
15 | if !(erl -version > /dev/null 2>&1); then
16 | echo "First, You must install the erlang otp"
17 | echo "http://www.erlang.org/download.html"
18 | exit 1
19 | fi
20 | echo "ok"
21 | }
22 |
23 | erl_lib()
24 | {
25 | echo -n "get the erlang lib path... "
26 | ERL_RUN="erl -eval 'io:format(\"ERL_LIB|~s|\", [code:lib_dir()]), init:stop()'"
27 | ERL_OUTPUT=$(eval $ERL_RUN)
28 | ERL_LIB=`echo $ERL_OUTPUT | cut -d '|' -f 2`
29 | export ERL_LIB
30 | echo "ok"
31 | }
32 |
33 | svn_co()
34 | {
35 | echo "checkout the mochiweb codes from the github..."
36 | if !(git clone https://github.com/mochi/mochiweb.git $MOCHI_DIR); then
37 | echo "git clone mochiweb codes error"
38 | exit 1
39 | fi
40 | echo "ok"
41 | }
42 |
43 | compile_mochi()
44 | {
45 | if !(cd $MOCHI_DIR && make ); then
46 | echo "compile the mochiweb code error"
47 | exit 1
48 | fi
49 | }
50 |
51 | erl_exists
52 | erl_lib
53 | echo "ERL_TOP is " $ERL_LIB
54 | MOCHI_DIR=$ERL_LIB/mochiweb
55 | svn_co
56 | compile_mochi
57 |
58 |
59 |
--------------------------------------------------------------------------------
/src/erlwsh_sup.erl:
--------------------------------------------------------------------------------
1 | %% @author author
2 | %% @copyright YYYY author.
3 |
4 | %% @doc Supervisor for the erlwsh application.
5 |
6 | -module(erlwsh_sup).
7 | -author('author ').
8 |
9 | -behaviour(supervisor).
10 |
11 | %% External exports
12 | -export([start_link/0, upgrade/0]).
13 |
14 | %% supervisor callbacks
15 | -export([init/1]).
16 |
17 | %% @spec start_link() -> ServerRet
18 | %% @doc API for starting the supervisor.
19 | start_link() ->
20 | supervisor:start_link({local, ?MODULE}, ?MODULE, []).
21 |
22 | %% @spec upgrade() -> ok
23 | %% @doc Add processes if necessary.
24 | upgrade() ->
25 | {ok, {_, Specs}} = init([]),
26 |
27 | Old = sets:from_list(
28 | [Name || {Name, _, _, _} <- supervisor:which_children(?MODULE)]),
29 | New = sets:from_list([Name || {Name, _, _, _, _, _} <- Specs]),
30 | Kill = sets:subtract(Old, New),
31 |
32 | sets:fold(fun (Id, ok) ->
33 | supervisor:terminate_child(?MODULE, Id),
34 | supervisor:delete_child(?MODULE, Id),
35 | ok
36 | end, ok, Kill),
37 |
38 | [supervisor:start_child(?MODULE, Spec) || Spec <- Specs],
39 | ok.
40 |
41 | %% @spec init([]) -> SupervisorTree
42 | %% @doc supervisor callback.
43 | init([]) ->
44 | Ip = case os:getenv("MOCHIWEB_IP") of false -> "0.0.0.0"; Any -> Any end,
45 | WebConfig = [
46 | {ip, Ip},
47 | {port, 8000},
48 | {docroot, erlwsh_deps:local_path(["priv", "www"])}],
49 | Web = {erlwsh_web,
50 | {erlwsh_web, start, [WebConfig]},
51 | permanent, 5000, worker, dynamic},
52 |
53 | Processes = [Web],
54 | {ok, {{one_for_one, 10, 10}, Processes}}.
55 |
--------------------------------------------------------------------------------
/src/erlwsh_deps.erl:
--------------------------------------------------------------------------------
1 | %% @author author
2 | %% @copyright YYYY author.
3 |
4 | %% @doc Ensure that the relatively-installed dependencies are on the code
5 | %% loading path, and locate resources relative
6 | %% to this application's path.
7 |
8 | -module(erlwsh_deps).
9 | -author('author ').
10 |
11 | -export([ensure/0, ensure/1]).
12 | -export([get_base_dir/0, get_base_dir/1]).
13 | -export([local_path/1, local_path/2]).
14 | -export([deps_on_path/0, new_siblings/1]).
15 |
16 | %% @spec deps_on_path() -> [ProjNameAndVers]
17 | %% @doc List of project dependencies on the path.
18 | deps_on_path() ->
19 | F = fun (X, Acc) ->
20 | ProjDir = filename:dirname(X),
21 | case {filename:basename(X),
22 | filename:basename(filename:dirname(ProjDir))} of
23 | {"ebin", "deps"} ->
24 | [filename:basename(ProjDir) | Acc];
25 | _ ->
26 | Acc
27 | end
28 | end,
29 | ordsets:from_list(lists:foldl(F, [], code:get_path())).
30 |
31 | %% @spec new_siblings(Module) -> [Dir]
32 | %% @doc Find new siblings paths relative to Module that aren't already on the
33 | %% code path.
34 | new_siblings(Module) ->
35 | Existing = deps_on_path(),
36 | SiblingEbin = filelib:wildcard(local_path(["deps", "*", "ebin"], Module)),
37 | Siblings = [filename:dirname(X) || X <- SiblingEbin,
38 | ordsets:is_element(
39 | filename:basename(filename:dirname(X)),
40 | Existing) =:= false],
41 | lists:filter(fun filelib:is_dir/1,
42 | lists:append([[filename:join([X, "ebin"]),
43 | filename:join([X, "include"])] ||
44 | X <- Siblings])).
45 |
46 |
47 | %% @spec ensure(Module) -> ok
48 | %% @doc Ensure that all ebin and include paths for dependencies
49 | %% of the application for Module are on the code path.
50 | ensure(Module) ->
51 | code:add_paths(new_siblings(Module)),
52 | code:clash(),
53 | ok.
54 |
55 | %% @spec ensure() -> ok
56 | %% @doc Ensure that the ebin and include paths for dependencies of
57 | %% this application are on the code path. Equivalent to
58 | %% ensure(?Module).
59 | ensure() ->
60 | ensure(?MODULE).
61 |
62 | %% @spec get_base_dir(Module) -> string()
63 | %% @doc Return the application directory for Module. It assumes Module is in
64 | %% a standard OTP layout application in the ebin or src directory.
65 | get_base_dir(Module) ->
66 | {file, Here} = code:is_loaded(Module),
67 | filename:dirname(filename:dirname(Here)).
68 |
69 | %% @spec get_base_dir() -> string()
70 | %% @doc Return the application directory for this application. Equivalent to
71 | %% get_base_dir(?MODULE).
72 | get_base_dir() ->
73 | get_base_dir(?MODULE).
74 |
75 | %% @spec local_path([string()], Module) -> string()
76 | %% @doc Return an application-relative directory from Module's application.
77 | local_path(Components, Module) ->
78 | filename:join([get_base_dir(Module) | Components]).
79 |
80 | %% @spec local_path(Components) -> string()
81 | %% @doc Return an application-relative directory for this application.
82 | %% Equivalent to local_path(Components, ?MODULE).
83 | local_path(Components) ->
84 | local_path(Components, ?MODULE).
85 |
--------------------------------------------------------------------------------
/src/erlwsh_web.erl:
--------------------------------------------------------------------------------
1 | %% @author author
2 | %% @copyright YYYY author.
3 |
4 | %% @doc Web server for erlwsh.
5 |
6 | -module(erlwsh_web).
7 | -author('dennis ').
8 | -vsn('0.01').
9 | -export([start/1, stop/0, loop/2]).
10 |
11 | %% External API
12 |
13 | start(Options) ->
14 | {DocRoot, Options1} = get_option(docroot, Options),
15 | Loop = fun (Req) ->
16 | ?MODULE:loop(Req, DocRoot)
17 | end,
18 | mochiweb_http:start([{name, ?MODULE}, {loop, Loop} | Options1]).
19 |
20 | stop() ->
21 | mochiweb_http:stop(?MODULE).
22 |
23 | loop(Req, DocRoot) ->
24 | "/" ++ Path = Req:get(path),
25 | case Req:get(method) of
26 | Method when Method =:= 'GET'; Method =:= 'HEAD' ->
27 | case Path of
28 | "shell" ->
29 | Socket=Req:get(socket),
30 | Addr=Req:get(peer),
31 | Port=integer_to_list(get_port(Socket)),
32 | Name=list_to_atom(Addr ++ ":" ++ Port),
33 | %Register process as ip:port name
34 | register(Name,self()),
35 | N=1,
36 | NameField=get_name_field(Name),
37 | Response = Req :ok ( { "text/html; charset=utf-8" ,
38 | [ { "Server" ,"Erlang-web-shell" } ] ,
39 | chunked} ) ,
40 | Response :write_chunk ( "Erlang web shell 0.01"
41 | ""
42 | ""
66 | " Erlang web shell 0.01 (dennis:killme2008@gmail.com)" ++
67 | get_form(NameField,N)) ,
68 | loop(NameField,Response,erl_eval:new_bindings(), N);
69 |
70 | _ ->
71 | Req:serve_file(Path, DocRoot)
72 | end;
73 | 'POST' ->
74 | case Path of
75 | "shell" ->
76 | Params=Req:parse_post(),
77 | Pid=erlang:list_to_existing_atom(proplists:get_value("name",Params)),
78 | case string:strip(proplists:get_value("str",Params)) of
79 | "halt()." ->
80 | Pid ! {client,exit};
81 | Str ->
82 | Pid ! {post_msg,Str}
83 | end,
84 | Req:ok({"text/plain", "success"});
85 | _ ->
86 | Req:not_found()
87 | end;
88 | _ ->
89 | Req:respond({501, [], []})
90 | end.
91 |
92 | get_name_field(Name)->
93 | io_lib:format("",[Name]).
94 |
95 | get_form(NameField,N)->
96 | io_lib:format(" ",[N,N,N,N]).
101 |
102 | get_port(Socket) ->
103 | case inet:peername(Socket) of
104 | {ok, {_Addr, Port}} ->
105 | Port
106 | end.
107 |
108 | %% Internal API
109 | loop(NameField, Response,Binding ,N ) ->
110 | receive
111 | {client,exit} ->
112 | Response:write_chunk(""),
116 | timer:sleep(100),
117 | Response:write_chunk(""),
118 | ok;
119 | {post_msg,Str}->
120 | try eshell:eval(Str,Binding) of
121 | {value,Value,NewBinding} ->
122 | Response:write_chunk(io_lib:format("~p",[Value]) ++ get_form(NameField,N+1)),
123 | loop(NameField,Response,NewBinding,N+1)
124 | catch
125 | _:Why->
126 | Response:write_chunk(io_lib:format("~p",[Why]) ++ get_form(NameField,N+1)),
127 | loop(NameField,Response,Binding,N+1)
128 | end;
129 | _ ->
130 | loop(NameField,Response,Binding,N)
131 | end.
132 |
133 | get_option(Option, Options) ->
134 | {proplists:get_value(Option, Options), proplists:delete(Option, Options)}.
135 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/priv/www/prototype.js:
--------------------------------------------------------------------------------
1 | /* Prototype JavaScript framework, version 1.6.1
2 | * (c) 2005-2009 Sam Stephenson
3 | *
4 | * Prototype is freely distributable under the terms of an MIT-style license.
5 | * For details, see the Prototype web site: http://www.prototypejs.org/
6 | *
7 | *--------------------------------------------------------------------------*/
8 |
9 | var Prototype = {
10 | Version: '1.6.1',
11 |
12 | Browser: (function(){
13 | var ua = navigator.userAgent;
14 | var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
15 | return {
16 | IE: !!window.attachEvent && !isOpera,
17 | Opera: isOpera,
18 | WebKit: ua.indexOf('AppleWebKit/') > -1,
19 | Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
20 | MobileSafari: /Apple.*Mobile.*Safari/.test(ua)
21 | }
22 | })(),
23 |
24 | BrowserFeatures: {
25 | XPath: !!document.evaluate,
26 | SelectorsAPI: !!document.querySelector,
27 | ElementExtensions: (function() {
28 | var constructor = window.Element || window.HTMLElement;
29 | return !!(constructor && constructor.prototype);
30 | })(),
31 | SpecificElementExtensions: (function() {
32 | if (typeof window.HTMLDivElement !== 'undefined')
33 | return true;
34 |
35 | var div = document.createElement('div');
36 | var form = document.createElement('form');
37 | var isSupported = false;
38 |
39 | if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) {
40 | isSupported = true;
41 | }
42 |
43 | div = form = null;
44 |
45 | return isSupported;
46 | })()
47 | },
48 |
49 | ScriptFragment: '