Compredux
What is Compredux ?
Compredux is a web content proxy that acts as a passthrough client to http sites on the web. The client can be routed to serve content on an web server that meets its requirements.
What are the requirements ?
To use Compredux your hosting server must meet the following conditions:
- Must have PHP 5.3 or higher
- Must have mod rewrite capable host and the ability to use .htaccess files
- The web server must have write access to the folder where the content will be hosted
How to install Compredux?
-
unzip / extract the archive into your web root directory or subfolder
-
Rename index.example.php to index.php
Thats it You should be able to visit your website with the sub path of /subdir like this: http://www.yoursite.com/[subdir]
How to select /exclude content ?
Example 1. instantiate client and echo content:
<?php
include('Autoloader.php');
$client = new Compredux\Client();
$client->request();
$client->initHeaders();
if (!$Compredux\Client->isType('html')) {
echo $client->getContent();
exit();
}
echo $client->getContent();
Only use selection handles when the content type is html to allow other types to use pure passthrough, use a condition like this:
if (!$Compredux\Client->isType('html')) {
echo $client->getContent();
exit();
}
Selection is done by CSS handles.
To select elements by CSS class preface with a . like '.analytics' To select elements by element ID use the hash mark like '#content' To select elements by tag simply use the element name like 'body' Example 2. select the body exclude all analytics:
<?php
include('Autoloader.php');
$client = new Compredux\Client();
$client->request();
$client->initHeaders();
if (!$Compredux\Client->isType('html')) {
echo $client->getContent();
exit();
}
echo $client->getContent('body', '.analytics');
Array notation can be used to select multiple things Example 3. select everything exclude google analytics and getClicky:
<?php
include('Autoloader.php');
$client = new Compredux\Client();
$client->request();
$client->initHeaders();
if (!$Compredux\Client->isType('html')) {
echo $client->getContent();
exit();
}
echo $client->getContent(null, array(
'#gaq',
'#getClicky-top',
'#getClicky-bot'
));
Example 4. select multiple elements and arrange them with your custom templates:
<?php
include('Autoloader.php');
$client = new Compredux\Client();
$client->request();
$client->initHeaders();
if (!$Compredux\Client->isType('html')) {
echo $client->getContent();
exit();
}
$title = $client->getContent('title');
$headMeta = $client->getContent('meta');
$headLink = $client->getContent('head link');
$headScript = $client->getContent('head script');
$bodyScript = $client->getContent('body script');
$bodyContent = $client->getContent('#content');
<html>
<head>
<title> MyWebsite.com | $title </title>
echo $headMeta;
echo $headLink;
echo $headScript;
</head>
<body>
include('header.php');
echo $bodyContent;
include('footer.php');
echo $bodyScript;
</body>
Change Log
1.1 4/12/2011
added robots.txt
added second parameter to the getContent method. getContent now accepts a second parameter of string, array or null as a list of content to exclude from the selection.