Mercurial Hosting > linkmystyle
diff src/uploadcare/test2.html.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/uploadcare/test2.html.luan Fri Jul 11 20:57:49 2025 -0600 @@ -0,0 +1,62 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local Io = require "luan:Io.luan" +local Http = require "luan:http/Http.luan" +local Shared = require "site:/lib/Shared.luan" +local head = Shared.head or error() +local body_header = Shared.body_header or error() +local footer = Shared.footer or error() + + +return function() + Io.stdout = Http.response.text_writer() +%> +<!doctype html> +<html lang="en"> + <head> +<% head() %> + <style> + div[content] { + margin-left: 3%; + margin-right: 3%; + } + + img { + height: 100px; + } + </style> + <script> + 'use strict'; + + uploadcare.publicKey = '718cc25ec1508ca5801d'; // local + uploadcare.doNotStore = true; + uploadcare.cropprOptions = {}; + + function uploaded(uuid,filename) { + let url = 'https://ucarecdn.com/' + uuid + '/-/quality/smart/'; + // console.log(url); + let a = document.querySelector('[content] a'); + a.textContent = filename; + a.href = url; + document.querySelector('[content] img').src = url; + } + </script> + </head> + <body> + <div full> +<% body_header() %> + <div content> + <p>top</p> + <p> + <button onclick="uploadcare.upload(uploaded)">Upload File</button> + </p> + <p><a></a></p> + <p><img></p> + <p>bottom</p> + </div> +<% footer() %> + </div> + </body> +</html> +<% +end