Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/official-site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ Function pages in `content/functions/` use their filename as the public function
name. Keep the argument list in signature order and mark mandatory arguments with
`required: true`. The Markdown body can include SQL examples without escaping.

## Component reference

Component pages in `content/components/` list parameters under `top` and `row`.
Each `examples/*.md` file can contain `rows` in its YAML metadata. These rows
drive both the live preview and the copyable SQL. The Markdown body is the
example caption. Use numbered filenames to keep the examples in order.
References that have not moved still come from the SQL migrations.

## Landing page

The home page is rendered by `index.sql` and the `landing-page` custom template.
Expand Down
72 changes: 72 additions & 0 deletions examples/official-site/content/components/text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
icon: align-left
category: page-layout
summary: Write paragraphs using plain text or Markdown.
top:
- name: article
type: BOOLEAN
description: Makes long texts more readable by increasing the line height, adding margins, using a serif
font, and decorating the initial letter.
- name: center
type: BOOLEAN
description: Whether to center the title.
- name: contents
type: TEXT
description: A top-level paragraph of text to display, without any formatting, without having to make additional
queries.
- name: contents_md
type: TEXT
description: Rich text in the markdown format. Among others, this allows you to write bold text using `**bold**`,
italics using `*italics*`, and links using `[text](https://example.com)`.
- name: html
type: TEXT
description: Raw html code to include on the page. Don't use that if you are not sure what you are doing,
it may have security implications.
- id
- name: title
type: TEXT
description: Text header before the paragraph.
- name: unsafe_contents_md
type: TEXT
description: Markdown format with html blocks. Use this only with trusted content. See the html-blocks
section of the Commonmark spec for additional info.
row:
- name: bold
type: BOOLEAN
description: Whether the span of text should be displayed as bold.
- name: break
type: BOOLEAN
description: Indicates that the current span of text starts a new paragraph.
- name: code
type: BOOLEAN
description: Use a monospace font. Useful to display the text as code.
- name: color
type: COLOR
description: The name of a color for this span of text.
- name: contents
type: TEXT
required: true
description: A span of text to display
- name: contents_md
type: TEXT
description: Rich text in the markdown format. Among others, this allows you to write bold text using `**bold**`,
italics using `*italics*`, and links using `[text](https://example.com)`.
- name: italics
type: BOOLEAN
description: Whether the span of text should be displayed as italics.
- name: link
type: URL
description: An URL to which the user should be taken when they click on this span of text.
- name: size
type: INTEGER
description: A number between 1 and 6 indicating the font size.
- name: underline
type: BOOLEAN
description: Whether the span of text should be underlined.
- name: unsafe_contents_md
type: TEXT
description: Markdown format with html blocks. Use this only with trusted content. See the html-blocks
section of the Commonmark spec for additional info.
---

A paragraph of text. The entire component will render as a single paragraph, with each item being rendered as a span of text inside it, the styling of which can be customized using parameters.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
rows:
- component: text
contents: Hello, world ! <3
---

Rendering a simple text paragraph.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
rows:
- component: text
article: true
contents_md: |+

# Markdown in SQLPage

## Simple formatting

