librelist archives

« back to archive

Open-URI and Shoes

Open-URI and Shoes

From:
Patrick Ester
Date:
2015-02-22 @ 22:58
I am looking to display a webpage in Shoes. In doing some quick 
research, I see that open-uri might be able to do this. I am new to 
Ruby, so I am wondering if you could give me some tips on how to use 
Open-URI or if there is another tool to help me get a webpage displayed 
in a Shoes app?

Re: [shoes] Open-URI and Shoes

From:
Cecil Coupe
Date:
2015-02-23 @ 02:48
Hi Patrick,

   The Shoes method 'download' uses open-uri so most of the work as been 
done for you. But, that only gets you  the html of the webpage.  What do 
you want to do with the html?  It would be nearly impossible (or 
wonderfully difficult) to "Display" the whole thing in Shoes. If you 
want to load it into a normal browser, there is a way to do that. If you 
want to find and get a few pieces of data in the html there are ways to 
do that (search the web for hpricot tutorial)

--Cecil
On 02/22/2015 03:58 PM, Patrick Ester wrote:
> I am looking to display a webpage in Shoes. In doing some quick
> research, I see that open-uri might be able to do this. I am new to
> Ruby, so I am wondering if you could give me some tips on how to use
> Open-URI or if there is another tool to help me get a webpage displayed
> in a Shoes app?

Re: [shoes] Open-URI and Shoes

From:
Patrick Ester
Date:
2015-02-23 @ 03:11
Ideally, I would like to "display" the html. As it is nearly impossible 
to do this, I am interested in the idea of loading it in a normal 
browser. How would I go about this?

On 2/22/15 8:48 PM, Cecil Coupe wrote:
> Hi Patrick,
>
>     The Shoes method 'download' uses open-uri so most of the work as been
> done for you. But, that only gets you  the html of the webpage.  What do
> you want to do with the html?  It would be nearly impossible (or
> wonderfully difficult) to "Display" the whole thing in Shoes. If you
> want to load it into a normal browser, there is a way to do that. If you
> want to find and get a few pieces of data in the html there are ways to
> do that (search the web for hpricot tutorial)
>
> --Cecil
> On 02/22/2015 03:58 PM, Patrick Ester wrote:
>> I am looking to display a webpage in Shoes. In doing some quick
>> research, I see that open-uri might be able to do this. I am new to
>> Ruby, so I am wondering if you could give me some tips on how to use
>> Open-URI or if there is another tool to help me get a webpage displayed
>> in a Shoes app?
>

Re: [shoes] Open-URI and Shoes

From:
Cecil Coupe
Date:
2015-02-23 @ 03:24
If you are using Shoes 3.2 then this is known work:

def  open_url(url)
   if  RbConfig::CONFIG['host_os']=~  /mswin|mingw|cygwin/
     system("start#{url}")
   elsif  RbConfig::CONFIG['host_os']=~  /darwin/
     system("open#{url}")
   elsif  RbConfig::CONFIG['host_os']=~  /linux|bsd/
     system("xdg-open#{url}")
   end
end

Note that there is no interaction between the browser and your Shoes script.
They are independent after the launch. Of course the url can be a 
File://filename.html
that you wrote or download and saved.

--Cecil


On 02/22/2015 08:11 PM, Patrick Ester wrote:
> Ideally, I would like to "display" the html. As it is nearly impossible
> to do this, I am interested in the idea of loading it in a normal
> browser. How would I go about this?
>
> On 2/22/15 8:48 PM, Cecil Coupe wrote:
>> Hi Patrick,
>>
>>      The Shoes method 'download' uses open-uri so most of the work as been
>> done for you. But, that only gets you  the html of the webpage.  What do
>> you want to do with the html?  It would be nearly impossible (or
>> wonderfully difficult) to "Display" the whole thing in Shoes. If you
>> want to load it into a normal browser, there is a way to do that. If you
>> want to find and get a few pieces of data in the html there are ways to
>> do that (search the web for hpricot tutorial)
>>
>> --Cecil
>> On 02/22/2015 03:58 PM, Patrick Ester wrote:
>>> I am looking to display a webpage in Shoes. In doing some quick
>>> research, I see that open-uri might be able to do this. I am new to
>>> Ruby, so I am wondering if you could give me some tips on how to use
>>> Open-URI or if there is another tool to help me get a webpage displayed
>>> in a Shoes app?

Re: [shoes] Open-URI and Shoes

From:
peter marien
Date:
2015-02-24 @ 21:25
Not impossible but not with only shoes i'm afraid, see webkit in Qt, there
were some bindings for Gtk also, don't know if that is maintaned though,
here an example

require 'Qt4'
require 'qtwebkit'

class A < Qt::WebView
  slots 'mySlot(QUrl)'
  def initialize()
super()
connect(self, SIGNAL('linkClicked(QUrl)'), self, SLOT('mySlot(QUrl)'))
  end
  def mySlot(url)
if (url.path == 'quit')
  puts "quit"
  exit()
elsif (url.path == 'cont')
  setHtml <<EOP
<html>
 <head>
  <title>test</title>
 </head>
 <body>
  <div>
This is a test. That works</br>
<h2><a id='click' href="quit" onclick="quit()">Quit</a></h2>
  </div>
 </body>
</html>
EOP
 end
  end
end

Qt::Application.new(ARGV) do
   A.new() do |view|
view.page.setLinkDelegationPolicy(Qt::WebPage::DelegateAllLinks)
view.setHtml <<EOP
<html>
 <head>
  <title>test</title>
 </head>
 <body>
  <div>
This is a test.</br>
<a id='click' href="quit" onclick="quit()">quit</a>
<a id='click' href="cont" onclick="quit()">Click on me!</a>
  </div>
 </body>
</html>
EOP
view.show
  end
  exec
end


2015-02-23 4:24 GMT+01:00 Cecil Coupe <ccoupe@cableone.net>:

> If you are using Shoes 3.2 then this is known work:
>
> def  open_url(url)
>    if  RbConfig::CONFIG['host_os']=~  /mswin|mingw|cygwin/
>      system("start#{url}")
>    elsif  RbConfig::CONFIG['host_os']=~  /darwin/
>      system("open#{url}")
>    elsif  RbConfig::CONFIG['host_os']=~  /linux|bsd/
>      system("xdg-open#{url}")
>    end
> end
>
> Note that there is no interaction between the browser and your Shoes
> script.
> They are independent after the launch. Of course the url can be a
> File://filename.html
> that you wrote or download and saved.
>
> --Cecil
>
>
> On 02/22/2015 08:11 PM, Patrick Ester wrote:
> > Ideally, I would like to "display" the html. As it is nearly impossible
> > to do this, I am interested in the idea of loading it in a normal
> > browser. How would I go about this?
> >
> > On 2/22/15 8:48 PM, Cecil Coupe wrote:
> >> Hi Patrick,
> >>
> >>      The Shoes method 'download' uses open-uri so most of the work as
> been
> >> done for you. But, that only gets you  the html of the webpage.  What do
> >> you want to do with the html?  It would be nearly impossible (or
> >> wonderfully difficult) to "Display" the whole thing in Shoes. If you
> >> want to load it into a normal browser, there is a way to do that. If you
> >> want to find and get a few pieces of data in the html there are ways to
> >> do that (search the web for hpricot tutorial)
> >>
> >> --Cecil
> >> On 02/22/2015 03:58 PM, Patrick Ester wrote:
> >>> I am looking to display a webpage in Shoes. In doing some quick
> >>> research, I see that open-uri might be able to do this. I am new to
> >>> Ruby, so I am wondering if you could give me some tips on how to use
> >>> Open-URI or if there is another tool to help me get a webpage displayed
> >>> in a Shoes app?
>
>