diff --git a/cdn.admin.css b/cdn.admin.css new file mode 100644 index 0000000..c3f647a --- /dev/null +++ b/cdn.admin.css @@ -0,0 +1,3 @@ +.cdn-settings .advanced-help-link { + padding-right: 3px; +} diff --git a/cdn.admin.inc b/cdn.admin.inc index 1507a0b..ee0379f 100644 --- a/cdn.admin.inc +++ b/cdn.admin.inc @@ -13,16 +13,8 @@ * Form definition; general settings. */ function cdn_admin_general_settings_form(&$form_state) { - ctools_include('dependent'); - cdn_load_include('requirements'); - - // Prevent requirement errors from showing up twice. - if (empty($form_state['post'])) { - _cdn_admin_check_requirements(); - } - - $form['#submit'] = array('cdn_admin_settings_submit_show_cache_warning'); - + $form = array(); + _cdn_settings_form_prepare($form, $form_state); // Check which CDN integration mechanism is being used. $integration_method = _cdn_requirements_get_integration_mechanism(); @@ -54,6 +46,8 @@ function cdn_admin_general_settings_form(&$form_state) { '#value' => $desc, ); + $perm_url = url('admin/user/permissions', + array('fragment' => 'module-cdn')); $form[CDN_STATUS_VARIABLE] = array( '#type' => 'radios', '#title' => t('Status'), @@ -61,8 +55,12 @@ function cdn_admin_general_settings_form(&$form_state) { "If you don't want to use the CDN to serve files to your visitors yet, but you do want to see if it's working well for your site, then enable testing mode.
Users will only get the files from the CDN if they - have the %cdn-testing-mode-permission permission.", - array('%cdn-testing-mode-permission' => 'access files on CDN when in testing mode') + have the %cdn-testing-mode-permission + permission.", + array( + '!perm-url' => $perm_url, + '%cdn-testing-mode-permission' => 'access files on CDN when in testing mode', + ) ), '#required' => TRUE, '#options' => array( @@ -78,8 +76,11 @@ function cdn_admin_general_settings_form(&$form_state) { '#title' => t('Display statistics'), '#description' => t( 'Shows the CDN integration statistics of the current page, to users with - the %access-per-page-statistics permission.', - array('%access-per-page-statistics' => 'access per-page statistics') + the %access-per-page-statistics permission.', + array( + '!perm-url' => $perm_url, + '%access-per-page-statistics' => 'access per-page statistics', + ) ), '#return_value' => CDN_ENABLED, '#default_value' => variable_get(CDN_STATS_VARIABLE, CDN_DISABLED), @@ -94,36 +95,13 @@ function cdn_admin_general_settings_form(&$form_state) { * Form definition; details. */ function cdn_admin_details_form(&$form_state) { - ctools_include('dependent'); - - // Prevent requirement errors from showing up twice. - if (empty($form_state['post'])) { - _cdn_admin_check_requirements(); - } - - $form['#submit'] = array('cdn_admin_settings_submit_show_cache_warning'); + $form = array(); + _cdn_settings_form_prepare($form, $form_state); $form[CDN_MODE_VARIABLE] = array( '#type' => 'radios', '#title' => t('Mode'), - '#description' => t( - "It is essential that you understand the key - properties of a CDN, most importantly the differences between an - Origin Pull CDN and a Push CDN. If you understand that, - continue to make a choice between the two supported modes: - !mode-explanation-list", array( - '!cdn-article-url' => 'http://wimleers.com/article/key-properties-of-a-cdn', - '!mode-explanation-list' => theme('item_list', array( - t("Origin Pull mode replaces your domain name with - the Origin Pull CDN's domain name in the file URL."), - t("File Conveyor mode uses the File Conveyor - daemon to synchronize files and can be used with both Origin Pull - and Push CDNs. If you're using an Origin Pull CDN and want to - optimize files before they're synced to the CDN, it is also - recommended to use this mode.") - )), - ) - ), + '#description' => t('Choose a CDN integration mode.') . ' ' . theme('advanced_help_topic', 'cdn', 'admin-details-mode'), '#required' => TRUE, '#options' => array( CDN_MODE_BASIC => t('Origin Pull'), @@ -132,85 +110,29 @@ function cdn_admin_details_form(&$form_state) { '#default_value' => variable_get(CDN_MODE_VARIABLE, CDN_MODE_BASIC), ); - $form['settings'] = array( '#type' => 'fieldset', '#title' => t('Mode-specific settings'), - '#description' => t('Settings specific to the mode you have currently selected.'), ); - // - // Basic mode settings. + // Origin Pull mode settings. // - $format_variables = array( - '@format-url' => '<' . t('URL') . '>', - '@format-extensions' => '<' . t('extensions') . '>', - ); - $format_explanation_list_items = array( - t("@format-url is the CDN URL that should be used. E.g.: - 'http://cdn-a.com'.", $format_variables), - t("@format-extensions is an optional - setting to limit which file types should be served from a CDN. E.g.: - '.css .jpg .jpeg .png'.", $format_variables), - ); - $example_list_items = array( - t('This would serve all files from a single CDN: -
http://cdn-a.com
'), - t("This would serve CSS and images from CDN A, .zip files from CDN B and - everything else from CDN C: -
http://cdn-a.com|.css .jpg .jpeg .png\nhttp://cdn-b.com|.zip\nhttp://cdn-c.com
"), - ); $form['settings'][CDN_BASIC_MAPPING_VARIABLE] = array( '#type' => 'textarea', '#title' => t('CDN mapping'), - '#description' => t("Define which files are mapped to which CDN.
-
- Enter one mapping per line, in the format @format-url[|@format-extensions]:
- !format-explanation-list -
- Sample mappings: - !example-list", $format_variables + array( - '!format-explanation-list' => theme('item_list', $format_explanation_list_items), - '!example-list' => theme('item_list', $example_list_items), - )), + '#description' => t("Define which files are mapped to which CDN.") . ' ' . theme('advanced_help_topic', 'cdn', 'admin-details-mode-pull-cdn-mapping'), '#size' => 35, '#default_value' => variable_get(CDN_BASIC_MAPPING_VARIABLE, ''), '#process' => array('ctools_dependent_process'), '#dependency' => array('radio:' . CDN_MODE_VARIABLE => array(CDN_MODE_BASIC)), ); - $farfuture_extensions = variable_get(CDN_BASIC_FARFUTURE_EXTENSIONS_VARIABLE, CDN_BASIC_FARFUTURE_EXTENSIONS_DEFAULT); - $farfuture_variables = array( - '!extensions' => "." . implode(", .", explode("\n", $farfuture_extensions)) . "", - '!extensions-compressed' => "." . implode(", .", explode("\n", CDN_BASIC_FARFUTURE_GZIP_EXTENSIONS)) . "", - ); $form['settings'][CDN_BASIC_FARFUTURE_VARIABLE] = array( '#type' => 'checkbox', '#title' => t('Far Future expiration'), - '#description' => t('Recommended for maximum performance boost! -
- Mark all files served from the CDN to expire in the - far future (decades from now). This is the same as - telling browsers to always use the cached - files. This can significantly speed up page loads. - Files are also automatically compressed (when the - browser supports it), to speed up page loads even - further. -
- Of course, you still want visitors to immediately get - new versions of files when they change. That is why - unique filenames are generated automatically. -
- For the experts: the following HTTP - headers are set: Expires, - Cache-Control, - Last-Modified, Vary, for - files with one of the following extensions: !extensions - and of these extensions, some will also be - automatically compressed: !extensions-compressed.', $farfuture_variables - ), + '#description' => t('Mark all files served from the CDN to expire in the far future — improves client-side cacheability.') . ' ' . theme('advanced_help_topic', 'cdn', 'admin-details-mode-pull-far-future'), '#default_value' => variable_get(CDN_BASIC_FARFUTURE_VARIABLE, CDN_BASIC_FARFUTURE_DEFAULT), '#process' => array('ctools_dependent_process'), '#dependency' => array('radio:' . CDN_MODE_VARIABLE => array(CDN_MODE_BASIC)), @@ -229,59 +151,12 @@ function cdn_admin_details_form(&$form_state) { . ' (' . $ufi['machine_name'] . '): ' . $ufi['description']; } - $format_variables['!format-available-unique-identifier-methods'] = theme('item_list', $methods); - // '@format-available-unique-identifier-methods' - - - $format_explanation_list_items = array( - t("@format-directory is the directory (may include - wildcards) to which a unique identifier method will be applied. Multiple - directories may be listed, separated with semi-colons - (:). E.g.: - 'sites/*/modules/*:sites/*/themes/*'.", $format_variables), - t("@format-extensions is an optional - setting to limit which file types should use this unique identifier - method. E.g.: - '.css .jpg .jpeg .png'.", $format_variables), - t("@format-unique-identifier-method sets the unique - identifier method that should be applied to the aforementioned - directories, and only to (optionally) the listed file types. Available - methods are: !format-available-unique-identifier-methods.", - $format_variables), - ); - $example_list_items = array( - t("This would generate a unique identifier for Drupal core files based on - the Drupal core version, files in the site directory would get unique - identifiers based on the last time they were modified and movie files - would not receive a unique identifier (they're so large browser can't - cache them anyway): -
misc/*:modules/*:themes/*|drupal_version\nsites/*|mtime\nsites/*|.avi .m4v .mov .mp4 .wmv .flv|perpetual
"), - t("In this second example, we're dealing with a more high-traffic website, - where it is too costly to access the filesystem for every served file. - Therefor, this site defines a CDN_DEPLOYMENT_ID constant - somewhere in its codebase. This constant changes whenever a module or - theme changes. This is therefor far more efficient. See the last line: -
misc/*:modules/*:themes/*|drupal_version\nsites/*|mtime\nsites/*|.avi .m4v .mov .mp4 .wmv .flv|perpetual\nsites/*/modules/*:sites/*/themes/*|deployment_id
"), - ); + $format_variables['!ufi-methods'] = theme('item_list', $methods); + $form['settings'][CDN_BASIC_FARFUTURE_UNIQUE_IDENTIFIER_MAPPING_VARIABLE] = array( '#type' => 'textarea', '#title' => t('Unique file identifier generation'), - '#description' => t("Define how unique file identifiers are generated.
-
- Enter one rule per line, in the format @format-directory[|@format-extensions]|@format-unique-identifier-method:
- !format-explanation-list -

- Note that if no unique file identifier generation - method is specified for a file because none of the - above rules apply to it, the CDN module will fall - back to the !default-ufi-method method. -

- Sample mappings: - !example-list", $format_variables + array( - '!format-explanation-list' => theme('item_list', $format_explanation_list_items), - '!example-list' => theme('item_list', $example_list_items), - '!default-ufi-method' => '' . CDN_BASIC_FARFUTURE_UNIQUE_IDENTIFIER_DEFAULT . '', - )), + '#description' => theme('advanced_help_topic', 'cdn', 'admin-details-mode-pull-ufi') . ' ' . t('Define how unique file identifiers (UFIs) are generated.'), '#size' => 35, '#default_value' => variable_get(CDN_BASIC_FARFUTURE_UNIQUE_IDENTIFIER_MAPPING_VARIABLE, CDN_BASIC_FARFUTURE_UNIQUE_IDENTIFIER_MAPPING_DEFAULT), '#process' => array('ctools_dependent_process'), @@ -290,15 +165,38 @@ function cdn_admin_details_form(&$form_state) { '#dependency_count' => 2, ); + $form['settings']['ufis'] = array( + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#title' => t('Available UFI methods'), + '#input' => true, + '#id' => 'ufi-fs-id', + '#prefix' => '
', + '#suffix' => '
', + '#process'=> array('ctools_dependent_process'), + '#dependency_count' => 2, + '#dependency' => array('radio:' . CDN_MODE_VARIABLE => array(CDN_MODE_BASIC), + 'edit-cdn-farfuture-status' => array('1')) + ); + + $form['settings']['ufis']['content'] = array( + '#value' => t('Available UFI methods: !ufi-methods', $format_variables) . + '

' . t('Note that if no UFI method is specified for a file + (because no rule matches), the CDN module will fall + back to the mtime method.') . '

', + '#prefix' => '
', + '#suffix' => '
', + ); // - // Advanced mode settings. + // File Conveyor mode settings. // $form['settings'][CDN_ADVANCED_PID_FILE_VARIABLE] = array( '#type' => 'textfield', '#title' => t('PID file'), - '#description' => t('Full path to File Conveyor\'s PID file.'), + '#description' => t('Full path to File Conveyor\'s PID file.') . ' ' . theme('advanced_help_topic', 'cdn', 'admin-details-mode-fc-pid'), '#size' => 60, '#default_value' => variable_get(CDN_ADVANCED_PID_FILE_VARIABLE, ''), '#process' => array('ctools_dependent_process'), @@ -307,7 +205,7 @@ function cdn_admin_details_form(&$form_state) { $form['settings'][CDN_ADVANCED_SYNCED_FILES_DB_VARIABLE] = array( '#type' => 'textfield', '#title' => t('Synced files database'), - '#description' => t('Full path to File Conveyor\'s synced files database file.'), + '#description' => t('Full path to File Conveyor\'s synced files database file.') . ' ' . theme('advanced_help_topic', 'cdn', 'admin-details-mode-fc-db'), '#size' => 60, '#default_value' => variable_get(CDN_ADVANCED_SYNCED_FILES_DB_VARIABLE, ''), '#process' => array('ctools_dependent_process'), @@ -321,12 +219,8 @@ function cdn_admin_details_form(&$form_state) { * Form definition; other settings. */ function cdn_admin_other_settings_form(&$form_state) { - // Prevent requirement errors from showing up twice. - if (empty($form_state['post'])) { - _cdn_admin_check_requirements(); - } - - $form['#submit'] = array('cdn_admin_settings_submit_show_cache_warning'); + $form = array(); + _cdn_settings_form_prepare($form, $form_state); if (variable_get(CDN_MODE_VARIABLE, CDN_MODE_BASIC) == CDN_MODE_ADVANCED) { $form[CDN_DRUPAL_ROOT_VARIABLE] = array( @@ -348,20 +242,12 @@ function cdn_admin_other_settings_form(&$form_state) { $form['https'] = array( '#type' => 'fieldset', '#title' => t('HTTPS'), - '#description' => t('When a page is being served via HTTPS and the CDN - does not support HTTPS, then the file will not be - served from the CDN, because it would make the visit - insecure.
- If your CDN does support HTTPS, and if you - are not masking the original URL\'s domain - with another (sub)domain (using a CNAME record), - enable the corresponding setting below, and your CDN - will also be used on HTTPS pages.'), ); $form['https'][CDN_HTTPS_SUPPORT_VARIABLE] = array( '#type' => 'checkbox', '#title' => t('CDN supports HTTPS'), '#default_value' => variable_get(CDN_HTTPS_SUPPORT_VARIABLE, FALSE), + '#description' => t('Enable if you use HTTPS and your CDN supports it too.') . ' ' . theme('advanced_help_topic', 'cdn', 'admin-other-https'), ); $path_explanation = t( @@ -374,7 +260,9 @@ function cdn_admin_other_settings_form(&$form_state) { $form['exceptions'] = array( '#type' => 'fieldset', '#title' => t('Exceptions'), - '#description' => t('Which files should be served from a CDN is not as + '#description' => theme('advanced_help_topic', 'cdn', 'admin-other-exceptions') + . ' ' . + t('Which files should be served from a CDN is not as simple as it seems: there are bound to be exceptions. You can easily define those exceptions here, either by file URL, Drupal path or by Drupal path for @@ -386,25 +274,9 @@ function cdn_admin_other_settings_form(&$form_state) { '#title' => t('File URL'), '#description' => t("Files that are marked to not be served from the CDN because of a match in the blacklist, can be overridden to be served from - the CDN after all, if they have a match in the whitelist.
-
- All JavaScript files are excluded by default. This is necessary - to ensure a painless out-of-the-box experience. For maximum - performance, you should only exclude problematic JavaScript files. -
- Full explanation: it's necessary prevent any - possible cross-domain AJAX requests, which would violate the same origin - policy of browsers. Such violations potentially result in broken - functionality. Note that even requests to subdomains such as - cdn.yourdomain.com count as cross-domain requests!
- You can opt-in to including JavaScript files by default and then exclude - problematic ones, but then you should carefully note which JavaScript - files perform AJAX requests. You can prevent all potential problems by - using JSONP, - which is a work-around to allow for cross-domain AJAX - requests."), + the CDN after all, if they have a match in the whitelist."), '#collapsible' => TRUE, + '#collapsed' => TRUE, ); $form['exceptions']['file_path'][CDN_EXCEPTION_FILE_PATH_BLACKLIST_VARIABLE] = array( '#type' => 'textarea', @@ -505,19 +377,7 @@ function cdn_admin_other_settings_form(&$form_state) { $form['cdn_pick_server'][CDN_PICK_SERVER_PHP_CODE_VARIABLE] = array( '#type' => 'textarea', '#title' => t('PHP code for cdn_pick_server()'), - '#description' => t('The parameter $servers_for_file is - available to you (which is an array of servers), - you should return one of them (or return an empty - array if you do not want any of them to be used). -
- Internally, $servers_for_file looks - like this: -
$servers_for_file[0] = array(\'url\' => \'http://cdn1.com/image.jpg\', \'server\' => \'cdn1.com\');
-$servers_for_file[1] = array(\'url\' => \'http://cdn2.net/image.jpg\', \'server\' => \'cdn2.net\');
- Eventually, you should always end your code with - something like -
return $servers_for_file[$some_index];
- '), + '#description' => t('PHP code to select the most appropriate CDN server.') . ' ' . theme('advanced_help_topic', 'cdn', 'admin-other-https'), '#cols' => 60, '#rows' => ($php_code != '') ? count(explode("\n", $php_code)) + 1 : 5, '#default_value' => $php_code, @@ -653,3 +513,33 @@ function _cdn_admin_check_requirements() { return count($errors); } + +function _cdn_settings_form_prepare(&$form, $form_state) { + // Check requirements. + cdn_load_include('requirements'); + // Prevent requirement errors from showing up twice. + if (empty($form_state['post'])) { + _cdn_admin_check_requirements(); + } + + // Advanced help. + _cdn_check_advanced_help(); + $form['#attributes']['class'] = 'cdn-settings'; + drupal_add_css(drupal_get_path('module', 'cdn') . '/cdn.admin.css'); + + // Form. + ctools_include('dependent'); + $form['#submit'] = array('cdn_admin_settings_submit_show_cache_warning'); +} + +function _cdn_check_advanced_help() { + if (!module_exists('advanced_help')) { + $filename = db_result(db_query("SELECT filename FROM {system} WHERE type = 'module' AND name = 'advanced_help'")); + if ($filename && file_exists($filename)) { + drupal_set_message(t('If you enable the advanced help module, CDN will provide more and better help.', array('@modules' => url('admin/build/modules')))); + } + else { + drupal_set_message(t('If you install the advanced help module from !href, CDN will provide more and better help.', array('!href' => l('http://drupal.org/project/advanced_help', 'http://drupal.org/project/advanced_help')))); + } + } +} diff --git a/help/admin-details-mode-fc-db.html b/help/admin-details-mode-fc-db.html new file mode 100644 index 0000000..d55a612 --- /dev/null +++ b/help/admin-details-mode-fc-db.html @@ -0,0 +1,3 @@ +

After a file has been synced, File Conveyor stores the "absolute file path" to "URL of the file on the CDN" mapping in a SQLite database. The CDN module then uses this database to replace file URLs with their corresponding CDN URLs.

+ +

This file usually lives in the same directory as File Conveyor itself. By default, it's called synced_files.db.

diff --git a/help/admin-details-mode-fc-pid.html b/help/admin-details-mode-fc-pid.html new file mode 100644 index 0000000..40287bd --- /dev/null +++ b/help/admin-details-mode-fc-pid.html @@ -0,0 +1,3 @@ +

The CDN module uses File Conveyor's "PID file" (Process ID file) to know whether File Conveyor is up & running or not.

+ +

This file usually lives at ~/.fileconveyor.pid. Thus it is dependent on which user of the system executes File Conveyor.

diff --git a/help/admin-details-mode-fc.html b/help/admin-details-mode-fc.html new file mode 100644 index 0000000..06fcfd8 --- /dev/null +++ b/help/admin-details-mode-fc.html @@ -0,0 +1,3 @@ +

File Conveyor mode uses the File Conveyor daemon to synchronize files and can be used with both Origin Pull and Push CDNs. If you're using an Origin Pull CDN and want to optimize files before they're synced to the CDN, it is also recommended to use this mode.

+ +

Note that this requires a fair amount of server administration knowledge. It is powerful, but that power comes with the price of a more complex configuration.

\ No newline at end of file diff --git a/help/admin-details-mode-pull-cdn-mapping.html b/help/admin-details-mode-pull-cdn-mapping.html new file mode 100644 index 0000000..51735ad --- /dev/null +++ b/help/admin-details-mode-pull-cdn-mapping.html @@ -0,0 +1,16 @@ +

Format

+

Enter one mapping per line, in the format <URL>[|<extensions>]:

+ + + +

Sample mappings

+ \ No newline at end of file diff --git a/help/admin-details-mode-pull-far-future.html b/help/admin-details-mode-pull-far-future.html new file mode 100644 index 0000000..c0d58db --- /dev/null +++ b/help/admin-details-mode-pull-far-future.html @@ -0,0 +1,4 @@ +

Recommended for maximum performance boost!

+

Mark all files served from the CDN to expire in the far future (decades from now). This is the same as telling browsers to always use the cached files. This can significantly speed up page loads. Files are also automatically compressed (when the browser supports it), to speed up page loads even further.

+

Of course, you still want visitors to immediately get new versions of files when they change. That is why unique filenames are generated automatically.

+

For the experts: the following HTTP headers are set: Expires, Cache-Control, Last-Modified, Vary, for files with one of the following extensions: !extensions and of these extensions, some will also be automatically compressed: !extensions-compressed.

\ No newline at end of file diff --git a/help/admin-details-mode-pull-ufi.html b/help/admin-details-mode-pull-ufi.html new file mode 100644 index 0000000..27a0c6d --- /dev/null +++ b/help/admin-details-mode-pull-ufi.html @@ -0,0 +1,28 @@ +

What is this?

+ +

To be able to use Far Future expiration, we need to make sure that the URL of a file changes whenever the file changes. Otherwise, visitors will continue to use the old version of the file, that they've cached.
+Depending on the type of file, it is usually better to use a different unique file identifier (UFI) method. Overall, you will want to minimize the number of times that the file system needs to be accessed.

+ +

That's why the perpetual, drupal_version and deployment_id methods are the most efficient: they don't touch the file system at all. However, perpetual will never detect file changes, so only use that if you're absolutely certain a file will never change (e.g. for video files). drupal_version should only be used for Drupal core files. And deployment_id should probably only be used for files that are managed through version control.

+ +

Format

+

Enter one rule per line, in the format <directory>[|<extensions>]|<unique file identifier (UFI) method>:

+ + +

Note: To see which UFI methods are available, please consult the UI — this help system only allows for static content.

+ + +

Examples

+

This would generate a unique identifier for Drupal core files based on the Drupal core version, files in the site directory would get unique identifiers based on the last time they were modified and movie files would not receive a unique identifier (they're so large browser can't cache them anyway):

+
misc/*:modules/*:themes/*|drupal_version
+sites/*|mtime
+sites/*|.avi .m4v .mov .mp4 .wmv .flv|perpetual
+

In this second example, we're dealing with a more high-traffic website, where it is too costly to access the filesystem for every served file. Therefor, this site defines a CDN_DEPLOYMENT_ID constant somewhere in its codebase. This constant changes whenever a module or theme changes. This is therefor far more efficient. See the last line:

+
misc/*:modules/*:themes/*|drupal_version
+sites/*|mtime
+sites/*|.avi .m4v .mov .mp4 .wmv .flv|perpetual
+sites/*/modules/*:sites/*/themes/*|deployment_id
\ No newline at end of file diff --git a/help/admin-details-mode-pull.html b/help/admin-details-mode-pull.html new file mode 100644 index 0000000..2d7d4fd --- /dev/null +++ b/help/admin-details-mode-pull.html @@ -0,0 +1 @@ +

Origin Pull mode replaces your domain name with the Origin Pull CDN's domain name in the file URL.

\ No newline at end of file diff --git a/help/admin-details-mode.html b/help/admin-details-mode.html new file mode 100644 index 0000000..6e0a517 --- /dev/null +++ b/help/admin-details-mode.html @@ -0,0 +1,6 @@ +

It is essential that you understand the key properties of a CDN, most importantly the differences between an Origin Pull CDN and a Push CDN. If you understand that, continue to make a choice between the two supported modes:

+ + diff --git a/help/admin-details.html b/help/admin-details.html new file mode 100644 index 0000000..d2cceaf --- /dev/null +++ b/help/admin-details.html @@ -0,0 +1,2 @@ +

Here, you can configure the details of your CDN set-up. Click through +to other help topics to learn more about the implications of every setting.

\ No newline at end of file diff --git a/help/admin-other-cdn-pick-server.html b/help/admin-other-cdn-pick-server.html new file mode 100644 index 0000000..cd1758c --- /dev/null +++ b/help/admin-other-cdn-pick-server.html @@ -0,0 +1,26 @@ +

How to use

+

The parameter $servers_for_file is available to you (which is an array of servers), you should return one of them (or return an empty array if you do not want any of them to be used).

+

Internally, $servers_for_file looks like this:

+
$servers_for_file[0] = array('url' => 'http://cdn1.com/image.jpg', 'server' => 'cdn1.com');
+$servers_for_file[1] = array('url' => 'http://cdn2.net/image.jpg', 'server' => 'cdn2.net');
+

Eventually, you should always end your code with something like:

+
return $servers_for_file[$some_index];
+ +

Note: it's also possible to define a cdn_pick_server() function in a module. Because, yes, if you use the UI to implement this, PHP's eval() will be used.

+ + +

Example

+ +
    +
  1. Default behavior (pick the first server found — note that multiple servers can only be found if you're using File Conveyor), one would write: +

    return $servers_for_file[0];
    +

  2. +
  3. If you want to balance the number of files served by each CDN (i.e. on +average, each CDN serves the same amount of files on a page) instead of +picking the CDN based purely on filetype, one could write: +
    +$filename = basename($servers_for_file[0]['url']);
    +$unique_file_id = hexdec(substr(md5($filename), 0, 5));
    +return $servers_for_file[$unique_file_id % count($servers_for_file)];
    +
    +
diff --git a/help/admin-other-exceptions.html b/help/admin-other-exceptions.html new file mode 100644 index 0000000..6060682 --- /dev/null +++ b/help/admin-other-exceptions.html @@ -0,0 +1,33 @@ +

By default, some (mostly JavaScript) files are excluded. This is necessary to ensure a painless out-of-the-box experience. For maximum performance, you should only exclude problematic JavaScript files.
+Finally, when any of the pages of the Drupal back-end (admin section) are used, CDN integration is disabled by default.

+ +Detailed explanation +

It's necessary prevent any possible cross-domain AJAX requests, which would violate the same origin policy of browsers. Such violations potentially result in broken functionality. Note that even requests to subdomains such as cdn.yourdomain.com count as cross-domain requests!

+

You can opt-in to including JavaScript files by default and then exclude problematic ones, but then you should carefully note which JavaScript files perform AJAX requests. You can prevent all potential problems by using JSONP, which is a work-around to allow for cross-domain AJAX requests.

+ + +

File URL

+ +

Blacklist

+

A user-configurable blacklist.

+ +

Blacklist from modules

+

The CDN module blacklists the following files by default: +

+

+

Note: If you develop a module that ships with JavaScript files that should not be served from a CDN, you can implement the hook_cdn_blacklist() hook to automatically blacklist those files.

+ + +

Whitelist

+

Drupal core JavaScript files are whitelisted.

+ + +

Drupal path

+

A user-configurable blacklist of Drupal paths on which no files should be served from a CDN. This blacklist applies to all users

+ +

Drupal path for authenticated users

+

Similar to "Drupal path", but only applied to authenticated users.

+

By default, all Drupal back-end (admin*) pages are blacklisted and will thus not use any files from a CDN.

diff --git a/help/admin-other-https.html b/help/admin-other-https.html new file mode 100644 index 0000000..25cae4f --- /dev/null +++ b/help/admin-other-https.html @@ -0,0 +1,2 @@ +

When a page is being served via HTTPS and the CDN does not support HTTPS, then the file will not be served from the CDN, because it would make the visit insecure.

+

If your CDN does support HTTPS, and if you are not masking the original URL's domain with another (sub)domain (using a CNAME record), enable the corresponding setting below, and your CDN will also be used on HTTPS pages.

\ No newline at end of file diff --git a/help/admin-other.html b/help/admin-other.html new file mode 100644 index 0000000..637c6bc --- /dev/null +++ b/help/admin-other.html @@ -0,0 +1 @@ +

Here are the settings you usually don't need to touch. Make sure you know what you're doing!

\ No newline at end of file diff --git a/help/cdn.help.ini b/help/cdn.help.ini new file mode 100644 index 0000000..74c39b8 --- /dev/null +++ b/help/cdn.help.ini @@ -0,0 +1,72 @@ +[admin-details] +title = "Admin: Details" +weight = 1 + +[admin-details-mode] +title = "Mode" +parent = admin-details +weight = 1 + + + + +[admin-details-mode-pull] +title = "Origin Pull" +parent = admin-details-mode +weight = 1 + +[admin-details-mode-pull-cdn-mapping] +title = "CDN mapping" +parent = admin-details-mode-pull +weight = 1 + +[admin-details-mode-pull-far-future] +title = "Far Future expiration" +parent = admin-details-mode-pull +weight = 2 + +[admin-details-mode-pull-ufi] +title = "Unique file identifier generation" +parent = admin-details-mode-pull +weight = 3 + + + + +[admin-details-mode-fc] +title = "File Conveyor" +parent = admin-details-mode +weight = 2 + +[admin-details-mode-fc-pid] +title = "PID file" +parent = admin-details-mode-fc +weight = 1 + +[admin-details-mode-fc-db] +title = "Synced files database" +parent = admin-details-mode-fc +weight = 2 + + + + + +[admin-other] +title = "Admin: Other" +weight = 2 + +[admin-other-https] +title = "HTTPS" +parent = admin-other +weight = 1 + +[admin-other-exceptions] +title = "Exceptions" +parent = admin-other +weight = 2 + +[admin-other-cdn-pick-server] +title = "cdn_pick_server()" +parent = admin-other +weight = 3