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
6 changes: 6 additions & 0 deletions examples/official-site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ Write posts in `content/blog/` as Markdown with YAML metadata: `title`, `date`
set `external_url` and omit the body. The title is the public URL key, so keep it
when editing an existing post.

## Directories

Edit `content/guides.yaml` for the guides list and `content/projects.yaml` for the
example project cards. A project's `folder` must match its folder under
[`examples/`](../).

## Landing page

The home page is rendered by `index.sql` and the `landing-page` custom template.
Expand Down
28 changes: 28 additions & 0 deletions examples/official-site/content/guides.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- sort_order: 1
title: Your first website
link: /your-first-sql-website/
description: Install SQLPage and build a website from a SQL file.
- sort_order: 2
title: SQL and variables
link: /extensions-to-sql.sql
description: Read request parameters, set variables, and call SQLPage functions.
- sort_order: 3
title: Custom components
link: /custom_components.sql
description: Render your own HTML with Handlebars templates.
- sort_order: 4
title: Database migrations
link: /your-first-sql-website/migrations.sql
description: Create and update your database schema with versioned SQL files.
- sort_order: 5
title: Custom URLs
link: /your-first-sql-website/custom_urls.sql
description: Give your pages readable URLs and route requests to SQL files.
- sort_order: 6
title: Reverse proxy
link: /your-first-sql-website/nginx.sql
description: Serve your site with Nginx and HTTPS.
- sort_order: 7
title: Managed hosting
link: /your-first-sql-website/hosted.sql
description: Try SQLPage online or publish your website with DataPage.
68 changes: 68 additions & 0 deletions examples/official-site/content/projects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
- title: Advanced Authentication
folder: user-authentication
db_engine: postgres
description: Build a secure user authentication system with login, signup, and in-database session management.
- title: Authenticated CRUD
folder: CRUD - Authentication
db_engine: sqlite
description: Complete Create-Read-Update-Delete operations with user authentication.
- title: Image Gallery
folder: image gallery with user uploads
db_engine: sqlite
description: Create an image gallery with user uploads and session management.
- title: Developer UI
folder: SQLPage developer user interface
db_engine: postgres
description: A web-based interface for managing SQLPage files and database tables.
- title: Corporate Game
folder: corporate-conundrum
db_engine: sqlite
description: An interactive multiplayer board game with real-time updates.
- title: Roundest Pokemon
folder: roundest_pokemon_rating
db_engine: sqlite
description: Demo app with a distinct non-default design, using custom HTML templates for everything.
- title: Todo Application
folder: todo application (PostgreSQL)
db_engine: postgres
description: A full-featured todo list application with PostgreSQL backend.
- title: MySQL & JSON
folder: mysql json handling
db_engine: mysql
description: Learn advanced JSON manipulation in MySQL to build advanced SQLPage applications.
- title: Apache Web Server
folder: web servers - apache
db_engine: mysql
description: Use an existing Apache httpd Web Server to expose your SQLPage application.
- title: Sending Emails
folder: sending emails
db_engine: sqlite
description: Send email and attachments through SMTP with sqlpage.send_mail, and inspect the messages in a local Mailpit inbox.
- title: Simple Website
folder: simple-website-example
db_engine: sqlite
description: Basic website example with navigation and data management.
- title: Geographic App
folder: PostGIS - using sqlpage with geographic data
db_engine: postgres
description: Use SQLPage to create and manage geodata.
- title: Multi-step form
folder: forms-with-multiple-steps
db_engine: sqlite
description: Guide to the implementation of forms that spread over multiple pages.
- title: Custom HTML & JS
folder: custom form component
db_engine: mysql
description: Building a custom form component with a dynamic widget using HTML and javascript.
- title: Splitwise Clone
folder: splitwise
db_engine: sqlite
description: An expense tracker app to split expenses with your friends, with nice debt charts.
- title: Advanced Forms with MS SQL Server
folder: microsoft sql server advanced forms
db_engine: sql server
description: Forms with multi-value dropdowns, using SQL Server and its JSON functions.
- title: Rich Text Editor
folder: rich-text-editor
db_engine: sqlite
description: A rich text editor with bold, italic, lists, images, and more. It posts its contents as Markdown.
105 changes: 1 addition & 104 deletions examples/official-site/sqlpage/migrations/62_example_cards.sql
Original file line number Diff line number Diff line change
@@ -1,104 +1 @@
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',
'Send email and attachments through SMTP with sqlpage.send_mail, and inspect the messages in a local Mailpit inbox.'
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.'
;
CREATE TABLE example_cards (title TEXT NOT NULL, folder TEXT NOT NULL, db_engine TEXT, description TEXT NOT NULL);
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,3 @@ CREATE TABLE guide (
link TEXT NOT NULL UNIQUE,
description TEXT NOT NULL
);

