Custom URI scheme for Pharo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Custom URI scheme for Pharo

Manuel Leuenberger
Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘<a href="pharo://send?data=fancypants%E2%80%99" class="">pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel
 
Reply | Threaded
Open this post in threaded view
|

Re: Custom URI scheme for Pharo

kilon.alios
I think I remember this disussed before.
By talking with Pharo I assume here about another program talking to Pharo ? Possible not wrriten in Pharo ?

If thats the case then you can use whatever IPC works better for your needs. If the communication will be remotely I recommend sockets, for  fast local communication I recommend shared memory. They are both very mature technologies , very reliable and cross platform.

Now on the URI protocol, I think that will depend what you want to achieve. Any string will be easy to parse with Pharo's regex and trigger the approriate methods. Pharo also have Annoucements, think of it as an event system that awaits to be triggered by an event, usually a Pharo event but I see no reason why it cant listen to external events either. 

I do not think you will need a middle application , a servel client relation shipe should be more than enough. 

With my Atlas bridge which is a Pharo library that allows you to use Python libraries I did a neat trick with Pharo that it already communicated with Python via sockets, sending python commands but also Python could communicate back errors , then Pharo would trigger the debugger, display the python error inside the Pharo debugger and the debugger would pop up on the exact pharo command that send the faulty python code. You could then change the pharo command on the spot and it was resent and python continued like the error never happened to retain the all important live coding workflow.

I created a tiny protocol to difirentia incoming messages talking about errors from the ones returning python varriable values. Something stupid like "pythonError: blah blah" but it got the job done



On Tue, Oct 10, 2017 at 10:07 PM Manuel Leuenberger <[hidden email]> wrote:
Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel
 
Reply | Threaded
Open this post in threaded view
|

Re: Custom URI scheme for Pharo

Manuel Leuenberger
Sounds like a nice setup you got there :).

I want to integrate documents displayed in the system viewer, as they cannot be displayed within Pharo (Web, PDF, …). So hyperlinking is the only way I see to get something close. I created a little demo where I injected hyperlinks in a PDF like ‘<a href="pharo://click?whatever=youwant'" class="">pharo://click?whatever=youwant'. When you click them, a little Objective-C app catches the OS event and forwards it to an HTTP server running in Pharo. So I can do things like this:


On 11 Oct 2017, at 00:24, Dimitris Chloupis <[hidden email]> wrote:

I think I remember this disussed before.
By talking with Pharo I assume here about another program talking to Pharo ? Possible not wrriten in Pharo ?

If thats the case then you can use whatever IPC works better for your needs. If the communication will be remotely I recommend sockets, for  fast local communication I recommend shared memory. They are both very mature technologies , very reliable and cross platform.

Now on the URI protocol, I think that will depend what you want to achieve. Any string will be easy to parse with Pharo's regex and trigger the approriate methods. Pharo also have Annoucements, think of it as an event system that awaits to be triggered by an event, usually a Pharo event but I see no reason why it cant listen to external events either. 

I do not think you will need a middle application , a servel client relation shipe should be more than enough. 

With my Atlas bridge which is a Pharo library that allows you to use Python libraries I did a neat trick with Pharo that it already communicated with Python via sockets, sending python commands but also Python could communicate back errors , then Pharo would trigger the debugger, display the python error inside the Pharo debugger and the debugger would pop up on the exact pharo command that send the faulty python code. You could then change the pharo command on the spot and it was resent and python continued like the error never happened to retain the all important live coding workflow.

I created a tiny protocol to difirentia incoming messages talking about errors from the ones returning python varriable values. Something stupid like "pythonError: blah blah" but it got the job done



On Tue, Oct 10, 2017 at 10:07 PM Manuel Leuenberger <[hidden email]> wrote:
Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel
 

Reply | Threaded
Open this post in threaded view
|

Re: Custom URI scheme for Pharo

NorbertHartl
In reply to this post by Manuel Leuenberger
I think all you need is to do a system call out to the OS in order to register your scheme. For Mac OS it would be sonething like



And then you can see if it is what you want. Custom handlers associate a url scheme to an application binary. I‘m not sure you can use an image with it. So I would register a shell script and handle the adoption in the script.

Does that help?

Norbert

Am 10.10.2017 um 21:06 schrieb Manuel Leuenberger <[hidden email]>:

Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘<a href="pharo://send?data=fancypants%E2%80%99" class="">pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel
 
Reply | Threaded
Open this post in threaded view
|

Re: Custom URI scheme for Pharo

Manuel Leuenberger
That's what I did. Only I used a native Objective-C app, as it provides a simple API to register to the events and will even be started if it's not running yet.

Am 12.10.2017 08:50 schrieb Norbert Hartl <[hidden email]>:
I think all you need is to do a system call out to the OS in order to register your scheme. For Mac OS it would be sonething like



And then you can see if it is what you want. Custom handlers associate a url scheme to an application binary. I‘m not sure you can use an image with it. So I would register a shell script and handle the adoption in the script.

Does that help?

Norbert

Am 10.10.2017 um 21:06 schrieb Manuel Leuenberger <[hidden email]>:

Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel
 

Reply | Threaded
Open this post in threaded view
|

Re: Custom URI scheme for Pharo

NorbertHartl
Ok, I see. Building a native app and interfacing it from pharo is the most reliable version. I was just thinking that having a system call out it might be easier to make it cross-platform. I would be interested to have that available for all platforms.

Norbert

Am 12.10.2017 um 09:20 schrieb Manuel Leuenberger <[hidden email]>:

That's what I did. Only I used a native Objective-C app, as it provides a simple API to register to the events and will even be started if it's not running yet.

Am 12.10.2017 08:50 schrieb Norbert Hartl <[hidden email]>:
I think all you need is to do a system call out to the OS in order to register your scheme. For Mac OS it would be sonething like



And then you can see if it is what you want. Custom handlers associate a url scheme to an application binary. I‘m not sure you can use an image with it. So I would register a shell script and handle the adoption in the script.

Does that help?

Norbert

Am 10.10.2017 um 21:06 schrieb Manuel Leuenberger <[hidden email]>:

Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel
 

Reply | Threaded
Open this post in threaded view
|

Re: Custom URI scheme for Pharo

Manuel Leuenberger
Sure, a system call out would be nicest way to register a handler. Unfortunately, registering custom URI schemes seems to be completely different on every platform, as well as how they receive an activation event. OS X uses a plist, Windows a registry entry, for Linux depends on the distro. So I went for a minimal solution. But it should be doable to provide a platform-aware package that takes case of the installation.

On 12 Oct 2017, at 09:34, Norbert Hartl <[hidden email]> wrote:

Ok, I see. Building a native app and interfacing it from pharo is the most reliable version. I was just thinking that having a system call out it might be easier to make it cross-platform. I would be interested to have that available for all platforms.

Norbert

Am 12.10.2017 um 09:20 schrieb Manuel Leuenberger <[hidden email]>:

That's what I did. Only I used a native Objective-C app, as it provides a simple API to register to the events and will even be started if it's not running yet.

Am 12.10.2017 08:50 schrieb Norbert Hartl <[hidden email]>:
I think all you need is to do a system call out to the OS in order to register your scheme. For Mac OS it would be sonething like



And then you can see if it is what you want. Custom handlers associate a url scheme to an application binary. I‘m not sure you can use an image with it. So I would register a shell script and handle the adoption in the script.

Does that help?

Norbert

Am 10.10.2017 um 21:06 schrieb Manuel Leuenberger <[hidden email]>:

Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘<a href="pharo://send?data=fancypants’" class="">pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel
 


Reply | Threaded
Open this post in threaded view
|

Re: Custom URI scheme for Pharo

kilon.alios
In reply to this post by Manuel Leuenberger
Probably it was your thread but as I said you can make a "hack" and overlay a system GUI over Pharo GUI This way you can view the PDF, "inside" Pharo. I think it is even possile  to get the handle of the Pharo window and directly affect it to embed a PDF viewer. 

The second solution is better because you want have to wory about Pharo window resizing as the PDF will be trully embeded inisde the Pharo window instead of overlayed. 

I am willing to bet you can avoid the multiple windows anooyance in some way on another without making your head explode. Unless its not a priority for you.

Looks great, well done mate. Keep the creative juices flowing ;)

On Thu, Oct 12, 2017 at 2:02 AM Manuel Leuenberger <[hidden email]> wrote:
Sounds like a nice setup you got there :).

