Skip to content

Commit 5d81049

Browse files
authored
Merge branch 'sqlpage:main' into handle-requests-without-file-extension
2 parents e58b865 + 9567e4d commit 5d81049

File tree

11 files changed

+236
-61
lines changed

11 files changed

+236
-61
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- Add support for HTTP Basic Authentication in the [fetch](https://sql-page.com/documentation.sql?component=fetch#component) function.
66
- Fix a bug where the table component would not add the right css classes to table cells.
7+
- Better error messages when a CSV import fails (using a `copy` statement and a file upload).
8+
- Fix a bug where subsequent requests would fail after a failed CSV import on postgres (https://github.com/sqlpage/SQLPage/issues/788)
79

810
## 0.32.1 (2025-01-03)
911

Cargo.lock

Lines changed: 33 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ panic = "abort"
1818
codegen-units = 2
1919

2020
[dependencies]
21-
sqlx = { package = "sqlx-oldapi", version = "0.6.38", features = [
21+
sqlx = { package = "sqlx-oldapi", version = "0.6.39", features = [
2222
"any",
2323
"runtime-actix-rustls",
2424
"sqlite",

examples/official-site/assets/highlightjs-and-tabler-theme.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
--tblr-blue: rgb(var(--tblr-blue-rgb));
3232
--tblr-blue-lt-rgb: 21, 31, 53;
3333
--tblr-blue-lt: rgb(var(--tblr-blue-lt-rgb));
34-
--tblr-primary-rgb: 66, 99, 133;
34+
--tblr-primary-rgb: 95, 132, 169;
3535
--tblr-primary: rgb(var(--tblr-primary-rgb));
36-
--tblr-secondary: hsla(246.7, 60%, 94.1%, 0.85); /* Nebula purple */
36+
--tblr-secondary: hsla(247, 60%, 94%, 0.7); /* Nebula purple */
3737

3838
/* Luminous links */
3939
--tblr-link-color: hsl(212, 70%, 75%) !important; /* Star glow */

examples/official-site/colors.sql

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
select 'dynamic' as component, properties FROM example WHERE component = 'shell' LIMIT 1;
1+
set theme = coalesce($theme, 'custom');
2+
3+
select 'dynamic' as component, json_patch(json_extract(properties, '$[0]'), json_object(
4+
'title', $theme || ' SQLPage Colors',
5+
'css', case $theme when 'custom' then '/assets/highlightjs-and-tabler-theme.css' end,
6+
'theme', case $theme when 'default' then 'light' else 'dark' end
7+
)) as properties
8+
FROM example WHERE component = 'shell' LIMIT 1;
29

310
create temporary table if not exists colors as select column1 as color, column2 as hex from (values
411
('blue', '#0054a6'), ('azure', '#4299e1'), ('indigo', '#4263eb'), ('purple', '#ae3ec9'), ('pink', '#d6336c'), ('red', '#d63939'), ('orange', '#f76707'), ('yellow', '#f59f00'), ('lime', '#74b816'), ('green', '#2fb344'), ('teal', '#0ca678'), ('cyan', '#17a2b8'),
@@ -9,6 +16,77 @@ create temporary table if not exists colors as select column1 as color, column2
916
('primary', '#0054a6'), ('secondary', '#49566c'), ('success', '#2fb344'), ('info', '#17a2b8'), ('warning', '#f59f00'), ('danger', '#d63939'), ('light', '#f1f5f9'), ('dark', '#0f172a')
1017
);
1118

19+
select 'tab' as component;
20+
select 'Default theme' as title, '?theme=default' as link, 'Default theme' as description, case $theme when 'default' then 'primary' end as color, $theme = 'default' as disabled;
21+
select 'Custom theme' as title, '?theme=custom' as link, 'Custom theme' as description, case $theme when 'custom' then 'primary' end as color, $theme = 'custom' as disabled;
22+
23+
1224
select 'card' as component, 'Colors' as title;
1325
select color as title, hex as description, color as background_color
14-
from colors;
26+
from colors;
27+
28+
29+
select 'text' as component, '
30+
The colors above are from the [official site custom theme](https://github.com/sqlpage/SQLPage/blob/main/examples/official-site/assets/highlightjs-and-tabler-theme.css).
31+
View [this page with the default theme](?theme=default) to see the colors that are used by default.
32+
' as contents_md where $theme = 'custom';
33+
34+
select 'text' as component, '
35+
### Customization and theming
36+
37+
SQLPage is designed to be easily customizable and themable.
38+
You cannot pass arbitrary color codes to components from your SQL queries,
39+
but you can customize which exact color is associated to each color name.
40+
41+
#### Creating a custom theme
42+
43+
To create a custom theme, you can create a CSS file and use the [shell component](/component.sql?component=shell) to include it.
44+
45+
##### `index.sql`
46+
47+
```sql
48+
select ''shell'' as component, ''custom_theme.css'' as css, ''custom_theme'' as theme;
49+
```
50+
51+
##### `custom_theme.css`
52+
53+
```css
54+
:root,
55+
.layout-boxed[data-bs-theme="custom_theme"] {
56+
color-scheme: light;
57+
58+
/* Base text colors */
59+
--tblr-body-color: #cfd5e6;
60+
--tblr-text-secondary-rgb: 204, 209, 217;
61+
--tblr-secondary-color: #cccccc;
62+
--tblr-muted-color: rgba(191, 191, 191, 0.8);
63+
64+
/* Background colors */
65+
--tblr-body-bg: #0f1426;
66+
--tblr-bg-surface: #111629;
67+
--tblr-bg-surface-secondary: #151a2e;
68+
--tblr-bg-surface-tertiary: #191f33;
69+
70+
/* Primary and secondary colors */
71+
--tblr-primary-rgb: 95, 132, 169;
72+
--tblr-primary: rgb(var(--tblr-primary-rgb));
73+
--tblr-secondary-rgb: 235, 232, 255;
74+
--tblr-secondary: rgb(var(--tblr-secondary-rgb));
75+
76+
/* Border colors */
77+
--tblr-border-color: #151926;
78+
--tblr-border-color-translucent: #404d73b3;
79+
80+
/* Theme colors. All sqlpage colors can be customized in the same way. */
81+
--tblr-blue-rgb: 84, 151, 213; /* To convert between #RRGGBB color codes to decimal RGB values, you can use https://www.rapidtables.com/web/color/RGB_Color.html */
82+
--tblr-blue: rgb(var(--tblr-blue-rgb));
83+
84+
--tblr-red-rgb: 229, 62, 62;
85+
--tblr-red: rgb(var(--tblr-red-rgb));
86+
87+
--tblr-green-rgb: 72, 187, 120;
88+
--tblr-green: rgb(var(--tblr-green-rgb));
89+
}
90+
```
91+
' as contents_md;
92+

examples/official-site/sqlpage/migrations/13_tab.sql

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ INSERT INTO parameter (
1616
VALUES (
1717
'tab',
1818
'title',
19-
'Text to display on the tab.',
19+
'Text to display on the tab. If link is not set, the link will be the current page with a ''$tab'' parameter set to the tab''s title. If ''id'' is set, the page will be scrolled to the tab.',
2020
'TEXT',
2121
FALSE,
2222
FALSE
@@ -80,17 +80,29 @@ To implement contents that change based on the active tab, use the `tab` paramet
8080
For example, if the page is `/my-page.sql`, then the first tab will have a link of `/my-page.sql?tab=My+First+tab`.
8181
8282
You could then for instance display contents coming from the database based on the value of the `tab` parameter.
83-
For instance: `SELECT ''text'' AS component, contents_md FROM my_page_contents WHERE tab = $tab`
83+
For instance: `SELECT ''text'' AS component, contents_md FROM my_page_contents WHERE tab = $tab`.
84+
Or you could write different queries for different tabs and use the `$tab` parameter with a static value in a where clause to switch between tabs:
85+
86+
```sql
87+
select ''tab'' as component;
88+
select ''Projects'' as title, $tab = ''Projects'' as active;
89+
select ''Tasks'' as title, $tab = ''Tasks'' as active;
90+
91+
select ''table'' as component;
92+
93+
select * from my_projects where $tab = ''Projects'';
94+
select * from my_tasks where $tab = ''Tasks'';
95+
```
8496
8597
Note that the example below is completely static, and does not use the `tab` parameter to actually switch between tabs.
8698
View the [dynamic tabs example](/examples/tabs/).
8799
',
88100
JSON(
89101
'[
90102
{ "component": "tab" },
91-
{ "title": "This tab does not exist", "active": true },
92-
{ "title": "I am not a true tab" },
93-
{ "title": "Do not click here" }
103+
{ "title": "This tab does not exist", "active": true, "link": "?component=tab&tab=tab_1" },
104+
{ "title": "I am not a true tab", "link": "?component=tab&tab=tab_2" },
105+
{ "title": "Do not click here", "link": "?component=tab&tab=tab_3" }
94106
]'
95107
)
96108
),
@@ -101,7 +113,7 @@ View the [dynamic tabs example](/examples/tabs/).
101113
'[
102114
{ "component": "tab", "center": true },
103115
{ "title": "Hero", "link": "?component=hero#component", "icon": "home", "description": "The hero component is a full-width banner with a title and an image." },
104-
{ "title": "Tab", "active": true, "link": "?component=tab#component", "icon": "user", "color": "dark" },
116+
{ "title": "Tab", "link": "?component=tab#component", "icon": "user", "color": "purple" },
105117
{ "title": "Card", "link": "?component=card#component", "icon": "credit-card" }
106118
]'
107119
)

examples/official-site/sqlpage/migrations/54_blog_bompard.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
INSERT INTO blog_posts (title, description, icon, created_at, content)
33
VALUES
44
(
5-
'Alexis''s performance monitoring tool',
6-
'Alexis built a performance monitoring tool with SQLPage',
5+
'How I built a 360° performance monitoring tool with SQL Queries',
6+
'Alexis built a performance monitoring tool with SQLPage for a 100M€/year company',
77
'shirt',
8-
'2024-10-26',
8+
'2025-01-25',
99
'
1010
# How I Built And Deployed An Exhaustive Performance Monitoring Tool For a 100M€/year Company Using SQL Queries Only
1111

0 commit comments

Comments
 (0)