-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update screenshot with shot-scraper, closes #40
- Loading branch information
Showing
3 changed files
with
56 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Grab the database | ||
wget https://datasette.io/content.db | ||
|
||
# Setup the root plugin | ||
mkdir shot-plugins | ||
cat > shot-plugins/root.py <<EOL | ||
from datasette import hookimpl, Response | ||
@hookimpl | ||
def register_routes(): | ||
def login_as_root(datasette, request): | ||
response = Response.redirect("/-/edit-schema/content/licenses") | ||
response.set_cookie( | ||
"ds_actor", datasette.sign({"a": {"id": "root"}}, "actor") | ||
) | ||
return response | ||
return ( | ||
("/-/root", login_as_root), | ||
) | ||
EOL | ||
|
||
# Start the server in the background and capture its PID | ||
datasette -p 8045 content.db --plugins-dir shot-plugins & | ||
SERVER_PID=$! | ||
|
||
# Wait for server to start | ||
sleep 2 | ||
|
||
# Take the screenshot | ||
shot-scraper http://localhost:8045/-/root -w 800 -o datasette-edit-schema.png | ||
|
||
# Kill the server | ||
kill $SERVER_PID | ||
|
||
# Cleanup | ||
rm content.db | ||
rm -rf shot-plugins |