Răsfoiți Sursa

remove unnecessary nesting in clip and upload

Pi 4 luni în urmă
părinte
comite
c4e4741bdc

+ 15 - 2
util-sqlpage/clip.sql

@@ -1,3 +1,16 @@
-SET ":inner" = 'clip/Index.sql';
-SELECT 'dynamic' AS component, sqlpage.run_sql('clip/entry.sql') AS properties;
+SET ":title" = 'Clip';
+SET ":tool" = 'clip';
+SET ":hash" = COALESCE($hash, '');
+SET ":hash" = sqlpage.url_encode(:hash);
+SET ":color" = '#2fb344';
+SET ":tabler_color" = 'green';
+SET ":image" = '/static/clip/clip-favicon_square.svg';
+SET ":favicon" = :image;
+SET ":manifest" = '/static/clip/manifest.json';
+SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/theme.sql') AS properties;
+SET ":inner" = (CASE COALESCE(:inner, '')
+  WHEN 'sqlpage/Open.sql' THEN :inner
+  ELSE 'clip/Index.sql'
+END);
+SELECT 'dynamic' AS component, sqlpage.run_sql(:inner) AS properties;
 

+ 0 - 11
util-sqlpage/clip/entry.sql

@@ -1,11 +0,0 @@
-SET ":title" = 'Clip';
-SET ":tool" = 'clip';
-SET ":hash" = COALESCE($hash, '');
-SET ":hash" = sqlpage.url_encode(:hash);
-SET ":color" = '#2fb344';
-SET ":tabler_color" = 'green';
-SET ":image" = '/static/clip/clip-favicon_square.svg';
-SET ":favicon" = :image;
-SET ":manifest" = '/static/clip/manifest.json';
-SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/theme.sql') AS properties;
-SELECT 'dynamic' AS component, sqlpage.run_sql(:inner) AS properties;

+ 1 - 1
util-sqlpage/clip/open.sql

@@ -1,2 +1,2 @@
 SET ":inner" = 'sqlpage/Open.sql';
-SELECT 'dynamic' AS component, sqlpage.run_sql('clip/entry.sql') AS properties;
+SELECT 'dynamic' AS component, sqlpage.run_sql('clip.sql') AS properties;

+ 15 - 2
util-sqlpage/upload.sql

@@ -1,7 +1,20 @@
-SET ":inner" = 'upload/Index.sql';
+SET ":tool" = 'upload';
+SET ":hash" = COALESCE($hash, '');
+SET ":hash" = sqlpage.url_encode(:hash);
+SET ":title" = 'Upload';
+SET ":color" = '#f59f00';
+SET ":tabler_color" = 'yellow';
+SET ":image" = '/static/upload/upload-favicon_square.svg';
+SET ":favicon" = :image;
+SET ":manifest" = '/static/upload/manifest.json';
+SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/theme.sql') AS properties;
+SET ":inner" = (CASE COALESCE(:inner, '')
+  WHEN 'sqlpage/Open.sql' THEN :inner
+  ELSE 'upload/Index.sql'
+END);
 -- although using a variable works, docs say to pass the function as first argument
 -- https://sql.ophir.dev/functions.sql?function=read_file_as_data_url#function
 --SET ":file_name" = sqlpage.uploaded_file_name('content');
 SET ":mime_type" = sqlpage.uploaded_file_mime_type('content');
 SET ":content" = sqlpage.read_file_as_data_url(sqlpage.uploaded_file_path('content'));
-SELECT 'dynamic' AS component, sqlpage.run_sql('upload/entry.sql') AS properties;
+SELECT 'dynamic' AS component, sqlpage.run_sql(:inner) AS properties;

+ 0 - 11
util-sqlpage/upload/entry.sql

@@ -1,11 +0,0 @@
-SET ":tool" = 'upload';
-SET ":hash" = COALESCE($hash, '');
-SET ":hash" = sqlpage.url_encode(:hash);
-SET ":title" = 'Upload';
-SET ":color" = '#f59f00';
-SET ":tabler_color" = 'yellow';
-SET ":image" = '/static/upload/upload-favicon_square.svg';
-SET ":favicon" = :image;
-SET ":manifest" = '/static/upload/manifest.json';
-SELECT 'dynamic' AS component, sqlpage.run_sql('sqlpage/theme.sql') AS properties;
-SELECT 'dynamic' AS component, sqlpage.run_sql(:inner) AS properties;

+ 1 - 1
util-sqlpage/upload/open.sql

@@ -1,2 +1,2 @@
 SET ":inner" = 'sqlpage/Open.sql';
-SELECT 'dynamic' AS component, sqlpage.run_sql('upload/entry.sql') AS properties;
+SELECT 'dynamic' AS component, sqlpage.run_sql('upload.sql') AS properties;