beakerbrowser / beaker

An experimental peer-to-peer Web browser
https://beakerbrowser.com/
MIT License
6.75k stars 547 forks source link

Intents #1079

Open knownasilya opened 6 years ago

knownasilya commented 6 years ago

Intent Scheme: https://github.com/beakerbrowser/beaker/wiki/Intent-Scheme

I've been thinking of working on this and have had some discussions with @pfrazee in IRC, so decided to write down some notes for myself and in case anyone else wanted to come and help out.

Implementing intents as a MVF (Minimum Viable Feature) would include the following:

To take this beyond the basics the following might be implemented:

Related Issues


Follow dev here https://github.com/knownasilya/beaker/tree/feat/intents

knownasilya commented 6 years ago

@pfrazee feel free to correct or add anything that needs to be 👍

pfrazee commented 6 years ago

@knownasilya this is looking good. I'd probably just add a new internal web api (so, only exposed to beaker: and intent: locations) called beaker.intents for reading/writing the data.

Thinking forward, there are two other major pieces:

  1. The profile database will need a new table for storing the users' saved intents. I haven't totally thought out what schema it will need. At minimum, the profile ID (always 0 for now), the intent name, and the URL of the handler. Not too big of a deal
  2. We'll need some way for an application to declare which intents it can handle. This probably needs to be a dat.json field of some kind.
pfrazee commented 6 years ago

@knownasilya for now, if you can just get something serving on intent:share (or similar) with hardcoded handlers, that demos/mocks up the core experience, that'd be a good first step

knownasilya commented 6 years ago

@pfrazee what are you thinking would be on beaker.intents as a start?

For (1) each intent probably needs to also use a certain query param for further filtering. Like in the share example, if your service only shares text, it would have a type: ['text/html'] or something of the sort. Haven't thought through this enough though, and it's definitely not a required feature for a minimal implementation I think.

pfrazee commented 6 years ago

@knownasilya Yeah we can iterate our way to things like that. For now I think all you need is a list/query function that takes the intent name.

knownasilya commented 6 years ago

beaker-intents-0

Still very early and mostly hard coded stuff.

pfrazee commented 6 years ago

Very nice!

knownasilya commented 6 years ago

beaker-intents-1

Works with twitter

pfrazee commented 6 years ago

Nice. I wonder if we'll end up needing a translation between query param names when registering an intent. Eg, "Register for intent:share with the URL of https://foo.com?content={text}". We'll have to see-- obviously it'd be nicer if you could just say "...with the url of https://foo.com" and then have the params be added directly from the intent, with no remapping.

knownasilya commented 6 years ago

Yeah, been wondering the same. We might need a template like that:

let query = '?url=dat://mysite.com&text=hello';
let one = format('?share={text} {url}', query);
let two = format('?url={url}&content={url}', query);

// one => ?share=hello dat://mysite.com
// two => ?url=dat://mysite.com&content=hello
pfrazee commented 6 years ago

There's a fairly detailed spec for URI templates which is overkill for what we need, but might make good inspiration. I'm not sure we'd need more than simple string expansion, but who knows.

knownasilya commented 6 years ago

Yeah, have used that spec format a bit in the past. It might be a good solution so we aren't rolling something that is completely different. But if we can do simple, and then use the spec later without making it a breaking change, that would probably be best.

pfrazee commented 6 years ago

That's true, though that means we inherit that complex spec which I'd only want to do if I thought we needed most of the features

On Thu, Jul 19, 2018 at 2:20 PM Ilya Radchenko notifications@github.com wrote:

Yeah, have used that spec format a bit in the past. It might be a good solution so we aren't rolling something that is completely different. But if we can do simple, and then use the spec later without making it a breaking change, that would probably be best.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/beakerbrowser/beaker/issues/1079#issuecomment-406386073, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNhU1822toApTInLmZlu8oX3T29QQVrks5uINv0gaJpZM4VSE2C .

RangerMauve commented 6 years ago

What about using the same syntax as registerProtocolHandler? It uses %s as a placeholder for the URL.

It seems to be using the syntax for sprintf

knownasilya commented 6 years ago

I think only %s is supported. Would we be able to intercept that navigator call? We'd still have to specify the site as a service provider and then load it and get it's specified configs. Might be a way to do it but also allow manual setup from beaker or from dat.json.

pfrazee commented 6 years ago

Would we be able to intercept that navigator call?

I dont think that's what @RangerMauve was suggesting. Either way, let's not worry about this syntax yet because it's not clear we'll need it.

pfrazee commented 6 years ago

@knownasilya regarding intent registration, I think it'll need to be fields in the dat.json. I have a feeling if sites can prompt the user to install their intent-handlers, it'll become non-stop spam to do so (like with push notifications).

knownasilya commented 6 years ago

I wasn't even thinking about allowing that 😸 Agreed, dat.json is probably best.

Gozala commented 5 years ago

@knownasilya regarding intent registration, I think it'll need to be fields in the dat.json. I have a feeling if sites can prompt the user to install their intent-handlers, it'll become non-stop spam to do so (like with push notifications).

There is also study that supports the claim that permissions at install time causes users to grant permissions without considering what they are. So I would recommend incremental enhancement approach with different spam prevention mechanism:

Gozala commented 5 years ago

I think advantage of intents over navigator.registerProtocolHandler is that it provides one to many mapping so user can choose on demand. On the other hand navigator.registerProtocolHandler has advantage of more wider browser support.

I wonder if later could be enhanced to support one to many mapping.

Gozala commented 5 years ago

It also might be worth taking a look at Web Activities that Mozilla was pushing as counter proposal to intents & used in Firefox OS.