Mercurial Hosting > luan
annotate blog/src/index.html.luan @ 759:ae612dfc57cb 0.21
better handling of longs in rpc and json
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 19 Jul 2016 09:09:41 -0600 |
| parents | ca169567ce07 |
| children | 1460d297e960 |
| rev | line source |
|---|---|
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
1 local Luan = require "luan:Luan.luan" |
| 596 | 2 local error = Luan.error |
| 3 local ipairs = Luan.ipairs or error() | |
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
4 local Time = require "luan:Time.luan" |
|
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
5 local Io = require "luan:Io.luan" |
|
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
6 local Http = require "luan:http/Http.luan" |
|
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
7 local Post = require "site:/lib/Post.luan" |
| 596 | 8 |
| 9 | |
| 10 return function() | |
|
599
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
11 local query = Http.request.parameter.query |
|
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
12 |
| 596 | 13 Io.stdout = Http.response.text_writer() |
| 14 %> | |
| 15 <html> | |
| 16 <head> | |
| 17 <style> | |
| 18 @import "/site.css"; | |
| 19 </style> | |
| 20 </head> | |
| 21 <body> | |
|
599
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
22 <h1><a href="/">Demo Blog App</a></h1> |
|
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
23 |
|
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
24 <form> |
|
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
25 <input name=query type=text value="<%= query or "" %>"> |
|
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
26 <input type=submit value=Search> |
|
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
27 </form> |
| 596 | 28 |
| 29 <div><a href="new">Make New Post</a></div> | |
| 30 | |
| 31 <% | |
|
599
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
32 local posts = query and Post.search(query) or Post.get_all() |
|
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
33 for _, post in ipairs(posts) do |
| 596 | 34 %> |
| 35 <a name="p<%= post.id %>"> | |
| 36 <h2><%= post.subject %></h2> | |
| 37 <p><%= Time.format(post.date) %> - <a href="edit?post=<%= post.id %>">Edit</a></p> | |
| 38 <pre><%= post.content %></pre> | |
| 39 <hr> | |
| 40 <% | |
| 41 end | |
| 42 %> | |
| 43 | |
| 44 </body> | |
| 45 </html> | |
| 46 <% | |
| 47 end |
