Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#121 2011-05-19 20:44:09

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: rvm_css (v1.2)

On a 4.0.8 site I get the following error when attempting to save an existing style sheet:

Warning: fopen(/server/path/www/2-css/default.css) [function.fopen]: failed to open stream: Permission denied in /server/path/www/textpattern/lib/txplib_misc.php(570) : eval()'d code on line 94

Warning: fwrite(): supplied argument is not a valid stream resource in /server/path/www/textpattern/lib/txplib_misc.php(570) : eval()'d code on line 95

Warning: fclose(): supplied argument is not a valid stream resource in /server/path/www/textpattern/lib/txplib_misc.php(570) : eval()'d code on line 96

Warning: chmod() [function.chmod]: Operation not permitted in /server/path/www/textpattern/lib/txplib_misc.php(570) : eval()'d code on line 98

The css directory exists and is registered properly in the advanced prefs. Permissions on the directory are 755 and on the css files 644.

I’ve used the plugin on many sites and never encountered this.

Last edited by masa (2011-05-20 20:54:00)

Offline

#122 2011-05-20 09:30:43

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

Re: rvm_css (v1.2)

Check who owns the 2-css directory and the files contained in it. The only one who can write to that directory and the files in it, is the owner of the directory (if you use 644/755 permissions), so the owner has to be the same user that the PHP scripts are running as. Compare it to the image directory. The same applies there.

Offline

#123 2011-05-20 20:59:08

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: rvm_css (v1.2)

I compared the 2-css and the images directories.

2-css

Directory
owner: my ftp username
permissions: 755 (seems to be the default)

CSS files within dir
owner: my ftp username
permissions: 644
 
 
images

Directory
owner: my ftp username
permissions: 777 (!)

images within dir
owner: 30 (!)
permissions: 644

I vaguely recall, that I had to set perms for images to 777 in order to get image upload to work at all, but an owner of 30 seems a bit odd, no?

PS: setting the 2-css directory to 777 doesn’t help either.

Last edited by masa (2011-05-20 21:04:38)

Offline

#124 2011-05-20 21:44:28

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

Re: rvm_css (v1.2)

“30” is the UID (user id) of the PHP process that created the file. If there’s no username linked to that UID, it just shows the UID.
You can fix this by changing ownership of the directory and files to “30”, but I’m not sure if you’re allowed to do that (doesn’t hurt to try though).
Alternatively, keep the directory at 777, remove the default.css file and then save the CSS again from within TXP so it gets created owned by “30”.

But, unless this is a VPS with only you on it, switch to different hosting or at least ask the hosting provider to change the setup so you don’t have to use 777 permissions.

Offline

#125 2011-05-30 16:48:39

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: rvm_css (v1.2)

ruud wrote:

Alternatively, keep the directory at 777, remove the default.css file and then save the CSS again from within TXP so it gets created owned by “30”.

Thanks Ruud, that did the trick, and permissions on the directory are now 755.

Offline

#126 2011-11-19 18:05:43

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

Re: rvm_css (v1.2)

Version 0.7 released. See first post. Must’ve missed the bug report that Bloke posted almost a year ago, but thankfully wet gently nudged me in the right direction with a nice patch (which of course I failed to notice, but managed to duplicate nonetheless).

Offline

#127 2011-12-15 22:56:28

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

Re: rvm_css (v1.2)

Ruud> Any chance of adding less support? Seems like that would be a match made in heaven.

Basically you could write css in less shorthand and have it interpreted(and optionally minfied) when saving to the static file. Less looks really powerful/useful/efficient.

Offline

#128 2011-12-15 23:32:09

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 595
Website

Re: rvm_css (v1.2)

I was looking into this. Theory so far—edit the plugin code, change this:


  if ($format == 'link')
  {
    return '<link rel="'.$rel.'" type="text/css"'.
      ($media ? ' media="'.$media.'"' : '').
      ($title ? ' title="'.$title.'"' : '').
      ' href="'.hu.$file.'" />';
  }

To this:


  if ($format == 'link')
  {
    return '<link rel="'.$rel.'" type="stylesheet/less"'.
      ($media ? ' media="'.$media.'"' : '').
      ($title ? ' title="'.$title.'"' : '').
      ' href="'.hu.$file.'" />';
  }

And then just write your CSS in LESS syntax within TXP.

Edit: Nevermind, it’s the rel attribute, not type. So Ruud’s answer below should work.

Last edited by maruchan (2011-12-16 15:42:56)

Offline

#129 2011-12-16 11:18:23

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

Re: rvm_css (v1.2)

The example on the lesscss website says:

<link rel="stylesheet/less" type="text/css" href="styles.less">

Perhaps I’m overlooking something, but the difference with how you’d normally include a style sheet seems to be only the value of the ‘rel’ attribute, which is already configurable:

<txp:rvm_css rel="stylesheet/less" />

Offline

#130 2011-12-16 19:17:45

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

Re: rvm_css (v1.2)

Thanks guys…

Your solution would work, 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).

There’s a php library for less here

I went out on a limb and pasted the whole function into rvm_css then added a couple of lines prior to the save mechanism, but it generated a bunch of parse errors.

$less = new lessc();
$css = $less->parse($css);
fwrite($handle, $css);

I did verify that it parsed correctly by feeding it a string instead of a variable like this…

$css = $less->parse('.test-selector{padding:10+10px;}');

which produced a file containing this…

.test-selector{padding:20px;}

Conceptually I think it’s a pretty simple thing. Devil in details for this pixel monkey.

Last edited by mrdale (2011-12-16 19:26:57)

Offline

#131 2011-12-16 19:38:32

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: rvm_css (v1.2)

mrdale wrote:

…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).

+1

Offline

#132 2011-12-16 22:04:54

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

Re: rvm_css (v1.2)

You also get to minify the css if you like too.

Offline

Board footer

Powered by FluxBB