Skip to content

Commit

Permalink
Extract /-/plugins view into a method
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw authored and Simon Willison committed May 14, 2018
1 parent cf1fe69 commit eaf715a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,17 @@ def versions(self):
},
}

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):
app = Sanic(__name__)
default_templates = str(app_root / "datasette" / "templates")
Expand Down Expand Up @@ -419,19 +430,7 @@ def app(self):
"/-/versions<as_json:(\.json)?$>",
)
app.add_route(
JsonDataView.as_view(
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)
],
),
JsonDataView.as_view(self, "plugins.json", self.plugins),
"/-/plugins<as_json:(\.json)?$>",
)
app.add_route(
Expand Down

0 comments on commit eaf715a

Please sign in to comment.