diff src/index.html.luan @ 1:bd2abcd7190a

mostly done
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 20 Sep 2022 19:40:39 -0600
parents
children 81c73ce6541c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/index.html.luan	Tue Sep 20 19:40:39 2022 -0600
@@ -0,0 +1,89 @@
+local Luan = require "luan:Luan.luan"
+local error = Luan.error
+local ipairs = Luan.ipairs or error()
+local pairs = Luan.pairs or error()
+local Table = require "luan:Table.luan"
+local concat = Table.concat or error()
+local Html = require "luan:Html.luan"
+local html_encode = Html.encode or error()
+local Io = require "luan:Io.luan"
+local Http = require "luan:http/Http.luan"
+local Db = require "site:/lib/Db.luan"
+local Shared = require "site:/lib/Shared.luan"
+local to_list = Shared.to_list or error()
+local Logging = require "luan:logging/Logging.luan"
+local logger = Logging.logger "index.html"
+
+
+return function()
+	local query = Http.request.parameters.query or ""
+	local results, n = Db.search(query,1,100)
+	--logger.info("#results = "..#results)
+	Io.stdout = Http.response.text_writer()
+%>
+<!doctype html>
+<html>
+	<head>
+		<meta name="viewport" content="width=device-width, initial-scale=1">
+		<style>
+			@import "/site.css";
+
+			input {
+				display: block;
+				width: 100%;
+			}
+			td {
+				vertical-align: top;
+				padding-right: 8px;
+			}
+			td:first-child {
+				padding-right: 8px;
+			}
+		</style>
+		<title>Search ShareASale Affiliates</title>
+	</head>
+	<body>
+		<h2>Search ShareASale Affiliates</h2>
+		<form>
+			<input name=query value="<%= query %>" autofocus>
+		</form>
+		<p><a href="https://lucene.apache.org/core/4_9_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description">search syntax</a></p>
+		<p><%= #results %> of <%= n %></p>
+		<hr>
+<%
+	for _, doc in ipairs(results) do
+%>
+		<table>
+			<tr>
+				<td>user_id:</td>
+				<td><a href="https://account.shareasale.com/m-recruiting.cfm?mode=affiliate&userid=<%= doc.user_id %>"><%= doc.user_id %></a></td>
+			</tr>
+			<tr>
+				<td>user_name:</td>
+				<td><%= doc.user_name %></td>
+			</tr>
+			<tr>
+				<td>category:</td>
+				<td><%= concat( to_list(doc.category), ", " ) %></td>
+			</tr>
+			<tr>
+				<td>description:</td>
+				<td><%= html_encode(doc.description or "") %></td>
+			</tr>
+			<tr>
+				<td>websites:</td>
+				<td>
+<%		for _, s in ipairs(to_list(doc.websites)) do %>
+					<a href="<%=s%>"><%=s%></a><br>
+<%		end %>
+				</td>
+			</tr>
+		</table>
+		<hr>
+<%
+	end
+%>
+	</body>
+</html>
+<%
+end