Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 30c3ffbd83f856dff4951f2d3751f134efdf6eef @choptastic committed Dec 2, 2010
Showing with 2,755 additions and 0 deletions.
  1. +11 −0 .prototypes/action.erl
  2. +13 −0 .prototypes/element.erl
  3. +25 −0 .prototypes/page.erl
  4. +13 −0 Emakefile
  5. 0 ebin/.empty
  6. 0 include/records.hrl
  7. 0 src/actions/.ignore
  8. +34 −0 src/bindpostback.erl
  9. +22 −0 src/cluster.erl
  10. +17 −0 src/comet.erl
  11. +16 −0 src/effect.erl
  12. 0 src/elements/.ignore
  13. +13 −0 src/elements/element_canvas.erl
  14. +35 −0 src/index.erl
  15. +11 −0 src/live/basic.erl
  16. +21 −0 src/live/hello.erl
  17. +34 −0 src/loginbar.erl
  18. +27 −0 src/menubar.erl
  19. +7 −0 src/nitrogen_init.erl
  20. +8 −0 src/nitrogen_yaws.erl
  21. +23 −0 src/replace.erl
  22. +21 −0 src/replaceeffect.erl
  23. +90 −0 src/twitter.erl
  24. +23 −0 src/update.erl
  25. +139 −0 static/css/style.css
  26. BIN static/images/spinner.gif
  27. +534 −0 static/nitrogen/bert.js
  28. +374 −0 static/nitrogen/jquery-ui.js
  29. BIN static/nitrogen/jquery-ui/images/ui-anim_basic_16x16.gif
  30. BIN static/nitrogen/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png
  31. BIN static/nitrogen/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png
  32. BIN static/nitrogen/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png
  33. BIN static/nitrogen/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png
  34. BIN static/nitrogen/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png
  35. BIN static/nitrogen/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png
  36. BIN static/nitrogen/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png
  37. BIN static/nitrogen/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png
  38. BIN static/nitrogen/jquery-ui/images/ui-icons_222222_256x240.png
  39. BIN static/nitrogen/jquery-ui/images/ui-icons_2e83ff_256x240.png
  40. BIN static/nitrogen/jquery-ui/images/ui-icons_454545_256x240.png
  41. BIN static/nitrogen/jquery-ui/images/ui-icons_888888_256x240.png
  42. BIN static/nitrogen/jquery-ui/images/ui-icons_cd0a0a_256x240.png
  43. +10 −0 static/nitrogen/jquery-ui/jquery.ui.accordion.css
  44. +2 −0 static/nitrogen/jquery-ui/jquery.ui.all.css
  45. +34 −0 static/nitrogen/jquery-ui/jquery.ui.autocomplete.css
  46. +10 −0 static/nitrogen/jquery-ui/jquery.ui.base.css
  47. +35 −0 static/nitrogen/jquery-ui/jquery.ui.button.css
  48. +37 −0 static/nitrogen/jquery-ui/jquery.ui.core.css
  49. +61 −0 static/nitrogen/jquery-ui/jquery.ui.datepicker.css
  50. +13 −0 static/nitrogen/jquery-ui/jquery.ui.dialog.css
  51. +4 −0 static/nitrogen/jquery-ui/jquery.ui.progressbar.css
  52. +13 −0 static/nitrogen/jquery-ui/jquery.ui.resizable.css
  53. +17 −0 static/nitrogen/jquery-ui/jquery.ui.slider.css
  54. +11 −0 static/nitrogen/jquery-ui/jquery.ui.tabs.css
  55. +247 −0 static/nitrogen/jquery-ui/jquery.ui.theme.css
  56. +154 −0 static/nitrogen/jquery.js
  57. +29 −0 static/nitrogen/livevalidation.js
  58. +79 −0 static/nitrogen/nitrogen.css
  59. +456 −0 static/nitrogen/nitrogen.js
  60. BIN static/nitrogen/spinner.gif
  61. BIN static/nitrogen/spinner2.gif
  62. +32 −0 templates/bare.html
