forked from tonyg/rabbithub
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 66e69e8
Showing
87 changed files
with
7,151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.beam |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
MARKDOWN_SOURCES=$(wildcard doc/*.md) | ||
MARKDOWN_TARGETS=$(patsubst doc/%.md,doc/html/%.html,$(MARKDOWN_SOURCES)) | ||
|
||
all: ebin | ||
(cd src;$(MAKE)) | ||
|
||
docs: html-docs | ||
|
||
html-docs: doc/html $(MARKDOWN_TARGETS) | ||
|
||
doc/html: | ||
mkdir -p doc/html | ||
|
||
doc/html/%.html: doc/%.md | ||
(title=`grep '^# ' $< | head -1 | sed -e 's:^# ::'` ;\ | ||
t=/tmp/$*.md ;\ | ||
sed -e "s:@TITLE@:$$title:g" < doc/header.html > $@ ;\ | ||
python doc/buildtoc.py < $< > $$t ;\ | ||
markdown $$t >> $@ ;\ | ||
rm $$t ;\ | ||
cat doc/footer.html >> $@) | ||
|
||
ebin: | ||
mkdir -p ebin | ||
|
||
clean: clean-docs | ||
(cd src;$(MAKE) clean) | ||
|
||
clean-docs: clean-html | ||
|
||
clean-html: | ||
rm -rf doc/html |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This is the MIT license. | ||
|
||
Copyright (c) 2007 Mochi Media, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
all: | ||
(cd src;$(MAKE)) | ||
|
||
test: | ||
(cd src;$(MAKE) test) | ||
|
||
clean: | ||
(cd src;$(MAKE) clean) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MochiWeb is an Erlang library for building lightweight HTTP servers. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{application, mochiweb, | ||
[{description, "MochiMedia Web Server"}, | ||
{vsn, "0.01"}, | ||
{modules, [ | ||
mochihex, | ||
mochijson, | ||
mochijson2, | ||
mochinum, | ||
mochiweb, | ||
mochiweb_app, | ||
mochiweb_charref, | ||
mochiweb_cookies, | ||
mochiweb_echo, | ||
mochiweb_headers, | ||
mochiweb_html, | ||
mochiweb_http, | ||
mochiweb_multipart, | ||
mochiweb_request, | ||
mochiweb_response, | ||
mochiweb_skel, | ||
mochiweb_socket_server, | ||
mochiweb_sup, | ||
mochiweb_util, | ||
reloader, | ||
mochifmt, | ||
mochifmt_std, | ||
mochifmt_records | ||
]}, | ||
{registered, []}, | ||
{mod, {mochiweb_app, []}}, | ||
{env, []}, | ||
{applications, [kernel, stdlib]}]}. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
all: | ||
(cd src;$(MAKE)) | ||
|
||
clean: | ||
(cd src;$(MAKE) clean) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<head> | ||
<title>It Worked</title> | ||
</head> | ||
<body> | ||
MochiWeb running. | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include ../support/include.mk | ||
|
||
all: $(EBIN_FILES) | ||
|
||
debug: | ||
$(MAKE) DEBUG=-DDEBUG | ||
|
||
clean: | ||
rm -rf $(EBIN_FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{application, skel, | ||
[{description, "skel"}, | ||
{vsn, "0.01"}, | ||
{modules, [ | ||
skel, | ||
skel_app, | ||
skel_sup, | ||
skel_web, | ||
skel_deps | ||
]}, | ||
{registered, []}, | ||
{mod, {skel_app, []}}, | ||
{env, []}, | ||
{applications, [kernel, stdlib, crypto]}]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
%% @author author <[email protected]> | ||
%% @copyright YYYY author. | ||
|
||
%% @doc TEMPLATE. | ||
|
||
-module(skel). | ||
-author('author <[email protected]>'). | ||
-export([start/0, stop/0]). | ||
|
||
ensure_started(App) -> | ||
case application:start(App) of | ||
ok -> | ||
ok; | ||
{error, {already_started, App}} -> | ||
ok | ||
end. | ||
|
||
%% @spec start() -> ok | ||
%% @doc Start the skel server. | ||
start() -> | ||
skel_deps:ensure(), | ||
ensure_started(crypto), | ||
application:start(skel). | ||
|
||
%% @spec stop() -> ok | ||
%% @doc Stop the skel server. | ||
stop() -> | ||
Res = application:stop(skel), | ||
application:stop(crypto), | ||
Res. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
%% @author author <[email protected]> | ||
%% @copyright YYYY author. | ||
|
||
%% @doc Callbacks for the skel application. | ||
|
||
-module(skel_app). | ||
-author('author <[email protected]>'). | ||
|
||
-behaviour(application). | ||
-export([start/2,stop/1]). | ||
|
||
|
||
%% @spec start(_Type, _StartArgs) -> ServerRet | ||
%% @doc application start callback for skel. | ||
start(_Type, _StartArgs) -> | ||
skel_deps:ensure(), | ||
skel_sup:start_link(). | ||
|
||
%% @spec stop(_State) -> ServerRet | ||
%% @doc application stop callback for skel. | ||
stop(_State) -> | ||
ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
%% @author author <[email protected]> | ||
%% @copyright YYYY author. | ||
|
||
%% @doc Ensure that the relatively-installed dependencies are on the code | ||
%% loading path, and locate resources relative | ||
%% to this application's path. | ||
|
||
-module(skel_deps). | ||
-author('author <[email protected]>'). | ||
|
||
-export([ensure/0, ensure/1]). | ||
-export([get_base_dir/0, get_base_dir/1]). | ||
-export([local_path/1, local_path/2]). | ||
-export([deps_on_path/0, new_siblings/1]). | ||
|
||
%% @spec deps_on_path() -> [ProjNameAndVers] | ||
%% @doc List of project dependencies on the path. | ||
deps_on_path() -> | ||
F = fun (X, Acc) -> | ||
ProjDir = filename:dirname(X), | ||
case {filename:basename(X), | ||
filename:basename(filename:dirname(ProjDir))} of | ||
{"ebin", "deps"} -> | ||
[filename:basename(ProjDir) | Acc]; | ||
_ -> | ||
Acc | ||
end | ||
end, | ||
ordsets:from_list(lists:foldl(F, [], code:get_path())). | ||
|
||
%% @spec new_siblings(Module) -> [Dir] | ||
%% @doc Find new siblings paths relative to Module that aren't already on the | ||
%% code path. | ||
new_siblings(Module) -> | ||
Existing = deps_on_path(), | ||
SiblingEbin = filelib:wildcard(local_path(["deps", "*", "ebin"], Module)), | ||
Siblings = [filename:dirname(X) || X <- SiblingEbin, | ||
ordsets:is_element( | ||
filename:basename(filename:dirname(X)), | ||
Existing) =:= false], | ||
lists:filter(fun filelib:is_dir/1, | ||
lists:append([[filename:join([X, "ebin"]), | ||
filename:join([X, "include"])] || | ||
X <- Siblings])). | ||
|
||
|
||
%% @spec ensure(Module) -> ok | ||
%% @doc Ensure that all ebin and include paths for dependencies | ||
%% of the application for Module are on the code path. | ||
ensure(Module) -> | ||
code:add_paths(new_siblings(Module)), | ||
code:clash(), | ||
ok. | ||
|
||
%% @spec ensure() -> ok | ||
%% @doc Ensure that the ebin and include paths for dependencies of | ||
%% this application are on the code path. Equivalent to | ||
%% ensure(?Module). | ||
ensure() -> | ||
ensure(?MODULE). | ||
|
||
%% @spec get_base_dir(Module) -> string() | ||
%% @doc Return the application directory for Module. It assumes Module is in | ||
%% a standard OTP layout application in the ebin or src directory. | ||
get_base_dir(Module) -> | ||
{file, Here} = code:is_loaded(Module), | ||
filename:dirname(filename:dirname(Here)). | ||
|
||
%% @spec get_base_dir() -> string() | ||
%% @doc Return the application directory for this application. Equivalent to | ||
%% get_base_dir(?MODULE). | ||
get_base_dir() -> | ||
get_base_dir(?MODULE). | ||
|
||
%% @spec local_path([string()], Module) -> string() | ||
%% @doc Return an application-relative directory from Module's application. | ||
local_path(Components, Module) -> | ||
filename:join([get_base_dir(Module) | Components]). | ||
|
||
%% @spec local_path(Components) -> string() | ||
%% @doc Return an application-relative directory for this application. | ||
%% Equivalent to local_path(Components, ?MODULE). | ||
local_path(Components) -> | ||
local_path(Components, ?MODULE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
%% @author author <[email protected]> | ||
%% @copyright YYYY author. | ||
|
||
%% @doc Supervisor for the skel application. | ||
|
||
-module(skel_sup). | ||
-author('author <[email protected]>'). | ||
|
||
-behaviour(supervisor). | ||
|
||
%% External exports | ||
-export([start_link/0, upgrade/0]). | ||
|
||
%% supervisor callbacks | ||
-export([init/1]). | ||
|
||
%% @spec start_link() -> ServerRet | ||
%% @doc API for starting the supervisor. | ||
start_link() -> | ||
supervisor:start_link({local, ?MODULE}, ?MODULE, []). | ||
|
||
%% @spec upgrade() -> ok | ||
%% @doc Add processes if necessary. | ||
upgrade() -> | ||
{ok, {_, Specs}} = init([]), | ||
|
||
Old = sets:from_list( | ||
[Name || {Name, _, _, _} <- supervisor:which_children(?MODULE)]), | ||
New = sets:from_list([Name || {Name, _, _, _, _, _} <- Specs]), | ||
Kill = sets:subtract(Old, New), | ||
|
||
sets:fold(fun (Id, ok) -> | ||
supervisor:terminate_child(?MODULE, Id), | ||
supervisor:delete_child(?MODULE, Id), | ||
ok | ||
end, ok, Kill), | ||
|
||
[supervisor:start_child(?MODULE, Spec) || Spec <- Specs], | ||
ok. | ||
|
||
%% @spec init([]) -> SupervisorTree | ||
%% @doc supervisor callback. | ||
init([]) -> | ||
Ip = case os:getenv("MOCHIWEB_IP") of false -> "0.0.0.0"; Any -> Any end, | ||
WebConfig = [ | ||
{ip, Ip}, | ||
{port, 8000}, | ||
{docroot, skel_deps:local_path(["priv", "www"])}], | ||
Web = {skel_web, | ||
{skel_web, start, [WebConfig]}, | ||
permanent, 5000, worker, dynamic}, | ||
|
||
Processes = [Web], | ||
{ok, {{one_for_one, 10, 10}, Processes}}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
%% @author author <[email protected]> | ||
%% @copyright YYYY author. | ||
|
||
%% @doc Web server for skel. | ||
|
||
-module(skel_web). | ||
-author('author <[email protected]>'). | ||
|
||
-export([start/1, stop/0, loop/2]). | ||
|
||
%% External API | ||
|
||
start(Options) -> | ||
{DocRoot, Options1} = get_option(docroot, Options), | ||
Loop = fun (Req) -> | ||
?MODULE:loop(Req, DocRoot) | ||
end, | ||
mochiweb_http:start([{name, ?MODULE}, {loop, Loop} | Options1]). | ||
|
||
stop() -> | ||
mochiweb_http:stop(?MODULE). | ||
|
||
loop(Req, DocRoot) -> | ||
"/" ++ Path = Req:get(path), | ||
case Req:get(method) of | ||
Method when Method =:= 'GET'; Method =:= 'HEAD' -> | ||
case Path of | ||
_ -> | ||
Req:serve_file(Path, DocRoot) | ||
end; | ||
'POST' -> | ||
case Path of | ||
_ -> | ||
Req:not_found() | ||
end; | ||
_ -> | ||
Req:respond({501, [], []}) | ||
end. | ||
|
||
%% Internal API | ||
|
||
get_option(Option, Options) -> | ||
{proplists:get_value(Option, Options), proplists:delete(Option, Options)}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
cd `dirname $0` | ||
exec erl -pa $PWD/ebin $PWD/deps/*/ebin -boot start_sasl -s reloader -s skel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
cd `dirname $0` | ||
exec erl -pa $PWD/ebin $PWD/deps/*/ebin -boot start_sasl -s skel |
Oops, something went wrong.