summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-12-10 09:54:35 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-12-10 09:54:35 +0000
commitb86f45b1e688d2b7c6d092b007ece39995f82c3e (patch)
tree532eb64b175bd21d2b7fdb9e38e9775df72d3169 /modules
parent57eecc45f6dee8d0df453937cdbd5765e4174d44 (diff)
downloadbrdo-b86f45b1e688d2b7c6d092b007ece39995f82c3e.tar.gz
brdo-b86f45b1e688d2b7c6d092b007ece39995f82c3e.tar.bz2
#100516: CSS preprocessor to cache and compress all .css files. Benchmarks show up to 40% faster page loads.
Diffstat (limited to 'modules')
-rw-r--r--modules/block/block.module2
-rw-r--r--modules/color/color.module6
-rw-r--r--modules/help/help.module2
-rw-r--r--modules/profile/profile.module2
-rw-r--r--modules/search/search.module2
-rw-r--r--modules/system/system.module55
-rw-r--r--modules/tracker/tracker.module2
-rw-r--r--modules/user/user.module2
-rw-r--r--modules/watchdog/watchdog.module2
9 files changed, 52 insertions, 23 deletions
diff --git a/modules/block/block.module b/modules/block/block.module
index 7b5c52bcd..a44223e95 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -205,7 +205,7 @@ function block_admin_display($theme = NULL) {
global $theme_key, $custom_theme;
// Add CSS
- drupal_add_css(drupal_get_path('module', 'block') .'/block.css');
+ drupal_add_css(drupal_get_path('module', 'block') .'/block.css', 'module', 'all', FALSE);
// If non-default theme configuration has been selected, set the custom theme.
if ($theme) {
diff --git a/modules/color/color.module b/modules/color/color.module
index b6c43ef67..da275bcf8 100644
--- a/modules/color/color.module
+++ b/modules/color/color.module
@@ -41,7 +41,7 @@ function _color_page_alter(&$vars) {
// Override stylesheet
$path = variable_get('color_'. $theme_key .'_stylesheet', NULL);
if ($path) {
- $vars['css']['theme'] = array($path => array('path' => $path, 'media' => 'all'));
+ $vars['css']['all']['theme'][$path] = TRUE;
$vars['styles'] = drupal_get_css($vars['css']);
}
@@ -88,11 +88,11 @@ function color_scheme_form($theme) {
$info = color_get_info($theme);
// Add Farbtastic color picker
- drupal_add_css('misc/farbtastic/farbtastic.css');
+ drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
drupal_add_js('misc/farbtastic/farbtastic.js');
// Add custom CSS/JS
- drupal_add_css($base .'/color.css', 'module');
+ drupal_add_css($base .'/color.css', 'module', 'all', FALSE);
drupal_add_js($base .'/color.js');
drupal_add_js(array('color' => array(
'reference' => color_get_palette($theme, true)
diff --git a/modules/help/help.module b/modules/help/help.module
index 61800cd56..f23325497 100644
--- a/modules/help/help.module
+++ b/modules/help/help.module
@@ -37,7 +37,7 @@ function help_menu($may_cache) {
*/
function help_main() {
// Add CSS
- drupal_add_css(drupal_get_path('module', 'help') .'/help.css');
+ drupal_add_css(drupal_get_path('module', 'help') .'/help.css', 'module', 'all', FALSE);
$output = t('
<h2>Help topics</h2>
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 1437dfc89..424c5d926 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -422,7 +422,7 @@ function profile_admin_overview() {
*/
function profile_browse() {
// Add CSS
- drupal_add_css(drupal_get_path('module', 'profile') .'/profile.css');
+ drupal_add_css(drupal_get_path('module', 'profile') .'/profile.css', 'module', 'all', FALSE);
$name = arg(1);
list(,,$value) = explode('/', $_GET['q'], 3);
diff --git a/modules/search/search.module b/modules/search/search.module
index 255fc9839..3285d6298 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -1076,7 +1076,7 @@ function theme_search_block_form($form) {
*/
function search_data($keys = NULL, $type = 'node') {
// Add CSS
- drupal_add_css(drupal_get_path('module', 'search') .'/search.css');
+ drupal_add_css(drupal_get_path('module', 'search') .'/search.css', 'module', 'all', FALSE);
if (isset($keys)) {
if (module_hook($type, 'search')) {
diff --git a/modules/system/system.module b/modules/system/system.module
index e8d9e416f..6615b6c31 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -25,8 +25,6 @@ function system_help($section) {
return '<p>'. t('Welcome to the administration section. Here you may control how your site functions.') .'</p>';
case 'admin/by-module':
return '<p>'. t('This page shows you all available administration tasks for each module.') .'</p>';
- case 'admin/settings/page-caching':
- return '<p>'. t('Enabling the cache will offer a significant performance boost. Drupal can store and send compressed cached pages requested by "anonymous" users. By caching a web page, Drupal does not have to create the page each time someone wants to view it.') .'</p>';
case 'admin/build/themes':
return '<p>'. t('Select which themes are available to your users and specify the default theme. To configure site-wide display settings, click the "configure" task above. Alternately, to override these settings in a specific theme, click the "configure" link for the corresponding theme. Note that different themes may have different regions available for rendering content like blocks. If you want consistency in what your users see, you may wish to enable only one theme.') .'</p>';
case 'admin/build/themes/settings':
@@ -229,11 +227,11 @@ function system_menu($may_cache) {
'callback' => 'drupal_get_form',
'callback arguments' => array('system_error_reporting_settings'));
$items[] = array(
- 'path' => 'admin/settings/page-caching',
- 'title' => t('Page caching'),
- 'description' => t('Enable or disable page caching for anonymous users.'),
+ 'path' => 'admin/settings/performance',
+ 'title' => t('Performance'),
+ 'description' => t('Enable or disable page caching for anonymous users, and enable or disable CSS preprocessor.'),
'callback' => 'drupal_get_form',
- 'callback arguments' => array('system_page_caching_settings'));
+ 'callback arguments' => array('system_performance_settings'));
$items[] = array(
'path' => 'admin/settings/file-system',
'title' => t('File system'),
@@ -310,13 +308,13 @@ function system_menu($may_cache) {
if (arg(0) == 'admin') {
global $custom_theme;
$custom_theme = variable_get('admin_theme', '0');
- drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'core');
+ drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
}
// Add the CSS for this module. We put this in !$may_cache so it is only
// added once per request.
- drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'core');
- drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'core');
+ drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
+ drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
}
return $items;
@@ -643,7 +641,7 @@ function system_error_reporting_settings() {
return system_settings_form($form);
}
-function system_page_caching_settings() {
+function system_performance_settings() {
$description = '<p>'. t("The normal cache mode is suitable for most sites and does not cause any side effects. The aggressive cache mode causes Drupal to skip the loading (init) and unloading (exit) of enabled modules when serving a cached page. This results in an additional performance boost but can cause unwanted side effects.") .'</p>';
@@ -656,8 +654,13 @@ function system_page_caching_settings() {
else {
$description .= '<p>'. t('<strong class="ok">Currently, all enabled modules are compatible with the aggressive caching policy.</strong> Please note, if you use aggressive caching and enable new modules, you will need to check this page again to ensure compatibility.') .'</p>';
}
-
- $form['cache'] = array(
+ $form['page_cache'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Page cache'),
+ '#description' => t('Enabling the cache will offer a significant performance boost. Drupal can store and send compressed cached pages requested by <em>anonymous</em> users. By caching a web page, Drupal does not have to construct the page each time someone wants to view it.'),
+ );
+
+ $form['page_cache']['cache'] = array(
'#type' => 'radios',
'#title' => t('Caching mode'),
'#default_value' => variable_get('cache', CACHE_DISABLED),
@@ -667,13 +670,33 @@ function system_page_caching_settings() {
$period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
$period[0] = t('none');
- $form['cache_lifetime'] = array(
+ $form['page_cache']['cache_lifetime'] = array(
'#type' => 'select',
'#title' => t('Minimum cache lifetime'),
'#default_value' => variable_get('cache_lifetime', 0),
'#options' => $period,
'#description' => t('On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
);
+
+ $form['bandwidth_optimizations'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Bandwidth optimizations'),
+ '#description' => t('These options can help reduce both the size and number of requests made to your website. This can reduce the server load, the bandwidth used, and the average page loading time for your visitors.')
+ );
+
+ $directory = file_directory_path();
+ $is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
+ $form['bandwidth_optimizations']['preprocess_css'] = array(
+ '#type' => 'radios',
+ '#title' => t('Aggregate and compress CSS files'),
+ '#default_value' => variable_get('preprocess_css', FALSE) && $is_writable,
+ '#disabled' => !$is_writable,
+ '#options' => array(t('Disabled'), t('Enabled')),
+ '#description' => t("Some Drupal modules include their own CSS files. When these modules are enabled, each module's CSS file adds an additional HTTP request to the page, which can increase the load time of each page. These HTTP requests can also slightly increase server load. It is recommended to only turn this option on when your site is in production, as it can interfere with theme development. This option is disabled if you have not set up your files directory, or if your download method is set to private."),
+ );
+
+ $form['#submit']['system_settings_form_submit'] = array();
+ $form['#submit']['drupal_clear_css_cache'] = array();
return system_settings_form($form);
}
@@ -1102,6 +1125,7 @@ function system_settings_form_submit($form_id, $form_values) {
else {
drupal_set_message(t('The configuration options have been saved.'));
}
+
menu_rebuild();
}
@@ -1109,6 +1133,8 @@ function system_settings_form_submit($form_id, $form_values) {
* Menu callback; displays a listing of all themes.
*/
function system_themes() {
+
+ drupal_clear_css_cache();
$themes = system_theme_data();
ksort($themes);
@@ -1485,6 +1511,9 @@ function system_modules_submit($form_id, $form_values) {
if ($dependencies && !isset($form_values['confirm'])) {
return FALSE;
}
+
+ drupal_clear_css_cache();
+
return 'admin/build/modules';
}
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
index 8a06631a1..9eab3e5a7 100644
--- a/modules/tracker/tracker.module
+++ b/modules/tracker/tracker.module
@@ -74,7 +74,7 @@ function tracker_track_user() {
*/
function tracker_page($uid = 0) {
// Add CSS
- drupal_add_css(drupal_get_path('module', 'tracker') .'/tracker.css');
+ drupal_add_css(drupal_get_path('module', 'tracker') .'/tracker.css', 'module', 'all', FALSE);
if ($uid) {
$sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_post DESC';
diff --git a/modules/user/user.module b/modules/user/user.module
index 4a8471898..f8689d019 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -781,7 +781,7 @@ function user_menu($may_cache) {
else {
// Add the CSS for this module. We put this in !$may_cache so it is only
// added once per request.
- drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'core');
+ drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
if ($_GET['q'] == 'user' && $user->uid) {
// We want to make the current user's profile accessible without knowing
// their uid, so just linking to /user is enough. To achieve this goal,
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index 0dfd6a2f3..16129e11c 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -53,7 +53,7 @@ function watchdog_menu($may_cache) {
else {
if (arg(0) == 'admin' && arg(1) == 'logs') {
// Add the CSS for this module
- drupal_add_css(drupal_get_path('module', 'watchdog') .'/watchdog.css');
+ drupal_add_css(drupal_get_path('module', 'watchdog') .'/watchdog.css', 'module', 'all', FALSE);
}
}