diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-07-29 20:06:01 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-07-29 20:06:01 +0200 |
commit | d4a1ece8f011dd69db05b83d2f98e3207f1a7e48 (patch) | |
tree | 1f5d09b3087acce37afb5e37a49fff9c33863aaf | |
parent | 7d8a6abbb21979fd77dca10275ebb8e01a04b6e4 (diff) | |
download | rpg-d4a1ece8f011dd69db05b83d2f98e3207f1a7e48.tar.gz rpg-d4a1ece8f011dd69db05b83d2f98e3207f1a7e48.tar.bz2 |
add LESS support
still needs testing
-rw-r--r-- | inc/load.php | 1 | ||||
-rw-r--r-- | lib/exe/css.php | 19 |
2 files changed, 19 insertions, 1 deletions
diff --git a/inc/load.php b/inc/load.php index 5ca9b4cd8..258713e88 100644 --- a/inc/load.php +++ b/inc/load.php @@ -82,6 +82,7 @@ function load_autoload($name){ 'RemoteAPI' => DOKU_INC.'inc/remote.php', 'RemoteAPICore' => DOKU_INC.'inc/RemoteAPICore.php', 'Subscription' => DOKU_INC.'inc/subscription.php', + 'lessc' => DOKU_INC.'inc/lessc.inc.php', 'DokuWiki_Action_Plugin' => DOKU_PLUGIN.'action.php', 'DokuWiki_Admin_Plugin' => DOKU_PLUGIN.'admin.php', diff --git a/lib/exe/css.php b/lib/exe/css.php index 1e662c64a..4a9c825c1 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -154,7 +154,11 @@ function css_out(){ // apply style replacements $css = css_applystyle($css,$tplinc); - // place all @import statements at the top of the file + // parse LESS + $less = new lessc(); + $css = $less->compile($css); + + // place all remaining @import statements at the top of the file $css = css_moveimports($css); // compress whitespace and comments @@ -175,6 +179,9 @@ function css_out(){ * Does placeholder replacements in the style according to * the ones defined in a templates style.ini file * + * This also adds the ini defined placeholders as less variables + * (sans the surrounding __ and with a ini_ prefix) + * * @author Andreas Gohr <andi@splitbrain.org> */ function css_applystyle($css,$tplinc){ @@ -182,6 +189,13 @@ function css_applystyle($css,$tplinc){ if($styleini){ $css = strtr($css,$styleini['replacements']); + + $less = ''; + foreach($styleini as $key => $value){ + $key = trim($key, '_'); + $key = '@ini_'.$key; + $less .= "$key: $value\n"; + } } return $css; } @@ -333,14 +347,17 @@ function css_pluginstyles($mediatype='screen'){ $plugins = plugin_list(); foreach ($plugins as $p){ $list[DOKU_PLUGIN."$p/$mediatype.css"] = DOKU_BASE."lib/plugins/$p/"; + $list[DOKU_PLUGIN."$p/$mediatype.less"] = 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/style.less"] = DOKU_BASE."lib/plugins/$p/"; } // @deprecated 2012-04-09: rtl will cease to be a mode of its own, // please use "[dir=rtl]" in any css file in all, screen or print mode instead if($lang['direction'] == 'rtl'){ $list[DOKU_PLUGIN."$p/rtl.css"] = DOKU_BASE."lib/plugins/$p/"; + $list[DOKU_PLUGIN."$p/rtl.less"] = DOKU_BASE."lib/plugins/$p/"; } } return $list; |