Forum: Radiant CMS Inserting a local HTML page

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
621080472679266b8e9b81aff4800398?d=identicon&s=25 Saji Njarackalazhikam Hameed (Guest)
on 2007-07-04 07:53
(Received via mailing list)
Would it be possible to insert a local html page into a
radiant page? The situation is that I have scrapped some
info from a webpage and now want to include it into
a Radiant page that will serve as the 'Newsroom'.

any hints would be appreciated.

thanks
saji

--
Saji N. Hameed

APEC Climate Center                  +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705      saji@apcc21.net
KOREA
C0e931e4c48678091fea86704d835cfb?d=identicon&s=25 d n (Guest)
on 2007-07-04 08:37
(Received via mailing list)
Quick and dirty method would be to load the page into an iFrame in
one of the Radiant pages.

More elegantly, you could probably use an Ajax method to put the
contents of the page into a DIV on the Radiant page.
8aeb5ff3546efc726bab713e4e572a40?d=identicon&s=25 Keymone (Guest)
on 2007-07-04 08:42
(Received via mailing list)
hm... why not just copy HTML into Radiant page?
621080472679266b8e9b81aff4800398?d=identicon&s=25 Saji Njarackalazhikam Hameed (Guest)
on 2007-07-04 08:45
(Received via mailing list)
Thanks a lot. I will go for the iFrame method for the time being.

saji

* d n <npsd.42@gmail.com> [2007-07-03 23:35:33 -0700]:

> > radiant page? The situation is that I have scrapped some
> >
> _______________________________________________
> Radiant mailing list
> Post:   Radiant@lists.radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

--
Saji N. Hameed

APEC Climate Center                  +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705      saji@apcc21.net
KOREA
621080472679266b8e9b81aff4800398?d=identicon&s=25 Saji Njarackalazhikam Hameed (Guest)
on 2007-07-04 08:47
(Received via mailing list)
> hm... why not just copy HTML into Radiant page?

because the content of the page is constructed automatically by
scrapping News pages from say google news. Hence it would not be
convenient to cut-and-paste by hand, say everyday.

saji
..

* Keymone <keymone@gmail.com> [2007-07-04 09:40:45 +0300]:

> >
> > > saji
> > > Radiant mailing list
>
>
>
> --
> Regards, Keymone
> _______________________________________________
> Radiant mailing list
> Post:   Radiant@lists.radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

--
Saji N. Hameed

APEC Climate Center                  +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705      saji@apcc21.net
KOREA
8aeb5ff3546efc726bab713e4e572a40?d=identicon&s=25 Keymone (Guest)
on 2007-07-04 08:48
(Received via mailing list)
oh.. sorry :) missed that one
75f2022f13e4e677d080a2009c8a6dfb?d=identicon&s=25 Francesco Lunelli (Guest)
on 2007-07-04 10:28
(Received via mailing list)
Some time ago I used this method to include static html pages in a
Radiant site without using iframes. This method is far from to be
cmplete, there are many improvements, adn I hope I will have time to do
them, but it works. The biggest problem to resolve is the redirection of
inner links. I am working on this using apricot, but this part is not
complete. I hope I will be able to complete it soon.
If you need more feel free to ask me.

The possibility of capturing query parameters is not limited to
addressing different part of pages, but it could be useful in many ways,
I hope this possibility will be included in standard radiant
distribution.
In this case I used it to include static html pages into radiant
generated pages.
I have a customer that decided one of his emplyee MUST do some pages
using an editor like nvu. (Learning to use radiant cms is too difficult
for her)
But the rest of the site is generated from radiant, menu and pages etc.
For the moment the tag is customised to my needs, but I think it could
be easily modified to any needs.
First of all I modified the site_controller.rb according to this post
http://lists.radiantcms.org/pipermail/radiant/2007...

Then I created a custom tag

...
  require 'net/http'
  require 'uri'

  tag 'inner_site' do |tag|

# site is the url of the site I want to include risposta is the html
page I will get back

    site = tag.attr['site']
    risposta=""

# this is the radiant pag with "inner_site" tag for example
http://www.mysite.org/including
# the page "including" shoud be simply <r:inner_site
site="http://radiantcms.org" />

    server=request.env['PATH_INFO']

# this caputures the query string parameter (it should be made better
capturing all parameters in a hash with name and value, bu for the
moment it woks) The var @pagina contains the stati html page I want to
include. i.e /html/iniziative.html

    tag.globals.page.request.params.each do | param |
      @pagina = param[1].to_s.dup
    end
    if site
      url = URI.parse(site)
      res = Net::HTTP.start(url.host, url.port) {|http|
        @pagina ? http.get(@pagina) : http.get("/html/iniziative.html")
      }
# here I replace every internal link with a link to the radiant page
adding in the url the query string for the new page
#external links (those starting with http://) are leaved unchanged
# this part need a lot of work to be useful in every situation (pages
made with mac osx have different new line charachter, there should be a
better way to control if the link is internal or external) but form my
needs work enought.
# images and css paths are unchanged, so you will not see images and css
formatting
      res.body.each_line {|line|
        risposta+=  line=~/http/ ? line :
line.gsub(/href="(.*)"/,"href=\"#{server}?pag="+'\1"')
      }
    end
    risposta
  end


now you can use this form to include radiant site in your page
http://www.mysite.org/including?pag=/index



--
Francesco Lunelli
Ymir s.r.l.
Viale Verona 190/11
38100 Trento
C0e931e4c48678091fea86704d835cfb?d=identicon&s=25 d n (Guest)
on 2007-07-04 18:10
(Received via mailing list)
This is a great alternative to messy iframes...

