mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Extract /-/plugins view into a method
This commit is contained in:
parent
e2b0395cc2
commit
1a0ff0f44e
1 changed files with 12 additions and 13 deletions
|
|
@ -366,6 +366,17 @@ class Datasette:
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def plugins(self):
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"name": p["name"],
|
||||||
|
"static": p["static_path"] is not None,
|
||||||
|
"templates": p["templates_path"] is not None,
|
||||||
|
"version": p.get("version"),
|
||||||
|
}
|
||||||
|
for p in get_plugins(pm)
|
||||||
|
]
|
||||||
|
|
||||||
def app(self):
|
def app(self):
|
||||||
app = Sanic(__name__)
|
app = Sanic(__name__)
|
||||||
default_templates = str(app_root / "datasette" / "templates")
|
default_templates = str(app_root / "datasette" / "templates")
|
||||||
|
|
@ -419,19 +430,7 @@ class Datasette:
|
||||||
"/-/versions<as_json:(\.json)?$>",
|
"/-/versions<as_json:(\.json)?$>",
|
||||||
)
|
)
|
||||||
app.add_route(
|
app.add_route(
|
||||||
JsonDataView.as_view(
|
JsonDataView.as_view(self, "plugins.json", self.plugins),
|
||||||
self,
|
|
||||||
"plugins.json",
|
|
||||||
lambda: [
|
|
||||||
{
|
|
||||||
"name": p["name"],
|
|
||||||
"static": p["static_path"] is not None,
|
|
||||||
"templates": p["templates_path"] is not None,
|
|
||||||
"version": p.get("version"),
|
|
||||||
}
|
|
||||||
for p in get_plugins(pm)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
"/-/plugins<as_json:(\.json)?$>",
|
"/-/plugins<as_json:(\.json)?$>",
|
||||||
)
|
)
|
||||||
app.add_route(
|
app.add_route(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue