Skip to content

Commit 7231347

Browse files
committed
edit descriptions in the postgis example
1 parent a39b952 commit 7231347

File tree

4 files changed

+36
-10
lines changed

4 files changed

+36
-10
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
SELECT 'shell' as component,
2+
'Point edition' AS title,
3+
'/' as link,
4+
'book' as icon;
5+
6+
UPDATE spatial_data
7+
SET description = :Text
8+
WHERE id = $id::int AND :Text IS NOT NULL;
9+
10+
SELECT 'form' AS component, title
11+
FROM spatial_data WHERE id = $id::int;
12+
13+
SELECT
14+
'Text' AS name,
15+
'Description for the point: ' || title AS description,
16+
'textarea' AS type,
17+
description AS value
18+
FROM spatial_data
19+
WHERE id = $id::int;
20+
21+
SELECT 'text' as component,
22+
description as contents_md
23+
FROM spatial_data
24+
WHERE id = $id::int;

examples/PostGIS - using sqlpage with geographic data/index.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SELECT 'map' as component,
1616
SELECT title,
1717
ST_Y(geom) AS latitude,
1818
ST_X(geom) AS longitude,
19-
'point.sql?id=' || id as link
19+
format('[View](point.sql?id=%s) [Edit](edition_form.sql?id=%s)', id, id) as description_md
2020
FROM spatial_data;
2121

2222

examples/PostGIS - using sqlpage with geographic data/point.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ FROM spatial_data
3636
WHERE id = $id::int;
3737

3838
SELECT 'text' as component,
39-
description as contents_md
39+
description ||
40+
format(E'\n\n [Edit description](edition_form.sql?id=%s)', id)
41+
as contents_md
4042
FROM spatial_data
4143
WHERE id = $id::int;
4244

examples/PostGIS - using sqlpage with geographic data/sqlpage/migrations/0000_create_db.sql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
CREATE EXTENSION IF NOT EXISTS postgis;
22

3-
-- Create a spatialite-enabled database
4-
CREATE TABLE spatial_data (
5-
id SERIAL,
6-
title TEXT NOT NULL,
7-
geom geometry,
8-
description TEXT NOT NULL,
9-
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
3+
-- Create a table with a postgis geometry column
4+
CREATE TABLE IF NOT EXISTS spatial_data (
5+
id serial primary key NOT NULL,
6+
title text NOT NULL,
7+
geom geometry NULL,
8+
description text NOT NULL,
9+
created_at timestamp without time zone NULL DEFAULT CURRENT_TIMESTAMP
1010
);
1111

1212

13-
CREATE VIEW distances AS
13+
CREATE OR REPLACE VIEW distances AS
1414
SELECT from_point.id AS from_id,
1515
from_point.title AS from_label,
1616
to_point.id AS to_id,

0 commit comments

Comments
 (0)