forked from synrc/mad
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
26 changed files
with
178 additions
and
214 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
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,34 @@ | ||
[ | ||
%% DISPATCH RULE: {"URL MATCH" , handler, opts()} | ||
|
||
%% cowboy static handler, here single file access. | ||
{ "/favicon.ico", cowboy_static, {priv_file, {{appid}}, "static/favicon.ico"}} | ||
|
||
%% naga static handler, support gz compression, just gzip your static file | ||
%% you need to keep uncompressed version and a compression version in your static folder, according to client capabiliti | ||
%% the according version will be serve either from disk or memory | ||
,{ "/n2o/[...]", naga_static, { dir, "deps/n2o/priv", [ { mimetypes, cow_mimetypes, all } ] }} | ||
,{ "/{{appid}}/static/[...]", naga_static, { dir, "deps/{{appid}}/priv", [ { mimetypes, cow_mimetypes, all } ] }} | ||
|
||
%% naga convenient handler. | ||
,{"/$v/[...]", naga_indexof, { {{appid}},view,"/$v"}} | ||
%,{"/$c/[...]", naga_indexof, { {{appid}},controller,"/$c"}} | ||
,{"/$s/[...]", naga_indexof, { {{appid}},static,"/$s"}} | ||
|
||
|
||
%% YOUR RULES: dispatch {url/path}|code => application/controller/action | ||
%% no support for regex in url/path | ||
%% app is default alias for application | ||
%% ctrl is default alias for controller | ||
%% act is default alias for action | ||
%% you can redefine alias add in naga config section using | ||
%% {def_application, a}, | ||
%% {def_controller, c} | ||
%% {def_action, ac} where a,c,ac are atom | ||
|
||
,{ "/index", [{app, {{appid}} },{ctrl, index},{action,index}], []} | ||
,{ "/", [{app, {{appid}} },{ctrl, index},{action,index},{id, 42}], []} | ||
|
||
,{ 404, [{application, {{appid}} },{controller, error}, {action, '404'}], []} | ||
,{ 500, [{application, {{appid}} },{controller, error}, {action, '500'}], []} | ||
]. |
File renamed without changes.
File renamed without changes.
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 @@ | ||
-module(index). | ||
-export([index/3, event/1]). | ||
-default_action(index). | ||
-actions([index]). | ||
|
||
-include_lib("n2o/include/wf.hrl"). | ||
-include_lib("nitro/include/nitro.hrl"). | ||
-include_lib("naga/include/naga.hrl"). | ||
|
||
index(<<"GET">>, _, _) -> | ||
{ok, [{msg, "Hello World!!!!! "}]}. | ||
|
||
event(Event) -> | ||
wf:info(?MODULE,"Unknown Event: ~p~n",[Event]). |
4 changes: 2 additions & 2 deletions
4
priv/basic/project.app.src → priv/basic/apps/project/src/project.app.src
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
-module(error). | ||
-compile(export_all). | ||
-include_lib("n2o/include/wf.hrl"). | ||
-include_lib("nitro/include/nitro.hrl"). | ||
|
||
'404'(_, _, _) -> {ok, [{msg, "404 Not Found"}]}. | ||
|
||
event(Event) -> wf:info(?MODULE,"Unknown Event: ~p~n",[Event]). |
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 @@ | ||
-module(index). | ||
-export([index/3, event/1]). | ||
-default_action(index). | ||
-actions([index]). | ||
|
||
-include_lib("n2o/include/wf.hrl"). | ||
-include_lib("nitro/include/nitro.hrl"). | ||
-include_lib("naga/include/naga.hrl"). | ||
|
||
index(<<"GET">>, _, _) -> | ||
{ok, [{msg, "Hello World!!!!! "}]}. | ||
|
||
event(Event) -> | ||
wf:info(?MODULE,"Unknown Event: ~p~n",[Event]). |
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,4 @@ | ||
{% extend "layout/page.html" %} | ||
{% block body %} | ||
{{msg}} | ||
{% endblock %} |
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 @@ | ||
{% extends "layout/page.html" %} | ||
|
||
{% block body %} | ||
{{msg}} | ||
<br/> | ||
{{_session_id}} | ||
<br> | ||
{{_app}} | ||
<br> | ||
{{_action}} | ||
<br> | ||
{{_controller}} | ||
{% endblock %} | ||
|
11 changes: 6 additions & 5 deletions
11
priv/basic/project_priv_templates_index.html → priv/basic/project/src/view/layout/n2o.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 |
---|---|---|
@@ -1,20 +1,21 @@ | ||
<html> | ||
<head> | ||
<link href="/static/synrc.css" type="text/css" rel="stylesheet"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>{{title}}</title> | ||
</head> | ||
<body> | ||
{{body}} | ||
<script>{{script}}</script> | ||
hello layout n2o <br> | ||
{% block body %} {% endblock %} | ||
<script>{{script}}</script> | ||
<script src='/n2o/protocols/bert.js'></script> | ||
<script src='/n2o/protocols/client.js'></script> | ||
<script src='/n2o/protocols/nitrogen.js'></script> | ||
<script src='/n2o/validation.js'></script> | ||
<script src='/n2o/bullet.js'></script> | ||
<script src='/n2o/xhr.js'></script> | ||
<script src='/n2o/utf8.js'></script> | ||
<script src='/n2o/template.js'></script> | ||
<script src='/n2o/n2o.js'></script> | ||
<script>protos = [ $bert, $client ]; N2O_start();</script> | ||
<script src='/n2o/validation.js'></script> | ||
<script>protos = [$client,$bert]; N2O_start();</script> | ||
</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,10 @@ | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>{{title}}</title> | ||
</head> | ||
<body> | ||
hello layout page <br> | ||
{% block body %} {% endblock %} | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{sub_dirs,["apps"]}. | ||
{deps_dir,"deps"}. | ||
{deps, [ | ||
{lager, ".*", {git, "https://github.com/basho/lager", {tag, "3.0.1"} }}, | ||
{deps, [ | ||
{naga, ".*", {git, "git://github.com/naga-framework/naga", {tag, "master"} }} | ||
]}. | ||
|
Oops, something went wrong.