Skip to main content

This simple script lets people include bits of your content (hosted on whatever server you like) into their own pages. It uses the age-old technique used by ads of issuing writes from a Javascript file.

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.

Example

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.

News

0.2

  • In some cases extra <body> tags would be included in the transcluded content (when that tag should never be present).

0.1

Initial release

Release files for ScriptTranscluder 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ScriptTranscluder 0.2
File Size Uploaded
ScriptTranscluder-0.2.tar.gz 8.4 kB Details

Release files / ScriptTranscluder-0.2.tar.gz

Download URL ScriptTranscluder-0.2.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6a2c706f80c040eb6e4c3cb09cb7a6499d8c59ec8657b6b73465b981742a1015
BLAKE2b-256 checksum
How to use checksums
22a39ff69ee334a6212eebf4abaa8edd1b84ba4c8e6fa1edd906b12ad3f1716d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file

0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page