Stop using plugin-example.com, closes #1074

This commit is contained in:
Simon Willison 2020-10-31 12:47:42 -07:00
commit bf18b9ba17
4 changed files with 15 additions and 15 deletions

View file

@ -29,7 +29,7 @@ def prepare_connection(conn, database, datasette):
def extra_css_urls(template, database, table, view_name, columns, request, datasette):
async def inner():
return [
"https://plugin-example.com/{}/extra-css-urls-demo.css".format(
"https://plugin-example.datasette.io/{}/extra-css-urls-demo.css".format(
base64.b64encode(
json.dumps(
{
@ -57,10 +57,10 @@ def extra_css_urls(template, database, table, view_name, columns, request, datas
def extra_js_urls():
return [
{
"url": "https://plugin-example.com/jquery.js",
"url": "https://plugin-example.datasette.io/jquery.js",
"sri": "SRIHASH",
},
"https://plugin-example.com/plugin1.js",
"https://plugin-example.datasette.io/plugin1.js",
]

View file

@ -8,10 +8,10 @@ import json
def extra_js_urls():
return [
{
"url": "https://plugin-example.com/jquery.js",
"url": "https://plugin-example.datasette.io/jquery.js",
"sri": "SRIHASH",
},
"https://plugin-example.com/plugin2.js",
"https://plugin-example.datasette.io/plugin2.js",
]

View file

@ -1454,7 +1454,7 @@ def test_base_url_config(app_client_base_url_prefix, path):
"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.datasette.io/")
):
# If this has been made absolute it may start http://localhost/
if href.startswith("http://localhost/"):

View file

@ -125,7 +125,7 @@ def test_hook_extra_js_urls(app_client):
== {
"integrity": "SRIHASH",
"crossorigin": "anonymous",
"src": "https://plugin-example.com/jquery.js",
"src": "https://plugin-example.datasette.io/jquery.js",
}
]
@ -135,7 +135,7 @@ def test_plugins_with_duplicate_js_urls(app_client):
response = app_client.get("/fixtures")
# This test is a little tricky, as if the user has any other plugins in
# their current virtual environment those may affect what comes back too.
# What matters is that https://plugin-example.com/jquery.js is only there once
# What matters is that https://plugin-example.datasette.io/jquery.js is only there once
# and it comes before plugin1.js and plugin2.js which could be in either
# order
scripts = Soup(response.body, "html.parser").findAll("script")
@ -143,16 +143,16 @@ def test_plugins_with_duplicate_js_urls(app_client):
# No duplicates allowed:
assert len(srcs) == len(set(srcs))
# jquery.js loaded once:
assert 1 == srcs.count("https://plugin-example.com/jquery.js")
assert 1 == srcs.count("https://plugin-example.datasette.io/jquery.js")
# plugin1.js and plugin2.js are both there:
assert 1 == srcs.count("https://plugin-example.com/plugin1.js")
assert 1 == srcs.count("https://plugin-example.com/plugin2.js")
assert 1 == srcs.count("https://plugin-example.datasette.io/plugin1.js")
assert 1 == srcs.count("https://plugin-example.datasette.io/plugin2.js")
# jquery comes before them both
assert srcs.index("https://plugin-example.com/jquery.js") < srcs.index(
"https://plugin-example.com/plugin1.js"
assert srcs.index("https://plugin-example.datasette.io/jquery.js") < srcs.index(
"https://plugin-example.datasette.io/plugin1.js"
)
assert srcs.index("https://plugin-example.com/jquery.js") < srcs.index(
"https://plugin-example.com/plugin2.js"
assert srcs.index("https://plugin-example.datasette.io/jquery.js") < srcs.index(
"https://plugin-example.datasette.io/plugin2.js"
)