comparison blog/src/index.html.luan @ 596:6bb0c83116e9

add blog sample app
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 15 Sep 2015 21:30:33 -0600
parents
children 50540f0813e2
comparison
equal deleted inserted replaced
595:8370c4009cce 596:6bb0c83116e9
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