Skip to content

Commit 3d75398

Browse files
committed
Add the official sqlpage website as an example
1 parent 60923b1 commit 3d75398

File tree

3 files changed

+92
-80
lines changed

3 files changed

+92
-80
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
-- This line, at the top of the page, tells web browsers to keep the page locally in cache once they have it.
2+
select 'http_header' as component, 'max-age=3600' as "Cache-Control";
3+
select
4+
'SQLPage documentation' as title,
5+
'/' as link,
6+
'en-US' as lang,
7+
'Documentation for the SQLPage low-code web application framework.' as description;
8+
9+
10+
select 'text' as component, 'SQLPage documentation' as title;
11+
select 'Building an application with SQLPage is quite simple.' ||
12+
'To create a new web page, just create a new SQL file. ' ||
13+
'For each SELECT statement that you write, the data it returns will be analyzed and rendered to the user.';
14+
select 'The two most important concepts in SQLPage are ' as contents;
15+
select 'components' as contents, true as bold;
16+
select ' and ' as contents;
17+
select 'parameters' as contents, true as bold;
18+
select '.' as contents;
19+
select 'This page documents all the components that you can use in SQLPage and their parameters. ' ||
20+
'Use this as a reference when building your SQL application.' as contents;
21+
22+
select 'list' as component, 'components' as title;
23+
select
24+
name as title,
25+
description,
26+
icon,
27+
'?component='||name||'#component' as link,
28+
$component = name as active
29+
from component;
30+
31+
select 'text' as component,
32+
'The "'||$component||'" component' as title,
33+
'component' as id;
34+
select description as contents from component where name = $component;
35+
36+
select 'title' as component, 3 as level, 'Parameters' as contents where $component IS NOT NULL;
37+
select 'card' as component, 3 AS columns where $component IS NOT NULL;
38+
select
39+
name || (CASE WHEN top_level THEN ' (top-level)' ELSE '' END) as title,
40+
(CASE WHEN optional THEN '' ELSE 'REQUIRED. ' END) || description as description,
41+
type as footer,
42+
CASE WHEN top_level THEN 'lime' ELSE 'azure' END || CASE WHEN optional THEN '-lt' ELSE '' END as color
43+
from parameter where component = $component
44+
ORDER BY (NOT top_level), optional, name;
45+
46+
select
47+
'dynamic' as component,
48+
json_array(
49+
json_object('component', 'code'),
50+
json_object(
51+
'title', 'Example ' || (row_number() OVER ()),
52+
'description', description,
53+
'contents', (
54+
select
55+
group_concat(
56+
'SELECT ' || x'0A' ||
57+
(
58+
select group_concat(
59+
' ' || quote(value) || ' as ' || key, ',' || x'0A'
60+
) from json_each(top.value)
61+
) || ';',
62+
x'0A'
63+
)
64+
from json_each(properties) AS top
65+
)
66+
),
67+
json_object('component', 'title', 'level', 3, 'contents', 'Result'),
68+
json_object('component', 'dynamic', 'properties', properties)
69+
) as properties
70+
from example where component = $component;

examples/official-site/index.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
-- Using the 'shell' component at the top allows you to customize your web page, giving it a title and a description
3+
select 'shell' as component, 'sqlpage' as title, '/' as link, 'en' as lang,
4+
'Official SQLPage webpage: write web applications in SQL !' as description;
5+
6+
select 'text' as component, 'SQLPage: turn any database into a webapp' as title;
7+
SELECT 'SQLPage is a powerful tool for creating websites using only SQL. With SQLPage, you can create dynamic and functional websites without the need for complex programming languages. Simply define your website using a set of predefined components and fill them with the results of your SQL queries. This allows you to quickly and easily create a website that is tailored to your specific needs and requirements.' as contents, TRUE as break, 3 as size;
8+
9+
select 'text' as component, 'SQL-only' as title;
10+
SELECT 'One of the key benefits of SQLPage is that it allows you to use your existing SQL skills to create a website. If you are already familiar with SQL, you can use SQLPage to create a website without the need to learn additional programming languages. This makes it an ideal tool for people who are not professional programmers, but still want to create a website with a database.' as contents, TRUE as break, 4 as size;
11+
12+
select 'text' as component, 'Pre-defined components for everything' as title;
13+
SELECT 'In addition to its ease of use, SQLPage offers a wide range of features and capabilities. You can create a wide variety of components, including text blocks, charts, lists, and forms, and customise them with a variety of properties. This allows you to create a website that is tailored to your specific needs and requirements.' as contents, TRUE as break, 4 as size;
14+
15+
select 'text' as component, 'Get started!' as title;
16+
SELECT 'Overall, SQLPage is a powerful and innovative tool for creating websites using only SQL. With its ease of use and wide range of features, it offers a unique and valuable way to create dynamic and functional websites without the need for complex programming languages. If you want to create a website with a database, SQLPage is the perfect tool for you.' as contents, TRUE as break, 4 as size;

documentation.sql renamed to examples/official-site/sqlpage/migrations/01_documentation.sql

