comparison examples/blog/src/index.html.luan @ 779:c38f6619feb9

move blog into examples
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 28 Aug 2016 14:50:47 -0600
parents blog/src/index.html.luan@1460d297e960
children 21d157b153fe
comparison
equal deleted inserted replaced
778:305ffb00ebc1 779:c38f6619feb9
1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error
3 local ipairs = Luan.ipairs or error()
4 local Time = require "luan:Time.luan"
5 local Io = require "luan:Io.luan"
6 local Parsers = require "luan:Parsers.luan"
7 local bbcode_to_html = Parsers.bbcode_to_html or error()
8 local Html = require "luan:Html.luan"
9 local html_encode = Html.encode or error()
10 local Http = require "luan:http/Http.luan"
11 local Post = require "site:/lib/Post.luan"
12
13
14 return function()
15 local query = Http.request.parameter.query
16
17 Io.stdout = Http.response.text_writer()
18 %>
19 <html>
20 <head>
21 <style>
22 @import "/site.css";
23 </style>
24 </head>
25 <body>
26 <h1><a href="/">Demo Blog App</a></h1>
27
28 <form>
29 <input name=query type=text value="<%= query or "" %>">
30 <input type=submit value=Search>
31 </form>
32
33 <div><a href="new">Make New Post</a></div>
34
35 <%
36 local posts = query and Post.search(query) or Post.get_all()
37 for _, post in ipairs(posts) do
38 %>
39 <a name="p<%= post.id %>">
40 <h2><%= post.subject %></h2>
41 <p><%= Time.format(post.date) %> - <a href="edit?post=<%= post.id %>">Edit</a></p>
42 <pre><%= bbcode_to_html(html_encode(post.content)) %></pre>
43 <hr>
44 <%
45 end
46 %>
47
48 </body>
49 </html>
50 <%
51 end