-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
-- Insert the http_header component into the component table | ||
INSERT INTO component (name, description, icon) | ||
VALUES ( | ||
'cookie', | ||
'Sets a cookie in the client browser, used for session management and storing user-related information. | ||
This component creates a single cookie. Since cookies need to be set before the response body is sent to the client, | ||
this component should be placed at the top of the page, before any other components that generate output. | ||
After being set, a cookie can be accessed anywhere in your SQL code using the `sqlpage.cookie(''cookie_name'')` pseudo-function.', | ||
'cookie' | ||
); | ||
-- Insert the parameters for the http_header component into the parameter table | ||
INSERT INTO parameter ( | ||
component, | ||
name, | ||
description, | ||
type, | ||
top_level, | ||
optional | ||
) | ||
VALUES ( | ||
'cookie', | ||
'name', | ||
'The name of the cookie to set.', | ||
'TEXT', | ||
TRUE, | ||
FALSE | ||
), | ||
( | ||
'cookie', | ||
'value', | ||
'The value of the cookie to set.', | ||
'TEXT', | ||
TRUE, | ||
TRUE | ||
), | ||
( | ||
'cookie', | ||
'path', | ||
'The path for which the cookie will be sent. If not specified, the cookie will be sent for all paths.', | ||
'TEXT', | ||
TRUE, | ||
TRUE | ||
), | ||
( | ||
'cookie', | ||
'domain', | ||
'The domain for which the cookie will be sent. If not specified, the cookie will be sent for all domains.', | ||
'TEXT', | ||
TRUE, | ||
TRUE | ||
), | ||
( | ||
'cookie', | ||
'secure', | ||
'Whether the cookie should only be sent over a secure (HTTPS) connection. If not specified, the cookie will be sent over both secure and non-secure connections.', | ||
'BOOLEAN', | ||
TRUE, | ||
TRUE | ||
), | ||
( | ||
'cookie', | ||
'http_only', | ||
'Whether the cookie should only be accessible via HTTP and not via client-side scripts. If not specified, the cookie will be accessible via both HTTP and client-side scripts.', | ||
'BOOLEAN', | ||
TRUE, | ||
TRUE | ||
), | ||
( | ||
'cookie', | ||
'remove', | ||
'Set to TRUE to remove the cookie from the client browser. When specified, other parameters are ignored.', | ||
'BOOLEAN', | ||
TRUE, | ||
TRUE | ||
) | ||
; | ||
-- Insert an example usage of the http_header component into the example table | ||
INSERT INTO example (component, description, properties) | ||
VALUES ( | ||
'cookie', | ||
'Create a cookie named `username` with the value `John Doe`... | ||
```sql | ||
SELECT ''cookie'' as component, | ||
''username'' as name, | ||
''John Doe'' as value; | ||
``` | ||
and then display the value of the cookie: | ||
```sql | ||
SELECT ''text'' as component, | ||
''Your name is '' || COALESCE(sqlpage.cookie(''username''), ''not known to us''); | ||
``` | ||
', | ||
JSON('[]') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SQLPage application with custom login in Postgres | ||
|
||
This is a very simple example of a website that uses the SQLPage web application framework. It uses a Postgres database for storing the data. | ||
|
||
It lets an user log in and out, and it shows a list of the users that have logged in. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- Sets the username cookie to the value of the username parameter | ||
SELECT 'cookie' as component, | ||
'username' as name, | ||
$username as value | ||
WHERE $username IS NOT NULL; | ||
|
||
SELECT 'form' as component; | ||
SELECT 'username' as name, | ||
'User Name' as label, | ||
COALESCE($username, sqlpage.cookie('username')) as value, | ||
'try leaving this page and coming back, the value should be saved in a cookie' as description; | ||
|
||
select 'text' as component; | ||
select 'log out' as contents, 'logout.sql' as link; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- Sets the username cookie to the value of the username parameter | ||
SELECT 'cookie' as component, | ||
'username' as name, | ||
TRUE as remove; | ||
|
||
SELECT 'http_header' as component, 'index.sql' as Location; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"database_url": "sqlite://:memory:" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters