kopia lustrzana https://github.com/simonw/datasette
Deploy demo plugins to latest.datasette.io, refs #1074
rodzic
f0a740ac21
commit
d6db47f5c1
|
@ -31,7 +31,7 @@ jobs:
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pytest
|
run: pytest
|
||||||
- name: Build fixtures.db
|
- name: Build fixtures.db
|
||||||
run: python tests/fixtures.py fixtures.db fixtures.json
|
run: python tests/fixtures.py fixtures.db fixtures.json plugins
|
||||||
- name: Build docs.db
|
- name: Build docs.db
|
||||||
run: |-
|
run: |-
|
||||||
cd docs
|
cd docs
|
||||||
|
@ -50,6 +50,7 @@ jobs:
|
||||||
gcloud config set project datasette-222320
|
gcloud config set project datasette-222320
|
||||||
datasette publish cloudrun fixtures.db \
|
datasette publish cloudrun fixtures.db \
|
||||||
-m fixtures.json \
|
-m fixtures.json \
|
||||||
|
--plugins-dir=plugins \
|
||||||
--branch=$GITHUB_SHA \
|
--branch=$GITHUB_SHA \
|
||||||
--version-note=$GITHUB_SHA \
|
--version-note=$GITHUB_SHA \
|
||||||
--extra-options="--config template_debug:1" \
|
--extra-options="--config template_debug:1" \
|
||||||
|
|
|
@ -267,7 +267,7 @@ def generate_sortable_rows(num):
|
||||||
|
|
||||||
METADATA = {
|
METADATA = {
|
||||||
"title": "Datasette Fixtures",
|
"title": "Datasette Fixtures",
|
||||||
"description": "An example SQLite database demonstrating Datasette",
|
"description_html": 'An example SQLite database demonstrating Datasette. <a href="/login-as-root">Sign in as root user</a>',
|
||||||
"license": "Apache License 2.0",
|
"license": "Apache License 2.0",
|
||||||
"license_url": "https://github.com/simonw/datasette/blob/master/LICENSE",
|
"license_url": "https://github.com/simonw/datasette/blob/master/LICENSE",
|
||||||
"source": "tests/fixtures.py",
|
"source": "tests/fixtures.py",
|
||||||
|
|
|
@ -177,7 +177,7 @@ def actor_from_request(datasette, request):
|
||||||
def asgi_wrapper():
|
def asgi_wrapper():
|
||||||
def wrap(app):
|
def wrap(app):
|
||||||
async def maybe_set_actor_in_scope(scope, recieve, send):
|
async def maybe_set_actor_in_scope(scope, recieve, send):
|
||||||
if b"_actor_in_scope" in scope["query_string"]:
|
if b"_actor_in_scope" in scope.get("query_string", b""):
|
||||||
scope = dict(scope, actor={"id": "from-scope"})
|
scope = dict(scope, actor={"id": "from-scope"})
|
||||||
print(scope)
|
print(scope)
|
||||||
await app(scope, recieve, send)
|
await app(scope, recieve, send)
|
||||||
|
@ -237,12 +237,33 @@ def register_routes():
|
||||||
await datasette.render_template("render_message.html", request=request)
|
await datasette.render_template("render_message.html", request=request)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def login_as_root(datasette, request):
|
||||||
|
# Mainly for the latest.datasette.io demo
|
||||||
|
if request.method == "POST":
|
||||||
|
response = Response.redirect("/")
|
||||||
|
response.set_cookie(
|
||||||
|
"ds_actor", datasette.sign({"a": {"id": "root"}}, "actor")
|
||||||
|
)
|
||||||
|
return response
|
||||||
|
return Response.html(
|
||||||
|
"""
|
||||||
|
<form action="{}" method="POST">
|
||||||
|
<p>
|
||||||
|
<input type="hidden" name="csrftoken" value="{}">
|
||||||
|
<input type="submit" value="Sign in as root user"></p>
|
||||||
|
</form>
|
||||||
|
""".format(
|
||||||
|
request.path, request.scope["csrftoken"]()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(r"/one/$", one),
|
(r"/one/$", one),
|
||||||
(r"/two/(?P<name>.*)$", two),
|
(r"/two/(?P<name>.*)$", two),
|
||||||
(r"/three/$", three),
|
(r"/three/$", three),
|
||||||
(r"/post/$", post),
|
(r"/post/$", post),
|
||||||
(r"/csrftoken-form/$", csrftoken_form),
|
(r"/csrftoken-form/$", csrftoken_form),
|
||||||
|
(r"/login-as-root$", login_as_root),
|
||||||
(r"/not-async/$", not_async),
|
(r"/not-async/$", not_async),
|
||||||
(r"/add-message/$", add_message),
|
(r"/add-message/$", add_message),
|
||||||
(r"/render-message/$", render_message),
|
(r"/render-message/$", render_message),
|
||||||
|
|
|
@ -23,7 +23,7 @@ def test_homepage(app_client_two_attached_databases):
|
||||||
soup = Soup(response.body, "html.parser")
|
soup = Soup(response.body, "html.parser")
|
||||||
assert "Datasette Fixtures" == soup.find("h1").text
|
assert "Datasette Fixtures" == soup.find("h1").text
|
||||||
assert (
|
assert (
|
||||||
"An example SQLite database demonstrating Datasette"
|
"An example SQLite database demonstrating Datasette. Sign in as root user"
|
||||||
== soup.select(".metadata-description")[0].text.strip()
|
== soup.select(".metadata-description")[0].text.strip()
|
||||||
)
|
)
|
||||||
# Should be two attached databases
|
# Should be two attached databases
|
||||||
|
@ -949,8 +949,9 @@ def test_index_metadata(app_client):
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
soup = Soup(response.body, "html.parser")
|
soup = Soup(response.body, "html.parser")
|
||||||
assert "Datasette Fixtures" == soup.find("h1").text
|
assert "Datasette Fixtures" == soup.find("h1").text
|
||||||
assert "An example SQLite database demonstrating Datasette" == inner_html(
|
assert (
|
||||||
soup.find("div", {"class": "metadata-description"})
|
'An example SQLite database demonstrating Datasette. <a href="/login-as-root">Sign in as root user</a>'
|
||||||
|
== inner_html(soup.find("div", {"class": "metadata-description"}))
|
||||||
)
|
)
|
||||||
assert_footer_links(soup)
|
assert_footer_links(soup)
|
||||||
|
|
||||||
|
@ -1451,6 +1452,7 @@ def test_base_url_config(app_client_base_url_prefix, path):
|
||||||
"https://github.com/simonw/datasette",
|
"https://github.com/simonw/datasette",
|
||||||
"https://github.com/simonw/datasette/blob/master/LICENSE",
|
"https://github.com/simonw/datasette/blob/master/LICENSE",
|
||||||
"https://github.com/simonw/datasette/blob/master/tests/fixtures.py",
|
"https://github.com/simonw/datasette/blob/master/tests/fixtures.py",
|
||||||
|
"/login-as-root", # Only used for the latest.datasette.io demo
|
||||||
}
|
}
|
||||||
and not href.startswith("https://plugin-example.com/")
|
and not href.startswith("https://plugin-example.com/")
|
||||||
):
|
):
|
||||||
|
|
Ładowanie…
Reference in New Issue