Have you considered making this an extension, to easily add the tag,
and possibly a GUI to manage external pages, so they can be handled
by a name or other identifier, with the record keeping track of URL
and query parameters?
8802b1fa1b53e2197beea9454244f847?d=identicon&s=25 Sean Cribbs (Guest)
on 2007-07-04 22:17
(Received via mailing list)
Another alternative is to have your automatic scraping process run a
Ruby script (with script/runner) that loads the result of your
scraping into a page-part or snippet.  Then you can freely use this in
your pages and be confident that it will be updated automatically.

Sean
621080472679266b8e9b81aff4800398?d=identicon&s=25 Saji Njarackalazhikam Hameed (Guest)
on 2007-07-05 03:00
(Received via mailing list)
Francesco,

Thanks very much. I am using Radiant 0.6.1. Do I still have to modify
the site_controller.rb?
That is something I would like to avoid if possible.

saji
...

* Francesco Lunelli <francesco.l@ymir.it> [2007-07-04 10:26:35 +0200]:

> for her)
>   require 'uri'
> http://www.mysite.org/including
>     tag.globals.page.request.params.each do | param |
> # this part need a lot of work to be useful in every situation (pages
>     risposta
> Ymir s.r.l.
> Viale Verona 190/11
> 38100 Trento
>
>
> _______________________________________________
> Radiant mailing list
> Post:   Radiant@lists.radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

--
Saji N. Hameed

APEC Climate Center                  +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705      saji@apcc21.net
KOREA
621080472679266b8e9b81aff4800398?d=identicon&s=25 Saji Njarackalazhikam Hameed (Guest)
on 2007-07-05 03:05
(Received via mailing list)
Sean,

Thanks for this suggestion. Earlier the folks in the list helped me
to write a script to automate the creation of a page. I will try
using this to automatically create a page.

Nevertheless it will be nice if Radiant had a way to insert
local html files in an easy way (something in the way Francesco
is pointing to ).

thanks,

saji
..

* Sean Cribbs <seancribbs@gmail.com> [2007-07-04 15:17:08 -0500]:

> > because the content of the page is constructed automatically by
> > > On 7/4/07, d n <npsd.42@gmail.com> wrote:
> > > > > Would it be possible to insert a local html page into a
> > > > > Saji N. Hameed
> > > > > Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
> > > --
> > APEC Climate Center                                     +82 51 668 7470
> Radiant mailing list
> Post:   Radiant@lists.radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

--
Saji N. Hameed

APEC Climate Center                  +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705      saji@apcc21.net
KOREA
75f2022f13e4e677d080a2009c8a6dfb?d=identicon&s=25 Francesco Lunelli (Guest)
on 2007-07-05 14:52
(Received via mailing list)
Saji Njarackalazhikam Hameed ha scritto:
> Francesco,
>
> Thanks very much. I am using Radiant 0.6.1. Do I still have to modify the 
site_controller.rb?
> That is something I would like to avoid if possible.
>
> saji
> ...
>
>
I made this on a Radiant 0.6.1 if I am not worng you have to modify the
controller, but I am sure someone else on this list can confirm this
bettere than me.


I  post a little more recent version of my tag.
It is still far from to be complete.
It is a snapshot of code I was working on, I was doing some speed tests
page loading in two ways, using curl and using pure ruby method.
But the bottleneck wasn't there but in the url rewriting.
The url rewriting in this method
#      res.body.each_line {|line|
#        risposta+=  line=~/http/ ? line :
line.gsub(/href="(.*)"/,"href=\"#{server}?pag="+'\1"')
#      }
works but with unpredictable speed. In my tests sometimes it is quick
enought, sometimes it require too much time to complete.
Another problem to solve is in this line of code: res.body.each_line
{|line|... the method each.line dosnt' wotk correctly with different
endline charachters (unix windows machintosh) so before it you should
execute a test to find which endline charachter is the right one.
So I started to do some tests using apricot, but they still wasn't
functioning.
I will go on developing this tag as soon as I will have time enought to
complete it.


 tag 'inner_site' do |tag|
    site = tag.attr['site']
    pag =  tag.attr['pagina']
    risposta=""
    server=request.env['PATH_INFO']
    tag.globals.page.request.params.each do | param |
      @pagina = param[1].to_s.dup
    end
    if site

=begin
#-----------  curl method --------------
      url = @pagina ? URI.parse(site+@pagina) : URI.parse(site+pag)
     c = Curl::Easy.perform(url.to_s)
  #   c.body_str.each_line {|line|
  #     risposta+=  line=~/http/ ? line :
line.gsub(/href="(.*)"/,"href=\"#{server}?pag="+'\1"')
  #   }
   #----------- fine --------------------
=end

   # ------- pure ruby method-------
    url = URI.parse(site)
     res = Net::HTTP.start(url.host, url.port) {|http|
        @pagina ? http.get(@pagina) : http.get(pag)
      }
      risposta=res.body
#.gsub(/href="(?!http)(.*?)"/,"href=\"#{server}?pag="+'\1"')
#      res.body.each_line {|line|
#        risposta+=  line=~/http/ ? line :
line.gsub(/href="(.*)"/,"href=\"#{server}?pag="+'\1"')
#      }
   #---------- fine -------------

end
    #c.body_str
    risposta
  end

I hope this could be useful for you.
ciao

--
Francesco Lunelli
Ymir s.r.l.
Viale Verona 190/11
38100 Trento
This topic is locked and can not be replied to.