Mercurial Hosting > chat
comparison src/get_chat.js.luan @ 63:afd5ab5b02a2
file upload
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Wed, 05 Mar 2025 18:43:06 -0700 |
| parents | 9298b04607ae |
| children | 6cfef9850520 |
comparison
equal
deleted
inserted
replaced
| 62:ad9772fc588a | 63:afd5ab5b02a2 |
|---|---|
| 1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
| 2 local error = Luan.error | 2 local error = Luan.error |
| 3 local ipairs = Luan.ipairs or error() | 3 local ipairs = Luan.ipairs or error() |
| 4 local String = require "luan:String.luan" | |
| 5 local digest_message = String.digest_message or error() | |
| 4 local Parsers = require "luan:Parsers.luan" | 6 local Parsers = require "luan:Parsers.luan" |
| 5 local json_string = Parsers.json_string or error() | 7 local json_string = Parsers.json_string or error() |
| 6 local Io = require "luan:Io.luan" | 8 local Io = require "luan:Io.luan" |
| 7 local Http = require "luan:http/Http.luan" | 9 local Http = require "luan:http/Http.luan" |
| 8 local User = require "site:/lib/User.luan" | 10 local User = require "site:/lib/User.luan" |
| 16 local post_html = Shared.post_html or error() | 18 local post_html = Shared.post_html or error() |
| 17 local Logging = require "luan:logging/Logging.luan" | 19 local Logging = require "luan:logging/Logging.luan" |
| 18 local logger = Logging.logger "get_chat.js" | 20 local logger = Logging.logger "get_chat.js" |
| 19 | 21 |
| 20 | 22 |
| 21 local function html() | 23 local function get_html(user,chat) |
| 22 local user = current_user() or error() | |
| 23 local chat = Http.request.parameters.chat or error() | |
| 24 chat = get_chat_by_id(chat) or error() | |
| 25 chat.read(user) | 24 chat.read(user) |
| 26 local posts = post_search( "post_chat_id:"..chat.id, "id" ) | 25 local posts = post_search( "post_chat_id:"..chat.id, "id" ) |
| 27 %> | 26 %> |
| 28 <div top> | 27 <div top> |
| 29 <h3> | 28 <h3> |
| 46 post_html(post) | 45 post_html(post) |
| 47 end | 46 end |
| 48 %> | 47 %> |
| 49 <div input> | 48 <div input> |
| 50 <textarea oninput="fixTextarea(event)" onkeydown="textareaKey(event)"></textarea> | 49 <textarea oninput="fixTextarea(event)" onkeydown="textareaKey(event)"></textarea> |
| 50 <button onclick="uploadFile()" title="Add file"><img src="/images/upload_file.svg"></button> | |
| 51 <button onclick="addPost()" title="Send"><img src="/images/send.svg"></button> | 51 <button onclick="addPost()" title="Send"><img src="/images/send.svg"></button> |
| 52 </div> | 52 </div> |
| 53 </div> | 53 </div> |
| 54 <% | 54 <% |
| 55 end | 55 end |
| 56 | 56 |
| 57 return function() | 57 return function() |
| 58 local user = current_user() or error() | |
| 59 local chat = Http.request.parameters.chat or error() | |
| 60 chat = get_chat_by_id(chat) or error() | |
| 61 local html = `get_html(user,chat)` | |
| 62 local digest = digest_message("MD5",user.password..chat.id) | |
| 58 Io.stdout = Http.response.text_writer() | 63 Io.stdout = Http.response.text_writer() |
| 59 %> | 64 %> |
| 60 gotChat(<%=json_string(`html()`)%>); | 65 gotChat(<%=json_string(html)%>); |
| 66 filebinUrl = 'https://filebin.net/<%=digest%>/'; | |
| 61 <% | 67 <% |
| 62 end | 68 end |
