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: 7 additions & 1 deletion examples/official-site/search.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ where name = lower($search) or (kind = 'function' and lower($search) in (
))
order by kind limit 1;

select 'redirect' as component, '/configuration#' || name as link
from config_option where lower($search) in (name, 'sqlpage_' || name);

select 'shell-docs' as component, 'Search' as section,
coalesce($search || ' | ', '') || 'SQLPage documentation search' as title;

Expand All @@ -17,7 +20,10 @@ set escaped_search = '"' || replace(coalesce($search, ''), '"', '""') || '"';

with matches as (
select title, trim(description, char(13) || char(10) || ' ') as summary, page, parameters, fragment, rank,
row_number() over (partition by page, parameters order by rank, rowid) as position
row_number() over (
partition by page, parameters, case when page = '/configuration' then fragment end
order by rank, rowid
) as position
from documentation_fts
where documentation_fts match $escaped_search
)
Expand Down
20 changes: 20 additions & 0 deletions examples/official-site/test.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ xpath "normalize-space(//*[@id='listen_on']/dd)" contains "443"
xpath "//*[@id='database_connection_idle_timeout_seconds']" count == 1
body not contains "An error occurred"

GET http://localhost:8080/search.sql?search=LISTEN_ON
HTTP 302
[Asserts]
header "Location" == "/configuration#listen_on"

GET http://localhost:8080/search.sql?search=web_root
HTTP 302
[Asserts]
header "Location" == "/functions.sql?function=web_root"

GET http://localhost:8080/search.sql?search=SQLPAGE_WEB_ROOT
HTTP 302
[Asserts]
header "Location" == "/configuration#web_root"

GET http://localhost:8080/search.sql?search=SMTP
HTTP 200
[Asserts]
xpath "//main//a[starts-with(@href, '/configuration#smtp_')]" count > 1

GET http://localhost:8080/components.sql
HTTP 200
[Asserts]
Expand Down
3 changes: 3 additions & 0 deletions scripts/site/search.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ JOIN reference_entry AS e ON e.kind = 'component' AND e.name = x.component;

INSERT INTO documentation_fts(title, description, page, parameters)
SELECT title, description, '/blog.sql', json_object('post', title) FROM blog_posts;

INSERT INTO documentation_fts(title, description, page, fragment)
SELECT name, description_md, '/configuration', name FROM config_option;
4 changes: 4 additions & 0 deletions tests/site/prepared-seed.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ test("the published seed is reproducible and replays with searchable reference l
search.get("embed", "table component: embed").link,
"/component.sql?component=table#top-level-parameters-embed",
);
assert.equal(
search.get("listen_on", "listen_on").link,
"/configuration#listen_on",
);
const { source } = db
.prepare(
"SELECT source FROM example_with_source WHERE component = 'table' AND example_number = 4",
Expand Down
Loading