|
@@ -0,0 +1,32 @@
|
|
|
+SET request = json_object(
|
|
|
+ 'method', 'POST',
|
|
|
+ 'url', 'https://shandan.one/hash',
|
|
|
+ 'headers', json_object(),
|
|
|
+ 'body', json_object(
|
|
|
+ 'data', $json,
|
|
|
+ 'person', $tool
|
|
|
+ )
|
|
|
+);
|
|
|
+SET hash = sqlpage.fetch($request);
|
|
|
+SET fallback = 'https://shandan.one/upload/' || sqlpage.url_encode($hash);
|
|
|
+SET request = json_object(
|
|
|
+ 'method', 'POST',
|
|
|
+ 'url', 'https://shandan.one/qr',
|
|
|
+ 'headers', json_object(),
|
|
|
+ 'body', json_object(
|
|
|
+ 'data', $json,
|
|
|
+ 'fallback', $fallback
|
|
|
+ )
|
|
|
+);
|
|
|
+SET qr = sqlpage.fetch($request);
|
|
|
+INSERT INTO code(hash, content, svg, created)
|
|
|
+VALUES ($hash, $json, $qr, CURRENT_TIMESTAMP)
|
|
|
+ON CONFLICT DO
|
|
|
+UPDATE SET
|
|
|
+ content = excluded.content,
|
|
|
+ created = excluded.created,
|
|
|
+ svg = excluded.svg
|
|
|
+WHERE excluded.created > code.created;
|
|
|
+SELECT 'text' AS component;
|
|
|
+SELECT $json AS contents;
|
|
|
+--SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/link.sql') AS properties;
|