Mercurial Hosting > luan
annotate examples/blog/src/index.html.luan @ 1552:46d4baaad64d
add long_string_keys
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 04 Oct 2020 20:26:49 -0600 |
parents | bc40bc9aab3a |
children | ad5647031343 |
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" |
777
1460d297e960
add bbcode to blog example
Franklin Schmidt <fschmidt@gmail.com>
parents:
693
diff
changeset
|
6 local Parsers = require "luan:Parsers.luan" |
1460d297e960
add bbcode to blog example
Franklin Schmidt <fschmidt@gmail.com>
parents:
693
diff
changeset
|
7 local bbcode_to_html = Parsers.bbcode_to_html or error() |
1460d297e960
add bbcode to blog example
Franklin Schmidt <fschmidt@gmail.com>
parents:
693
diff
changeset
|
8 local Html = require "luan:Html.luan" |
1460d297e960
add bbcode to blog example
Franklin Schmidt <fschmidt@gmail.com>
parents:
693
diff
changeset
|
9 local html_encode = Html.encode or error() |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
10 local Http = require "luan:http/Http.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
599
diff
changeset
|
11 local Post = require "site:/lib/Post.luan" |
596 | 12 |
13 | |
14 return function() | |
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
15 local query = Http.request.parameters.query |
599
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
16 |
596 | 17 Io.stdout = Http.response.text_writer() |
18 %> | |
1216 | 19 <!doctype html> |
596 | 20 <html> |
21 <head> | |
22 <style> | |
23 @import "/site.css"; | |
24 </style> | |
25 </head> | |
26 <body> | |
599
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
27 <h1><a href="/">Demo Blog App</a></h1> |
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
28 |
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
29 <form> |
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
30 <input name=query type=text value="<%= query or "" %>"> |
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
31 <input type=submit value=Search> |
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
32 </form> |
596 | 33 |
1217 | 34 <div><a href="new.html">Make New Post</a></div> |
596 | 35 |
36 <% | |
599
50540f0813e2
support default search fields in lucene;
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
37 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
|
38 for _, post in ipairs(posts) do |
596 | 39 %> |
40 <a name="p<%= post.id %>"> | |
41 <h2><%= post.subject %></h2> | |
1387
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1217
diff
changeset
|
42 <p> |
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1217
diff
changeset
|
43 <%= Time.format(post.date) %> |
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1217
diff
changeset
|
44 - <a href="edit.html?post=<%= post.id %>">Edit</a> |
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1217
diff
changeset
|
45 - <a href="delete?post=<%= post.id %>">Delete</a> |
bc40bc9aab3a
start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1217
diff
changeset
|
46 </p> |
777
1460d297e960
add bbcode to blog example
Franklin Schmidt <fschmidt@gmail.com>
parents:
693
diff
changeset
|
47 <pre><%= bbcode_to_html(html_encode(post.content)) %></pre> |
596 | 48 <hr> |
49 <% | |
50 end | |
51 %> | |
52 | |
53 </body> | |
54 </html> | |
55 <% | |
56 end |