# Help on Extension: EmbedPage

**URL:** <https://www.ruby-forum.com/t/help-on-extension-embedpage/88196>\
**Category:** Radiant CMS\
**Created:** [March 8, 2007, 9:31pm UTC](https://www.ruby-forum.com/t/help-on-extension-embedpage/88196 "2007-03-08T21:31:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nolic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nolic](https://www.ruby-forum.com/u/nolic)\
**Post date:** [March 8, 2007, 9:31pm UTC](https://www.ruby-forum.com/t/help-on-extension-embedpage/88196/1 "2007-03-08T21:31:02Z")

</div>

Im building an extension to embed another RoR app in Radiant. I followed  
the  
instructions at -  
[http://dev.radiantcms.org/radiant/wiki/HowToWriteAnExtension](http://dev.radiantcms.org/radiant/wiki/HowToWriteAnExtension) to generate  
the  
skeleton called M7Embed

## The main file is: embed\_extension.rb

class M7embedExtension \< Radiant::Extension  
version “1.0”  
description “Allows you to embed other sites in Radiant”  
url “”

def activate  
EmbedPage  
end

def deactivate  
end

## end

## and a model embed\_page.rb:

class EmbedPage \< Page  
tag ‘embed\_page’ do |tag|  
require ‘open-uri’

```
open(tag.attr['url']).read

```

## end end

The issue I am running into is that generally the application I am  
trying to  
load has relative references, and when it is embedded, it assumes  
everything  
is coming from the embedding page, and not the application… can anyone  
suggest how to remedy this?

As an example of this code embedding google -  
[http://beta.method-seven.com/embed](http://beta.method-seven.com/embed)

Thanks in advance for your help,

Colin

P.s. - Credit to Joannou Ng for submitting a behavior to this list on  
Jan  
18th that was used as the basis for this extension.

---

<div class="post-metadata">

**Author:** ![nolic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nolic](https://www.ruby-forum.com/u/nolic)\
**Post date:** [March 8, 2007, 9:36pm UTC](https://www.ruby-forum.com/t/help-on-extension-embedpage/88196/2 "2007-03-08T21:36:03Z")

</div>

Colin,

You might be better off with an IFRAME or something similar, otherwise  
you will have to create a bunch of workarounds in your Rails application  
to deal with a different HTTP\_REFERER.

The other option, of course, is to fuse Radiant with your application,  
i.e. making your application into an extension, but that may not be  
appropriate.

Sean

---

<div class="post-metadata">

**Author:** ![nolic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nolic](https://www.ruby-forum.com/u/nolic)\
**Post date:** [March 9, 2007, 8:26pm UTC](https://www.ruby-forum.com/t/help-on-extension-embedpage/88196/3 "2007-03-09T20:26:37Z")

</div>

Colin N. wrote:

> The issue I am running into is that generally the application I am  
> trying to  
> load has relative references, and when it is embedded, it assumes  
> everything  
> is coming from the embedding page, and not the application… can anyone  
> suggest how to remedy this?

as an example:

You might have your Radiant at [radiant.example.com](http://radiant.example.com), and  
[radiant.example.com/embeddedapp](http://radiant.example.com/embeddedapp)  
calls  
\<r:embed\_page=“[myapptoembed.example.com](http://myapptoembed.example.com)”/\>

And then the resultant page would have soemething like this  
Login

But the problem if you then click “Login” your browser will go to

[radiant.example.com/embeddedapp/login](http://radiant.example.com/embeddedapp/login)

when it should really be going to

[myapptoembed.example.com/login](http://myapptoembed.example.com/login)

But the real problem you are going to have is when you Submit that login  
form  
And even it makes a POST to:

- [myapptoembed.example.com/login](http://myapptoembed.example.com/login)  
it will then redirect to:
- [myapptoembed.example.com/loggedin](http://myapptoembed.example.com/loggedin)  
instead of coming back to some sort of Radiant equivalent:
- [radiant.example.com/embeddedapp/loggedin](http://radiant.example.com/embeddedapp/loggedin)

Now if all you want to do is make

[myapptoembed.example.com](http://myapptoembed.example.com)

show up at

[radiant.example.com/embeddedapp](http://radiant.example.com/embeddedapp)

All you really need is some Apache rewrite directives. Apache can  
automatically convert each url as it comes in to the right back-end  
url…

So, the question is… what are you REALLY trying to accomplish here?
