Comments (12)
I tried adding this:
app.on("open-file", (event, path) => {
console.log("open-file:", event, path)
});
// Directly before this line:
app.whenReady().then(() => {
But the icon in the Dock (at least when running in npm start
dev mode) doesn't accept dropped files. There must be something special I need to do to tell macOS that this icon accepts dropped files, but I don't know what that is.
from datasette-app.
This might turn out to be part of the work on #54.
from datasette-app.
Maybe this will start working if I add the 'open-file' event handler and run a proper build of the application?
No, tried that and it didn't make the icon a drop target.
from datasette-app.
On Windows it sounds like dragging a file to the icon will work differently - it will call the application itself and pass that file path as process.argv
argument: https://stackoverflow.com/questions/57900693/electron-drag-and-drop-a-file-on-the-icon
I only care about macOS for the moment though.
from datasette-app.
This might be the answer! electron/electron#4403 (comment)
Second, I added a CFBundleDocumentTypes section to Mac app's Info.plist and listed the acceptable file types. (See https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html )
from datasette-app.
From electron-userland/electron-builder#3732 (comment) it looks like you can add things to Info.plist
by populating the "extendInfo"
key used by electrion-builder
: https://www.electron.build/configuration/mac
GitHub code search has some examples: https://github.com/search?l=JSON&q=extendInfo+CFBundleDocumentTypes&type=Code
These examples look useful:
- https://github.com/alanzchen/jupyter-desktop/blob/946ba54bc7bc9297a9ef7a8f620c34caedf27932/package.json
- https://github.com/karino2/electron-textdeck/blob/c9ef8e9a4bdb69924b14d50cad15b29a5bcc1be3/package.json
- https://github.com/heilerich/actualmoney/blob/1e008525c75b8b1569b3cc57176999d10b9a70ed/package.json
from datasette-app.
This worked:
diff --git a/package.json b/package.json
index 9aa3db1..7ee237e 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,16 @@
"appId": "io.datasette.app",
"mac": {
"category": "public.app-category.developer-tools",
+ "extendInfo": {
+ "CFBundleDocumentTypes": [
+ {
+ "CFBundleTypeExtensions": [
+ "csv", "tsv", "db"
+ ],
+ "LSHandlerRank": "Alternate"
+ }
+ ]
+ },
"hardenedRuntime" : true,
"gatekeeperAssess": false,
"entitlements": "build/entitlements.mac.plist",
from datasette-app.
From #88 (comment)
One remaining catch: once I add the
CFBundleDocumentTypes
configuration from #40 it will be possible to drag a CSV or DB file onto the Datasette icon to launch the application and fire the event.But... the current event code assumes that the server has already started up:
Lines 822 to 860 in 78b86be
Need to handle the case where that event is fired before the server has had a chance to start.
from datasette-app.
After that last commit (and doing a proper application install) .db
files on my computer are now showing the Datasette icon and double-clicking them opens them in Datasette!
(But only if Datasette is already open, I still need to fix it so the open-file
event works if the server hasn't yet started).
Also .csv
files are now showing Datasette in their "Open with" menu.
from datasette-app.
Tangential to this issue but relevant to Windows (#71), Application Registration needs to be done on Windows in order for Datasette to be a viable .csv
handler โ and also for native recent files functionality in Windows Explorer to work.
Filed away for later when you look into Windows I guess.
from datasette-app.
Tested with this build https://github.com/simonw/datasette-app/actions/runs/1225528995 and while double-clicking a .db file or "Open in Datasette"-ing a CSV file did cause the Datasette application to open, the files were NOT attached once it had started up.
With Datasette open double-clicking or using "Open in Datasette" did work.
from datasette-app.
The build from https://github.com/simonw/datasette-app/actions/runs/1225558655 works!
from datasette-app.
Related Issues (20)
- Create `brew install --cask datasette-app` for macOS HOT 1
- Publish ("export") to web with authentication and metadata (minimum feature set) HOT 4
- Can't "go back" after choosing view as JSON or CSV and saving/storing queries in underlying SQLite
- Allow for load / open of data from URL where CSV (or JSON?) is compressed
- Allow handling of larger CSV files e.g. CFPB complaints data HOT 1
- Switch to Playwright for automated tests HOT 28
- Failing to render in retina resolution when running on my MacBook Pro (macOS Catalina) HOT 1
- Research faster launch times
- Mechanism for plugins that need a specific DB HOT 3
- "Loading..." hangs on launch after parsing "tag_name" in a plugin HOT 6
- npm test is failing HOT 2
- All sorts of features not working due to bad HTTP requests HOT 9
- London Fire Brigade demo breaks HOT 7
- Import CSV from URL should show errors
- New Playwright tests should exercise key features
- Ability to use templates
- The icon looks blurry in the alt-tab window
- Loading... hangs on launch with packaging.version.InvalidVersion HOT 6
- "About Datasette" button fails to open information window HOT 2
- Unable to load preload script HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datasette-app.