users.css extra file and plugin internal css

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

users.css extra file and plugin internal css

Post by blog.brockha.us »

Some plugins add css to the serendipity css by hooking into the css event and checking, if the user has already added a class for the plugins elements.

Something like that:

Code: Select all

case 'css':
    if (strpos($eventData, '.serendipity_oembed')) {
        // class exists in CSS, so a user has customized it and we don't need default
        // (doesn't work with templates like BP or 2k11 as the user css is loaded from a seperate file)
        return true;
    }
    // patch some extra css here
But this doesn't work for templates like BP or 2k11, as the user adds extra css to a seperate css file called users.css. The hook only shows entries of the default template css, not the users.css added later.

Is there something we can do about that? Have we at all? I guess it's not that bad, as css entries of the users css are evaluated later by the browser and will overwrite the internal css classes (so I hope at least), but it would be cool, not to emit the internal css at all then.
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: users.css extra file and plugin internal css

Post by garvinhicking »

Hi!

Basically, what comes to my mind is a config.inc.php of those templates, where they can hook into the "css" hook themselves (this is a feature of s9y 1.6, the syntax is AFAIR documented in the config.inc.php of bulletproof). Then the template could check the user.css for the classes, and if so, add empty classes to the serendipity.css class so that other plugins will not complain about it missing.

But that's quite complicated and would take up processing time for something that might not really be required, since you mention that styles can be overwritten in the users.css....

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: users.css extra file and plugin internal css

Post by Timbalu »

Gna... not really!
And what about copied plugin css files in the usertemplate? Btw., an empty file in there would prevent the loading in the plugin too.

Why, Grischa, should someone use these class rules in user.css, if not intending to overwrite some specific classes brought by core gathered css file?

I might think of having some easy global $serendipity['template']['usercsstakeover'] = false; in your plugins 'css' eventhook and a usertemplates config.inc.php set $serendipity['template']['csstakeover'] = true, telling all plugins with that option to return without hooking the css into serendipity.css. But that is something to do by the user himself only, I presume (and there would better help an empty "plugin".css in the template).
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: users.css extra file and plugin internal css

Post by yellowled »

Correct me if I'm wrong, but isn't the mechanism of serendipity.css.php like this?

1. insert styles provided by plugins
2. insert style_fallback.css
3. insert style.css

Both BP's and 2k11's user.css are referenced after serendipity.css in the index.tpl, they are supposed to overwrite styles used in serendipity.css.

So why should this hook have access to the user.css?

(BTW, I already suggested a mechanism to include a user.css [or even other stylesheet files, for that matter] in serendipity.css.php since I think it would be a good thing in terms of performance. Can't remember why Garvin didn't like that idea back then.)

YL
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Re: users.css extra file and plugin internal css

Post by blog.brockha.us »

Well okay, I think to be able to overwrite only some parts of the plugin css is a good argument to leave it like that. The user doesn't have to create the css completely new then.
Thanks for discussing. :)
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
Post Reply