From e3776c06c37cc197709dac60892604dfea894ac2 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Mon, 29 Nov 2010 01:34:36 +0100 Subject: Remove enc=utf-8 in VIM modeline as it is not allowed in VIM 7.3 As of VIM 7.3 it is no longer possible to specify the encoding in the modeline. This gives an error message whenever such a file is opened, thus this commit removes the enc setting from the modeline. --- lib/exe/css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index 76f40c7bb..e64ebc22a 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -330,4 +330,4 @@ function css_comment_cb($matches){ return $matches[0]; } -//Setup VIM: ex: et ts=4 enc=utf-8 : +//Setup VIM: ex: et ts=4 : -- cgit v1.2.3 From f7d780b9b82a664525120a90a8b1cb25be57d0e0 Mon Sep 17 00:00:00 2001 From: Gabriel Birke Date: Sun, 9 Jan 2011 13:18:19 +0100 Subject: Preserve @import statements in CSS --- lib/exe/css.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index e64ebc22a..eb2d96513 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -122,6 +122,9 @@ function css_out(){ // apply style replacements $css = css_applystyle($css,$tplinc); + + // place all @import statements at the top of the file + $css = css_moveimports($css); // compress whitespace and comments if($conf['compress']){ @@ -265,6 +268,7 @@ function css_loadfile($file,$location=''){ if(!$location) return $css; $css = preg_replace('#(url\([ \'"]*)((?!/|http://|https://| |\'|"))#','\\1'.$location.'\\3',$css); + $css = preg_replace('#(@import\s+[\'"])((?!/|http://|https://))#', '\\1'.$location.'\\2"', $css); return $css; } @@ -296,6 +300,29 @@ function css_pluginstyles($mode='screen'){ return $list; } +/** + * Move all @import statements in a combined stylesheet to the top so they + * aren't ignored by the browser. + * + * @author Gabriel Birke + */ +function css_moveimports($css) +{ + if(!preg_match_all('/@import\s+(?:url\([^)]+\)|"[^"]+")\s*[^;]*;\s*/', $css, $matches, PREG_OFFSET_CAPTURE)) { + return $css; + } + $newCss = ""; + $imports = ""; + $offset = 0; + foreach($matches[0] as $match) { + $newCss .= substr($css, $offset, $match[1] - $offset); + $imports .= $match[0]; + $offset = $match[1] + strlen($match[0]); + } + $newCss .= substr($css, $offset); + return $imports.$newCss; +} + /** * Very simple CSS optimizer * -- cgit v1.2.3 From 6e0b4b67444b8434ed2c351ea0e36008667251d5 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 9 Jan 2011 14:52:50 +0100 Subject: Fixed css_loadfile and removed unneeded complexity, added testcases --- lib/exe/css.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index eb2d96513..4db81de0b 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -267,8 +267,8 @@ function css_loadfile($file,$location=''){ $css = io_readFile($file); if(!$location) return $css; - $css = preg_replace('#(url\([ \'"]*)((?!/|http://|https://| |\'|"))#','\\1'.$location.'\\3',$css); - $css = preg_replace('#(@import\s+[\'"])((?!/|http://|https://))#', '\\1'.$location.'\\2"', $css); + $css = preg_replace('#(url\([ \'"]*)(?!/|http://|https://| |\'|")#','\\1'.$location,$css); + $css = preg_replace('#(@import\s+[\'"])(?!/|http://|https://)#', '\\1'.$location, $css); return $css; } -- cgit v1.2.3 From 318cd03ee91d3a5344bab636a77c3cb19c32c5b7 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sat, 26 Feb 2011 21:22:14 +0000 Subject: improved css.php and core styles * code cleanup in lib/exe/css.php * renamed 'default' userstyle to 'screen' in config_cascade * splitted core lib/styles/style.css up into all.css, print.css and screen.css --- lib/exe/css.php | 61 +++++++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 32 deletions(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index 4db81de0b..98a34860e 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -30,10 +30,10 @@ function css_out(){ global $lang; global $config_cascade; - $style = ''; + $mediatype = 'screen'; if (isset($_REQUEST['s']) && in_array($_REQUEST['s'], array('all', 'print', 'feed'))) { - $style = $_REQUEST['s']; + $mediatype = $_REQUEST['s']; } $tpl = trim(preg_replace('/[^\w-]+/','',$_REQUEST['t'])); @@ -46,7 +46,7 @@ function css_out(){ } // The generated script depends on some dynamic options - $cache = getCacheName('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tplinc.$style,'.css'); + $cache = getCacheName('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tplinc.$mediatype,'.css'); // load template styles $tplstyles = array(); @@ -60,27 +60,29 @@ function css_out(){ // Array of needed files and their web locations, the latter ones // are needed to fix relative paths in the stylesheets $files = array(); - //if (isset($tplstyles['all'])) $files = array_merge($files, $tplstyles['all']); - if(!empty($style)){ - $files[DOKU_INC.'lib/styles/'.$style.'.css'] = DOKU_BASE.'lib/styles/'; - // load plugin, template, user styles - $files = array_merge($files, css_pluginstyles($style)); - if (isset($tplstyles[$style])) $files = array_merge($files, $tplstyles[$style]); - - if(isset($config_cascade['userstyle'][$style])){ - $files[$config_cascade['userstyle'][$style]] = DOKU_BASE; - } - }else{ - $files[DOKU_INC.'lib/styles/style.css'] = DOKU_BASE.'lib/styles/'; - // load plugin, template, user styles - $files = array_merge($files, css_pluginstyles('screen')); - if (isset($tplstyles['screen'])) $files = array_merge($files, $tplstyles['screen']); + // load core styles + $files[DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/'; + // load plugin styles + $files = array_merge($files, css_pluginstyles($mediatype)); + // load template styles + if (isset($tplstyles[$mediatype])) { + $files = array_merge($files, $tplstyles[$mediatype]); + } + // if old 'default' userstyle setting exists, make it 'screen' userstyle for backwards compatibility + if (isset($config_cascade['userstyle']['default'])) { + $config_cascade['userstyle']['screen'] = $config_cascade['userstyle']['default']; + } + // load user styles + if(isset($config_cascade['userstyle'][$mediatype])){ + $files[$config_cascade['userstyle'][$mediatype]] = DOKU_BASE; + } + // load rtl styles + // @todo: this currently adds the rtl styles only to the 'screen' media type + // but 'print' and 'all' should also be supported + if ($mediatype=='screen') { if($lang['direction'] == 'rtl'){ if (isset($tplstyles['rtl'])) $files = array_merge($files, $tplstyles['rtl']); } - if(isset($config_cascade['userstyle']['default'])){ - $files[$config_cascade['userstyle']['default']] = DOKU_BASE; - } } // check cache age & handle conditional request @@ -122,7 +124,7 @@ function css_out(){ // apply style replacements $css = css_applystyle($css,$tplinc); - + // place all @import statements at the top of the file $css = css_moveimports($css); @@ -278,20 +280,15 @@ function css_loadfile($file,$location=''){ * * @author Andreas Gohr */ -function css_pluginstyles($mode='screen'){ +function css_pluginstyles($mediatype='screen'){ global $lang; $list = array(); $plugins = plugin_list(); foreach ($plugins as $p){ - if($mode == 'all'){ - $list[DOKU_PLUGIN."$p/all.css"] = DOKU_BASE."lib/plugins/$p/"; - }elseif($mode == 'print'){ - $list[DOKU_PLUGIN."$p/print.css"] = DOKU_BASE."lib/plugins/$p/"; - }elseif($mode == 'feed'){ - $list[DOKU_PLUGIN."$p/feed.css"] = DOKU_BASE."lib/plugins/$p/"; - }else{ + $list[DOKU_PLUGIN."$p/$mediatype.css"] = DOKU_BASE."lib/plugins/$p/"; + // alternative for screen.css + if ($mediatype=='screen') { $list[DOKU_PLUGIN."$p/style.css"] = DOKU_BASE."lib/plugins/$p/"; - $list[DOKU_PLUGIN."$p/screen.css"] = DOKU_BASE."lib/plugins/$p/"; } if($lang['direction'] == 'rtl'){ $list[DOKU_PLUGIN."$p/rtl.css"] = DOKU_BASE."lib/plugins/$p/"; @@ -302,7 +299,7 @@ function css_pluginstyles($mode='screen'){ /** * Move all @import statements in a combined stylesheet to the top so they - * aren't ignored by the browser. + * aren't ignored by the browser. * * @author Gabriel Birke */ -- cgit v1.2.3 From 7b4ea0818922673113eb39a2062d802b38492186 Mon Sep 17 00:00:00 2001 From: marklundeberg Date: Tue, 8 Mar 2011 21:44:55 -0800 Subject: Make interwiki links match with every other icon-link: need 1px top and bottom padding or else the icons' top and bottom pixel rows get cut off. --- lib/exe/css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index 98a34860e..03f900034 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -204,7 +204,7 @@ function css_interwiki(){ // default style echo 'a.interwiki {'; echo ' background: transparent url('.DOKU_BASE.'lib/images/interwiki.png) 0px 1px no-repeat;'; - echo ' padding-left: 16px;'; + echo ' padding: 1px 0px 1px 16px;'; echo '}'; // additional styles when icon available -- cgit v1.2.3