annotate src/edit_post.js.luan @ 66:f067de76084c

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 06 Mar 2025 03:09:24 -0700
parents af41be2dcdec
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Parsers = require "luan:Parsers.luan"
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local json_string = Parsers.json_string or error()
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Io = require "luan:Io.luan"
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Http = require "luan:http/Http.luan"
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local Post = require "site:/lib/Post.luan"
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local get_post_by_id = Post.get_by_id or error()
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 return function()
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local post = Http.request.parameters.post or error()
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 post = get_post_by_id(post) or error()
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 Io.stdout = Http.response.text_writer()
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 %>
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 openEditPost('<%=post.id%>',<%=json_string(post.content)%>);
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 <%
af41be2dcdec add edit_post
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 end