Mercurial Hosting > freedit
annotate src/edit.js.luan @ 61:389e5d8e5f8a default tip
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 06 Dec 2022 13:37:25 -0700 |
parents | 8b5b1bce7d6b |
children |
rev | line source |
---|---|
15 | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | |
3 local Html = require "luan:Html.luan" | |
4 local html_encode = Html.encode or error() | |
5 local Parsers = require "luan:Parsers.luan" | |
6 local json_string = Parsers.json_string or error() | |
7 local Io = require "luan:Io.luan" | |
8 local Http = require "luan:http/Http.luan" | |
9 local Post = require "site:/lib/Post.luan" | |
10 | |
11 | |
12 return function() | |
13 local post = Http.request.parameters.post or error() | |
14 post = Post.get_by_id(post) or error() | |
15 Io.stdout = Http.response.text_writer() | |
16 %> | |
33
4fdc4ec0050b
upload with uploadcare
Franklin Schmidt <fschmidt@gmail.com>
parents:
25
diff
changeset
|
17 let postDiv = document.querySelector('[post="<%=post.id%>"]'); |
4fdc4ec0050b
upload with uploadcare
Franklin Schmidt <fschmidt@gmail.com>
parents:
25
diff
changeset
|
18 postDiv.querySelector('[output]').style.display = 'none'; |
46 | 19 bbcodeCreate( postDiv.querySelector('[edit]'), { |
20 content: <%= json_string(html_encode(post.content)) %>, | |
60 | 21 buttons: { |
22 Save: saveEdit, | |
23 Cancel: cancelEdit, | |
24 } | |
46 | 25 } ); |
33
4fdc4ec0050b
upload with uploadcare
Franklin Schmidt <fschmidt@gmail.com>
parents:
25
diff
changeset
|
26 let textarea = postDiv.querySelector('textarea'); |
4fdc4ec0050b
upload with uploadcare
Franklin Schmidt <fschmidt@gmail.com>
parents:
25
diff
changeset
|
27 textarea.focus(); |
15 | 28 <% |
29 end |