@@ -0,0 +1,11 @@
+%% -*- mode: nitrogen -*-
+-module (action_[[[NAME]]]).
+-compile (export_all).
+-include_lib ("nitrogen/include/wf.hrl").
+-include("records.hrl").
+
+%% Move the following line to records.hrl:
+-record([[[NAME]]], {?ACTION_BASE(action_[[[NAME]]]), attr1, attr2}).
+
+render_action(_Record = #[[[NAME]]]{}) ->
+ "alert('Hello, from [[[NAME]]]!');".
@@ -0,0 +1,13 @@
+%% -*- mode: nitrogen -*-
+-module (element_[[[NAME]]]).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+-include("records.hrl").
+
+%% Move the following line to records.hrl:
+-record([[[NAME]]], {?ELEMENT_BASE(element_[[[NAME]]]), attr1, attr2}).
+
+reflect() -> record_info(fields, [[[NAME]]]).
+
+render_element(_Record = #[[[NAME]]]{}) ->
+ "<b>Hello from [[[NAME]]]</b>".
@@ -0,0 +1,25 @@
+%% -*- mode: nitrogen -*-
+-module ([[[NAME]]]).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+-include("records.hrl").
+
+main() -> #template { file="./site/templates/bare.html" }.
+
+title() -> "Hello from [[[NAME]]].erl!".
+
+body() ->
+ [
+ #panel { style="margin: 50px 100px;", body=[
+ #span { text="Hello from [[[NAME]]].erl!" },
+
+ #p{},
+ #button { text="Click me!", postback=click },
+
+ #p{},
+ #panel { id=placeholder }
+ ]}
+ ].
+
+event(click) ->
+ wf:insert_top(placeholder, "<p>You clicked the button!").
@@ -0,0 +1,13 @@
+{
+ [
+ "./src/*",
+ "./src/*/*",
+ "./src/*/*/*",
+ "./src/*/*/*/*"
+ ],
+ [
+ { i, "./include" },
+ { outdir, "./ebin" },
+ debug_info
+ ]
+}.
No changes.
No changes.
No changes.
@@ -0,0 +1,34 @@
+-module(bindpostback).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+main() -> #template{file="site/templates/bare.html"}.
+
+title() -> "Data binding with postback demo".
+
+get_data() ->
+ [{"Apples","5"},{"Bananas","4"},{"Oranges","6"}].
+
+body() ->
+ Data = get_data(),
+ Map = {fruit@body,qty@body},
+ #table{rows=[
+ #bind{data=Data,map=Map,transform=fun format_data/2,body=[
+ #tablerow{cells=[
+ #tablecell{id=fruit},
+ #tablecell{id=qty},
+ #tablecell{body=#link{id=wishlist,text="Wishlist"}},
+ #tablecell{body=#link{id=buy,text="Add to Cart"}}
+ ]}
+ ]}
+ ]}.
+
+format_data({Fruit,_} = DataRow,Acc) ->
+ {DataRow,Acc,[{wishlist@postback,{wishlist,Fruit}},{buy@postback,{buy,Fruit}}]}.
+
+event({Action,Name}) ->
+ wf:info({Action,Name}),
+ CurList = wf:session_default(Action,[]),
+ NewList = [Name | CurList],
+ wf:session(Action,NewList),
+ wf:wire(#alert{text=wf:f("New ~p: ~p",[Action,NewList])}).
@@ -0,0 +1,22 @@
+-module (cluster).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+-include("records.hrl").
+
+main() -> #template { file="./site/templates/bare.html" }.
+
+title() -> "Clustering Demo".
+
+body() ->
+ Counter = case wf:session(counter) of
+ undefined -> 0;
+ N -> N
+ end,
+ wf:session(counter,Counter + 1),
+ [
+ "Node: ",wf:to_list(node()),
+ #br{},
+ wf:to_list(Counter),#br{}
+ ].
+
+event(_) -> ok.
@@ -0,0 +1,17 @@
+-module(comet).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+main() -> #template{file="site/templates/bare.html"}.
+
+title() -> "Simple Comet Example".
+
+body() ->
+ wf:comet(fun()-> count(0) end),
+ ["Counter: ",#span{id=countspan}].
+
+count(Counter) ->
+ timer:sleep(1000),
+ wf:update(countspan,"blah" ++ wf:to_list(Counter)),
+ wf:flush(), % flush commands to browser
+ ?MODULE:count(Counter + 1).
@@ -0,0 +1,16 @@
+-module(effect).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+main() -> #template{file="site/templates/bare.html"}.
+
+title() -> "Effect demo".
+
+body() ->
+ wf:wire(doit,effected,#event{
+ type=click,actions=#effect{effect=shake}
+ }),
+ [
+ #panel{id=effected,body="Doing Something"},
+ #button{id=doit,text="Do it"}
+ ].
No changes.
@@ -0,0 +1,13 @@
+%% -*- mode: nitrogen -*-
+-module (element_canvas).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+-include("records.hrl").
+
+%% Move the following line to records.hrl:
+-record(canvas, {?ELEMENT_BASE(element_canvas), attr1, attr2}).
+
+reflect() -> record_info(fields, canvas).
+
+render_element(_Record = #canvas{}) ->
+ "<b>Hello from canvas</b>".
@@ -0,0 +1,35 @@
+%% -*- mode: nitrogen -*-
+-module (index).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+main() -> #template { file="./site/templates/bare.html" }.
+
+title() -> "Welcome to Nitrogen".
+
+body() ->
+ #container_12 { body=[
+ #grid_8 { alpha=true, prefix=2, suffix=2, omega=true, body=inner_body() }
+ ]}.
+
+inner_body() ->
+ [
+ #h1 { text="Welcome to Nitrogen" },
+ #p{},
+ "
+ If you can see this page, then your Nitrogen server is up and
+ running. Click the button below to test postbacks.
+ ",
+ #p{},
+ #button { id=button, text="Click me!", postback=click },
+ #p{},
+ "
+ Run <b>./bin/dev help</b> to see some useful developer commands.
+ "
+ ].
+
+event(click) ->
+ wf:replace(button, #panel {
+ body="You clicked the button!",
+ actions=#effect { effect=highlight }
+ }).
@@ -0,0 +1,11 @@
+-module(basic).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+main() -> #template{file="site/templates/bare.html"}.
+
+title() -> "".
+
+body() -> ok.
+
+event(_) -> ok.
@@ -0,0 +1,21 @@
+-module(hello).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+main() -> #template{file="site/templates/bare.html"}.
+
+body() ->
+ wf:wire(whatever,field,#validate{validators=[
+ #is_required{text="Please enter something"}
+ ]}),
+ [
+ #textbox{id=field,class=textbox,text="Something"},
+ #button{id=whatever,text="Click ME",postback=clicked}
+ ].
+
+
+
+
+event(clicked) ->
+ FieldValue = wf:q(field),
+ wf:wire(#alert{text=FieldValue}).
@@ -0,0 +1,34 @@
+-module(loginbar).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+logged_in(U) -> [
+ #span{class=user,text=U},
+ " | ",
+ #link{postback=logout,delegate=?MODULE,text="Log Out"}
+].
+
+logged_out() -> [
+ #textbox{id=login,text="Your Name"},
+ #button{postback=login,delegate=?MODULE,text="Log In"}
+].
+
+login_body() ->
+ case wf:user() of
+ undefined -> logged_out();
+ U -> logged_in(U)
+ end.
+
+loginbar() ->
+ #panel{id=loginbox,body=login_body()}.
+
+event(login) ->
+ Login = wf:q(login),
+ wf:user(Login),
+ wf:update(loginbox,login_body()),
+ menubar:update();
+event(logout) ->
+ wf:logout(),
+ wf:update(loginbox,login_body()),
+ menubar:update().
+
@@ -0,0 +1,27 @@
+-module(menubar).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+menu() ->
+ Data = case wf:user() of
+ undefined -> [];
+ _ -> [
+ {"/update","Update"},
+ {"/replace","Replace"},
+ {"/replaceeffect","Replace with Effect"},
+ {"/effect","Effect"},
+ {"/cluster","Clustering"},
+ {"/comet","Comet"},
+ {"/bindpostback","Advanced Bind"},
+ {"/twitter","Twitter Search"}
+ ]
+ end,
+ Map = {menulink@url,menulink@text},
+ #bind{data=Data,map=Map,empty_body="Log In for Menu",body=[
+ #list{class=menu,body=[
+ #listitem{body=#link{id=menulink}}
+ ]}
+ ]}.
+
+update() ->
+ wf:update("div.menu",menu()).
@@ -0,0 +1,7 @@
+-module(nitrogen_init).
+-export ([init/0]).
+
+%% Called during application startup.
+%% Put other initialization code here.
+init() ->
+ application:start(nprocreg).
@@ -0,0 +1,8 @@
+-module(nitrogen_yaws).
+-export ([out/1]).
+
+out(Arg) ->
+ RequestBridge = simple_bridge:make_request(yaws_request_bridge, Arg),
+ ResponseBridge = simple_bridge:make_response(yaws_response_bridge, Arg),
+ nitrogen:init_request(RequestBridge, ResponseBridge),
+ nitrogen:run().
@@ -0,0 +1,23 @@
+-module(replace).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+main() -> #template{file="site/templates/bare.html"}.
+
+
+title() -> "Update Demo".
+
+body() ->
+ #panel{id=wrapper,body=[
+ "Click below<br />",
+ #button{id=but,text="Click Me!",postback=replace}
+ ]}.
+
+event(replace) ->
+ wf:replace(but,[
+ "You clicked it<br />",
+ #link{
+ url="http://erlang.org",
+ text="Here's Erlang"
+ }
+ ]).
@@ -0,0 +1,21 @@
+-module(replaceeffect).
+-compile(export_all).
+-include_lib("nitrogen/include/wf.hrl").
+
+main() -> #template{file="site/templates/bare.html"}.
+
+
+title() -> "Update Demo".
+
+
+body() ->
+ #button{id=but,text="Click Me!",postback=replace}.
+
+event(replace) ->
+ wf:replace(but,
+ #link{
+ url="http://erlang.org",
+ text="Here's Erlang",
+ actions=#show{effect=puff}
+ }
+ ).
Oops, something went wrong.

0 comments on commit 30c3ffb

Please sign in to comment.