Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External URL inclution #27

Merged
merged 3 commits into from May 3, 2012
Merged

External URL inclution #27

merged 3 commits into from May 3, 2012

Conversation

aseba
Copy link
Contributor

@aseba aseba commented Apr 18, 2012

This is a small patch that you may be interested in

I've added a small patch to allow us to include external pages into the template. You just add the url as a parameter to the include call and it will add an echo file_get_contents() to the template. It's not very scalable, Maybe a good idea would be to cache the included page, but as it is works perfect for us.

It's something to handle with care but really powerful, and made our lives easier at building templates, Maybe you guys use this patch

Cheers!

@feulf
Copy link
Owner

feulf commented Apr 18, 2012

Cool. I'll test it today! Could you do the same for RainTpl 3?

@feulf
Copy link
Owner

feulf commented Apr 24, 2012

The inclusion of external HTML is nice, but what about security? I mean, RainTpl has a sandbox to load templates by untrusted source, so if for instance you have a CMS, you can let the users load their own template. What it could cause the loading of external sources?

I think a template that load an external source is not dangerous at all, but it considering it will load the external source each time is been called, that it could make the template slow to load, which it should be a smaller issue.

What's your opinion on it? I think I'll implement your change anyway because is very useful!

@aseba
Copy link
Contributor Author

aseba commented Apr 24, 2012

That's what I was saying that it's something to handle with care.. hehe

In our context, security is not an issue because the pages we include are controlled by us. If you see, for example, http://editor.olapic.com/photos/cbschicago the header is being included with this patch. As we work with other clients trying to do a white label with their brand over our product, the inclution of external files made easier for us to do that. They just give us an URL with an stand alone header and footer, we include it, and we are done. If they change it, we dont need to do anything.

I'm sure not everyone would need this but ours is a good example of when to use it. hehehe

On the other hand, Loading and external source everytime IS slower. And thats something we are working on. I would like to cache the external resource in some way (maybe on a file) and include that if we have it. I haven't done that yet because I didn't have the time But it may be a good idea indeed.

Cheers!

@feulf
Copy link
Owner

feulf commented Apr 24, 2012

Well, you can already cache an included file in RainTpl 2, e.g.:
{include="http://yourlink.com" cache="3600"}
http://www.raintpl.com/Documentation/Documentation-for-web-designers/RainTPL-Tags/_include_%20template%20_/

I think the main problem is the security, but it can be solved with a setting that can enable/disable the remote include, which by default it should be disabled:
RainTpl::configure( "allow_remote_include", true );

we also need a default cache time for remote include, 0 by default:
RainTpl::configure( "remote_include_cache_time", 0 );

Do you think you can do that? In case I will at first opportunity to work on it.

feulf added a commit that referenced this pull request May 3, 2012
External URL inclution
@feulf feulf merged commit 9fbb328 into feulf:master May 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants