Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-01-01 20:27:21

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

rvm_css (v1.2)

This plugin automatically stores a copy of your style sheet(s) as a static file. Static files are served several orders of magnitude faster than PHP files (200 times faster, in my own tests on a FastCGI-based server).

I originally wrote this plugin for a website that had two style sheets for every page (one for printing) and the built-in method of serving both style sheets cost as much CPU time and memory as serving the page itself. The server load for this website was reduced by 50% after using this plugin.

Download

Changelog:

  • version 0.1 (2007-06-11) [never released]
  • version 0.2 (2008-01-01)
    • file name sanitized
    • deleting a style sheet deletes the corresponding static file
    • degrade gracefully if static file cannot be stored or read
    • save style sheet in all situations (not just when saving an existing raw css file)
  • version 0.3 (2008-01-02)
    • return stylesheet url when format attribute is not set to ‘link’ (didn’t work before)
    • do not force the use of ‘default’ style sheet on 404 error page
  • version 0.4 (2008-12-20)
    • use correct CSS content when copying or saving a new style sheet (thanks Maniqui/Julián)
  • version 0.5 (2009-12-19)
    • compatible with future versions of TXP that may not use base64 encoding anymore when storing the style sheet in the database.
  • version 0.6 (2010-11-11)
    • force 644 permissions on static CSS files
    • cleanup prefs after plugin removal
    • support the ‘name’ attribute (TXP 4.3+), but keep support for the ‘n’ attribute (TXP 4.2 and lower)
  • version 0.7 (2011-11-19)
    • fixed ‘undefined constant txp_version’ error (thanks Bloke and wet)
  • version 0.8 (2011-12-19)
    • support for less syntax added (read the plugin help, because this does require you to manually install the less.inc.php file… unless someone packages it as an add-on plugin)
  • version 0.9 (2012-04-07)
    • improve support for less syntax when hosting it on a windows server (thanks redbot and Bloke).
  • version 1.0 (2013-02-28)
    • compress output when using “less” (thanks qrayg)
    • support multiple css files in one rvm_css call. This doesn’t concatenate (that’s not possible), but by doing so it keeps working as a drop-in replacement for the standard TXP css tag.
  • version 1.1 (2016-02-07)
    • compatible to TXP 4.6
  • version 1.2 (2018-03-25)
    • compatible with TXP4.7, including multi-theme support
    • include textpack translations

Offline

#2 2008-01-01 20:35:42

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,243
Website GitHub

Re: rvm_css (v1.2)

Genius. Nice one, Ruud. I wonder if stm_javascript can be given the same treatment?

Last edited by Bloke (2008-01-01 20:36:24)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2008-01-02 00:45:17

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: rvm_css (v1.2)

beautious! will test this out when i can. but this is definitely gonna be another staple for my txp installations.

Offline

#4 2008-01-02 03:00:31

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rvm_css (v1.2)

Great, the must have thing, indeed.

Cheers!

Offline

#5 2008-01-02 03:10:54

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: rvm_css (v1.2)

Oh sorted Ruud. :)

Last edited by thebombsite (2008-01-02 03:36:24)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#6 2008-01-02 04:24:40

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 743

Re: rvm_css (v1.2)

fantastic

Offline

#7 2008-01-02 06:11:10

NeilA
Member
From: Blue Mountains, Australia
Registered: 2004-08-15
Posts: 316
Website

Re: rvm_css (v1.2)

Thanks for this Rudd… but having a small problem getting it to work with a template by Reid…
Plugin is installed, activated, and the css files have been created.

This is what is currently in the page head referring to css:

bc..
<style type=“text/css” media=“screen”>

@import url(“<txp:css n=“grs1_primary” />”);

</style>

<txp:hide> —————————————————————————————-
Conditional comment to serve style sheet to IE 6.0 and under
————————————————————————————— </txp:hide>

<!—[if lt IE 7]>

<style type=“text/css” media=“screen”>

@import url(“<txp:css n=“grs1_ie” />”);

</style>

<![endif]—>

Simply replacing the <txp:css with your tag doesn’t work – I end up with no css being used at all.
Can you explain what I’m doing wrong?

Many thanks


Neil – Blue Mountains, Australia

http://westserve.org
http://ministrygrounds.net.au

Offline

#8 2008-01-02 08:01:42

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

Re: rvm_css (v1.2)

Can you send me the tag trace + the rest of the generated HTML code for that page by email?

Offline

#9 2008-01-02 08:30:02

NeilA
Member
From: Blue Mountains, Australia
Registered: 2004-08-15
Posts: 316
Website

Re: rvm_css (v1.2)

Will do Rudd, thanks.


Neil – Blue Mountains, Australia

http://westserve.org
http://ministrygrounds.net.au

Offline

#10 2008-01-02 09:52:54

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: rvm_css (v1.2)

Fantastic plugin! Thanks Ruud. Any chance of expanding this to the JS files in stm_javascript?

Offline

#11 2008-01-02 10:19:36

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: rvm_css (v1.2)

BTW – does not work in error_default pages. I had this which did not work:

<!-- CSS -->
<txp:rvm_css format="link" n="default" />
<txp:rvm_css format="link" n="menu" />

Changed it back to:

<!-- CSS -->
<link rel="stylesheet" href="<txp:css n="default"/>" type="text/css" />
<txp:css format="link" n="menu" />

Works again.

Offline

#12 2008-01-02 10:29:38

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

Re: rvm_css (v1.2)

How does it not work? What URL do you see for the style sheet in the HTML code?

Offline

Board footer

Powered by FluxBB