Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#85 2009-01-07 11:18:03

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

Re: rvm_css (v1.2)

Or use the <txp:rvm_css /> tag, which should work (otherwise it’s a bug).
_

Offline

#86 2009-02-03 12:10:29

isellsoap
New Member
Registered: 2009-02-03
Posts: 2

Re: rvm_css (v1.2)

I have a strange problem.

My CSS implementation: <style type=“text/css”>@import url(“<txp:rvm_css />”);</style>

This works fine for the frontpage and for all section pages but when I go to a single article it displays the site as if there isn’t any css file. When I look into the page source code the CSS implementation is there, so normally there shouldn’t be any problem. Can someone help me on this?

Last edited by isellsoap (2009-02-03 12:11:38)

Offline

#87 2009-02-03 16:10:02

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: rvm_css (v1.2)

you could use <txp:rvm_css n="name_of_styles" /> . The disadvantage would be that you can’t hook up a new stylesheet easily under the sections tab.

You could also have a look at the tag trace to see what happens.

Last edited by JanDW (2009-02-03 16:12:12)


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

#88 2009-02-06 17:14:31

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

Re: rvm_css (v1.2)

isellsoap wrote:

My CSS implementation: <style type=“text/css”>@import url(“<txp:rvm_css />”);</style>

This works fine for the frontpage and for all section pages but when I go to a single article it displays the site as if there isn’t any css file. When I look into the page source code the CSS implementation is there, so normally there shouldn’t be any problem. Can someone help me on this?

So the URL that rvm_css inserts in the HTML code is correct? In that case it’s not a plugin problem.

Offline

#89 2009-03-04 02:48:13

johnnie
Member
Registered: 2007-03-10
Posts: 58

Re: rvm_css (v1.2)

Ruud, I have an idea. See this as a feature request:

To further speed up CSS serving, would it be possible to add some simple minification to the locally stored css file? e.g. removing newlines, removing comments etc. It should all be possible using some regular expresions. That way CSS would still be editable in a nice manner, but the actually served version is a lot smaller! See http://www.refresh-sf.com/yui/ for an example CSS minifier.

Offline

#90 2009-03-04 03:50:29

johnnie
Member
Registered: 2007-03-10
Posts: 58

Re: rvm_css (v1.2)

There, I’ve done the work for you. Replace the rvm_css_save() function with this to get minified CSS stored to the server (not the DB, so you can still edit the easily workable ‘beautiful’ version of your CSS!). On larger CSS files, the savings can be quite good! Ofcourse you might want to add an option for this or something like that, but here’s the code for it:

function rvm_css_save()
{
  global $path_to_site, $rvm_css_dir;

  $name = (ps('copy') or ps('savenew')) ? ps('newname') : ps('name');
  $filename = strtolower(sanitizeForUrl($name));

  if (empty($rvm_css_dir) or !$filename)
  {
    return;
  }

  $css = safe_field('css', 'txp_css', "name='".doSlash($name)."'");

  if ($css)
  {
    $minicss = base64_decode($css);
    $minicss = preg_replace("/\r\n/","",$minicss);
    $minicss = preg_replace("/:(\s*|\t*)/",":",$minicss);
    $minicss = preg_replace("/;(\s*|\t*)/",";",$minicss);
    $minicss = preg_replace("/,\s*/",",",$minicss);
    $minicss = preg_replace("/(\s*|\t*){/","{",$minicss);
    $minicss = preg_replace("/}(\s*|\t*)/","}",$minicss);
    $minicss = preg_replace("/\/\*(.*?)\*\//","",$minicss);
    $file   = $path_to_site.'/'.$rvm_css_dir.'/'.$filename.'.css';
    $handle = fopen($file, 'wb');
    fwrite($handle, $minicss);
    fclose($handle);
  }
}

Last edited by johnnie (2009-03-04 03:51:45)

Offline

#91 2009-04-10 14:57:58

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: rvm_css (v1.2)

Fantastic. Thank you very much for this plugin.

Please can I ask, if my CSS tab textarea is not full of the actual CSS but just:

@import url(‘/_my-stuff/style/my-style.css’);

will the plugin only cache those 50 or so characters (so I am gaining little benefit), or does it import the CSS and cache the full file?

If only the 50 or so characters, then the answer is presumably to just copy the CSS in and forget the @import?

Sorry if this is a newbie-ish question and thanks in advance for any comment.

Cheers, -Alan


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#92 2009-06-24 18:28:29

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

Re: rvm_css (v1.2)

@johnnie, if you really want to minify, you can optimize a lot more. For example (91 chars):

body {
  border-left: 1px;
  border-right: 1px;
  border-top: 1px;
  border-bottom: 1px;
}

Can be compressed to (72 chars, 21% reduction):

body{border-left:1px;border-right:1px;border-top:1px;border-bottom:1px;}

But can also be re-written to (16 chars, 82% reduction), which is also easier to read:

body{border:1px}

I think the benefits of minifying don’t outweigh the added code complexity (especially if you’re already compressing CSS using deflate/gzip). It reduces bandwidth usage, but I suspect that on most websites the bandwidth used by serving CSS files is only a few percent of total bandwidth used.

Offline

#93 2009-06-24 18:33:36

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

Re: rvm_css (v1.2)

@alanfluff, you’ll benefit from this plugin, because you avoid the use of textpattern to serve that single import line (instead it’s served from a separate static file, which is many times faster than serving stuff through a PHP script). So basically when CSS loads, it first loads a static file containing the import line, which then in turn loads another static file with the bulk of your CSS code.

You could benefit slightly more if you put the contents of my-style.css directly in the CSS tab textarea.

Offline

#94 2009-06-24 19:14:17

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: rvm_css (v1.2)

Thanks Ruud — I am using the plugin and it is making a mASSIVe difference – quite brilliant :)


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#95 2009-09-21 13:33:27

sebatorresi
Member
From: Spain
Registered: 2009-05-27
Posts: 105
Website

Re: rvm_css (v1.2)

Thanks a lot man!
Great plug in


Sonríe | Smile . <txp:lover />

Offline

#96 2009-11-11 07:43:47

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,087
Website Mastodon

Re: rvm_css (v1.2)

I disabled the plugin. then i deleted it. but in my Preferences > Advanced >

i still see this:
rvm_css_dir _mycss

Should it not revert back to the default line?


…. texted postive

Offline

Board footer

Powered by FluxBB