Mercurial Hosting > linkmystyle
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/delete_pic.js.luan Fri Jul 11 20:57:49 2025 -0600 @@ -0,0 +1,22 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local Io = require "luan:Io.luan" +local Http = require "luan:http/Http.luan" +local Pic = require "site:/lib/Pic.luan" +local User = require "site:/lib/User.luan" + + +return function() + local user = User.current() or error() + local pic_id = Http.request.parameters.pic or error() + local pic = Pic.get_by_id(pic_id) + if pic ~= nil then + pic.user_id == user.id or error(user.id) + pic.delete() + end + Io.stdout = Http.response.text_writer() +%> + //document.querySelector('span[pic="<%=pic_id%>"]').outerHTML = ''; + location = '/pics.html'; +<% +end