From fb26609325d211b0a49bb858ab7785a9b0bfbbf7 Mon Sep 17 00:00:00 2001 From: lovasoa Date: Thu, 8 May 2025 01:03:26 +0200 Subject: [PATCH] Refactor example cards: move example cards data to a new migration file and remove deprecated SQL from index.sql. Add rich text editor SVG asset. --- .../examples/tabs/images/rich-text-editor.svg | 86 +++++++++++++++ .../official-site/examples/tabs/index.sql | 19 ---- .../sqlpage/migrations/57_client_ip.sql | 2 +- .../sqlpage/migrations/62_example_cards.sql | 104 ++++++++++++++++++ 4 files changed, 191 insertions(+), 20 deletions(-) create mode 100644 examples/official-site/examples/tabs/images/rich-text-editor.svg create mode 100644 examples/official-site/sqlpage/migrations/62_example_cards.sql diff --git a/examples/official-site/examples/tabs/images/rich-text-editor.svg b/examples/official-site/examples/tabs/images/rich-text-editor.svg new file mode 100644 index 00000000..409c52d9 --- /dev/null +++ b/examples/official-site/examples/tabs/images/rich-text-editor.svg @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/official-site/examples/tabs/index.sql b/examples/official-site/examples/tabs/index.sql index 2248f80a..b5f32855 100644 --- a/examples/official-site/examples/tabs/index.sql +++ b/examples/official-site/examples/tabs/index.sql @@ -6,25 +6,6 @@ select 'dynamic' as component, json_patch(json_extract(properties, '$[0]'), json )) as properties FROM example WHERE component = 'shell' LIMIT 1; -drop table if exists example_cards; -create temporary table if not exists example_cards as -select 'Advanced Authentication' as title, 'user-authentication' as folder, 'postgres' as db_engine, 'Build a secure user authentication system with login, signup, and in-database session management.' as description union all -select 'Authenticated CRUD', 'CRUD - Authentication', 'sqlite', 'Complete Create-Read-Update-Delete operations with user authentication.' union all -select 'Image Gallery', 'image gallery with user uploads', 'sqlite', 'Create an image gallery with user uploads and session management.' union all -select 'Developer UI', 'SQLPage developer user interface', 'postgres', 'A web-based interface for managing SQLPage files and database tables.' union all -select 'Corporate Game', 'corporate-conundrum', 'sqlite', 'An interactive multiplayer board game with real-time updates.' union all -select 'Roundest Pokemon', 'roundest_pokemon_rating', 'sqlite', 'Demo app with a distinct non-default design, using custom HTML templates for everything.' union all -select 'Todo Application', 'todo application (PostgreSQL)', 'postgres', 'A full-featured todo list application with PostgreSQL backend.' union all -select 'MySQL & JSON', 'mysql json handling', 'mysql', 'Learn advanced JSON manipulation in MySQL to build advanced SQLPage applications.' union all -select 'Apache Web Server', 'web servers - apache', 'mysql', 'Use an existing Apache httpd Web Server to expose your SQLPage application.' union all -select 'Sending Emails', 'sending emails', 'sqlite', 'Use the fetch function to send emails (or interact with any other HTTP API).' union all -select 'Simple Website', 'simple-website-example', 'sqlite', 'Basic website example with navigation and data management.' union all -select 'Geographic App', 'PostGIS - using sqlpage with geographic data', 'postgres', 'Use SQLPage to create and manage geodata.' union all -select 'Multi-step form', 'forms-with-multiple-steps', 'sqlite', 'Guide to the implementation of forms that spread over multiple pages.' union all -select 'Custom HTML & JS', 'custom form component', 'mysql', 'Building a custom form component with a dynamic widget using HTML and javascript.' union all -select 'Splitwise Clone', 'splitwise', 'sqlite', 'An expense tracker app to split expenses with your friends, with nice debt charts.' union all -select 'Advanced Forms with MS SQL Server', 'microsoft sql server advanced forms', 'sql server', 'Forms with multi-value dropdowns, using SQL Server and its JSON functions.'; - select 'tab' as component, true as center; select 'Show all examples' as title, 'All database examples' as description, '?' as link, $db is null as active; select db_engine as title, diff --git a/examples/official-site/sqlpage/migrations/57_client_ip.sql b/examples/official-site/sqlpage/migrations/57_client_ip.sql index db8bc13f..168451f4 100644 --- a/examples/official-site/sqlpage/migrations/57_client_ip.sql +++ b/examples/official-site/sqlpage/migrations/57_client_ip.sql @@ -26,7 +26,7 @@ The function returns: ### ⚠️ Important Notes for Production Use -When running behind a reverse proxy (e.g., Nginx, Apache, Cloudflare): +When [running behind a reverse proxy](/your-first-sql-website/nginx.sql) (e.g., Nginx, Apache, Cloudflare): - This function will return the IP address of the reverse proxy, not the actual client - To get the real client IP, use [`sqlpage.header`](?function=header): `sqlpage.header(''x-forwarded-for'')` or `sqlpage.header(''x-real-ip'')` - The exact header name depends on your reverse proxy configuration diff --git a/examples/official-site/sqlpage/migrations/62_example_cards.sql b/examples/official-site/sqlpage/migrations/62_example_cards.sql new file mode 100644 index 00000000..04a7c90d --- /dev/null +++ b/examples/official-site/sqlpage/migrations/62_example_cards.sql @@ -0,0 +1,104 @@ +create table + example_cards as +select + 'Advanced Authentication' as title, + 'user-authentication' as folder, -- Has to exactly match the folder name in the /examples/ directory + 'postgres' as db_engine, + 'Build a secure user authentication system with login, signup, and in-database session management.' as description +union all +select + 'Authenticated CRUD', + 'CRUD - Authentication', + 'sqlite', + 'Complete Create-Read-Update-Delete operations with user authentication.' +union all +select + 'Image Gallery', + 'image gallery with user uploads', + 'sqlite', + 'Create an image gallery with user uploads and session management.' +union all +select + 'Developer UI', + 'SQLPage developer user interface', + 'postgres', + 'A web-based interface for managing SQLPage files and database tables.' +union all +select + 'Corporate Game', + 'corporate-conundrum', + 'sqlite', + 'An interactive multiplayer board game with real-time updates.' +union all +select + 'Roundest Pokemon', + 'roundest_pokemon_rating', + 'sqlite', + 'Demo app with a distinct non-default design, using custom HTML templates for everything.' +union all +select + 'Todo Application', + 'todo application (PostgreSQL)', + 'postgres', + 'A full-featured todo list application with PostgreSQL backend.' +union all +select + 'MySQL & JSON', + 'mysql json handling', + 'mysql', + 'Learn advanced JSON manipulation in MySQL to build advanced SQLPage applications.' +union all +select + 'Apache Web Server', + 'web servers - apache', + 'mysql', + 'Use an existing Apache httpd Web Server to expose your SQLPage application.' +union all +select + 'Sending Emails', + 'sending emails', + 'sqlite', + 'Use the fetch function to send emails (or interact with any other HTTP API).' +union all +select + 'Simple Website', + 'simple-website-example', + 'sqlite', + 'Basic website example with navigation and data management.' +union all +select + 'Geographic App', + 'PostGIS - using sqlpage with geographic data', + 'postgres', + 'Use SQLPage to create and manage geodata.' +union all +select + 'Multi-step form', + 'forms-with-multiple-steps', + 'sqlite', + 'Guide to the implementation of forms that spread over multiple pages.' +union all +select + 'Custom HTML & JS', + 'custom form component', + 'mysql', + 'Building a custom form component with a dynamic widget using HTML and javascript.' +union all +select + 'Splitwise Clone', + 'splitwise', + 'sqlite', + 'An expense tracker app to split expenses with your friends, with nice debt charts.' +union all +select + 'Advanced Forms with MS SQL Server', + 'microsoft sql server advanced forms', + 'sql server', + 'Forms with multi-value dropdowns, using SQL Server and its JSON functions.' +union all +select + 'Rich Text Editor', + 'rich-text-editor', + 'sqlite', + 'A rich text editor with bold, italic, lists, images, and more. It posts its contents as Markdown.' +;