|
Cookbook /
IncludeUrlSummary: Include html pages into PmWiki 2.x pages
Version: 2007-11-23
Status: stable
Prerequisites: pmwiki-2.0
Maintainer:
Categories: Includes
Download: includeurl.phpΔ
QuestionHow can I include the contents of another page in a wiki page? AnswerFirst, be sure you're aware of the security and possible copyright risks of letting the content of other (arbitrary!) URLs appear in your pages. Once you've gotten past that hurdle, the following code in your
Markup('includeurl', 'directives',
"/\\(:includeurl\\s+(http:[^$UrlExcludeChars]*?)\\s*:\\)/e",
"Keep(implode('',file(str_replace('&','&','$1'))))");
Embedding other pages (Alternative Answer)includeurl.phpΔ lets you embed other pages in a wiki page. Download script, copy to cookbook folder, and install by adding to config.php:
include_once("$FarmD/cookbook/includeurl.php");
The script adds the markup The included page is an embedded object, size can be determined with width and height parameters (default is width=100% and height=400px). This means the page will display with its own styling etc, not just a crude text content display and erronous inclusion of html head code as happens with above markup. Links will continue to work, as does everything else. Embedding a page as an object is similar to the html iframe element. Internet Explorer 6, 7, Firefox and all modern Mozilla browswers support embedded objects, IE5 and earlier does not. The parameter iframe=1 or iframe=true will result in the use of the <iframe ..> html tag instead of the more general <object ..> tag. But still use optional parameter border=.. if needed, not frameborder. Note that <iframe> is discontinued in the XHTML 1.1 specification. But some browsers may have difficulties with the use of the <object> tag. If iframe option is not used, browsers will use <object> tag, except IE, which will use <iframe> (since IE seems not to cope with <object> too well). Setting (:includeurl /samplesite/path/page.html :)
Version updates of includeurl.php
ExampleHere's an example that includes the contents from http://www.example.com into this page: (:includeurl http://www.example.com:) DiscussionKeep in mind that most things served up by a browser aren't designed to be included by other pages -- i.e., they have extra <html>, <head>, <title>, <body>, etc. tags in them that will probably not display correctly when embedded in another page. This recipe makes no attempt to remove the extra information. Note that this isn't needed if you just want to include an external resource in a layout template -- you can just use IncludeUrl not working in IE / changed "object" to "iframe"It doesn't work yet! s. Re: IncludeUrl not working with IE or Netscape?. Perhaps it's because of a object tag vulnerability in IE and/or a security fix, cause other object types are working in IE, e.g. SVG-objects or IE doesn't support the object types text/html. For this reason and becaus in the IncludeUrl cookbook is hard coded type="text/html" - so you can't anyway use this markup for other things like html - I have replaced <object> with <iframe> and now it works in IE too: Has somebody any reasons to do this not? cg, 2006-08-01 Seems reasonable, but IFRAME is not supported any longer from XHTML 1.1. - I changed the hard-coded type="twext/html" to be optionally set within the markup in includeurl.phpΔ, for those who like to experiment with othe robject types. HansB August 02, 2006, at 03:41 AM I changed includeurl.php so that it will now use the <iframe> tag if the option iframe=1 or iframe=true is specified in the markup. HansB August 03, 2006, at 03:58 AM SecurityDid I mention that this can be a really dangerous thing to allow on an open-edit website? See AlsoContributorsMimick old IncludeUrl script [*http://foo.bar/bleh.html*]
Markup('includeurl', 'directives',
"/\\(:includeurl\\s+(http:[^$UrlExcludeChars]*?)\\s*:\\)/e",
"Keep(implode('',file(str_replace('&','&','$1'))))");
Markup('[*','_begin',
"/\\[\\*(http:[^$UrlExcludeChars]*?)\\*\\]/e",
"Keep(implode('',file(str_replace('&','&','$1'))))");
Notes
Markup for httpsTo get https to also work with the includeurl markup, use the following:
Markup('includeurl', 'directives',
"/\\(:includeurl\\s+(https?:[^$UrlExcludeChars]*?)\\s*:\\)/e",
"Keep(implode('',file(str_replace('&','&','$1'))))");
Markup when allow_url_fopen is disabledOn some systems the option to open files via their URI is diasbled. One can bypass this by using a class that emulates the identical behavior. Download browseremulator.class.phpΔ and place into the cookbook/ directory. Place this into the local/config.php file:
function BrowserEmulatorFile($file){
include_once('cookbook/browseremulator.class.php');
$BrowserEmulator = new BrowserEmulator();
return implode('',$BrowserEmulator->file($file));
}
Markup('includeurl', 'directives',
"/\\(:includeurl\\s+(http:[^$UrlExcludeChars]*?)\\s*:\\)/e",
"Keep(BrowserEmulatorFile('$1'))");
Using IncludeUrl to embed files from a Subversion repository via TRACHere is how I, Christian Ridderström, have used this recipe to embed files from a Subversion repository via TRAC. Download the script as usual, then insert something like the following into your configuration file:
// Enable a restricted version of includeurl for embedding
// material from the repositor via TRAC
if(true) {
include_once("$FarmD/cookbook/includeurl.php");
DisableMarkup("includeurl"); // Arbitrary URIs may not be included
Markup('includesvn', 'directives',
'/\\(:includesvn (.*?) (.*?)\\s*:\\)/ei',
"IncludeSvn(\$pagename, PSS('$1'), PSS('$2'))");
function IncludeSvn($pagename, $path, $opt) {
$uri = "http://www.lyx.org/trac/browser/lyx-devel/trunk/"
. $path . "?format=raw";
return IncludeUrl($pagename, $uri, $opt);
}
}
You can then use the markup |