Lines changed: 6 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
-- This line, at the top of the page, tells web browsers to keep the page locally in cache once they have it.
2-
select 'http_header' as component, 'max-age=3600' as "Cache-Control";
3-
4-
DROP TABLE IF EXISTS example;
5-
DROP TABLE IF EXISTS parameter;
6-
DROP TABLE IF EXISTS component;
7-
8-
CREATE TABLE IF NOT EXISTS component(
1+
CREATE TABLE component(
92
name TEXT PRIMARY KEY,
103
description TEXT NOT NULL,
114
icon TEXT -- icon name from tabler icon
125
);
136

14-
CREATE TABLE IF NOT EXISTS parameter(
7+
CREATE TABLE parameter(
158
top_level BOOLEAN DEFAULT FALSE,
169
name TEXT,
1710
component TEXT REFERENCES component(name) ON DELETE CASCADE,
@@ -21,7 +14,7 @@ CREATE TABLE IF NOT EXISTS parameter(
2114
PRIMARY KEY (component, top_level, name)
2215
);
2316

24-
CREATE TABLE IF NOT EXISTS example(
17+
CREATE TABLE example(
2518
component TEXT REFERENCES component(name) ON DELETE CASCADE,
2619
description TEXT,
2720
properties TEXT,
@@ -140,7 +133,9 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
140133
('underline', 'Whether the span of text should be underlined.', 'BOOLEAN', FALSE, TRUE),
141134
('bold', 'Whether the span of text should be displayed as bold.', 'BOOLEAN', FALSE, TRUE),
142135
('code', 'Use a monospace font. Useful to display the text as code.', 'BOOLEAN', FALSE, TRUE),
143-
('italics', 'Whether the span of text should be displayed as italics.', 'BOOLEAN', FALSE, TRUE)
136+
('italics', 'Whether the span of text should be displayed as italics.', 'BOOLEAN', FALSE, TRUE),
137+
('break', 'Indicates that the current span of text starts a new paragraph.', 'BOOLEAN', FALSE, TRUE),
138+
('size', 'A number between 1 and 6 indicating the font size.', 'INTEGER', FALSE, TRUE)
144139
);
145140

146141
INSERT INTO example(component, description, properties) VALUES
@@ -275,72 +270,3 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
275270
INSERT INTO example(component, description, properties) VALUES
276271
('shell', 'This example contains the values used for the shell of the page you are currently viewing.',
277272
json('[{"title": "SQLPage documentation", "link": "/", "lang": "en-US", "description": "Documentation for the SQLPage low-code web application framework."}]'));
278-
279-
select
280-
'SQLPage documentation' as title,
281-
'/' as link,
282-
'en-US' as lang,
283-
'Documentation for the SQLPage low-code web application framework.' as description;
284-
285-
286-
select 'text' as component, 'SQLPage documentation' as title;
287-
select 'Building an application with SQLPage is quite simple.' ||
288-
'To create a new web page, just create a new SQL file. ' ||
289-
'For each SELECT statement that you write, the data it returns will be analyzed and rendered to the user.';
290-
select 'The two most important concepts in SQLPage are ' as contents;
291-
select 'components' as contents, true as bold;
292-
select ' and ' as contents;
293-
select 'parameters' as contents, true as bold;
294-
select '.' as contents;
295-
select 'This page documents all the components that you can use in SQLPage and their parameters. ' ||
296-
'Use this as a reference when building your SQL application.' as contents;
297-
298-
select 'list' as component, 'components' as title;
299-
select
300-
name as title,
301-
description,
302-
icon,
303-
'?component='||name||'#component' as link,
304-
$component = name as active
305-
from component;
306-
307-
select 'text' as component,
308-
'The "'||$component||'" component' as title,
309-
'component' as id;
310-
select description as contents from component where name = $component;
311-
312-
select 'title' as component, 3 as level, 'Parameters' as contents where $component IS NOT NULL;
313-
select 'card' as component, 3 AS columns where $component IS NOT NULL;
314-
select
315-
name || (CASE WHEN top_level THEN ' (top-level)' ELSE '' END) as title,
316-
(CASE WHEN optional THEN '' ELSE 'REQUIRED. ' END) || description as description,
317-
type as footer,
318-
CASE WHEN top_level THEN 'lime' ELSE 'azure' END || CASE WHEN optional THEN '-lt' ELSE '' END as color
319-
from parameter where component = $component
320-
ORDER BY (NOT top_level), optional, name;
321-
322-
select
323-
'dynamic' as component,
324-
json_array(
325-
json_object('component', 'code'),
326-
json_object(
327-
'title', 'Example ' || (row_number() OVER ()),
328-
'description', description,
329-
'contents', (
330-
select
331-
group_concat(
332-
'SELECT ' || x'0A' ||
333-
(
334-
select group_concat(
335-
' ' || quote(value) || ' as ' || key, ',' || x'0A'
336-
) from json_each(top.value)
337-
) || ';',
338-
x'0A'
339-
)
340-
from json_each(properties) AS top
341-
)
342-
),
343-
json_object('component', 'title', 'level', 3, 'contents', 'Result'),
344-
json_object('component', 'dynamic', 'properties', properties)
345-
) as properties
346-
from example where component = $component;

0 commit comments

Comments
 (0)