Commits

Arjan Scherpenisse  committed f11d034

Moved mod_test's templates, dispatch and resources into testsandbox.

- Used lib tag for adding stylesheets and added missing ones
- Moved koe.jpg into testsandbox site
- Fixed confirm postback

Fixes issue 79

  • Participants
  • Parent commits 7bd358e

Comments (0)

Files changed (17)

File modules/mod_test/dispatch/testing

-[
-%% Just for testing
-{helloworld, ["helloworld"], resource_template, [{template, "helloworld.tpl"}, {anonymous, true}]},
-{test,       ["test"],       resource_test_helloworld,        []}
-].

File modules/mod_test/mod_test.erl

-%% @author Marc Worrell <marc@worrell.nl>
-%% @copyright 2009 Marc Worrell
-%% @date 2009-06-03
-%% @doc Simple module for testing the module system.
-
-%% Copyright 2009 Marc Worrell
-%%
-%% 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(mod_test).
--author("Marc Worrell <marc@worrell.nl>").
-
--mod_title("Test module").
--mod_description("Simple tests - no need to enable this module.").
--mod_prio(1000).

File modules/mod_test/resources/resource_test_helloworld.erl

-%% @author author <author@example.com>
-%% @copyright YYYY author.
-%% @doc Example webmachine_resource.
-
--module(resource_test_helloworld).
--export([event/2, periodic/2]).
-
--include_lib("resource_html.hrl").
-
-html(Context) ->
-    {Incr, Context2} = z_context:incr_session(helloworld_counter, 1, Context),
-    Html = z_template:render("test_helloworld.tpl", [{helloworld_counter,Incr}], Context2),
-    % Html = z_template:render("idtest.tpl", Context2),
-    % _Pid = z_context:spawn_link_page(?MODULE, periodic, [], Context3),
-    z_context:output(Html, Context2).
-
-
-event({postback, show_confirm, _TriggerId, _TargetId}, Context) ->
-    z_render:wire({confirm, [{text,"This is a Javascript Confirm"},{postback,confirm_ok}]}, Context);
-event({postback, show_alert, _TriggerId, _TargetId}, Context) ->
-    z_render:wire({alert, [{text,"This is a Javascript Alert"}]}, Context);
-event({postback, confirm_ok, _TriggerId, _TargetId}, Context) ->
-    z_render:wire({alert, [{text,"You confirmed"}]}, Context);
-event({postback, show_growl, _TriggerId, _TargetId}, Context) ->
-    z_render:wire({growl, [{text,"This is a Growl Alert that disappears automatically after some time."}]}, Context);
-event({postback, show_growl_stay, _TriggerId, _TargetId}, Context) ->
-    z_render:wire({growl, [{text,"This is a Growl Alert that stays until you close it."},{stay,1}]}, Context);
-
-event({postback, fill_content, _TriggerId, _TargetId}, Context) ->
-    z_render:update("content", "Hello World<br/>", Context);
-event({postback, insert_top, _TriggerId, _TargetId}, Context) ->
-    z_render:insert_top("content", "At the top<br/>", Context);
-event({postback, insert_bottom, _TriggerId, _TargetId}, Context) ->
-    z_render:insert_bottom("content", "At the bottom<br/>", Context);
-
-event({drop, Drag, Drop}, Context) ->
-    z_render:wire({growl, [{text,["You dropped ",Drag#dragdrop.tag," on ",Drop#dragdrop.tag]}]}, Context);
-event({drag, Drag, Drop}, Context) ->
-    z_render:wire({growl, [{text,["You dragged ",Drag#dragdrop.tag," to ",Drop#dragdrop.tag]}]}, Context);
-
-event({sort, Drags, Drop}, Context) ->
-    DragIds = [ Id || #dragdrop{id=Id} <- Drags],
-    Msg = io_lib:format("Result ~p on ~p",[DragIds,Drop#dragdrop.id]),
-    z_render:wire({growl, [{text,Msg}]}, Context);
-
-event({submit, _Tag, _FormId, _TargetId}, Context) ->
-    Email = z_context:get_q_validated("email", Context),
-    z_render:wire({growl, [{text,["You posted a valid email address \"",Email,"\""]}]}, Context);
-    
-event(Event, Context) ->
-    Error = io_lib:format("~p: unknown event ~p", [?MODULE,Event]),
-    z_render:wire({growl, [{text,Error},{stay,1}]}, Context).
-
-
-
-periodic(_Args, Context) ->
-    Date = httpd_util:rfc1123_date(),
-    z_context:add_script_session([<<"z_growl_add('According to the server, the Universal Sprout Time is now<br/><strong>">>,Date,<<"</strong>', 0);">>], Context),
-    timer:sleep(10000),
-    ?MODULE:periodic([], Context).
-
-
-    

File modules/mod_test/templates/catinclude_test.person.tpl

-<p>Person: {{ m.rsc[id].title }}</p>

File modules/mod_test/templates/catinclude_test.tpl

-<p>Something else for id:{{ id|format_integer }}</p>

File modules/mod_test/templates/helloworld.tpl

-Hello World!

File modules/mod_test/templates/test_helloworld.tpl

-<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
-<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\">
-    <head>
-        <title>zotonic</title>
-
-		<link href="/lib/css/zp-base.css" type="text/css" media="screen" rel="stylesheet" /> 
-		<link href="/lib/css/zp-type.css" type="text/css" media="screen" rel="stylesheet" /> 
-		<link href="/lib/css/zp-forms.css" type="text/css" media="screen" rel="stylesheet" /> 
-		<link href="/lib/css/zp-project.css" type="text/css" media="screen" rel="stylesheet" /> 
-
-		<!--[if IE]><link href="/lib/css/zp-ie.css" type="text/css" media="screen" rel="stylesheet" /><![endif]--> 
-    </head>
-
-    <body>
-		{% wire type="unload" action={alert text="Bye"} %}
-		<div class="zp-wrapper"> 
-	        <h1>Hello, new world {{ helloworld_counter }}</h1>
-		
-			<div class="zp-50 content"> 
-				<div class="padding"> 
-
-					<h2>The menu should be below</h2>
-					
-					{% menu %}
-
-					<h2>Postbacks which give some content</h2>
-					<p>
-						{% button text="Fill the content div" postback="fill_content"  %}
-						{% button text="Insert Top" postback="insert_top"  %}
-						{% button text="Insert Bottom" postback="insert_bottom" %}
-					</p>
-	
-					<div class="clear"></div>
-
-					<div id="content" style="border: 1px solid green; padding: 10px; width: 100px">
-						This is the content div
-					</div>
-		
-					<h2>Some drag/drop testing</h2>
-
-					{% draggable id="drag1" tag="drag1" %}
-					<div id="drag1" style="border: 2px solid #c33; background-color: #e99; padding: 10px; width: 100px; height: 50px">
-						<p>
-							Drag Me
-						</p>
-					</div>
-		
-					<div class="clear">&nbsp;</div>
-
-					{% droppable id="drop1" tag="drop1" %}
-					<div id="drop1" style="border: 2px solid #3c3; background-color: #9e9; padding: 10px; width: 100px; height: 50px">
-						<p>
-							Drop Here
-						</p>
-					</div>
-
-					<h2>Sorter and sortables</h2>
-
-					<div id="sort" class="padding">
-						<div id="s1">
-							<p>sortable 1</p>
-						</div>
-						<div id="s2">
-							<p>sortable 2</p>
-						</div>
-						<div id="s3">
-							<p>sortable 3</p>
-						</div>
-						<div id="s4">
-							<p>sortable 4</p>
-						</div>
-						<div id="s5">
-							<p>sortable 5</p>
-						</div>
-					</div>
-
-					{% sorter id="sort" %}
-					{% sortable id="s1" %}
-					{% sortable id="s2" %}
-					{% sortable id="s3" %}
-					{% sortable id="s4" %}
-					{% sortable id="s5" %}
-					
-					<h2>Some effects</h2>
-					
-					<div class="zp-20">
-						{% button text="Hide" action={hide target="ef"} %}
-						{% button text="Show" action={show target="ef"} %}<br/><br/>
-						{% button text="Fade" action={fade_out target="ef"} %}
-						{% button text="Appear" action={fade_in target="ef"} %}<br/><br/>
-						{% button text="Toggle" action={toggle target="ef"} %}<br/><br/>
-						
-						<a id="tgl" href="#">wired toggle</a>
-						{% wire id="tgl" action={toggle target="ef"} %}
-					</div>
-
-					<div class="zp-40">
-						<div id="ef" style="border:1px solid black; background-color: #99c; padding: 10px">
-							<p>Use the buttons on the left to test different effects on this div.</p>
-						</div>
-					</div>
-
-				</div>
-			</div>
-
-			<div class="zp-50"> 
-				<div class="padding"> 
-					<h2>Some postbacks</h2>
-
-					<h3>Javascript confirm</h3>
-					<p>
-						{% button text="Show Confirm" postback="show_confirm" %}<br/><br/>
-					</p>
-				
-					<h3>Growl</h3>
-					<p>
-						{% button text="Show Temporary Growl" postback="show_growl"  %}<br/><br/>
-						{% button text="Show Permanent Growl" postback="show_growl_stay" %}<br/><br/>
-					</p>
-					
-					<hr/>
-					
-					<h2>Form validation</h2>
-				
-					{% wire id="myform" type="submit" postback="some_tag" action={toggle target="ef"} %}
-					<form id="myform" method="POST" action="postback">
-					{# You could also use: delegate="module_handling_form" #}
-
-						<label for="email">e-mail</label>
-						<input type="text" id="email" name="email" value="" />
-						{% validate id="email" type={presence} type={email} %}
-						
-						<div class="clear"></div>
-						<button type="submit">Submit</button>
-						<div class="clear"></div>
-
-					</form>
-
-					<h2>Redirect to somewhere</h2>
-					
-					{% button text="Redirect to /" action={redirect location="/"} %}
-				</div>
-			</div>
-		</div>
-		
-		<hr/>
-		
-		<div class="zp-wrapper">
-			<div class="padding">
-				<h2>Dynamic id with <tt>#id</tt></h2>
-
-				{{ #id }}
-
-				{% button id=#id %}
-				<div class="clear"></div>
-
-				<h2>Cached include</h2>
-
-				<p>Include below is cached for 10 seconds</p>
-				
-				{% include "test_included.tpl" maxage=10 %}
-
-				<h2>Some images</h2>
-
-				<p>
-				{% image "koe.jpg" width=200 height=200 crop="east" mono blur style="border: 1px solid black" %}
-				{% image "koe.jpg" width=200 height=200 crop style="border: 1px solid black" %}
-				{% image "koe.jpg" width=200 height=200 crop="west" blur="20x8" style="border: 1px solid black" %}
-				</p>
-
-				<div class="clear"></div>
-
-				<p>
-				{% image "koe.jpg" width=200 height=200 crop="east" grey style="border: 1px solid black" %}
-				{% image "koe.jpg" width=200 height=200 crop style="border: 1px solid black" %}
-				{% image "koe.jpg" width=200 height=200 crop="west" grey blur="20x8" style="border: 1px solid black" %}
-				</p>
-
-				<div class="clear"></div>
-
-				<h3>And the url of an image</h3>
-
-				{% image_url "koe.jpg" width=400 crop="east" blur grey %}
-
-				<h2>Id test (cont)</h2>
-
-				And the id of above again: {{ #id }}
-				
-				<h2>catinclude test</h2>
-				
-				<p><strong>A person</strong></p>
-				{% catinclude "catinclude_test.tpl" 1 %}
-
-				<p><strong>Not a person</strong></p>
-				{% catinclude "catinclude_test.tpl" 2 %}
-
-				<h2>all catinclude test</h2>
-				
-				{% all catinclude "catinclude_test.tpl" 1 %}
-			</div>
-		</div>
-
-		{% include "_js_include.tpl" %}
-		{% script %}
-
-    </body>
-</html>

File modules/mod_test/templates/test_included.tpl

-<p>Hello I have been included on {% now "jS F Y H:i:s" %} </p>
-
-Id in the include: {{ #id }}

File priv/sites/testsandbox/dispatch/testing

+[
+%% Just for testing
+{helloworld, ["helloworld"], resource_template, [{template, "helloworld.tpl"}, {anonymous, true}]},
+{test,       ["test"],       resource_test_helloworld,        []}
+].

File priv/sites/testsandbox/files/archive/koe.jpg

Added
New image

File priv/sites/testsandbox/resources/resource_test_helloworld.erl

+%% @author author <author@example.com>
+%% @copyright YYYY author.
+%% @doc Example webmachine_resource.
+
+-module(resource_test_helloworld).
+-export([event/2, periodic/2]).
+
+-include_lib("resource_html.hrl").
+
+html(Context) ->
+    {Incr, Context2} = z_context:incr_session(helloworld_counter, 1, Context),
+    Html = z_template:render("test_helloworld.tpl", [{helloworld_counter,Incr}], Context2),
+    % Html = z_template:render("idtest.tpl", Context2),
+    % _Pid = z_context:spawn_link_page(?MODULE, periodic, [], Context3),
+    z_context:output(Html, Context2).
+
+
+event({postback, show_confirm, _TriggerId, _TargetId}, Context) ->
+    z_render:wire({confirm, [{text,"This is a Javascript Confirm"},{postback,confirm_ok}, {delegate, ?MODULE}]}, Context);
+event({postback, show_alert, _TriggerId, _TargetId}, Context) ->
+    z_render:wire({alert, [{text,"This is a Javascript Alert"}]}, Context);
+event({postback, confirm_ok, _TriggerId, _TargetId}, Context) ->
+    z_render:wire({alert, [{text,"You confirmed"}]}, Context);
+event({postback, show_growl, _TriggerId, _TargetId}, Context) ->
+    z_render:wire({growl, [{text,"This is a Growl Alert that disappears automatically after some time."}]}, Context);
+event({postback, show_growl_stay, _TriggerId, _TargetId}, Context) ->
+    z_render:wire({growl, [{text,"This is a Growl Alert that stays until you close it."},{stay,1}]}, Context);
+
+event({postback, fill_content, _TriggerId, _TargetId}, Context) ->
+    z_render:update("content", "Hello World<br/>", Context);
+event({postback, insert_top, _TriggerId, _TargetId}, Context) ->
+    z_render:insert_top("content", "At the top<br/>", Context);
+event({postback, insert_bottom, _TriggerId, _TargetId}, Context) ->
+    z_render:insert_bottom("content", "At the bottom<br/>", Context);
+
+event({drop, Drag, Drop}, Context) ->
+    z_render:wire({growl, [{text,["You dropped ",Drag#dragdrop.tag," on ",Drop#dragdrop.tag]}]}, Context);
+event({drag, Drag, Drop}, Context) ->
+    z_render:wire({growl, [{text,["You dragged ",Drag#dragdrop.tag," to ",Drop#dragdrop.tag]}]}, Context);
+
+event({sort, Drags, Drop}, Context) ->
+    DragIds = [ Id || #dragdrop{id=Id} <- Drags],
+    Msg = io_lib:format("Result ~p on ~p",[DragIds,Drop#dragdrop.id]),
+    z_render:wire({growl, [{text,Msg}]}, Context);
+
+event({submit, _Tag, _FormId, _TargetId}, Context) ->
+    Email = z_context:get_q_validated("email", Context),
+    z_render:wire({growl, [{text,["You posted a valid email address \"",Email,"\""]}]}, Context);
+    
+event(Event, Context) ->
+    Error = io_lib:format("~p: unknown event ~p", [?MODULE,Event]),
+    z_render:wire({growl, [{text,Error},{stay,1}]}, Context).
+
+
+
+periodic(_Args, Context) ->
+    Date = httpd_util:rfc1123_date(),
+    z_context:add_script_session([<<"z_growl_add('According to the server, the Universal Sprout Time is now<br/><strong>">>,Date,<<"</strong>', 0);">>], Context),
+    timer:sleep(10000),
+    ?MODULE:periodic([], Context).
+
+
+    

File priv/sites/testsandbox/templates/catinclude_test.person.tpl

+<p>Person: {{ m.rsc[id].title }}</p>

File priv/sites/testsandbox/templates/catinclude_test.tpl

+<p>Something else for id:{{ id|format_integer }}</p>

File priv/sites/testsandbox/templates/helloworld.tpl

+Hello World!

File priv/sites/testsandbox/templates/test_helloworld.tpl

+<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
+<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\">
+    <head>
+        <title>zotonic</title>
+
+        {% lib 
+        "/css/zp-base.css"
+        "/css/zp-type.css"
+        "/css/zp-forms.css"
+        "/css/zp-project.css"
+        "/css/zp-growl.css" 
+        "/css/zp-dialog.css" 
+        %}
+
+		<!--[if IE]><link href="/lib/css/zp-ie.css" type="text/css" media="screen" rel="stylesheet" /><![endif]--> 
+    </head>
+
+    <body>
+		{% wire type="unload" action={alert text="Bye"} %}
+		<div class="zp-wrapper"> 
+	        <h1>Hello, new world {{ helloworld_counter }}</h1>
+		
+			<div class="zp-50 content"> 
+				<div class="padding"> 
+
+					<h2>The menu should be below</h2>
+					
+					{% menu %}
+
+					<h2>Postbacks which give some content</h2>
+					<p>
+						{% button text="Fill the content div" postback="fill_content"  %}
+						{% button text="Insert Top" postback="insert_top"  %}
+						{% button text="Insert Bottom" postback="insert_bottom" %}
+					</p>
+	
+					<div class="clear"></div>
+
+					<div id="content" style="border: 1px solid green; padding: 10px; width: 100px">
+						This is the content div
+					</div>
+		
+					<h2>Some drag/drop testing</h2>
+
+					{% draggable id="drag1" tag="drag1" %}
+					<div id="drag1" style="border: 2px solid #c33; background-color: #e99; padding: 10px; width: 100px; height: 50px">
+						<p>
+							Drag Me
+						</p>
+					</div>
+		
+					<div class="clear">&nbsp;</div>
+
+					{% droppable id="drop1" tag="drop1" %}
+					<div id="drop1" style="border: 2px solid #3c3; background-color: #9e9; padding: 10px; width: 100px; height: 50px">
+						<p>
+							Drop Here
+						</p>
+					</div>
+
+					<h2>Sorter and sortables</h2>
+
+					<div id="sort" class="padding">
+						<div id="s1">
+							<p>sortable 1</p>
+						</div>
+						<div id="s2">
+							<p>sortable 2</p>
+						</div>
+						<div id="s3">
+							<p>sortable 3</p>
+						</div>
+						<div id="s4">
+							<p>sortable 4</p>
+						</div>
+						<div id="s5">
+							<p>sortable 5</p>
+						</div>
+					</div>
+
+					{% sorter id="sort" %}
+					{% sortable id="s1" %}
+					{% sortable id="s2" %}
+					{% sortable id="s3" %}
+					{% sortable id="s4" %}
+					{% sortable id="s5" %}
+					
+					<h2>Some effects</h2>
+					
+					<div class="zp-20">
+						{% button text="Hide" action={hide target="ef"} %}
+						{% button text="Show" action={show target="ef"} %}<br/><br/>
+						{% button text="Fade" action={fade_out target="ef"} %}
+						{% button text="Appear" action={fade_in target="ef"} %}<br/><br/>
+						{% button text="Toggle" action={toggle target="ef"} %}<br/><br/>
+						
+						<a id="tgl" href="#">wired toggle</a>
+						{% wire id="tgl" action={toggle target="ef"} %}
+					</div>
+
+					<div class="zp-40">
+						<div id="ef" style="border:1px solid black; background-color: #99c; padding: 10px">
+							<p>Use the buttons on the left to test different effects on this div.</p>
+						</div>
+					</div>
+
+				</div>
+			</div>
+
+			<div class="zp-50"> 
+				<div class="padding"> 
+					<h2>Some postbacks</h2>
+
+					<h3>Javascript confirm</h3>
+					<p>
+						{% button text="Show Confirm" postback="show_confirm" %}<br/><br/>
+					</p>
+				
+					<h3>Growl</h3>
+					<p>
+						{% button text="Show Temporary Growl" postback="show_growl"  %}<br/><br/>
+						{% button text="Show Permanent Growl" postback="show_growl_stay" %}<br/><br/>
+					</p>
+					
+					<hr/>
+					
+					<h2>Form validation</h2>
+				
+					{% wire id="myform" type="submit" postback="some_tag" action={toggle target="ef"} %}
+					<form id="myform" method="POST" action="postback">
+					{# You could also use: delegate="module_handling_form" #}
+
+						<label for="email">e-mail</label>
+						<input type="text" id="email" name="email" value="" />
+						{% validate id="email" type={presence} type={email} %}
+						
+						<div class="clear"></div>
+						<button type="submit">Submit</button>
+						<div class="clear"></div>
+
+					</form>
+
+					<h2>Redirect to somewhere</h2>
+					
+					{% button text="Redirect to /" action={redirect location="/"} %}
+				</div>
+			</div>
+		</div>
+		
+		<hr/>
+		
+		<div class="zp-wrapper">
+			<div class="padding">
+				<h2>Dynamic id with <tt>#id</tt></h2>
+
+				{{ #id }}
+
+				{% button id=#id %}
+				<div class="clear"></div>
+
+				<h2>Cached include</h2>
+
+				<p>Include below is cached for 10 seconds</p>
+				
+				{% include "test_included.tpl" maxage=10 %}
+
+				<h2>Some images</h2>
+
+				<p>
+				{% image "koe.jpg" width=200 height=200 crop="east" mono blur style="border: 1px solid black" %}
+				{% image "koe.jpg" width=200 height=200 crop style="border: 1px solid black" %}
+				{% image "koe.jpg" width=200 height=200 crop="west" blur="20x8" style="border: 1px solid black" %}
+				</p>
+
+				<div class="clear"></div>
+
+				<p>
+				{% image "koe.jpg" width=200 height=200 crop="east" grey style="border: 1px solid black" %}
+				{% image "koe.jpg" width=200 height=200 crop style="border: 1px solid black" %}
+				{% image "koe.jpg" width=200 height=200 crop="west" grey blur="20x8" style="border: 1px solid black" %}
+				</p>
+
+				<div class="clear"></div>
+
+				<h3>And the url of an image</h3>
+
+				{% image_url "koe.jpg" width=400 crop="east" blur grey %}
+
+				<h2>Id test (cont)</h2>
+
+				And the id of above again: {{ #id }}
+				
+				<h2>catinclude test</h2>
+				
+				<p><strong>A person</strong></p>
+				{% catinclude "catinclude_test.tpl" 1 %}
+
+				<p><strong>Not a person</strong></p>
+				{% catinclude "catinclude_test.tpl" 2 %}
+
+				<h2>all catinclude test</h2>
+				
+				{% all catinclude "catinclude_test.tpl" 1 %}
+			</div>
+		</div>
+
+		{% include "_js_include.tpl" %}
+		{% script %}
+
+    </body>
+</html>

File priv/sites/testsandbox/templates/test_included.tpl

+<p>Hello I have been included on {% now "jS F Y H:i:s" %} </p>
+
+Id in the include: {{ #id }}

File priv/sites/zotonicwww/files/archive/koe.jpg

Removed
Old image