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
|
||||
run: pytest
|
||||
- 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
|
||||
run: |-
|
||||
cd docs
|
||||
|
@ -50,6 +50,7 @@ jobs:
|
|||
gcloud config set project datasette-222320
|
||||
datasette publish cloudrun fixtures.db \
|
||||
-m fixtures.json \
|
||||
--plugins-dir=plugins \
|
||||
--branch=$GITHUB_SHA \
|
||||
--version-note=$GITHUB_SHA \
|
||||
--extra-options="--config template_debug:1" \
|
||||
|
|
|
@ -267,7 +267,7 @@ def generate_sortable_rows(num):
|
|||
|
||||
METADATA = {
|
||||
"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_url": "https://github.com/simonw/datasette/blob/master/LICENSE",
|
||||
"source": "tests/fixtures.py",
|
||||
|
|
|
@ -177,7 +177,7 @@ def actor_from_request(datasette, request):
|
|||
def asgi_wrapper():
|
||||
def wrap(app):
|
||||
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"})
|
||||
print(scope)
|
||||
await app(scope, recieve, send)
|
||||
|
@ -237,12 +237,33 @@ def register_routes():
|
|||
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 [
|
||||
(r"/one/$", one),
|
||||
(r"/two/(?P<name>.*)$", two),
|
||||
(r"/three/$", three),
|
||||
(r"/post/$", post),
|
||||
(r"/csrftoken-form/$", csrftoken_form),
|
||||
(r"/login-as-root$", login_as_root),
|
||||
(r"/not-async/$", not_async),
|
||||
(r"/add-message/$", add_message),
|
||||
(r"/render-message/$", render_message),
|
||||
|
|
|
@ -23,7 +23,7 @@ def test_homepage(app_client_two_attached_databases):
|
|||
soup = Soup(response.body, "html.parser")
|
||||
assert "Datasette Fixtures" == soup.find("h1").text
|
||||
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()
|
||||
)
|
||||
# Should be two attached databases
|
||||
|
@ -949,8 +949,9 @@ def test_index_metadata(app_client):
|
|||
assert response.status == 200
|
||||
soup = Soup(response.body, "html.parser")
|
||||
assert "Datasette Fixtures" == soup.find("h1").text
|
||||
assert "An example SQLite database demonstrating Datasette" == inner_html(
|
||||
soup.find("div", {"class": "metadata-description"})
|
||||
assert (
|
||||
'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)
|
||||
|
||||
|
@ -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/blob/master/LICENSE",
|
||||
"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/")
|
||||
):
|
||||
|
|
Ładowanie…
Reference in New Issue