596
|
1 local Luan = require "luan:Luan"
|
|
2 local error = Luan.error
|
|
3 local ipairs = Luan.ipairs or error()
|
|
4 local Time = require "luan:Time"
|
|
5 local Io = require "luan:Io"
|
|
6 local Http = require "luan:http/Http"
|
|
7 local Post = require "site:/lib/Post"
|
|
8
|
|
9
|
|
10 return function()
|
|
11 Io.stdout = Http.response.text_writer()
|
|
12 %>
|
|
13 <html>
|
|
14 <head>
|
|
15 <style>
|
|
16 @import "/site.css";
|
|
17 </style>
|
|
18 </head>
|
|
19 <body>
|
|
20 <h1>Demo Blog App</h1>
|
|
21
|
|
22 <div><a href="new">Make New Post</a></div>
|
|
23
|
|
24 <%
|
|
25 for _, post in ipairs(Post.get_all()) do
|
|
26 %>
|
|
27 <a name="p<%= post.id %>">
|
|
28 <h2><%= post.subject %></h2>
|
|
29 <p><%= Time.format(post.date) %> - <a href="edit?post=<%= post.id %>">Edit</a></p>
|
|
30 <pre><%= post.content %></pre>
|
|
31 <hr>
|
|
32 <%
|
|
33 end
|
|
34 %>
|
|
35
|
|
36 </body>
|
|
37 </html>
|
|
38 <%
|
|
39 end
|