SQLPage supports only plain text as column values, but markdown allows easily adding **bold**, *italics*, [external links](https://github.com/sqlpage/SQLPage), [links to other pages](/index.sql) and [intra-page links](#my-paragraph).

## Lists
### Unordered lists
* SQLPage is easy
* SQLPage is fun
* SQLPage is free

### Ordered lists
1. SQLPage is fast
2. SQLPage is safe
3. SQLPage is open-source

## Code
```sql
SELECT 'list' AS component;
SELECT name as title FROM users;
```

## Tables

| SQLPage component | Description | Documentation link |
| --- | --- | --- |
| text | A paragraph of text. | [Documentation](https://sql-page.com/documentation.sql?component=text) |
| list | A list of items. | [Documentation](https://sql-page.com/documentation.sql?component=list) |
| steps | A progress indicator. | [Documentation](https://sql-page.com/documentation.sql?component=steps) |
| form | A series of input fields. | [Documentation](https://sql-page.com/documentation.sql?component=form) |

## Quotes
> Fantastic.
>
> — [HackerNews User](https://news.ycombinator.com/item?id=36194473#36209061) about SQLPage

## Images
![SQLPage logo](https://sql-page.com/favicon.ico)

## Horizontal rules
---

---

Rendering rich text using markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
rows:
- component: text
title: About SQL
- contents: SQL
bold: true
italics: true
- contents: ' is a domain-specific language used in programming and designed for managing data held in a '
- contents: relational database management system
link: https://en.wikipedia.org/wiki/Relational_database
- contents: . It is particularly useful in handling structured data.
---

Rendering a paragraph with links and styling.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
rows:
- component: text
contents_md: This is a link to the [next paragraph](#my-paragraph). You can open this link in a new tab
and the page will scroll to the paragraph on load.
- component: text
id: my-paragraph
contents_md: This **is** the next paragraph.
---

An intra-page link to a section of the page.
21 changes: 21 additions & 0 deletions examples/official-site/content/components/title.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
icon: letter-case-upper
since: 0.19.0
category: page-layout
summary: Add a heading and choose its level.
top:
- name: center
type: BOOLEAN
description: Whether to center the title.
- class
- name: contents
type: TEXT
required: true
description: A text to display.
- id
- name: level
type: INTEGER
description: Set the heading level (default level is 1)
---

`level` sets the HTML heading (`h1` through `h6`). Use level 1 for the page title, level 2 for sections, and level 3 for subsections so readers can navigate by heading.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
rows:
- component: title
contents: Level 1
- component: title
contents: Level 2
level: 2
- component: title
contents: Level 3
level: 3
---

Displays several titles with different levels.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
rows:
- component: title
contents: Level 1
center: true
---

Displays a centered title.
10 changes: 10 additions & 0 deletions examples/official-site/content/shared-parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
id:
name: id
type: TEXT
description: id attribute added to the container in HTML. It can be used to target this item through css
or for scrolling to this item through links (use "#id" in link url).
class:
name: class
type: TEXT
description: class attribute added to the container in HTML. It can be used to apply custom styling to this
item through css. Added in v0.18.0.
76 changes: 0 additions & 76 deletions examples/official-site/sqlpage/migrations/01_documentation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -165,82 +165,6 @@ INSERT INTO example(component, description, properties) VALUES
'{"title": "Final account approval", "description": "ophir.dev", "link": "https://ophir.dev/", "icon":"eye-check", "active": true},' ||
'{"title":"Account creation", "icon":"check"}]'));

INSERT INTO component(name, icon, description) VALUES
('text', 'align-left', 'A paragraph of text. The entire component will render as a single paragraph, with each item being rendered as a span of text inside it, the styling of which can be customized using parameters.');

INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'text', * FROM (VALUES
-- top level
('title', 'Text header before the paragraph.', 'TEXT', TRUE, TRUE),
('center', 'Whether to center the title.', 'BOOLEAN', TRUE, TRUE),
('html', 'Raw html code to include on the page. Don''t use that if you are not sure what you are doing, it may have security implications.', 'TEXT', TRUE, TRUE),
('contents', 'A top-level paragraph of text to display, without any formatting, without having to make additional queries.', 'TEXT', TRUE, TRUE),
('contents_md', 'Rich text in the markdown format. Among others, this allows you to write bold text using `**bold**`, italics using `*italics*`, and links using `[text](https://example.com)`.', 'TEXT', TRUE, TRUE),
('article', 'Makes long texts more readable by increasing the line height, adding margins, using a serif font, and decorating the initial letter.', 'BOOLEAN', TRUE, TRUE),
-- item level
('contents', 'A span of text to display', 'TEXT', FALSE, FALSE),
('contents_md', 'Rich text in the markdown format. Among others, this allows you to write bold text using `**bold**`, italics using `*italics*`, and links using `[text](https://example.com)`.', 'TEXT', FALSE, TRUE),
('link', 'An URL to which the user should be taken when they click on this span of text.', 'URL', FALSE, TRUE),
('color', 'The name of a color for this span of text.', 'COLOR', FALSE, TRUE),
('underline', 'Whether the span of text should be underlined.', 'BOOLEAN', FALSE, TRUE),
('bold', 'Whether the span of text should be displayed as bold.', 'BOOLEAN', FALSE, TRUE),
('code', 'Use a monospace font. Useful to display the text as code.', 'BOOLEAN', FALSE, TRUE),
('italics', 'Whether the span of text should be displayed as italics.', 'BOOLEAN', FALSE, TRUE),
('break', 'Indicates that the current span of text starts a new paragraph.', 'BOOLEAN', FALSE, TRUE),
('size', 'A number between 1 and 6 indicating the font size.', 'INTEGER', FALSE, TRUE)
) x;

INSERT INTO example(component, description, properties) VALUES
('text', 'Rendering a simple text paragraph.', json('[{"component":"text", "contents":"Hello, world ! <3"}]')),
('text', 'Rendering rich text using markdown', json('[{"component":"text", "article": true, "contents_md":"\n'||
'# Markdown in SQLPage\n\n' ||
'## Simple formatting\n\n' ||
'SQLPage supports only plain text as column values, but markdown allows easily adding **bold**, *italics*, [external links](https://github.com/sqlpage/SQLPage), [links to other pages](/index.sql) and [intra-page links](#my-paragraph). \n\n' ||
'## Lists\n' ||
'### Unordered lists\n' ||
'* SQLPage is easy\n' ||
'* SQLPage is fun\n' ||
'* SQLPage is free\n\n' ||
'### Ordered lists\n' ||
'1. SQLPage is fast\n' ||
'2. SQLPage is safe\n' ||
'3. SQLPage is open-source\n\n' ||
'## Code\n' ||
'```sql\n' ||
'SELECT ''list'' AS component;\n' ||
'SELECT name as title FROM users;\n' ||
'```\n\n' ||
'## Tables\n\n' ||
'| SQLPage component | Description | Documentation link |\n' ||
'| --- | --- | --- |\n' ||
'| text | A paragraph of text. | [Documentation](https://sql-page.com/documentation.sql?component=text) |\n' ||
'| list | A list of items. | [Documentation](https://sql-page.com/documentation.sql?component=list) |\n' ||
'| steps | A progress indicator. | [Documentation](https://sql-page.com/documentation.sql?component=steps) |\n' ||
'| form | A series of input fields. | [Documentation](https://sql-page.com/documentation.sql?component=form) |\n\n' ||
'## Quotes\n' ||
'> Fantastic.\n>\n' ||
'> — [HackerNews User](https://news.ycombinator.com/item?id=36194473#36209061) about SQLPage\n\n' ||
'## Images\n' ||
'![SQLPage logo](https://sql-page.com/favicon.ico)\n\n' ||
'## Horizontal rules\n' ||
'---\n\n' ||
'"}]')),
('text', 'Rendering a paragraph with links and styling.',
json('[{"component":"text", "title":"About SQL"}, '||
'{"contents":"SQL", "bold":true, "italics": true}, '||
'{"contents":" is a domain-specific language used in programming and designed for managing data held in a "},'||
'{"contents": "relational database management system", "link": "https://en.wikipedia.org/wiki/Relational_database"},'||
'{"contents": ". It is particularly useful in handling structured data."}]')
),
(
'text',
'An intra-page link to a section of the page.',
json('[
{"component":"text", "contents_md":"This is a link to the [next paragraph](#my-paragraph). You can open this link in a new tab and the page will scroll to the paragraph on load."},
{"component":"text", "id": "my-paragraph", "contents_md": "This **is** the next paragraph."}
]')
)
;

INSERT INTO component(name, icon, description) VALUES
('form', 'cursor-text', '
## Building forms in SQL
Expand Down
56 changes: 1 addition & 55 deletions examples/official-site/sqlpage/migrations/35_code_title.sql
Original file line number Diff line number Diff line change
@@ -1,57 +1,3 @@
-- Documentation for the title component
INSERT INTO component (name, description, icon, introduced_in_version) VALUES (
'title',
'`level` sets the HTML heading (`h1` through `h6`). Use level 1 for the page title, level 2 for sections, and level 3 for subsections so readers can navigate by heading.',
'letter-case-upper',
'0.19.0'
);

INSERT INTO parameter (component,name,description,type,top_level,optional) VALUES (
'title',
'center',
'Whether to center the title.',
'BOOLEAN',
TRUE,
TRUE
),(
'title',
'contents',
'A text to display.',
'TEXT',
TRUE,
FALSE
),(
'title',
'level',
'Set the heading level (default level is 1)',
'INTEGER',
TRUE,
TRUE
);

-- Insert example(s) for the component
INSERT INTO example(component, description, properties) VALUES (
'title',
'Displays several titles with different levels.',
JSON(
'[
{"component":"title","contents":"Level 1"},
{"component":"title","contents":"Level 2","level": 2},
{"component":"title","contents":"Level 3","level": 3}
]'
)
);

INSERT INTO example(component, description, properties) VALUES (
'title',
'Displays a centered title.',
JSON(
'[
{"component":"title","contents":"Level 1","center": true}
]'
)
);

-- Documentation for the code component
INSERT INTO component (name, description, icon, introduced_in_version) VALUES (
'code',
Expand Down Expand Up @@ -112,4 +58,4 @@ INSERT INTO example(component, description, properties) VALUES (
}
]'
)
);
);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ WITH copy(name, category, summary) AS (VALUES
('hero', 'page-layout', 'Introduce a page with a headline, media, and a call to action.'),
('html', 'page-layout', 'Insert your own HTML markup into the page.'),
('shell', 'page-layout', 'Set the page layout, navigation, branding, and footer.'),
('text', 'page-layout', 'Write paragraphs using plain text or Markdown.'),
('title', 'page-layout', 'Add a heading and choose its level.'),

('cookie', 'http-responses', 'Set a cookie in the visitor''s browser.'),
('csv', 'http-responses', 'Export query rows as a downloadable CSV file.'),
Expand Down
Loading
Loading