INSERT INTO guide (sort_order, title, link, description) VALUES
(1, 'Your first website', '/your-first-sql-website/', 'Install SQLPage and build a website from a SQL file.'),
(2, 'SQL and variables', '/extensions-to-sql.sql', 'Read request parameters, set variables, and call SQLPage functions.'),
(3, 'Custom components', '/custom_components.sql', 'Render your own HTML with Handlebars templates.'),
(4, 'Database migrations', '/your-first-sql-website/migrations.sql', 'Create and update your database schema with versioned SQL files.'),
(5, 'Custom URLs', '/your-first-sql-website/custom_urls.sql', 'Give your pages readable URLs and route requests to SQL files.'),
(6, 'Reverse proxy', '/your-first-sql-website/nginx.sql', 'Serve your site with Nginx and HTTPS.'),
(7, 'Managed hosting', '/your-first-sql-website/hosted.sql', 'Try SQLPage online or publish your website with DataPage.');
8 changes: 8 additions & 0 deletions scripts/site/content.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ export function fields(map, allowed) {
return Object.fromEntries(map);
}

export function collection(dir, file, visit) {
atFile(join(dir, file), (source) => {
const items = parse(source, { mapAsMap: true });
if (!Array.isArray(items)) throw new Error("Expected a YAML list");
for (const item of items) visit(item);
});
}

export function text(value, name) {
if (typeof value !== "string" || !value.trim())
throw new Error(`Expected text in ${name}`);
Expand Down
35 changes: 35 additions & 0 deletions scripts/site/directories.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { readdirSync } from "node:fs";
import { resolve } from "node:path";
import { collection, fields, text } from "./content.mjs";

export function insertDirectories(seed, content) {
collection(content, "guides.yaml", (item) => {
const g = fields(item, ["sort_order", "title", "link", "description"]);
if (!Number.isSafeInteger(g.sort_order))
throw new Error("Expected an integer sort_order");
seed.row(
"INSERT INTO guide (sort_order, title, link, description) VALUES (?, ?, ?, ?)",
g.sort_order,
text(g.title, "title"),
text(g.link, "link"),
text(g.description, "description"),
);
});
const folders = new Set(
readdirSync(resolve(content, "../.."), { withFileTypes: true })
.filter((entry) => entry.isDirectory())
.map((entry) => entry.name),
);
collection(content, "projects.yaml", (item) => {
const p = fields(item, ["title", "folder", "db_engine", "description"]);
if (!folders.has(p.folder))
throw new Error(`No example directory named ${p.folder}`);
seed.row(
"INSERT INTO example_cards (title, folder, db_engine, description) VALUES (?, ?, ?, ?)",
text(p.title, "title"),
p.folder,
p.db_engine ?? null,
text(p.description, "description"),
);
});
}
2 changes: 2 additions & 0 deletions scripts/site/documentation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { readdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { DatabaseSync } from "node:sqlite";
import { fields, pages, text } from "./content.mjs";
import { insertDirectories } from "./directories.mjs";

// Let SQLite quote bound values for the migration exactly as it executed them.
export class Seed {
Expand Down Expand Up @@ -67,6 +68,7 @@ export function writeDocumentation(content, migrations) {
if (n < version) db.exec(readFileSync(join(migrations, file), "utf8"));
}
const seed = new Seed(db);
insertDirectories(seed, content);
insertPosts(seed, join(content, "blog"));
writeFileSync(
join(migrations, `${version}_documentation_content.sql`),
Expand Down
Loading