external html page include

Discussion in 'Ruby' started by Sam Ginko, Jul 19, 2009.

  1. Sam Ginko

    Sam Ginko Guest

    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/.
    Sam Ginko, Jul 19, 2009
    #1
    1. Advertising

  2. Sam Ginko

    7stud -- Guest

    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/.
    7stud --, Jul 19, 2009
    #2
    1. Advertising

  3. Sam Ginko

    7stud -- Guest

    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/.
    7stud --, Jul 19, 2009
    #3
  4. Sam Ginko

    Sam Ginko Guest

    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/.
    Sam Ginko, Jul 19, 2009
    #4
  5. Sam Ginko

    7stud -- Guest

    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/.
    7stud --, Jul 19, 2009
    #5
  6. Sam Ginko

    Sam Ginko Guest

    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/.
    Sam Ginko, Jul 20, 2009
    #6
  7. Sam Ginko

    Chris Rhoden Guest

    [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/.
    >>
    >>

    >
    Chris Rhoden, Jul 20, 2009
    #7
  8. Sam Ginko

    Chris Rhoden Guest

    [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/.
    >
    >
    Chris Rhoden, Jul 20, 2009
    #8
  9. Sam Ginko

    Sam Ginko Guest

    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/.
    Sam Ginko, Jul 20, 2009
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. x

    include external html code

    Mr. x, Oct 25, 2003, in forum: HTML
    Replies:
    1
    Views:
    651
    Leif K-Brooks
    Oct 27, 2003
  2. Darko
    Replies:
    2
    Views:
    326
    Darko
    Oct 16, 2006
  3. Joey
    Replies:
    5
    Views:
    985
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    899
    Andreas Bogenberger
    Feb 22, 2008
  5. mac
    Replies:
    4
    Views:
    2,194
    Neredbojias
    May 13, 2009
Loading...

Share This Page