mediawiki.action.history.diff: Rework print styles
authorBartosz Dziewoński <matma.rex@gmail.com>
Tue, 18 Nov 2014 12:32:11 +0000 (13:32 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 18 Nov 2014 17:48:15 +0000 (18:48 +0100)
* Remove extremely old print styles for diffs from commonPrint.css,
  added back in r6970. These were created for the old yellow-green-red
  diff styles and look terrible now.
* Add new, minimal print styles, that replace background colors with
  text decoration (underline for inserted text, line-through for
  deleted). Motivation is the same as in r6970: light colored backgrounds
  work great on displays, but not very well in black-and-white print.
* Fixed diff styles demo (mediawiki.action.history.diff.html), updated
  with print styles and better example.

Bug: 73544
Change-Id: Ibf08fa11f84ac0cf8c7ed4da8af2b8804de6ab6f

docs/uidesign/mediawiki.action.history.diff.html
resources/Resources.php
resources/src/mediawiki.action/mediawiki.action.history.diff.css
resources/src/mediawiki.action/mediawiki.action.history.diff.print.css [new file with mode: 0644]
resources/src/mediawiki.legacy/commonPrint.css

index 5edcfb8..615558f 100644 (file)
@@ -1,57 +1,91 @@
 <!DOCTYPE html>
 <html lang="en" dir="ltr">
 <head>
-       <link rel="stylesheet" href="../../resources/mediawiki.action/mediawiki.action.history.diff.css">
+       <meta charset="utf-8">
+       <link rel="stylesheet" href="../../resources/src/mediawiki.action/mediawiki.action.history.diff.css">
+       <link rel="stylesheet" media="print" href="../../resources/src/mediawiki.action/mediawiki.action.history.diff.print.css">
 </head>
-<body style="background-color: #C0C0C0;">
-<p>
-This show various styles for our diff action, the background being hardcoded to gray (<code>#C0C0C0</code>) The reference style sheet is:</p>
-<p>
-<code><a href="../../resources/mediawiki.action/mediawiki.action.history.diff.css">resources/mediawiki.action/mediawiki.action.history.diff.css</a></code>.
-</p>
-<p>
-This file might help us fix our diff colors which have been a recurring issues among the community for a loooong time.</p>
-
-<p>
-First, show the diff mostly like it would be chown on a wiki</p>
-<table class="diff">
+<body>
+
+<p>This show various styles for our diff action. Style sheet: <code><a href="../../resources/src/mediawiki.action/mediawiki.action.history.diff.css">resources/src/mediawiki.action/mediawiki.action.history.diff.css</a></code>.</p>
+<p>This file might help us fix our diff colors which have been a recurring issues among the community for a loooong time.</p>
+<p>Try it out in print mode, too. Style sheet: <code><a href="../../resources/src/mediawiki.action/mediawiki.action.history.diff.print.css">resources/src/mediawiki.action/mediawiki.action.history.diff.print.css</a></code>.</p>
+
+<p>Practical example copied from MediaWiki's HTML output:</p>
+
+<table class="diff diff-contentalign-left">
+       <colgroup><col class="diff-marker">
+       <col class="diff-content">
+       <col class="diff-marker">
+       <col class="diff-content">
+       </colgroup>
+<tbody>
 <tr>
-       <td class="diff-marker">-</td>
-       <td class="diff-deletedline"><div>
-               Some content <span class="diffchange diffchange-inline">deleted / replaced</span>
-       </div></td>
+       <td class="diff-marker">−</td>
+       <td class="diff-deletedline"><div>Lorem ipsum dolor sit amet<del class="diffchange diffchange-inline">, consectetur adipisicing elit</del>, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div></td>
        <td class="diff-marker">+</td>
-       <td class="diff-addedline"><div>
-               Some content <span class="diffchange diffchange-inline">added / replacement</span>
-       </div></td>
+       <td class="diff-addedline"><div>Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div></td>
 </tr>
-</table>
-
+<tr>
+       <td class="diff-marker">−</td>
+       <td class="diff-deletedline"></td>
+       <td colspan="2" class="diff-empty">&nbsp;</td>
+</tr>
+<tr>
+       <td class="diff-marker">−</td>
+       <td class="diff-deletedline"><div>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div></td>
+       <td colspan="2" class="diff-empty">&nbsp;</td>
+</tr>
+<tr>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"></td>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"></td>
+</tr>
+<tr>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"><div>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</div></td>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"><div>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</div></td>
+</tr>
+<tr>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"></td>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"></td>
+</tr>
+<tr>
+       <td class="diff-marker">−</td>
+       <td class="diff-deletedline"><div>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim<del class="diffchange diffchange-inline"> id est laborum</del>.</div></td>
+       <td class="diff-marker">+</td>
+       <td class="diff-addedline"><div>Excepteur sint occaecat cupidatat non proident, sunt<ins class="diffchange diffchange-inline"> reprehenderit in voluptate</ins> in culpa qui officia deserunt mollit anim.</div></td>
+</tr>
+<tr>
+       <td colspan="2" class="diff-empty">&nbsp;</td>
+       <td class="diff-marker">+</td>
+       <td class="diff-addedline"></td>
+</tr>
+<tr>
+       <td colspan="2" class="diff-empty">&nbsp;</td>
+       <td class="diff-marker">+</td>
+       <td class="diff-addedline"><div>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div></td>
+</tr>
+</tbody></table>
 
-<p>
-Below are some basic lines being applied one or two classes. Mainly for debugging purposes</p>
+<p>Below are some basic lines being applied one or two classes. Mainly for debugging purposes.</p>
 
 <table class="diff">
-
        <tr><th>Diff</th></tr>
 
        <tr><td class="diff-addedline"><code>diff-addedline</code>: added line</td></tr>
        <tr><td class="diff-deletedline"><code>diff-deletedline</code>: deleted line</td></tr>
        <tr><td class="diff-context"><code>diff-context</code>: context</td></tr>
 
-
-       <tr><th>Same as above with a <code>&lt;span&gt;</code> child element having the <code>diffchange</code> class</th></tr>
+       <tr><th>Same as above with a <code>&lt;ins&gt;</code> or <code>&lt;del&gt;</code> child element having the <code>diffchange</code> class:</th></tr>
 
        <tr><td class="diffchange">Diffchange</td></tr>
-       <tr><td class="diff-addedline">
-               <span class="diffchange">Added line + diffchange</span>
-       </td></tr>
-       <tr><td class="diff-deletedline">
-               <span class="diffchange">Deleted line + diffchange</span>
-       </td></tr>
-       <tr><td class="diff-context">
-               <span class="diffchange">Context + diffchange</span>
-       </td></tr>
+       <tr><td class="diff-addedline"><ins class="diffchange">Added line + diffchange</ins></td></tr>
+       <tr><td class="diff-deletedline"><del class="diffchange">Deleted line + diffchange</del></td></tr>
 </table>
 
 </body>
index cfac8a9..c39ba3b 100644 (file)
@@ -1053,7 +1053,10 @@ return array(
                'group' => 'mediawiki.action.history',
        ),
        'mediawiki.action.history.diff' => array(
-               'styles' => 'resources/src/mediawiki.action/mediawiki.action.history.diff.css',
+               'styles' => array(
+                       'resources/src/mediawiki.action/mediawiki.action.history.diff.css',
+                       'resources/src/mediawiki.action/mediawiki.action.history.diff.print.css' => array( 'media' => 'print' ),
+               ),
                'group' => 'mediawiki.action.history',
                'targets' => array( 'desktop', 'mobile' ),
        ),
index 092a597..0887476 100644 (file)
@@ -1,6 +1,6 @@
-/*
-** Diff rendering
-*/
+/*!
+ * Diff rendering
+ */
 table.diff {
        border: none;
        border-spacing: 4px;
diff --git a/resources/src/mediawiki.action/mediawiki.action.history.diff.print.css b/resources/src/mediawiki.action/mediawiki.action.history.diff.print.css
new file mode 100644 (file)
index 0000000..76b5c9b
--- /dev/null
@@ -0,0 +1,16 @@
+/*!
+ * Diff rendering
+ */
+td.diff-context,
+td.diff-addedline .diffchange,
+td.diff-deletedline .diffchange {
+       background-color: transparent;
+}
+
+td.diff-addedline .diffchange {
+       text-decoration: underline;
+}
+
+td.diff-deletedline .diffchange {
+       text-decoration: line-through;
+}
index 9405719..a52ccb6 100644 (file)
@@ -323,44 +323,6 @@ div.gallerytext {
        word-wrap: break-word;
 }
 
-/**
- * Diff rendering
- */
-table.diff {
-       background: white;
-}
-
-td.diff-otitle {
-       background: #ffffff;
-}
-
-td.diff-ntitle {
-       background: #ffffff;
-}
-
-td.diff-addedline {
-       background: #ccffcc;
-       font-size: smaller;
-       border: solid 2px black;
-}
-
-td.diff-deletedline {
-       background: #ffffaa;
-       font-size: smaller;
-       border: dotted 2px black;
-}
-
-td.diff-context {
-       background: #eeeeee;
-       font-size: smaller;
-}
-
-.diffchange {
-       color: silver;
-       font-weight: bold;
-       text-decoration: underline;
-}
-
 /**
  * Table rendering
  * As on shared.css but with white background.