Inserting a local HTML page


#1

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 removed_email_address@domain.invalid
KOREA


#2

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.


#3

hm… why not just copy HTML into Radiant page?


#4

Thanks a lot. I will go for the iFrame method for the time being.

saji

radiant page? The situation is that I have scrapped some


Radiant mailing list
Post: removed_email_address@domain.invalid
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 removed_email_address@domain.invalid
KOREA


#5

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

saji
Radiant mailing list


Regards, Keymone


Radiant mailing list
Post: removed_email_address@domain.invalid
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 removed_email_address@domain.invalid
KOREA


#6

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-February/003480.html

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 L.
Ymir s.r.l.
Viale Verona 190/11
38100 Trento


#7

oh… sorry :slight_smile: missed that one


#8

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?


#9

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


#10

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

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: removed_email_address@domain.invalid
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 removed_email_address@domain.invalid
KOREA


#11

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

because the content of the page is constructed automatically by

On 7/4/07, d n removed_email_address@domain.invalid 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: removed_email_address@domain.invalid
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 removed_email_address@domain.invalid
KOREA


#12

Saji Njarackalazhikam H. 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 L.
Ymir s.r.l.
Viale Verona 190/11
38100 Trento