Skip to content

Commit

Permalink
Upgrade to datasette 0.40 with YAML metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 22, 2020
1 parent b08640b commit 81f7735
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 17 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
gcloud config set project datasette-222320
datasette publish cloudrun browse.db about.db map.db \
--service niche-museums \
--metadata metadata.json \
--metadata metadata.yaml \
--install=datasette-haversine \
--install=datasette-pretty-json \
--install=datasette-template-sql \
Expand All @@ -59,5 +59,4 @@ jobs:
--install=datasette-atom \
--template-dir=templates \
--plugins-dir=plugins \
--static css:static/ \
--branch=286ed286b68793532c2a38436a08343b45cfbc91
--static css:static/
12 changes: 0 additions & 12 deletions metadata.json

This file was deleted.

65 changes: 65 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
title: www.niche-museums.com
databases:
browse:
queries:
nearby: |-
select *, haversine(latitude, longitude, cast(:latitude as real), cast(:longitude as real), 'mi') as distance_mi
from museums order by distance_mi
feed: |-
SELECT
'tag:niche-museums.com,' || substr(m.created, 0, 11) || ':' || m.id as atom_id,
m.name as atom_title,
m.created as atom_updated,
'https://www.niche-museums.com/browse/museums/' || m.id as atom_link,
coalesce(
'<img src="' || m.photo_url || '?w=800&amp;h=400&amp;fit=crop&amp;auto=compress">',
''
) || render_markdown(
m.description || '
' || coalesce(
(
select
group_concat(
'* [' || json_extract(p.value, '$.title') || '](' || json_extract(p.value, '$.url') || ') ' || json_extract(p.value, '$.author') || ', ' || json_extract(p.value, '$.publication') || ', ' || json_extract(p.value, '$.date'),
'
'
)
from
json_each(coalesce(m.press, '[{}]')) as p
),
''
)
) || coalesce(
(
select
group_concat(
'<p><img src="' || json_extract(ph.value, '$.url') || '?w=400&auto=compress"></p>',
''
)
from
json_each(coalesce(m.photos, '[{}]')) as ph
),
''
) as atom_content_html
FROM
museums m
order by
m.created desc
limit
15
search: |-
select
museums_fts.rank,
museums.*
from
museums
join museums_fts on museums.id = museums_fts.rowid
where
museums_fts match case
:q
when '' then '*'
else escape_fts_query(:q)
end
order by
museums_fts.rank
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
datasette
datasette~=0.40
datasette-haversine
datasette-template-sql>=1.0
datasette-pretty-json
Expand Down
2 changes: 1 addition & 1 deletion serve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ datasette browse.db about.db map.db -p 8211 \
--template-dir=templates/ \
--plugins-dir=plugins/ \
--static css:static/ \
-m metadata.json
-m metadata.yaml

0 comments on commit 81f7735

Please sign in to comment.