I want to integrate documents displayed in the system viewer, as they cannot be displayed within Pharo (Web, PDF, …). So hyperlinking is the only way I see to get something close. I created a little demo where I injected hyperlinks in a PDF like ‘pharo://click?whatever=youwant'. When you click them, a little Objective-C app catches the OS event and forwards it to an HTTP server running in Pharo. So I can do things like this:


On 11 Oct 2017, at 00:24, Dimitris Chloupis <[hidden email]> wrote:

I think I remember this disussed before.
By talking with Pharo I assume here about another program talking to Pharo ? Possible not wrriten in Pharo ?

If thats the case then you can use whatever IPC works better for your needs. If the communication will be remotely I recommend sockets, for  fast local communication I recommend shared memory. They are both very mature technologies , very reliable and cross platform.

Now on the URI protocol, I think that will depend what you want to achieve. Any string will be easy to parse with Pharo's regex and trigger the approriate methods. Pharo also have Annoucements, think of it as an event system that awaits to be triggered by an event, usually a Pharo event but I see no reason why it cant listen to external events either. 

I do not think you will need a middle application , a servel client relation shipe should be more than enough. 

With my Atlas bridge which is a Pharo library that allows you to use Python libraries I did a neat trick with Pharo that it already communicated with Python via sockets, sending python commands but also Python could communicate back errors , then Pharo would trigger the debugger, display the python error inside the Pharo debugger and the debugger would pop up on the exact pharo command that send the faulty python code. You could then change the pharo command on the spot and it was resent and python continued like the error never happened to retain the all important live coding workflow.

I created a tiny protocol to difirentia incoming messages talking about errors from the ones returning python varriable values. Something stupid like "pythonError: blah blah" but it got the job done



On Tue, Oct 10, 2017 at 10:07 PM Manuel Leuenberger <[hidden email]> wrote:
Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel
 

Reply | Threaded
Open this post in threaded view
|

Re: Custom URI scheme for Pharo

Manuel Leuenberger
Yes, that was my thread. Thanks for the hint with overlaying a transparent OS window and controlling it from within Pharo. The overlay solution is not a priority for me, as it would require me to dive deeper into the macOS world. I rather live in the Pharo world, for now. :)

On 12 Oct 2017, at 10:26, Dimitris Chloupis <[hidden email]> wrote:

Probably it was your thread but as I said you can make a "hack" and overlay a system GUI over Pharo GUI This way you can view the PDF, "inside" Pharo. I think it is even possile  to get the handle of the Pharo window and directly affect it to embed a PDF viewer. 

The second solution is better because you want have to wory about Pharo window resizing as the PDF will be trully embeded inisde the Pharo window instead of overlayed. 

I am willing to bet you can avoid the multiple windows anooyance in some way on another without making your head explode. Unless its not a priority for you.

Looks great, well done mate. Keep the creative juices flowing ;)

On Thu, Oct 12, 2017 at 2:02 AM Manuel Leuenberger <[hidden email]> wrote:
Sounds like a nice setup you got there :).

I want to integrate documents displayed in the system viewer, as they cannot be displayed within Pharo (Web, PDF, …). So hyperlinking is the only way I see to get something close. I created a little demo where I injected hyperlinks in a PDF like ‘pharo://click?whatever=youwant'. When you click them, a little Objective-C app catches the OS event and forwards it to an HTTP server running in Pharo. So I can do things like this:


On 11 Oct 2017, at 00:24, Dimitris Chloupis <[hidden email]> wrote:

I think I remember this disussed before.
By talking with Pharo I assume here about another program talking to Pharo ? Possible not wrriten in Pharo ?

If thats the case then you can use whatever IPC works better for your needs. If the communication will be remotely I recommend sockets, for  fast local communication I recommend shared memory. They are both very mature technologies , very reliable and cross platform.

Now on the URI protocol, I think that will depend what you want to achieve. Any string will be easy to parse with Pharo's regex and trigger the approriate methods. Pharo also have Annoucements, think of it as an event system that awaits to be triggered by an event, usually a Pharo event but I see no reason why it cant listen to external events either. 

I do not think you will need a middle application , a servel client relation shipe should be more than enough. 

