Mercurial Hosting > shareasale
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:6b17b5030868 | 1:bd2abcd7190a |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local ipairs = Luan.ipairs or error() | |
4 local pairs = Luan.pairs or error() | |
5 local Table = require "luan:Table.luan" | |
6 local concat = Table.concat or error() | |
7 local Html = require "luan:Html.luan" | |
8 local html_encode = Html.encode or error() | |
9 local Io = require "luan:Io.luan" | |
10 local Http = require "luan:http/Http.luan" | |
11 local Db = require "site:/lib/Db.luan" | |
12 local Shared = require "site:/lib/Shared.luan" | |
13 local to_list = Shared.to_list or error() | |
14 local Logging = require "luan:logging/Logging.luan" | |
15 local logger = Logging.logger "index.html" | |
16 | |
17 | |
18 return function() | |
19 local query = Http.request.parameters.query or "" | |
20 local results, n = Db.search(query,1,100) | |
21 --logger.info("#results = "..#results) | |
22 Io.stdout = Http.response.text_writer() | |
23 %> | |
24 <!doctype html> | |
25 <html> | |
26 <head> | |
27 <meta name="viewport" content="width=device-width, initial-scale=1"> | |
28 <style> | |
29 @import "/site.css"; | |
30 | |
31 input { | |
32 display: block; | |
33 width: 100%; | |
34 } | |
35 td { | |
36 vertical-align: top; | |
37 padding-right: 8px; | |
38 } | |
39 td:first-child { | |
40 padding-right: 8px; | |
41 } | |
42 </style> | |
43 <title>Search ShareASale Affiliates</title> | |
44 </head> | |
45 <body> | |
46 <h2>Search ShareASale Affiliates</h2> | |
47 <form> | |
48 <input name=query value="<%= query %>" autofocus> | |
49 </form> | |
50 <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> | |
51 <p><%= #results %> of <%= n %></p> | |
52 <hr> | |
53 <% | |
54 for _, doc in ipairs(results) do | |
55 %> | |
56 <table> | |
57 <tr> | |
58 <td>user_id:</td> | |
59 <td><a href="https://account.shareasale.com/m-recruiting.cfm?mode=affiliate&userid=<%= doc.user_id %>"><%= doc.user_id %></a></td> | |
60 </tr> | |
61 <tr> | |
62 <td>user_name:</td> | |
63 <td><%= doc.user_name %></td> | |
64 </tr> | |
65 <tr> | |
66 <td>category:</td> | |
67 <td><%= concat( to_list(doc.category), ", " ) %></td> | |
68 </tr> | |
69 <tr> | |
70 <td>description:</td> | |
71 <td><%= html_encode(doc.description or "") %></td> | |
72 </tr> | |
73 <tr> | |
74 <td>websites:</td> | |
75 <td> | |
76 <% for _, s in ipairs(to_list(doc.websites)) do %> | |
77 <a href="<%=s%>"><%=s%></a><br> | |
78 <% end %> | |
79 </td> | |
80 </tr> | |
81 </table> | |
82 <hr> | |
83 <% | |
84 end | |
85 %> | |
86 </body> | |
87 </html> | |
88 <% | |
89 end |