Page MenuHomePhabricator

It should be possible to hide the heading on the main page without hiding the heading on its associated diff page
Closed, ResolvedPublic

Description

Author: vlakoff

Description:
<body> tag has the same class attributes for "normal view" and "diff", for example:

http://en.wikipedia.org/wiki/Foobar
and
http://en.wikipedia.org/w/index.php?title=Foobar&diff=prev&oldid=482777894

It would be very useful for CSS styling to be able to distinguish these pages through <body> classes

QA

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:27 AM
bzimport set Reference to bz36294.
bzimport added a subscriber: Unknown Object (MLST).

The <body> contains action- prefixed class names (e.g. action-view, action-history, action-edit etc.). However "diff' is not an action, but a component of the view action.

It is not a different page action or layout, it therefor doesn't make sense to style the entire page differently just because it contains a diff component.

The diff component itself can be styled by using the css hooks of the diff component:

  • table.diff
  • .diff-marker
  • .diff-content
  • .diff-otitle
  • .diff-ntitle
  • .diff-lineno
  • .diff-deletedline
  • etc. (See also ./resources/mediawiki.action/mediawiki.action.history.diff.css)

If you need a selector for the entire page, could you elaborate on a use case?

vlakoff wrote:

On the French wiki homepage, we hide the H1:

http://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Accueil_principal

However, the H1 is also hidden on this page's diffs:

http://fr.wikipedia.org/w/index.php?title=Wikip%C3%A9dia:Accueil_principal&diff=75110565&oldid=prev

For consistency, it would be great to hide the H1 only on the viewed page, and nowhere else.

Note that the issue also concerns the English wiki

Jdlrobson renamed this task from views and diffs should be distinguishable for CSS to It should be possible to hide the heading on the main page without hiding the heading on its associated diff page.Jan 13 2021, 7:41 PM
Jdlrobson updated the task description. (Show Details)
Jdlrobson added a subscriber: Jdlrobson.

Seems reasonable and use case is clear. Can be done inside OutputPage::headElement
A class action-view-diff should be added to such pages. Will happily review patch.

The heading is also not shown on history page, which does not look good too. Relatedly, there should be api (perhaps in OutputPage or WebReqeuest) to easily and centrally tell whether we're currently in diff view

The heading is also not shown on history page, which does not look good too. Relatedly, there should be api (perhaps in OutputPage or WebReqeuest) to easily and centrally tell whether we're currently in diff view

Curious how, for the purposes of the <body> CSS class action-<action name> diff pages count as view, which is technically sorta correct but very unintuitive and in the case of the fr.wikipedia pages mentioned in the task description, it does mean it's not possible to distinguish in CSS whether we're truly viewing the page or whether we're viewing a diff.
Not sure what the best way forward here would be; I'm tempted to suggest that diff views should identify themselves as action-diff because it makes logical sense, except diffs aren't an action, they're "just" action=view with a diff param tacked into the whole query string. Tricky! :-/

Change 749580 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] Hiding main page heading should not hide title on diff/history views

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

This should be fixed by T297019 as it will remove the need for adding CSS to hide the main page title in MediaWiki:Common.css
I did forget to check that action === view in that task, so this follow up is needed: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/749580

Change 749580 merged by jenkins-bot:

[mediawiki/core@master] Hiding main page heading should not hide title on diff/history views

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

I tried this change out on Italian Wikipedia and it resolved the bug (heading now present):
https://it.wikipedia.org/w/index.php?title=Pagina_principale&type=revision&diff=122948985&oldid=122947071

Screen Shot 2022-01-06 at 9.49.53 AM.png (1×2 px, 399 KB)

I've communicated this out to communities T298715