simonw / datasette

An open source multi-tool for exploring and publishing data
https://datasette.io
Apache License 2.0
9.53k stars 686 forks source link

Writable canned queries live demo on Glitch #805

Open simonw opened 4 years ago

simonw commented 4 years ago

Needs to run somewhere with a mutable disk drive, so not Cloud Run or Heroku or Vercel.

I think I'll put it on Glitch.

simonw commented 4 years ago

I'd like to illustrate writable canned queries without the risk of someone abusing and breaking it (or filling it with bad content).

I don't want to have to monitor it, so an application that won't run out of disk space after a few months would be good too.

Maybe a polling app? If I'm only tracking integer numbers of votes it shouldn't ever run out of space.

simonw commented 4 years ago

Would be useful if I had a plugin that could authenticate users based on a secret environment variable (maybe for a password) - that way I could have an "admin" account on the Glitch app that is allowed to setup new polls, while anonymous users can only vote on them.

simonw commented 4 years ago

Part of #806

simonw commented 4 years ago

Create data.db with:

echo '{"emoji": "🐯", "score": 0}' | sqlite-utils insert data.db emojis --pk=emoji -
echo '{"emoji": "🐺", "score": 0}' | sqlite-utils insert data.db emojis --pk=emoji -

Then run Datasette with this metadata.yaml:

title: Datasette Poll
databases:
  data:
    queries:
      vote:
        sql: |-
          update emojis set score = score + 1 where emoji = :emoji
        write: true
simonw commented 4 years ago

I can't get Datasette working on Glitch installed from a URL - I'm going to try this on Glitch once I've shipped the 0.44 release in #806.

simonw commented 4 years ago

This needs the startup hook, see https://github.com/simonw/datasette/issues/834#issuecomment-643501064

simonw commented 4 years ago

I can use magic parameters from #842 in this.

simonw commented 4 years ago

https://github.com/simonw/datasette-glitch is my new plugin that outputs the root login link on Glitch when the server starts.

simonw commented 4 years ago

Using datasette-glitch and the new https://github.com/simonw/datasette-write - currently running on datasette==0.45a4 - works on Glitch. The console shows a login link which gives you a cookie which allows you access to the /-/write interface.

simonw commented 4 years ago

How about a blog? Pre-configured canned queries that are only available to "root", plus datasette-template-sql and default templates for the index page and blog entry pages.

simonw commented 4 years ago

No I prefer the idea that logged out users can still perform some writes, in a not-likely-to-attract-abuse way.

So a root-user-can-configure-polls, logged-out-users-can-vote-in-them demo would be good.

Or... crazy idea: a collaborative drawing program? A grid of cells of emoji, anyone can add an emoji to a cell. Would involve a bit of JavaScript. I could use https://github.com/joeattardi/emoji-button for this.