Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register custom browser protocols for .pdez and .pdex files #559

Closed
processing-bot opened this issue Sep 23, 2022 · 8 comments
Closed

Register custom browser protocols for .pdez and .pdex files #559

processing-bot opened this issue Sep 23, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@processing-bot
Copy link
Collaborator

Created by: SableRaf

Since Processing 4.0, you can bundle sketches as double-clickable .pdez files and Libraries/Modes/Tools as .pdex files for easy sharing and installation. (see Processing #73, Processing #3987, and the release notes for 4.0 beta1)

A great next step would be to allow .pdez and .pdex files to be opened in the PDE directly from a url in a web browser. This would enable easier sharing of sketches on the forum, better UX for multi-tab examples on the website, and open the possibility for online Processing sketch galleries.

This would require the user to register the protocol on their system (which I imagine could be done from the PDE ?) For example, this page describes the steps needed to register a custom browser protocol on Window, macOS and Linux. There is also a W3C documentation page about custom scheme and content handlers.

@processing-bot
Copy link
Collaborator Author

Created by: SableRaf

On a side note, we may need to warn people to only run code when they trust the author (similar to VSCode's restricted mode)

image

@processing-bot
Copy link
Collaborator Author

Created by: benfry

That should be in place because the file extension mapping should be happening. Is that not working?

For the second point, can you open a separate issue? Or perhaps even before that, have you tried it to see what it says now? I realize it's not making a stink about the security implications, but it should already be prompting whether you meant to open it or not.

@processing-bot
Copy link
Collaborator Author

Created by: SableRaf

It works as intended if you download the file then open it.

I was talking about opening the file directly by clicking a link in the form processing4://my-website.com/sketch220924.pdez in the browser. This requires an extra step of registering the URI scheme at the OS level. If Processing already does that I couldn't find it in core.

@processing-bot
Copy link
Collaborator Author

Created by: SableRaf

I did some more research.

On macOS at least, the first step is adding the protocol name and scheme to the info.plist file. For example:

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleURLName</key>
		<string>Processing 4</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>processing4</string>
		</array>
	</dict>
</array>

Then there needs to be a handler for these URLs in the PDE code using setOpenURIHandler from what I understand (which is admittedly very little).

References:

@processing-bot
Copy link
Collaborator Author

Created by: benfry

You can just use http:// or https:// URLs, no need to do a special protocol handler.

@processing-bot
Copy link
Collaborator Author

Created by: SableRaf

I made a quick test to show the current behavior: https://sableraf.github.io/testURIscheme/

http:// or https:// links trigger the browser to download the file (tested on Windows 10 and macOS 12.5.1)

Note: I also included a placeholder link with a processingOrg:// custom protocol for future testing.

@processing-bot
Copy link
Collaborator Author

Created by: benfry

Implemented for macOS and Windows for 4.2; uses pde:// and can point to a local file or an https url online. More to come…

@processing-bot
Copy link
Collaborator Author

Created by: SableRaf

Thanks @benfry this is amazing! Shoutout to @opyh for initially suggesting the idea in a conversation we had back in August.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant