changeset 391:2f5cc9c2cbf0

replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 24 Apr 2015 14:05:52 -0600
parents bfbbce690bba
children 8668f3799ad9
files core/src/luan/modules/Html.luan lucene/src/luan/modules/lucene/Web_search.luan web/src/luan/modules/web/run.luan web/src/luan/modules/web/shell.luan website/src/diff.html.luan website/src/docs.html.luan website/src/examples/hi2_simply_html.luan website/src/index.html.luan website/src/manual.html.luan website/src/pil.html.luan website/src/tutorial.html.luan
diffstat 11 files changed, 227 insertions(+), 194 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/modules/Html.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/core/src/luan/modules/Html.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -38,16 +38,9 @@
 end
 
 
-function simply_html_page(parts)
-	local head = parts.head
-%>
-<!DOCTYPE html>
-<html lang="en">
-	<head>
+function simply_html_head() %>
 		<meta charset="utf-8">
 		<meta name="viewport" content="width=device-width, initial-scale=1">
-
-		<% head and head() %>
 		
 		<link href="http://www.simplyhtml.org/assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
 		<link rel="stylesheet" href="http://www.simplyhtml.org/assets/font-awesome/css/font-awesome.min.css">
@@ -55,12 +48,8 @@
 
 		<link href="http://www.simplyhtml.org/assets/simplyhtml/simplyhtml.css" rel="stylesheet"/>
 		<script src="http://www.simplyhtml.org/assets/simplyhtml/simplyhtml.js"></script>
-	</head>
-	<body>
-		<% parts.body() %>
-		
+<% end
+
+function simply_html_body_bottom() %>
 		<script src="http://www.simplyhtml.org/assets/bootstrap/js/bootstrap.min.js"></script>
-	</body>
-</html>
-<%
-end
+<% end
--- a/lucene/src/luan/modules/lucene/Web_search.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/lucene/src/luan/modules/lucene/Web_search.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -10,95 +10,102 @@
 local Html = require "luan:Html"
 
 
