Skip to content

Commit

Permalink
Update screenshot with shot-scraper, closes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 9, 2023
1 parent 4f9222c commit 80b5e44
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 16 deletions.
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Datasette plugin for modifying table schemas
## Installation

Install this plugin in the same environment as Datasette.

$ pip install datasette-edit-schema

```bash
pip install datasette-edit-schema
```
## Usage

Navigate to `/-/edit-schema/dbname/tablename` on your Datasette instance to edit a specific table.
Expand All @@ -49,19 +49,20 @@ These permission checks will call the `permission_allowed()` plugin hook with th
## Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-edit-schema
python3 -mvenv venv
source venv/bin/activate

```bash
cd datasette-edit-schema
python3 -mvenv venv
source venv/bin/activate
```
Or if you are using `pipenv`:

pipenv shell

```bash
pipenv shell
```
Now install the dependencies and tests:

pip install -e '.[test]'

```bash
pip install -e '.[test]'
```
To run the tests:

pytest
```bash
pytest
```
Binary file modified datasette-edit-schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions update-screenshot.sh
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

0 comments on commit 80b5e44

Please sign in to comment.