Mercurial Hosting > linkmystyle
comparison src/pic.html.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 ipairs = Luan.ipairs or error() | |
| 4 local Html = require "luan:Html.luan" | |
| 5 local html_encode = Html.encode or error() | |
| 6 local Parsers = require "luan:Parsers.luan" | |
| 7 local json_string = Parsers.json_string or error() | |
| 8 local Io = require "luan:Io.luan" | |
| 9 local Http = require "luan:http/Http.luan" | |
| 10 local Shared = require "site:/lib/Shared.luan" | |
| 11 local pub_head = Shared.pub_head or error() | |
| 12 local show_saved = Shared.show_saved or error() | |
| 13 local Pic = require "site:/lib/Pic.luan" | |
| 14 local get_pic_by_id = Pic.get_by_id or error() | |
| 15 local User = require "site:/lib/User.luan" | |
| 16 local get_user_by_id = User.get_by_id or error() | |
| 17 local Link = require "site:/lib/Link.luan" | |
| 18 local get_owner_links = Link.get_owner_links or error() | |
| 19 | |
| 20 | |
| 21 return function() | |
| 22 local pic = Http.request.parameters.pic or error() | |
| 23 pic = get_pic_by_id(pic) | |
| 24 if pic == nil then | |
| 25 Http.response.send_error(404) | |
| 26 return | |
| 27 end | |
| 28 local pic_title = pic.title | |
| 29 local pic_id = pic.id | |
| 30 local links = get_owner_links(pic_id) | |
| 31 local user = get_user_by_id(pic.user_id) or error() | |
| 32 local title = user.html_title() | |
| 33 local is_saved = Http.request.parameters.saved ~= nil | |
| 34 local saved = is_saved and "?saved" or "" | |
| 35 local back_path = "/"..user.name..saved | |
| 36 Io.stdout = Http.response.text_writer() | |
| 37 %> | |
| 38 <!doctype html> | |
| 39 <html pic> | |
| 40 <head> | |
| 41 <script> | |
| 42 window.Page = <%=json_string(pic_title)%>; | |
| 43 </script> | |
| 44 <% pub_head(user) %> | |
| 45 <title>Link My Style | <%=title%> | <%= html_encode(pic_title) %></title> | |
| 46 </head> | |
| 47 <body colored> | |
| 48 <% if is_saved then | |
| 49 show_saved("/pic.html?pic="..pic_id) | |
| 50 end %> | |
| 51 <div pub_background_img></div> | |
| 52 <div pub_content> | |
| 53 <div back> | |
| 54 <a href="<%=back_path%>#p-<%=pic_id%>"><img src="/images/keyboard_backspace.svg"></a> | |
| 55 </div> | |
| 56 <div body> | |
| 57 <div left> | |
| 58 <img pic <%=pic.title_attr()%> src="<%=pic.get_url()%>"> | |
| 59 <div hashtags><%=pic.hashtags_html(back_path)%></div> | |
| 60 </div> | |
| 61 <div outer_links> | |
| 62 <div links> | |
| 63 <% for _, link in ipairs(links) do %> | |
| 64 <a link=x href="<%=link.url%>"><%=html_encode(link.title)%></a> | |
| 65 <% end %> | |
| 66 </div> | |
| 67 </div> | |
| 68 </div> | |
| 69 </div> | |
| 70 </body> | |
| 71 </html> | |
| 72 <% | |
| 73 end |