-local function form()
-	Html.simply_html_page{
-		head = function() %>
-			<title>Lucene Query</title>
-<%		end;
-		body = function() %>
-			<div container>
-				<h3 margin-top="1.5em">Lucene Query</h3>
-				<form horizontal name="form0" method="post" margin-top="2em">
-					<div row>
-						<div colspan=2 align="right">
-							<label>Query:</label>
-						</div>
-						<div colspan=10>
-							<input name="query" size="80" value="Query.all_docs" autofocus />
-							<div textcolor="#888">Query examples: <i>Query.term{ type = 'user' }</i> or <i>"type:user AND name:Joe"</i></div>
-						</div>
-					</div>
-					<div row margin-top="1em">
-						<div colspan=2 align="right">
-							<label>Max Rows:</label>
-						</div>
-						<div colspan=10>
-							<input name="rows" value="100" size="3" maxlength="5" /></p>
-						</div>
-					</div>
-					<div row margin-top="1em">
-						<div colspan=2 align="right">
-							<label>Sort:</label>
-						</div>
-						<div colspan=10>
-							<input name="sort" size="60" />
-							<div textcolor="#888">Sort examples: Query.sort{{ field = 'id', type='int' }}</div>
-						</div>
-					</div>
-					<div row margin-top="1em">
-						<div colspan=2></div>
-						<div colspan=10>
-							<input type="submit" textcolor="white" bgcolor="#337ab7" large/>
-						</div>
-					</div>
-				</form>
-			</div>
-<%		end;
-	}
-end
-
-
-local function result(query,sort,headers,table)
-	Html.simply_html_page{
-		body = function() %>
-			<div container>
-				<h3 margin-top="1.5em">Lucene Query Results</h3>
+local function form() %>
+<html>
+	<head>
+		<% Html.simply_html_head() %>
+		<title>Lucene Query</title>
+	</head>
+	<body>
+		<div container>
+			<h3 margin-top="1.5em">Lucene Query</h3>
+			<form horizontal name="form0" method="post" margin-top="2em">
 				<div row>
 					<div colspan=2 align="right">
 						<label>Query:</label>
 					</div>
 					<div colspan=10>
-						<b><%=query%></b></p>
+						<input name="query" size="80" value="Query.all_docs" autofocus />
+						<div textcolor="#888">Query examples: <i>Query.term{ type = 'user' }</i> or <i>"type:user AND name:Joe"</i></div>
 					</div>
 				</div>
-				<div row>
+				<div row margin-top="1em">
+					<div colspan=2 align="right">
+						<label>Max Rows:</label>
+					</div>
+					<div colspan=10>
+						<input name="rows" value="100" size="3" maxlength="5" /></p>
+					</div>
+				</div>
+				<div row margin-top="1em">
 					<div colspan=2 align="right">
 						<label>Sort:</label>
 					</div>
 					<div colspan=10>
-						<b><%=sort%></b></p>
+						<input name="sort" size="60" />
+						<div textcolor="#888">Sort examples: Query.sort{{ field = 'id', type='int' }}</div>
+					</div>
+				</div>
+				<div row margin-top="1em">
+					<div colspan=2></div>
+					<div colspan=10>
+						<input type="submit" textcolor="white" bgcolor="#337ab7" large/>
 					</div>
 				</div>
-				<table border condensed margin-top="1.5em">
+			</form>
+		</div>
+		<% Html.simply_html_body_bottom() %>
+	</body>
+</html>
+<% end
+
+
+local function result(query,sort,headers,table) %>
+<html>
+	<head>
+		<% Html.simply_html_head() %>
+		<title>Lucene Query</title>
+	</head>
+	<body>
+		<div container>
+			<h3 margin-top="1.5em">Lucene Query Results</h3>
+			<div row>
+				<div colspan=2 align="right">
+					<label>Query:</label>
+				</div>
+				<div colspan=10>
+					<b><%=query%></b></p>
+				</div>
+			</div>
+			<div row>
+				<div colspan=2 align="right">
+					<label>Sort:</label>
+				</div>
+				<div colspan=10>
+					<b><%=sort%></b></p>
+				</div>
+			</div>
+			<table border condensed margin-top="1.5em">
+				<tr>
+					<th></th>
+					<% for _, header in ipairs(headers) do %>
+						<th><%=header%></th>
+					<% end %>
+				</tr>
+				<% for i, row in ipairs(table) do %>
 					<tr>
-						<th></th>
-						<% for _, header in ipairs(headers) do %>
-							<th><%=header%></th>
+						<td><%=i%></td>
+						<% for col in range(1, #headers) do %>
+							<td><%= row[col] or "" %></td>
 						<% end %>
 					</tr>
-					<% for i, row in ipairs(table) do %>
-						<tr>
-							<td><%=i%></td>
-							<% for col in range(1, #headers) do %>
-								<td><%= row[col] or "" %></td>
-							<% end %>
-						</tr>
-					<% end %>
-				</table>
-			</div>
-<%		end;
-	}
-end
+				<% end %>
+			</table>
+		</div>
+		<% Html.simply_html_body_bottom() %>
+	</body>
+</html>
+<% end
 
 
 local function index_of(tbl,val)
--- a/web/src/luan/modules/web/run.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/web/src/luan/modules/web/run.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -23,27 +23,29 @@
 	end
 end
 
-local function form()
-	Html.simply_html_page{
-		head = function() %>
-			<title>Run Luan Code</title>
-<%		end;
-		body = function() %>
-			<center margin-top=10>
-				<h3>Run Luan Code</h3>
+local function form() %>
+<html>
+	<head>
+		<% Html.simply_html_head() %>
+		<title>Run Luan Code</title>
+	</head>
+	<body>
+		<center margin-top=10>
+			<h3>Run Luan Code</h3>
+		</center>
+		<form name="form0" method="post">
+			<input type="hidden" name="content_type" value="text/plain" />
+			<center>
+				<textarea name="code" rows="20" cols="90" wrap="off" autofocus></textarea>
 			</center>
-			<form name="form0" method="post">
-				<input type="hidden" name="content_type" value="text/plain" />
-				<center>
-					<textarea name="code" rows="20" cols="90" wrap="off" autofocus></textarea>
-				</center>
-				<center margin-top=5>
-					<input type="submit" value="Execute Luan Code" textcolor="white" bgcolor="#337ab7"/>
-				</center>
-			</form>
-<%		end;
-	}
-end
+			<center margin-top=5>
+				<input type="submit" value="Execute Luan Code" textcolor="white" bgcolor="#337ab7"/>
+			</center>
+		</form>
+		<% Html.simply_html_body_bottom() %>
+	</body>
+</html>
+<% end
 
 function service()
 	Io.stdout = Http.response.text_writer()
--- a/web/src/luan/modules/web/shell.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/web/src/luan/modules/web/shell.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -40,26 +40,29 @@
 	end
 
 	Io.stdout = Http.response.text_writer()
-	Html.simply_html_page{
-		head = function() %>
-			<title>Luan Shell</title>
-<%		end;
-		body = function() %>
-			<div container>
-				<h3>Luan Shell</h3>
-				<p>This is a command shell.  Enter commands below.</p>
-				<pre><%
-				for _,v in ipairs(history) do
-					Io.stdout.write(v)
-				end
-				%></pre>
-				<form name='form0' method='post'>
-					% <input name='cmd' size="80" autofocus>
-					<input type="submit" value="run" textcolor="white" bgcolor="#337ab7">
-					<input type="submit" name="clear" value="clear" textcolor="white" bgcolor="#337ab7">
-				</form>
-			</div>
-<%		end;
-	}
-
+%>
+<html>
+	<head>
+		<% Html.simply_html_head() %>
+		<title>Luan Shell</title>
+	</head>
+	<body>
+		<div container>
+			<h3>Luan Shell</h3>
+			<p>This is a command shell.  Enter commands below.</p>
+			<pre><%
+			for _,v in ipairs(history) do
+				Io.stdout.write(v)
+			end
+			%></pre>
+			<form name='form0' method='post'>
+				% <input name='cmd' size="80" autofocus>
+				<input type="submit" value="run" textcolor="white" bgcolor="#337ab7">
+				<input type="submit" name="clear" value="clear" textcolor="white" bgcolor="#337ab7">
+			</form>
+		</div>
+		<% Html.simply_html_body_bottom() %>
+	</body>
+</html>
+<%
 end
--- a/website/src/diff.html.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/website/src/diff.html.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -6,11 +6,13 @@
 
 function service()
 	Io.stdout = Http.response.text_writer()
-	Html.simply_html_page{
-		head = function() %>
-			<title>How Luan differs from Lua</title>
-<%		end;
-		body = function() %>
+%>
+<html>
+<head>
+	<% Html.simply_html_head() %>
+	<title>How Luan differs from Lua</title>
+</head>
+<body>
 
 <div container>
 <% Shared.header() %>
@@ -218,6 +220,8 @@
 
 </div>
 		
-<%		end;
-	}
+<% Html.simply_html_body_bottom() %>
+</body>
+</html>
+<%
 end
--- a/website/src/docs.html.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/website/src/docs.html.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -6,11 +6,13 @@
 
 function service()
 	Io.stdout = Http.response.text_writer()
-	Html.simply_html_page{
-		head = function() %>
-			<title>Luan Documentation</title>
-<%		end;
-		body = function() %>
+%>
+<html>
+	<head>
+		<% Html.simply_html_head() %>
+		<title>Luan Documentation</title>
+	</head>
+	<body>
 		<div container>
 			<% Shared.header() %>
 			<h1 margin-bottom="1em">Luan Documentation</h1>
@@ -25,6 +27,8 @@
 			</big>
 
 		</div>
-<%		end;
-	}
+		<% Html.simply_html_body_bottom() %>
+	</body>
+</html>
+<%
 end
--- a/website/src/examples/hi2_simply_html.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/website/src/examples/hi2_simply_html.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -4,33 +4,41 @@
 
 
 local function form() %>
-				<form>
-					<label>What is you name?</label>
-					<input name="name" margin-bottom="1em">
-					<input type=submit>
-				</form>
+			<form>
+				<label>What is you name?</label>
+				<input name="name" margin-bottom="1em">
+				<input type=submit>
+			</form>
 <% end
 
+
 local function hello() %>
-				<p>Hi <%= name %>!</p>
+			<p>Hi <%= name %>!</p>
 <% end
 
+
 function service()
 	Io.stdout = Http.response.text_writer()
 	name = Http.request.parameters.name
-	Html.simply_html_page{
-		body = function() %>
-			<div container>
-				<h1 margin-bottom="1em">Hello</h1>
-				<%
-				if name == nil then
-					form()
-				else
-					hello()
-				end
-				%>
-				<p margin-top="2em"><small>This page was made with <a href="http://www.simplyhtml.org/">SimplyHTML</a>.</small></p>
-			</div>
-<%		end;
-	}
+%>
+<html>
+	<head>
+		<% Html.simply_html_head() %>
+	</head>
+	<body>
+		<div container>
+			<h1 margin-bottom="1em">Hello</h1>
+			<%
+			if name == nil then
+				form()
+			else
+				hello()
+			end
+			%>
+			<p margin-top="2em"><small>This page was made with <a href="http://www.simplyhtml.org/">SimplyHTML</a>.</small></p>
+		</div>
+		<% Html.simply_html_body_bottom() %>
+	</body>
+</html>
+<%
 end
--- a/website/src/index.html.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/website/src/index.html.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -5,11 +5,13 @@
 
 function service()
 	Io.stdout = Http.response.text_writer()
-	Html.simply_html_page{
-		head = function() %>
-			<title>Luan</title>
-<%		end;
-		body = function() %>
+%>
+<html>
+	<head>
+		<% Html.simply_html_head() %>
+		<title>Luan</title>
+	</head>
+	<body>
 		<div container>
 			<h1>The Luan Programming Language</h1>
 			<big>
@@ -24,6 +26,8 @@
 			</big>
 			<p margin-top="2em"><small>This website was made with <a href="http://www.simplyhtml.org/">SimplyHTML</a>.</small></p>
 		</div>
-<%		end;
-	}
+		<% Html.simply_html_body_bottom() %>
+	</body>
+</html>
+<%
 end
--- a/website/src/manual.html.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/website/src/manual.html.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -6,11 +6,13 @@
 
 function service()
 	Io.stdout = Http.response.text_writer()
-	Html.simply_html_page{
-		head = function() %>
-			<title>Luan Reference Manual</title>
-<%		end;
-		body = function() %>
+%>
+<html>
+<head>
+	<% Html.simply_html_head() %>
+	<title>Luan Reference Manual</title>
+</head>
+<body>
 
 <div container>
 <% Shared.header() %>
@@ -10226,6 +10228,8 @@
 
 </div>
 
-<%		end;
-	}
+<% Html.simply_html_body_bottom() %>
+</body>
+</html>
+<%
 end
--- a/website/src/pil.html.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/website/src/pil.html.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -6,11 +6,13 @@
 
 function service()
 	Io.stdout = Http.response.text_writer()
-	Html.simply_html_page{
-		head = function() %>
-			<title>Programming in Lua</title>
-<%		end;
-		body = function() %>
+%>
+<html>
+	<head>
+		<% Html.simply_html_head() %>
+		<title>Programming in Lua</title>
+	</head>
+	<body>
 		<div container>
 			<% Shared.header() %>
 			<h1 margin-bottom="1em">Programming in Lua</h1>
@@ -18,6 +20,8 @@
 			<p>Even though <a href="http://www.lua.org/pil/">Programming in Lua</a> is about Lua, not Luan, it still serves as an excellent introduction to Luan since the languages are so close.</p>
 
 		</div>
-<%		end;
-	}
+		<% Html.simply_html_body_bottom() %>
+	</body>
+</html>
+<%
 end
--- a/website/src/tutorial.html.luan	Fri Apr 24 12:31:13 2015 -0600
+++ b/website/src/tutorial.html.luan	Fri Apr 24 14:05:52 2015 -0600
@@ -6,11 +6,13 @@
 
 function service()
 	Io.stdout = Http.response.text_writer()
-	Html.simply_html_page{
-		head = function() %>
-			<title>Luan Tutorial</title>
-<%		end;
-		body = function() %>
+%>
+<html>
+<head>
+	<% Html.simply_html_head() %>
+	<title>Luan Tutorial</title>
+</head>
+<body>
 
 <div container>
 <% Shared.header() %>
@@ -102,6 +104,8 @@
 
 </div>
 		
-<%		end;
-	}
+<% Html.simply_html_body_bottom() %>
+</body>
+</html>
+<%
 end