Explorar el Código

make open action an url param

Pi hace 3 meses
padre
commit
fefd632b97

+ 0 - 4
rest/pyapi.py

@@ -122,10 +122,6 @@ def normalize(route):
 def send_static(filename):
     return static_file(filename, root='rest/static')
 
-@route('/<route:re:(clip|goto|upload)>/open')
-def _get_clip(route):
-    return redirect(f'/{route}/open.sql')
-
 @route('/<route:re:(clip|goto|upload|code)>', method=['GET', 'POST'])
 def clip(route):
     return redirect(f'/{route}.sql')

+ 1 - 1
rest/static/clip/manifest.json

@@ -7,7 +7,7 @@
   "shortcuts": [
     {
       "name": "Open",
-      "url": "/clip/open",
+      "url": "/clip?action=open",
       "icons": [{ "src": "/static/ftark-open.png", "sizes": "96x96" }]
     },
     {

+ 1 - 1
rest/static/goto/manifest.json

@@ -7,7 +7,7 @@
   "shortcuts": [
     {
       "name": "Open",
-      "url": "/goto/open",
+      "url": "/goto?action=open",
       "icons": [{ "src": "/static/ftark-open.png", "sizes": "96x96" }]
     },
     {

+ 1 - 1
rest/static/upload/manifest.json

@@ -7,7 +7,7 @@
   "shortcuts": [
     {
       "name": "Open",
-      "url": "/upload/open",
+      "url": "/upload?action=open",
       "icons": [{ "src": "/static/ftark-open.png", "sizes": "96x96" }]
     },
     {

+ 3 - 3
util-sqlpage/clip.sql

@@ -8,9 +8,9 @@ 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
+SET ":action" = COALESCE(:action, $action, '');
+SET ":inner" = (CASE :action
+  WHEN 'open' THEN 'sqlpage/Open.sql'
   ELSE 'clip/Index.sql'
 END);
 SELECT 'dynamic' AS component, sqlpage.run_sql(:inner) AS properties;
-

+ 2 - 2
util-sqlpage/clip/form.sql

@@ -2,12 +2,12 @@ SET ":view" = COALESCE(:content, '') <> '' AND COALESCE(:action, '') <> ('Edit a
 SELECT 'button' AS component;
 SELECT 'Open' AS title
 , 1 AS width
-, '/clip/open.sql?' AS link
+, '/clip.sql?action=open' AS link
 ;
 SELECT 'New' AS title
 , 1 AS width
 , 'gray-500' AS color
-, '/clip.sql?' AS link
+, '/clip.sql' AS link
 ;
 
 SELECT 'form' AS component

+ 0 - 2
util-sqlpage/clip/open.sql

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

+ 3 - 2
util-sqlpage/goto.sql

@@ -8,8 +8,9 @@ SET ":tabler_color" = 'google';
 SET ":image" = '/static/goto/chain-link2fr-3-2.svg';
 SET ":favicon" = :image;
 SET ":manifest" = '/static/goto/manifest.json';
-SET ":inner" = (CASE :inner
-  WHEN 'sqlpage/Open.sql' THEN :inner
+SET ":action" = COALESCE($action, :action, '');
+SET ":inner" = (CASE :action
+  WHEN 'open' THEN 'sqlpage/Open.sql'
   ELSE 'goto/Index.sql'
 END);
 SELECT 'dynamic' AS component, sqlpage.run_sql('goto/redirect.sql') AS properties

+ 1 - 1
util-sqlpage/goto/form.sql

@@ -2,7 +2,7 @@ SET ":view" = COALESCE(:content, '') <> '';
 SELECT 'button' AS component;
 SELECT 'Open' AS title
 , 1 AS width
-, '/goto/open.sql' AS link
+, '/goto.sql?action=open' AS link
 ;
 SELECT 'New' AS title
 , 1 AS width

+ 0 - 2
util-sqlpage/goto/open.sql

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

+ 3 - 2
util-sqlpage/upload.sql

@@ -7,8 +7,9 @@ SET ":tabler_color" = 'yellow';
 SET ":image" = '/static/upload/upload-favicon_square.svg';
 SET ":favicon" = :image;
 SET ":manifest" = '/static/upload/manifest.json';
-SET ":inner" = (CASE COALESCE(:inner, '')
-  WHEN 'sqlpage/Open.sql' THEN :inner
+SET ":action" = COALESCE($action, :action, '');
+SET ":inner" = (CASE :action
+  WHEN 'open' THEN 'sqlpage/Open.sql'
   ELSE 'upload/Index.sql'
 END);
 SET ":file_name" = sqlpage.uploaded_file_name('content');

+ 2 - 1
util-sqlpage/upload/form.sql

@@ -2,7 +2,7 @@ SET ":view" = COALESCE(:content, '') <> '';
 SELECT 'button' AS component;
 SELECT 'Open' AS title
 , 1 AS width
-, '/upload/open.sql' AS link
+, '/upload.sql?action=open' AS link
 ;
 SELECT 'New' AS title
 , 1 AS width
@@ -13,6 +13,7 @@ SELECT 'Download' AS title
 , 2 AS width
 , 'gray-500' AS color
 , '/upload/'||:hash AS link
+WHERE :hash <> ''
 ;
 
 SELECT 'form' AS component

+ 0 - 2
util-sqlpage/upload/open.sql

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