Page MenuHomePhabricator

Top-level pages in the template namespace are not recognized as TemplateStyles stylesheets
Open, LowPublic

Description

The content model for template styles sheets isn't correct. Just created w:no:Mal:Example-template-styles.css, and given the .css suffix it should be given the sanitized-css content model. On inspection it has the wikitext content model.

TemplateStyles is just enabled (T193786) and I guess it is just some additional configuration that is needed.

I have requested a manual change of content model, so it might have changed when someone checks this report.

Event Timeline

jeblad created this task.May 11 2018, 12:57 PM
Restricted Application added subscribers: Danmichaelo, Aklapper. · View Herald TranscriptMay 11 2018, 12:57 PM
jeblad updated the task description. (Show Details)May 11 2018, 12:58 PM
Tgr added a subscriber: Tgr.May 11 2018, 1:20 PM

Stylesheets are assumed to be subpages currently; see T191612 for related discussion. (Also related: T177027: Should we allow sanitized-css (TemplateStyles) content under titles where it is not the default content model?.)

Tgr renamed this task from Style sheets in template space does not get correct content model to Top-level pages in the template namespace are not recognized as TemplateStyles stylesheets.May 11 2018, 1:21 PM

You can change its content model (as an admin) in Special:ChangeContentModel to whatever you want.

Anomie added a subscriber: Anomie.May 11 2018, 1:53 PM

Stylesheets are assumed to be subpages currently

More specifically, the content model defaults to TemplateStyles sanitized CSS only for new subpages in the Template namespace ending with ".css". It doesn't do so for pages that aren't subpages.

There are various ways around this:

  • Use Special:ChangeContentModel to explicitly set the model.
  • Make the edit via the action API's action=edit, where the contentmodel parameter can be used to specify the model.
  • Create the page as a subpage where it will get the model defaulted, then move it to the appropriate title.

I asked for a change of content model, but figured out it was faster to recreate the stylesheet as a subpage.

I believe it would be better to default to sanitized-css if the suffix is .css in the template space, than also have a condition on the page being a subpage. It seems more obvious to me, as it implies reuse of the stylesheet.

Deskana triaged this task as Low priority.May 11 2018, 2:57 PM
Deskana added a subscriber: Deskana.

I believe it would be better to default to sanitized-css if the suffix is .css in the template space, than also have a condition on the page being a subpage. It seems more obvious to me, as it implies reuse of the stylesheet.

There are arguments for and against.

On the one hand, it's relatively easy to know what Template:X/styles.css is doing simply by looking at its name, because styles.css is a subpage of Template:X, whereas the name of Template:Y.css makes it less clear and makes it seem like it's a template intended for direct use, rather than CSS for other templates.

On the other hand, as you say, it might be clearer for Template:Z to use Template:Y.css rather than Template:X/styles.css, as the former page seems more general purpose and the latter more specific.

Regardless, for now, this is not a priority issue: not only are other ways to accomplish what you're intending, but there are also several workarounds noted by @Anomie that let you do exactly what you want anyway.

In my opinion this is an overly complicated rule that doesn't fit the mental model of how this should work. I guess more users will complain about this in the future.

I prefer the subpage request, since it forces proper documentation of rhe new baby from the first beginning.

It enforces junction to the related template it shall serve, which might be the hen for a couple of chicken templates sharing the same CSS and implementing similar tasks.

The naming TemplateStyles suggested that this is a particular CSS style assigned to a particular template. It was not supposed to bypass the sysop controlled CSS in MediaWiki: namespace by arbitrary CSS that might occur at every point in every page, established by every user and polluting the wiki with unlimited amount of classes and unmaintainable interactions.

In German Wikipedia we would not permit loose Template:somewhat.css flying around not related to anything and popping up and activated somewhere and whereever.

One day effects might be limited to the template which embeds the CSS, and then relying on loose things anywhere become a real problem.

Vvjjkkii renamed this task from Top-level pages in the template namespace are not recognized as TemplateStyles stylesheets to i4caaaaaaa.Jul 1 2018, 1:10 AM
Vvjjkkii raised the priority of this task from Low to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
CommunityTechBot renamed this task from i4caaaaaaa to Top-level pages in the template namespace are not recognized as TemplateStyles stylesheets.Jul 2 2018, 1:37 PM
CommunityTechBot lowered the priority of this task from High to Low.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added a subscriber: Aklapper.
Seb35 added a subscriber: Seb35.Sep 19 2018, 6:25 PM

