Closed (fixed)
Project:
Diff
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
7 Dec 2007 at 22:15 UTC
Updated:
13 Feb 2008 at 18:42 UTC
Jump to comment: Most recent file
This is a small part of the monolithic patch http://drupal.org/node/125494
Hopefully by breaking them up we can move them through faster.
This part deals with:
1. Diff output is generated via theme() functions. This uses a new DiffDrupalFormatter class instead of the DiffTableFormatter class. The normal theme function implementation implement the same behaviour as the DiffTableFormatter had.
I would be glad if someone with theme framework experience could check this part.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | diff_125494_theme_table_3.patch | 18.18 KB | moonray |
| #12 | diff_test_files.zip | 16.22 KB | moonray |
| #8 | diff_125494_theme_table_2.patch | 17.84 KB | moonray |
| #6 | diff_125494_theme_table_1.patch | 17.58 KB | moonray |
| diff_125494_theme_table.patch | 8.67 KB | moonray |
Comments
Comment #1
moshe weitzman commentedPatch looks very nice. But it is incomplete since it leaves behind the now unused TableDiffFormatter in diffengine.php
Comment #2
moonray commentedI was just updating this patch, and ran into a problem, and would like some suggestions.
This patch attempts to render the table using theme('table'). Now, since the patch from http://drupal.org/node/198110 has been entered in CVS, theme('table') can no longer properly render this.
Why? It's lacking the ability to add
<col class="diff-marker" />before the thead tag.This really is an issue with theme('table'), but fixing that would require waiting until D6 (if a patch got submitted and approved).
So, now for the question: do we create a new theme('diff_table'), or do we try to get D6 core fixed and wait for it, or both (and not wait for D6)?
Comment #3
dwwDo we care? Is that class fundamental to the functionality from #198110? Seems like all it does is add a 1em width, and I find it hard to believe that fundamentally alters the behavior of the other patch.
that said, theme('table') is a mess. there's no point trying to fix it in D6, we're *way* past the point where such a far reaching API change would go in. there was talk on the devel list of big changes to theme('table') in D7, but no reason to hold up good patches in here for another 1+ years...
i say we just forget about the "diff-marker" class, lose the 1em width, and continue on.
Comment #4
moonray commentedActually, it does more than loose the 1em class.
The col tags (with classes diff-marker and diff-content) in conjunction with the css
table.diff { table-layout: fixed; }are essential in making sure the columns are a certain width and no wider when there is content that's wider than the table. Without them, the columns will change width at will, which was what that patch was made to fix.I did a test with Firefox and Safari. Firefox will display things properly if I add a class to the marker column (in DiffEngine.php) and adjust the column width to 1em there. Safari, however, stretches the the content table cell, breaking layout.
I tried a few other possibilities, but nothing else seems to work consistently, which is probably why wikipedia did it this way. :-)
Comment #5
dwwhrm, interesting. thanks for the explanation, i've never been much of a CSS ninja...
in terms of what that means for this patch, i'm not sure. seems like theme('table') isn't flexible enough (once again) to do what we need, so it seems like we still can't use it. i'm not much of a theme ninja, either, so i don't know the best solution. ideas welcome.
Comment #6
moonray commentedCreated a patch that adds a modified version of theme_table, theme_diff_table to accomplish col tags. It also takes care of removing the TableDiffFormatter function from diffengine.php.
Hopefully this will do.
Comment #7
dwwThis is great. This patch is getting pretty close to RTBC, and once it's in, there's only a little bit more goodness to harvest from http://drupal.org/node/125494 and we'll be in good shape to make progress on the rest of the issues in the queue.
So, here are my latest concerns about this patch:
A) Why are we making the caller responsible for sanitizing input we hand to contextLine() instead of just putting the check_plain() directly in that function? Seems safer that way than having a comment about it. Sure, there's only 1 call site now, but even then, it seems cleaner and needing less code to do the check_plain() "once" in the function itself.
[disclaimer] the rest of this isn't my strongest area of drupal knowledge [/disclaimer]
B) Seems a little evil to fork theme('table') like that, but perhaps that's our only option given the extra classes and such you're trying to add. I'd really like other thoughts on this before I'd be willing to commit the patch.
C) The DrupalDiffFormatter class looks like an improvement. However, it seems like it's still hard-coding a fair bit of HTML in its output formatting. If we really want to make this output themeable, don't we want to use theme functions directly inside this formatter class? For example:
Could be something like:
and then, outside of the class entirely, just have a few of these:
(Note also the code style for spacing around string concatenation and literals)...
If I wanted to alter the look of the diff output, and I was a designer, I'd much rather just tweak a few theme functions like this than have to understand and hack my own copy of the DrupalDiffFormatter class.
Thanks again!
Comment #8
moonray commentedTo address your concerns:
A) The caller is always from within DrupalDiffFormatter. Also, we can't do check_plain() inside the addedLine, deletedLine, contextLine because we sometimes it's being fed escaped HTML already. Here is a comment from the code:
// Notice that WordLevelDiff returns HTML-escaped output.
// Hence, we will be calling addedLine/deletedLine without HTML-escaping.
B) I can't think of any other way to accomplish this. I'm always open to better ideas.
C) I've added three theme functions to deal with the HTML: theme_diff_header_line, theme_diff_content_line, theme_diff_empty_line.
Patch attached.
Comment #9
moshe weitzman commentedThis all looks good, except for that form of theme_table(). Have you tried to accomplish same by adding a class attribute to each cell? I know it isn't pretty, but we do this routinely. For example note sortable tables - every cell in the column which is the current 'sort by' has an 'active' class.
This page suggests that we could accomplish same by adding classes to each cell: http://www.htmldog.com/guides/htmladvanced/tables/
I think colgroup and col are useful and i would love if you submitted a patch to core for these. once accepted, we would happily use it here.
Comment #10
moonray commentedI actually did try that before customizing the theme_table function.
See post #4:
"I did a test with Firefox and Safari. Firefox will display things properly if I add a class to the marker column (in DiffEngine.php) and adjust the column width to 1em there. Safari, however, stretches the the content table cell, breaking layout."
It's a cross-browser issue.
Comment #11
moshe weitzman commenteddid you test with safari3? i have that available, if you could put up a test pge somewhere. if you tested with safari3 and it is still busted, then we can proceed with commit.
Comment #12
moonray commentedFind attached an archive containing a test without using col tags.
It breaks for me using safari 3, on the mac.
Comment #13
moonray commentedAnd here is a slightly updated patch (another tweak to keep safari happy when there are 'no visible changes').
Comment #14
moshe weitzman commentedfinally committed to HEAD and DRUPAL-5. thanks so much, moonray.
Comment #15
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.