Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#133 2011-12-17 22:57:06

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: rvm_css (v1.2)

I think it’s best if someone creates a new plugin specifically for people wanting to use less-markup. Adding it to rvm_css would explode it’s size, which doesn’t benefit those who use plain css. I’m not adding it.

Offline

#134 2011-12-18 10:42:58

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: rvm_css (v1.2)

Okay okay, I’ll have a look ;) [removed some garbage posts]

Offline

#135 2011-12-18 16:27:41

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: rvm_css (v1.2)

mrdale wrote:

… but I actually I had something more powerful in mind. Rather than interpreting less-markup every time the page is loaded client side (and negating the benefits of css caching) interpret the less-markup when the static css file is saved. This way the css files continue to be css for the client, the css in the database continues to contain less-markup, and the client experience is exactly the same (speedy too).

I think this is a first rate idea and, if executed in the manner Dale suggests, would be more practical and useful than the WordPress LESS plugin is for WordPress users, for instance.

Currently, to make LESS work for me, I use ExpanDrive to access cnk_versioning generated LESS/CSS (and pages and forms) text files outside Textpattern using Textmate. ExpanDrive lets me ‘watch’ the LESS files on the site’s web server using LESS.js (or SimpLESS or CodeKit) on my Mac and interprets them to write the CSS version back to the server. It works pretty well but requires me to use cnk_versioning and ExpanDrive which I usually would rather not. So Dale’s concept is most attractive to me.

My one concern, I think, is that the PHP version of LESS, lessphp, and presumably the basis for a Textpattern plugin, be maintained as well the official LESS distribution LESS.js (Javascript) promises to be.

Thank you Ruud, for offering to take a look at it all.

Last edited by joebaich (2011-12-18 16:28:59)

Offline

#136 2011-12-19 14:22:34

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: rvm_css (v1.2)

LESS support added in version 0.8. It does require you to install the less.inc.php file manually (unless someone puts it into a separate plugin. rvm_css simply checks if the lessc class exists and uses it if it does), which makes it easier to keep that file up-to-date without me having to keep track of updates (because I don’t use LESS myself).

Offline

#137 2011-12-19 18:30:02

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: rvm_css (v1.2)

Awesome!

The parser is a bit touchy about valid markup, so it’ll vomit on you if you’re code isn’t clean. Also, at this point it doesn’t preserve comments. I’m looking into it.

FYI: The cheap and nasty way to active less is to hack the entire phpless class (minus the php line of course) into rvm css.

Offline

#138 2011-12-19 18:34:25

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: rvm_css (v1.2)

^^ yes, that works, but including PHP code is faster than using ‘eval’ to load a plugin, I think, especially if you’re using some kind of op-code cache.

Offline

#139 2011-12-19 18:45:51

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: rvm_css (v1.2)

Yes, it’s awesome! I have given it a run around an existing site’s CSS as much as I dare. I noted the non preservation of comments and see that is an intended outcome. I did get an exception when saving/processing one file but it is an IE6 hack comprised only a bunch of MS filters and it was a product of the lessc class. Thanks again Mr Dale and Ruud.

Offline

#140 2011-12-20 05:04:41

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: rvm_css (v1.2)

There is a difficulty with handling less file imports, for instance
import 'reset.less';
import 'grid.less'; in the default style (less) file in the Textpattern interface.

From the lessphp documentation

Multiple LESS files can be compiled into a single CSS file by using the @import statement. Be careful, the LESS import statement shares syntax with the CSS import statement. If the file being imported ends in a .less extension, or no extension, then it is treated as a LESS import. Otherwise it is left alone and outputted directly.

The plugin generates files with a .css extension and so there is no ability to parse and outputting css from the less code in imported files.

Offline

#141 2011-12-20 13:00:43

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: rvm_css (v1.2)

joebaich wrote:

The plugin generates files with a .css extension and so there is no ability to parse and outputting css from the less code in imported files.

Right, because the static files don’t contain any LESS code, just plain CSS.

Offline

#142 2011-12-20 14:50:13

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: rvm_css (v1.2)

ruud wrote:

Right, because the static files don’t contain any LESS code, just plain CSS.

Yes, the static files produced by the plug-in contain only plain CSS, but to use the full power of LESS one needs to have a static files with a LESS extension (or no extension). Importing supporting CSS static files (e.g. grid.css) into a main CSS static file (e.g. default.css) after they have been individually processed by less.php isn’t the same thing at all. One great strength of LESS is that an imported LESS file can contain a generic calculating mechanism which operates on a set of particular variables contained in the main LESS file. So ‘imported grid.less’ can contain a mathematical expression of the CSS grid which when taken in conjunction with the relevant variables in default.less by less.php will produce default.css with a precise statement of the desired columns CSS without carrying the ‘calculator’ or ‘grid tables’ with it. This is well explained on the Sematic.gs web site.

This does make things more complex for the plug-in doesn’t it?

Last edited by joebaich (2011-12-20 14:53:37)

Offline

#143 2011-12-20 15:25:22

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: rvm_css (v1.2)

If the plugin creates not just a static file default.css (plain CSS), but also default.less (original LESS code), would that solve the problem? Note that the goal of this is still to serve pure CSS to the visitor, not LESS code, the .less file would only be used by the lessphp compiler (assuming it can use these files).

Last edited by ruud (2011-12-20 15:40:26)

Offline

#144 2011-12-20 15:53:32

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: rvm_css (v1.2)

I think it probably would. The espoused method using LESS.js and its imitators is to have a LESS files folder and a CSS files folder at the ‘same level’ (e.g. …/styles/less/ and ../styles/css) and it ‘finds’ them. Although that’s a neater arrangement for humans I don’t think having the corresponding LESS and CSS files in the same folder would be a problem for less.php.

Offline

Board footer

Powered by FluxBB