With my Atlas bridge which is a Pharo library that allows you to use Python libraries I did a neat trick with Pharo that it already communicated with Python via sockets, sending python commands but also Python could communicate back errors , then Pharo would trigger the debugger, display the python error inside the Pharo debugger and the debugger would pop up on the exact pharo command that send the faulty python code. You could then change the pharo command on the spot and it was resent and python continued like the error never happened to retain the all important live coding workflow.

I created a tiny protocol to difirentia incoming messages talking about errors from the ones returning python varriable values. Something stupid like "pythonError: blah blah" but it got the job done



On Tue, Oct 10, 2017 at 10:07 PM Manuel Leuenberger <[hidden email]> wrote:
Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel
 


Reply | Threaded
Open this post in threaded view
|

Re: Custom URI scheme for Pharo

kilon.alios
I cant argue with that , dealing with C can be quite “an interesting” experience :D it’s better and probably healthier when it happens at small dosages.
On Thu, 12 Oct 2017 at 11:56, Manuel Leuenberger <[hidden email]> wrote:
Yes, that was my thread. Thanks for the hint with overlaying a transparent OS window and controlling it from within Pharo. The overlay solution is not a priority for me, as it would require me to dive deeper into the macOS world. I rather live in the Pharo world, for now. :)

On 12 Oct 2017, at 10:26, Dimitris Chloupis <[hidden email]> wrote:

Probably it was your thread but as I said you can make a "hack" and overlay a system GUI over Pharo GUI This way you can view the PDF, "inside" Pharo. I think it is even possile  to get the handle of the Pharo window and directly affect it to embed a PDF viewer. 

The second solution is better because you want have to wory about Pharo window resizing as the PDF will be trully embeded inisde the Pharo window instead of overlayed. 

I am willing to bet you can avoid the multiple windows anooyance in some way on another without making your head explode. Unless its not a priority for you.

Looks great, well done mate. Keep the creative juices flowing ;)

On Thu, Oct 12, 2017 at 2:02 AM Manuel Leuenberger <[hidden email]> wrote:
Sounds like a nice setup you got there :).

I want to integrate documents displayed in the system viewer, as they cannot be displayed within Pharo (Web, PDF, …). So hyperlinking is the only way I see to get something close. I created a little demo where I injected hyperlinks in a PDF like ‘pharo://click?whatever=youwant'. When you click them, a little Objective-C app catches the OS event and forwards it to an HTTP server running in Pharo. So I can do things like this:


On 11 Oct 2017, at 00:24, Dimitris Chloupis <[hidden email]> wrote:

I think I remember this disussed before.
By talking with Pharo I assume here about another program talking to Pharo ? Possible not wrriten in Pharo ?

If thats the case then you can use whatever IPC works better for your needs. If the communication will be remotely I recommend sockets, for  fast local communication I recommend shared memory. They are both very mature technologies , very reliable and cross platform.

Now on the URI protocol, I think that will depend what you want to achieve. Any string will be easy to parse with Pharo's regex and trigger the approriate methods. Pharo also have Annoucements, think of it as an event system that awaits to be triggered by an event, usually a Pharo event but I see no reason why it cant listen to external events either. 

I do not think you will need a middle application , a servel client relation shipe should be more than enough. 

With my Atlas bridge which is a Pharo library that allows you to use Python libraries I did a neat trick with Pharo that it already communicated with Python via sockets, sending python commands but also Python could communicate back errors , then Pharo would trigger the debugger, display the python error inside the Pharo debugger and the debugger would pop up on the exact pharo command that send the faulty python code. You could then change the pharo command on the spot and it was resent and python continued like the error never happened to retain the all important live coding workflow.

I created a tiny protocol to difirentia incoming messages talking about errors from the ones returning python varriable values. Something stupid like "pythonError: blah blah" but it got the job done



On Tue, Oct 10, 2017 at 10:07 PM Manuel Leuenberger <[hidden email]> wrote:
Hi,

Is there any support from the VM/Application package to add custom URI schemes to listen to from within Pharo? I would like to have a hyperlink like ‘pharo://send?data=fancypants’ in an arbitrary document that, when clicked, switches to Pharo and calls a hook I can register. Could someone give me a hint how to achieve that, or do I have to build a little bridge application that handles the scheme registration and talks with Pharo through another channel? Currently, I only need this for OS X.

Cheers,
Manuel