mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Apply render_cell plugin on table views, refs #352
This commit is contained in:
parent
510e01f224
commit
61e9a4d601
6 changed files with 19 additions and 24 deletions
|
|
@ -223,6 +223,8 @@ def extra_js_urls():
|
|||
@hookimpl
|
||||
def render_cell(value):
|
||||
# Render {"href": "...", "label": "..."} as link
|
||||
if not isinstance(value, str):
|
||||
return None
|
||||
stripped = value.strip()
|
||||
if not stripped.startswith("{") and stripped.endswith("}"):
|
||||
return None
|
||||
|
|
@ -230,6 +232,8 @@ def render_cell(value):
|
|||
data = json.loads(value)
|
||||
except ValueError:
|
||||
return None
|
||||
if not isinstance(data, dict):
|
||||
return None
|
||||
if set(data.keys()) != {"href", "label"}:
|
||||
return None
|
||||
href = data["href"]
|
||||
|
|
@ -389,9 +393,12 @@ INSERT INTO "searchable_fts" (rowid, text1, text2, [name with . and spaces])
|
|||
CREATE TABLE [select] (
|
||||
[group] text,
|
||||
[having] text,
|
||||
[and] text
|
||||
[and] text,
|
||||
[json] text
|
||||
);
|
||||
INSERT INTO [select] VALUES ('group', 'having', 'and',
|
||||
'{"href": "http://example.com/", "label":"Example"}'
|
||||
);
|
||||
INSERT INTO [select] VALUES ('group', 'having', 'and');
|
||||
|
||||
CREATE TABLE infinity (
|
||||
value REAL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue