Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > external html page include

Reply
Thread Tools

external html page include

 
 
Sam Ginko
Guest
Posts: n/a
 
      07-19-2009
I would like to include an external html page into a .rhtml document. I
know you can do it with iframes but that is not what I want. Does ruby
have an include tag for that?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
7stud --
Guest
Posts: n/a
 
      07-19-2009
Sam Ginko wrote:
> I would like to include an external html page into a .rhtml document. I
> know you can do it with iframes but that is not what I want. Does ruby
> have an include tag for that?


Who cares what ruby has? The generated page is html. If you can't do
it with the available html tags, e.g. frames or iframes, then ruby isn't
going to magically be able to help you.

It sounds like you are trying to get ruby to enter into a conspiracy
with you to steal content.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
7stud --
Guest
Posts: n/a
 
      07-19-2009
Sam Ginko wrote:
> I would like to include an external html page into a .rhtml document. I
> know you can do it with iframes but that is not what I want. Does ruby
> have an include tag for that?


On the other hand, if you are trying to incorporate some raw html into a
rhtml page, just read the file and output it:

<%= %> # executes the Ruby code and displays the result


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Sam Ginko
Guest
Posts: n/a
 
      07-19-2009
How? with a File.Open()?. I'm new to ruby so I'm not sure if that is
what I should do.


7stud -- wrote:
> Sam Ginko wrote:
>> I would like to include an external html page into a .rhtml document. I
>> know you can do it with iframes but that is not what I want. Does ruby
>> have an include tag for that?

>
> On the other hand, if you are trying to incorporate some raw html into a
> .rhtml page, just read the file and output it:
>
> <%= %> # executes the Ruby code and displays the result


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      07-19-2009
Sam Ginko wrote:
> How? with a File.Open()?. I'm new to ruby so I'm not sure if that is
> what I should do.
>


You could write:

f = File.open("page.htm")
f.read()

or you could combine that into one line:

File.open("page.htm").read()

or you could use the shortcut:

IO.read("page.htm")
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Sam Ginko
Guest
Posts: n/a
 
      07-19-2009
That is what I thought and it aint working. I'm trying to open a file on
another server i:e http://docs.google.com/View?id=10. So I guess iframe
is the only option

7stud -- wrote:
> Sam Ginko wrote:
>> How? with a File.Open()?. I'm new to ruby so I'm not sure if that is
>> what I should do.
>>

>
> You could write:
>
> f = File.open("page.htm")
> f.read()
>
> or you could combine that into one line:
>
> File.open("page.htm").read()
>
> or you could use the shortcut:
>
> IO.read("page.htm")


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Chris Rhoden
Guest
Posts: n/a
 
      07-19-2009
[Note: parts of this message were removed to make it a legal post.]

Didn't look closely enough at what's going on here.

What exactly are you trying to do? The previous response should work.

However, if you are actually requesting a page from something like Google
Docs, you need to realize that the request will be made at the server, not
in the browser, so your cookies will not be in the request, so you will not
be authenticated unless you explicitly do that. It is more trouble than it's
worth in most cases.

Additionally, unless you intend to alter the HTML in some way before
including it in the page, it will look all off, so probably best to stick
with iFrames unless it is absolutely necessary to scrape (which is what you
are doing)

-chris

On Sun, Jul 19, 2009 at 7:38 PM, Chris Rhoden <> wrote:

> You should use something like
> require 'open-uri'
>
> puts open('http://some-url.com/file').read
>
> or the curl libraries.
>
> Chris Rhoden
> Chief Developer - (ph)Pea
> Co-Founder - Invalid Media
>
>
>
> On Sun, Jul 19, 2009 at 7:13 PM, Sam Ginko <> wrote:
>
>> That is what I thought and it aint working. I'm trying to open a file on
>> another server i:e http://docs.google.com/View?id=10. So I guess iframe
>> is the only option
>>
>> 7stud -- wrote:
>> > Sam Ginko wrote:
>> >> How? with a File.Open()?. I'm new to ruby so I'm not sure if that is
>> >> what I should do.
>> >>
>> >
>> > You could write:
>> >
>> > f = File.open("page.htm")
>> > f.read()
>> >
>> > or you could combine that into one line:
>> >
>> > File.open("page.htm").read()
>> >
>> > or you could use the shortcut:
>> >
>> > IO.read("page.htm")

>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>>

>


 
Reply With Quote
 
Chris Rhoden
Guest
Posts: n/a
 
      07-19-2009
[Note: parts of this message were removed to make it a legal post.]

You should use something like
require 'open-uri'

puts open('http://some-url.com/file').read

or the curl libraries.

Chris Rhoden
Chief Developer - (ph)Pea
Co-Founder - Invalid Media


On Sun, Jul 19, 2009 at 7:13 PM, Sam Ginko <> wrote:

> That is what I thought and it aint working. I'm trying to open a file on
> another server i:e http://docs.google.com/View?id=10. So I guess iframe
> is the only option
>
> 7stud -- wrote:
> > Sam Ginko wrote:
> >> How? with a File.Open()?. I'm new to ruby so I'm not sure if that is
> >> what I should do.
> >>

> >
> > You could write:
> >
> > f = File.open("page.htm")
> > f.read()
> >
> > or you could combine that into one line:
> >
> > File.open("page.htm").read()
> >
> > or you could use the shortcut:
> >
> > IO.read("page.htm")

>
> --
> Posted via http://www.ruby-forum.com/.
>
>


 
Reply With Quote
 
Sam Ginko
Guest
Posts: n/a
 
      07-20-2009
You're right. I'll stick with iframes.

thanks anyway


Chris Rhoden wrote:
> Didn't look closely enough at what's going on here.
>
> What exactly are you trying to do? The previous response should work.
>
> However, if you are actually requesting a page from something like
> Google
> Docs, you need to realize that the request will be made at the server,
> not
> in the browser, so your cookies will not be in the request, so you will
> not
> be authenticated unless you explicitly do that. It is more trouble than
> it's
> worth in most cases.
>
> Additionally, unless you intend to alter the HTML in some way before
> including it in the page, it will look all off, so probably best to
> stick
> with iFrames unless it is absolutely necessary to scrape (which is what
> you
> are doing)
>
> -chris


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
include an external html file (form ) mac HTML 4 05-13-2009 08:01 PM
/* #include <someyhing.h> */ => include it or do not include it?That is the question .... Andreas Bogenberger C Programming 3 02-22-2008 10:53 AM
How to include a given HTML page in aspx page..?? ms_sarwar ASP .Net 1 09-07-2007 06:32 AM
include HTML code from html page Kevin ASP .Net 1 09-27-2005 06:04 PM
include external html code Mr. x HTML 1 10-27-2003 11:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57