diff blog/src/index.html.luan @ 599:50540f0813e2

support default search fields in lucene; add search to blog;
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 16 Sep 2015 20:55:49 -0600
parents 6bb0c83116e9
children ca169567ce07
line wrap: on
line diff
--- a/blog/src/index.html.luan	Wed Sep 16 14:32:52 2015 -0600
+++ b/blog/src/index.html.luan	Wed Sep 16 20:55:49 2015 -0600
@@ -8,6 +8,8 @@
 
 
 return function()
+	local query = Http.request.parameter.query
+
 	Io.stdout = Http.response.text_writer()
 %>
 <html>
@@ -17,12 +19,18 @@
 		</style>
 	</head>
 	<body>
-		<h1>Demo Blog App</h1>
+		<h1><a href="/">Demo Blog App</a></h1>
+
+		<form>
+			<input name=query type=text value="<%= query or "" %>">
+			<input type=submit value=Search>
+		</form>
 
 		<div><a href="new">Make New Post</a></div>
 
 		<%
-		for _, post in ipairs(Post.get_all()) do
+		local posts = query and Post.search(query) or Post.get_all()
+		for _, post in ipairs(posts) do
 			%>
 			<a name="p<%= post.id %>">
 			<h2><%= post.subject %></h2>