0
|
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 Shared = require "site:/lib/Shared.luan"
|
|
6 local head = Shared.head or error()
|
|
7 local body_header = Shared.body_header or error()
|
|
8 local footer = Shared.footer or error()
|
|
9
|
|
10
|
|
11 return function()
|
|
12 Io.stdout = Http.response.text_writer()
|
|
13 %>
|
|
14 <!doctype html>
|
|
15 <html lang="en">
|
|
16 <head>
|
|
17 <% head() %>
|
|
18 <style>
|
|
19 div[content] {
|
|
20 margin-left: 3%;
|
|
21 margin-right: 3%;
|
|
22 }
|
|
23
|
|
24 img {
|
|
25 height: 100px;
|
|
26 }
|
|
27 </style>
|
|
28 <script>
|
|
29 'use strict';
|
|
30
|
|
31 uploadcare.publicKey = '718cc25ec1508ca5801d'; // local
|
|
32 uploadcare.doNotStore = true;
|
|
33 uploadcare.cropprOptions = {};
|
|
34
|
|
35 function uploaded(uuid,filename) {
|
|
36 let url = 'https://ucarecdn.com/' + uuid + '/-/quality/smart/';
|
|
37 // console.log(url);
|
|
38 let a = document.querySelector('[content] a');
|
|
39 a.textContent = filename;
|
|
40 a.href = url;
|
|
41 document.querySelector('[content] img').src = url;
|
|
42 }
|
|
43 </script>
|
|
44 </head>
|
|
45 <body>
|
|
46 <div full>
|
|
47 <% body_header() %>
|
|
48 <div content>
|
|
49 <p>top</p>
|
|
50 <p>
|
|
51 <button onclick="uploadcare.upload(uploaded)">Upload File</button>
|
|
52 </p>
|
|
53 <p><a></a></p>
|
|
54 <p><img></p>
|
|
55 <p>bottom</p>
|
|
56 </div>
|
|
57 <% footer() %>
|
|
58 </div>
|
|
59 </body>
|
|
60 </html>
|
|
61 <%
|
|
62 end
|