Giter Site home page Giter Site logo

datasette-app's Introduction

Datasette Desktop

A macOS desktop application that wraps Datasette. See Building a desktop application for Datasette for background on this project.

Installation

Grab the latest release from the releases page. Download Datasette.app.zip, uncompress it and drag Datasette.app to your /Applications folder - then double-click the icon.

The first time you launch the app it will install the latest version of Datasette, which could take a little while. Subsequent application launches will be a lot quicker.

Application features

  • Includes a full copy of Python which stays separate from any other Python versions you may have installed
  • Installs the latest Datasette release the first time it runs
  • The application can open existing SQLite database files or read CSV files into an in-memory database
  • It can also create a new, empty SQLite database file and create tables in that database by importing CSV data
  • By default the server only accepts connections from your computer, but you can use "File -> Access Control -> Anyone on my networks" to make it visible to other computers on your network (or devices on your Tailscale network).
  • Datasette plugins can be installed using the "Install Plugin" menu item

How it works

The app consists of two parts: the Electron app, and a custom Datasette plugin called datasette-app-support.

You can install a development version of the app like so:

# Clone the repo
git clone https://github.com/simonw/datasette-app
cd datasette-app

# Download standalone Python
./download-python.sh

# Install Electron dependencies and start it running:
npm install
npm start

When the app first starts up it will create a Python virtual environment in ~/.datasette-app/venv and install both Datasette and the datasette-app-support plugin into that environment.

To run the Electron tests:

npm test

The Electron tests may leave a datasette process running. You can find the process ID for this using:

ps aux | grep xyz

Then use kill PROCESS_ID to terminate it.

datasette-app

How to develop plugins

You can develop new Datasette plugins directly against your installation of Datasette Desktop. The Writing Plugins documentation mostly applies as-is, but the one extra thing you will need to do is to install an editable version of your plugin directly into the virtual environment used by Datasette Desktop.

To do this, first create a new plugin in a folder called datasette-your-new-plugin with a setup.py, as described in the plugin documentation. The easiest way to do that is using the datasette-plugin cookiecutter template.

Then cd into that directory and run the following:

~/.datasette-app/venv/bin/pip install -e .

This will install the plugin into your Datasette Desktop environment, such that any edits you make to the files in that directory will be picked up the next time the embedded Datasette server is restarted.

You can restart the server either by quitting and restarting the Datasette Desktop application, or by enabling the Debug menu ("Datasette -> About Datasette -> Enable Debug Menu") and then using "Debug -> Restart Server".

Release process

To ship a new release, increment the version number in package.json and then create a new release with a matching tag.

Then run a deploy of datasette.io to update the latest release link that is displayed on the datasette.io/desktop page.

datasette-app's People

Contributors

mnckapilan avatar simonw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

datasette-app's Issues

Figure out what goes in the first public alpha release

It needs to be a thing that users can install on macOS (maybe without it being fully signed, perhaps they have to approve it?) that gives them a working Datasette instance that launches when they launch this application.

Figure out if I can use the macOS sandbox

Something that makes me nervous about this app is that people can install plugins - and I can't guarantee they won't end up installing a malicious plugin that runs malware or steals data or similar.

On macOS it's now possible to lock down apps so they can only interact with their own private "sandbox" folder plus any files that the user explicitly opens using the native file open dialog. This sounds ideal! I can use the sandbox for the virtual environment and install plugins in there, but any malicious plugins (or bugs in my own code) would be limited in how much trouble they could cause.

Researching how to do this with Electron apps is made harder by the fact that Electron has its own sandbox concept which is something completely different - a browser security concept inherited from Chrome.

Basic CI test harness

Can start with something such that if a commit prevents the app from launching entirely the tests fail.

If you open a CSV and then install a plugin the CSV table vanishes

This is because opening a CSV imports into the temporary in-memory database, and installing a plugin restarts the server.

Could maybe keep track of which CSVs have been opened and re-import them after a restart of the server within the current application session?

Might not be worth fixing this.

Ability to open a CSV file in an in-memory database

The first release of this app will have a lot more impact if it can open CSV files. No need for these to be imported into an on-disk SQLite database - they can be opened in memory instead.

File -> Open CSV

Option to share server with others on your network

For the moment I'm going to lock this down so that it's only visible to the current, authenticated use from localhost - but in the future it might be good to have an option for sharing your data by running the server attached to 0.0.0.0 so you can share links with other people on your network.

Originally posted by @simonw in #37 (comment)

Support .db or .csv/.tsv files being dragged and dropped onto the app (or app icon)

Would be useful as a shortcut for opening files.

https://www.electronjs.org/docs/api/app#event-open-file-macos suggests this may be possible through listening to the open-file event:

Emitted when the user wants to open a file with the application. The open-file event is usually emitted when the application is already open and the OS wants to reuse the application to open the file. open-file is also emitted when a file is dropped onto the dock and the application is not yet running. Make sure to listen for the open-file event very early in your application startup to handle this case (even before the ready event is emitted).

Investigate python-build-standalone

https://python-build-standalone.readthedocs.io/en/latest/building.html#macos

Since I would ideally like Datasette.app to support Python plugins, maybe what I really need is a full-blown Python system tucked away inside the Datasette.app macOS package, with the ability to install extra packages into it?

if so, python-build-standalone could be relevant - it's part of the PyOxidizer project.

Maybe I don't need any of the mechanisms from things like PyInstaller or PyOxidizer that combine my code together into a single executable - I just need to be sure that when a user installs the Datasette.app application it has a guaranteed Python environment that it can use to run datasette and its plugins.

Alternative, better mechanism for authenticating user than --root

This is partly an alternative to #36 where I wanted to share cookies between multiple BrowserWindow instances.

But also... I don't like using --root because it turns on a bunch of confusing tools that are usually intended for debugging. Instead I think datasette-app-support should provide a mechanism for signing the user in as "id": "datasette-app" - then I can use custom permissions to enable things like datasette-upload-csvs without turning on debugging menus for the root user.

Improve how newly opened files correspond to opening windows

I think this would work best, for both CSV and Database file openings using the menu options:

  • If there is only one visible window AND it is on the homepage, navigate that to the database page (for open DB) or the new table page (for open CSV)
  • Otherwise, open a new window pointing to either that database or that table page

Debug -> Open DevTools option

I figured this out in #36 (comment)

+        {
+          label: 'Debug',
+          submenu: [{
+            label: 'Open DevTools',
+            click() {
+              BrowserWindow.getFocusedWindow().webContents.openDevTools();
+            }
+          }]
+        }

Maybe have this available in development but not in production?

Or could keep it in production - or maybe have a secret keyboard shortcut for it?

Compensate for the lack of a back button

Right now there are pages within Datasette (such as the JSON or CSV exports) which provide no way to navigate back out of them - hence it's easy to get stuck:

no-back-button

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.