Commit 99d5e9bc authored by jdelaune's avatar jdelaune

Initial commit

parents
# $Id$
==============================
Info
==============================
Simple CDN re-writes the URL of certain website elements (which can be extended using plugins) for use with a CDN Mirror service. Setup literally takes about a minute.
==============================
Installation
==============================
1. Drop the simplecdn folder into the modules directory (/sites/all/modules/)
4. Enable Simple CDN module (?q=/admin/build/modules) and optionally any element plugins you want to use your CDN Mirror with.
5. Make sure you change the module settings so it works with your site (?q=admin/settings/simplecdn), you'll need to setup at least one mirror.
Required Modules:
------------------------------
- None
==============================
Custom Code Use
==============================
Pop this code anywhere to insert an audio player.
| simplecdn_rewrite_url($url, $element_id); ?>
1. $url - the URL you want to convert to use with the CDN Mirror
3. $element_id - this is registered by plugins or other modules, examples include: image, imagecache, mp3player etc.
==============================
For developers wanting to integrate Simple CDN with their modules
==============================
Integration is very easy, you only need two bits of code. One an invoke function to the API so Simple CDN can register your element as something which can be used.
| /**
| * Implementation of hook_simplecdnapi().
| */
| function yourmodulename_simplecdnapi($op) {
| switch ($op) {
| case 'load':
| return array(
| 'eid' => 'yourmodulename',
| 'name' => 'Your Module Name',
| );
| break;
| }
| }
Next you will need to place this code where you need a URL to be processed by Simple CDN
| if (module_exists('simplecdn')) {
| $url = simplecdn_rewrite_url($url, 'yourmodulename');
| }
==============================
The Future
==============================
If you have any questions, issues, or feature suggestions then please do leave feedback on the project page (http://drupal.org/project/simplecdn)
==============================
Sponsorship
==============================
This module is sponsored by Alpha International (http://www.alpha.org), Holy Trinity Brompton (http://www.htb.org.uk) and CoreDesigns (http://www.coredesigns.co.uk)
\ No newline at end of file
; $Id$
name = Image
description = Enable the use of images (Drupal Core) with Simple CDN.
core = 6.x
package = CDN
dependencies[] = simplecdn
\ No newline at end of file
<?php
// $Id$
function simplecdn_image_install() {
//Do Nothing
}
function simplecdn_image_uninstall() {
//Do Nothing
}
\ No newline at end of file
<?php
// $Id$
/**
* Implementation of hook_help().
*/
function simplecdn_image_help($path, $arg) {
$output = '';
switch ($path) {
case "admin/help#simplecdn_image":
$output = '<p>'. t("Enable the use of images (Drupal Core) with Simple CDN.") .'</p>';
break;
}
return $output;
}
/**
* Implementation of hook_simplecdnapi().
*/
function simplecdn_image_simplecdnapi($op) {
switch ($op) {
case 'load':
return array(
'eid' => 'image',
'name' => 'Image',
);
break;
}
}
/**
* Override Theme Function (Drupal 6.9).
*/
function phptemplate_image($path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
if (!$getsize || (is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {
$attributes = drupal_attributes($attributes);
$url = (url($path) == $path) ? $path : (base_path() . $path);
$url = simplecdn_rewrite_url($url, 'image'); // ADDED LINE
return '<img src="'. check_url($url) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. (isset($image_attributes) ? $image_attributes : '') . $attributes .' />';
}
}
\ No newline at end of file
; $Id$
name = ImageCache
description = Enable the use of images (via ImageCache) with Simple CDN.
core = 6.x
package = CDN
dependencies[] = simplecdn
dependencies[] = imagecache
\ No newline at end of file
<?php
// $Id$
function simplecdn_imagecache_install() {
//Do Nothing
}
function simplecdn_imagecache_uninstall() {
//Do Nothing
}
\ No newline at end of file
<?php
// $Id$
/**
* Implementation of hook_help().
*/
function simplecdn_imagecache_help($path, $arg) {
$output = '';
switch ($path) {
case "admin/help#simplecdn_imagecache":
$output = '<p>'. t("Enable the use of images (via ImageCache) with Simple CDN.") .'</p>';
break;
}
return $output;
}
/**
* Implementation of hook_simplecdnapi().
*/
function simplecdn_imagecache_simplecdnapi($op) {
switch ($op) {
case 'load':
return array(
'eid' => 'imagecache',
'name' => 'ImageCache',
);
break;
}
}
/**
* Override Theme Function (ImageCache 6.x-2.0-beta8).
*/
function phptemplate_imagecache($namespace, $path, $alt = '', $title = '', $attributes = NULL) {
if ($image = image_get_info(imagecache_create_path($namespace, $path))) {
$attributes['width'] = $image['width'];
$attributes['height'] = $image['height'];
}
// check is_null so people can intentionally pass an empty array of attributes to override
// the defaults completely... if
if (is_null($attributes)) {
$attributes['class'] = 'imagecache imagecache-'. $namespace;
}
$attributes = drupal_attributes($attributes);
$imagecache_url = imagecache_create_url($namespace, $path);
$imagecache_url = simplecdn_rewrite_url($imagecache_url, 'imagecache'); // ADDED LINE
return '<img src="'. $imagecache_url .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $attributes .' />';
}
\ No newline at end of file
; $Id$
name = Simple CDN
description = Enable a mirror CDN on certain elements of your site.
core = 6.x
package = CDN
\ No newline at end of file
<?php
function simplecdn_install() {
drupal_install_schema('simplecdn');
}
function simplecdn_uninstall() {
drupal_uninstall_schema('simplecdn');
}
function simplecdn_schema() {
$schema['simplecdn_mirrors'] = array(
'fields' => array(
'mid' => array(
'description' => t('The primary identifier for a CDN mirror.'),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE),
'name' => array(
'description' => t('The name of the CDN mirror.'),
'type' => 'varchar',
'length' => 20,
'not null' => TRUE,
'default' => ''),
'url' => array(
'description' => t('If the player should autostart or not.'),
'type' => 'varchar',
'length' => 256,
'not null' => TRUE,
'default' => 'http://'),
),
'primary key' => array('mid'),
);
return $schema;
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment