Mercurial Hosting > linkmystyle
comparison src/delete_link.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 Link = require "site:/lib/Link.luan" | |
6 local User = require "site:/lib/User.luan" | |
7 | |
8 | |
9 return function() | |
10 local user = User.current() or error() | |
11 local link_id = Http.request.parameters.link or error() | |
12 local link = Link.get_by_id(link_id) | |
13 if link ~= nil then | |
14 link.user_id == user.id or error() | |
15 link.delete() | |
16 end | |
17 Io.stdout = Http.response.text_writer() | |
18 %> | |
19 let div = document.querySelector('div[link="<%=link_id%>"]'); | |
20 if(div) div.outerHTML = ''; | |
21 <% | |
22 end |