This condition about a subpage was introduced in b301a30a with a lot of other code. I guess it was a design to add a condition "subpage of Template" to mandate styles to be related to one (and only one) template, and possibly avoid generic styles like Template:Foo.css.

In the future it could depend on how the communities want to use TemplateStyles:

  • either a strict policy with a given stylesheet for a single template (statu quo), or
  • generic stylesheets shared by multiple templates.

Generic stylesheets currently can be added in MediaWiki:Common.css, but it makes templates less self-contained and hence less easily maintained and less easily exported. A generic stylesheet in Template:Foo.css would not change a lot this point, although there would be a more direct link between the templates and the stylesheets.

I guess, depending on the approval or not of this issue on the long term, the stylesheets will be either minimal if strictly associated with a template, or more extensive if generic stylesheets in Template:Foo.css are allowed. The question here is the balance between generic styles and specific styles. Perhaps one solution or the other will emerge with time, and intensive users could have a qualified opinion about it (and if both solutions are sensible, perhaps it could be created a configuration parameter).

I guess it was a design to add a condition "subpage of Template" to mandate styles to be related to one (and only one) template, and possibly avoid generic styles like Template:Foo.css.

"Mandate", "require", and "forbid" are too strong. Yes, the intention of TemplateStyles is that each stylesheet is associated with a template (or family of related templates), which naturally lends itself to using subpages for the stylesheets, so we have only subpages with the right naming pattern default to the TemplateStyles content model.

But there's no effort made to forbid other usage patterns, they're just not the default.

Change 461525 had a related patch set uploaded (by Seb35; owner: Seb35):
[mediawiki/extensions/TemplateStyles@master] Allow Sanitized CSS in non-subpages

https://gerrit.wikimedia.org/r/461525

Change 461526 had a related patch set uploaded (by Seb35; owner: Seb35):
[mediawiki/extensions/TemplateStyles@master] Allow Sanitized CSS in non-subpages according to a parameter

https://gerrit.wikimedia.org/r/461526

Seb35 added a comment.Sep 20 2018, 7:37 AM

Thanks for the clarification.

I submitted two changes to:

  1. either enable the Sanitized CSS on non-subpages templates,
  2. either add a parameter to choose per-wiki the behaviour between the statu quo and the first point.

Obviously the two changes are incompatible, only one can be merged (or neither if it is decided to refuse this task). I have personally no specific opinion about what should be chosen.

Seb35 added a comment.Sep 24 2018, 6:39 PM

@jeblad @PerfektesChaos and other TemplateStyles users : there are now two patches to enable by default Sanitized CSS on top-level pages in templates, either unconditionally (which I guess would not satisfy @PerfektesChaos) either on a per-wiki and per-namespace basis, hence different communities could have different parameters. I point out this is only about the by default behaviour, there is always the possibility to change the content model (for users having this right).

Do you have any opinion now? (it can be be the statu quo)

If no opinion now, this task can become "idle" for some time in order to gain some experience with real management of TemplateStyles.

I stick to the position that this is encouraging uncontrolled misuse of CSS rules in classes suddenly appearing somewhere on pages, with no real chance for editors to understand when and why which class with which name has which effect under these conditions; consider name collision.

And you are putting efforts on every wiki to make a poll now and create a consensus on something nearly nobody will understand, at least no regular editor, and to apply at system operators for a certain configuration per-wiki.

Even more, it is not necessary to do what you are doing, since you just need a central template which has no effect on transclusion but will host all project wide selectors and styles for no specific case.

If it would have been the intention to create a mess like you do the feature would not have been called TemplateStyles but FreeStyle.

If ever, your patch must not be default, changing status quo, but opt-in for yourself only on a special request and you are to organise a poll in your wiki to change config.

Tgr added a comment.Sep 24 2018, 8:54 PM

Let's tone down the rhetoric a bit.

I think we should wait for T200687: MCR support in TemplateStyles which is not that far away now and will completely change how TemplateStyles styles are stored (and might or might not provide special support for sharing a style between multiple templates).