Selaa lähdekoodia

get preview working

Pi 4 kuukautta sitten
vanhempi
säilyke
36bb863698
3 muutettua tiedostoa jossa 15 lisäystä ja 3 poistoa
  1. 2 1
      util-sqlpage/code/form-fuel.sql
  2. 6 2
      util-sqlpage/code/form.sql
  3. 7 0
      util-sqlpage/sqlpage/Style.sql

+ 2 - 1
util-sqlpage/code/form-fuel.sql

@@ -5,10 +5,11 @@ SET ":expiry" = COALESCE(:expiry, (SELECT expiry FROM code_detail WHERE hash = $
 SET ":value" = COALESCE(:value, (SELECT value FROM code_detail WHERE hash = $hash));
 SET ":store" = COALESCE(:store, (SELECT store FROM code_detail WHERE hash = $hash));
 SET ":used" = COALESCE(:used, (SELECT used FROM code_detail WHERE hash = $hash));
+SET ":content" = (SELECT json(content) FROM code WHERE hash = $hash);
 SET ":validate" = 'Update';
 SET "$action" = 'Update';
 SET ":method" = 'post';
-SET ":preview" = (SELECT used FROM code_detail WHERE hash = $hash);
+SET ":preview" = (SELECT 'data:image/svg+xml,'||svg FROM code WHERE hash = $hash);
 SET ":autofill" = TRUE;
 SET ":filter_config" = '[
   {"name": "store", "required": true},

+ 6 - 2
util-sqlpage/code/form.sql

@@ -21,8 +21,12 @@ SET ":filter_options" = (
 SELECT 'card' AS component
 , 1 AS columns
 WHERE COALESCE($hash, '') <> '';
-SELECT COALESCE(type||' ','') || COALESCE(store||' ', '') || COALESCE(expiry, created) AS title
-, COALESCE(content->>'content'||' ', '') || COALESCE(content->>'type', '') AS description
+SELECT COALESCE($hash, '') || COALESCE($type||' ','') || COALESCE($store||' ', '') || COALESCE($expiry, $created, '') AS title
+, '
+| Type | Content |
+|:-----|:--------|
+| ' || COALESCE($content->>'format', '') || ' | ' || COALESCE($content->>'content', '') || ' |
+' AS description_md
 , $preview AS top_image
 , $tabler_color AS color
 WHERE COALESCE($hash, '') <> ''

+ 7 - 0
util-sqlpage/sqlpage/Style.sql

@@ -15,5 +15,12 @@ details svg, details img {
     width: 40%;
     margin: 10% 30% 10% 30%;
 }
+table td, table th {
+   padding-left: 5px;
+   padding-right: 5px;
+   padding-top: 2px;
+   padding-bottom: 2px;
+   border-width: 1px;
+}
 </style>' AS html
 ;