Transclude content via <script> tags
If you mount this at http://example.com/includer.js then you can use tags like:
<script src="http://example.com/includer.js?url=encoded-url"></script> <script src="http://example.com/includer.js?url=encoded-url%23fragment"></script> <script src="http://example.com/includer.js?url=encoded-url&dest=otherId"></script>
These each include the content from the encoded-url. If you give a fragment, it grabs just the bit of identified text. If you don’t, it’ll take all the text in the <body> of the page.
It will put the output exactly where the <script> tag is in the page. If you want to put it someplace else, &dest=id will put it in the element with the given id. In that case it adds a little onload(-like) handler, and then sets the innerHTML of element with that id. If you can’t fetch the url, then it will put a small error message into the page in its place.
By default it restricts urls based on the opt-in wildcards of the allowed_urls setting. You can use allowed_urls = * to allow anything, but this is not recommended. You can also use same_host = true to allow requests to the same host as where the includer is hosted.
To minimize backend traffic, set cache_dir to a location to save the requested pages. All the caching is handled by httplib2.
To run an example, install the package and use paster serve development.ini (development.ini is in the tarball). This will start up a server on http://localhost:8080/ where you can view an example.
In some cases extra <body> tags would be included in the transcluded content (when that tag should never be present).
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.