Mercurial Hosting > linkmystyle
comparison src/delete_pic.js.luan @ 0:8f4df159f06b
start public repo
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 11 Jul 2025 20:57:49 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8f4df159f06b |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local Io = require "luan:Io.luan" | |
4 local Http = require "luan:http/Http.luan" | |
5 local Pic = require "site:/lib/Pic.luan" | |
6 local User = require "site:/lib/User.luan" | |
7 | |
8 | |
9 return function() | |
10 local user = User.current() or error() | |
11 local pic_id = Http.request.parameters.pic or error() | |
12 local pic = Pic.get_by_id(pic_id) | |
13 if pic ~= nil then | |
14 pic.user_id == user.id or error(user.id) | |
15 pic.delete() | |
16 end | |
17 Io.stdout = Http.response.text_writer() | |
18 %> | |
19 //document.querySelector('span[pic="<%=pic_id%>"]').outerHTML = ''; | |
20 location = '/pics.html'; | |
21 <% | |
22 end |