Page 1 of 1

users.css extra file and plugin internal css

Posted: Fri Jan 20, 2012 11:21 am
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.

Re: users.css extra file and plugin internal css

Posted: Fri Jan 20, 2012 2:18 pm
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

Re: users.css extra file and plugin internal css

Posted: Fri Jan 20, 2012 6:27 pm
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).

Re: users.css extra file and plugin internal css

Posted: Fri Jan 20, 2012 11:01 pm
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

Re: users.css extra file and plugin internal css

Posted: Sat Jan 21, 2012 7:22 pm
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. :)