Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently, signatures are coupled with comment module. The signature field is stored with the user table. Logically, the code for signatures should be included there as well.
Note that comment module still prints $user->signature explictly in the comment. The goal is to remove that and display it in a theme function instead, but baby steps. :P See http://drupal.org/node/10938 for (much) more discussion. :P
Comment | File | Size | Author |
---|---|---|---|
#24 | signature-cleanup.patch | 4.41 KB | webchick |
#22 | separator.patch | 3.76 KB | webchick |
#17 | sig_5.patch | 14.28 KB | webchick |
#16 | sig_4.patch | 12.49 KB | webchick |
#15 | sig_3.patch | 12.49 KB | webchick |
Comments
Comment #1
webchickAfter talking w/ Steven, he recommended I do this in two steps instead, so adjusting title.
Comment #2
webchickNote: this is not scope creep! :)
If we run signatures through a theme function, there is no way they can be appended to the comment body as they currently are, because then you get <div ... etc. in the comment body on edit. Therefore, we must now render signatures dynamically on view, which is fine, because that was the next thing I was going to fix. ;)
There's no update path.... Steven said he would help me out with that.
Comment #3
Steven CreditAttribution: Steven commentedOkay so I had a nice chat with webchick about this... and it's an incredibly hairy problem. Here's what we agreed upon:
The best way to do this is to split off the signature from the comment body completely, and just add it when viewing.
However, I think this is a really bad idea. So far, we've had an unofficial rule that all updates involve one-time operations. Once you've upgraded, there should be no left over cruft in the code that runs. This code would affect even fresh 6.0 installs.
The only solution that follows this rule would be a best effort solution that only removes the user's current signature from their comments. Comments with outdated signatures would show up with two signatures. The question here is how much of an issue this would be. Personally, I don't think people care that much about outdated content, and if a site does have some often frequented forum topics (like a FAQ), the admin can still edit them and manually remove the signature.
In the end, having the signature not be separate from the comment body is a very bad idea, regardless of whether signatures are retro-active or not, so I think this move is inevitable any way.
Comment #4
eaton CreditAttribution: eaton commentedI agree with Steven's comments and webchick's proposal. Changing the look-and-feel of our forums to match other forum systems isn't that hard. Our implementation of signatures, though, makes it almost impossible to achieve similar *workflow*.
This patch makes it possible, and leaving slightly messy data in old comments (doubled signatures, etc) is by far the lesser of two evils.
Comment #5
webchickDifferent approach, based on Steven's awesome feedback. Thanks, Steven! :D
This method removes the theme function and hook_comment in favour of adding a new variable to comment.tpl.php. This way, the output is totally themeable, even by people who don't know PHP. :) Also, the legacy issue can be resolved via the theme, so I'm moving this to needs review.
Comment #6
BioALIEN CreditAttribution: BioALIEN commentedbest effort solution that only removes the user's current signature from their comments
To be honest, even this is a little OTT. Just implement the proposed functionality and forget all about previous comments. If a user bothers to edit an existing post, then they should remember to remove any signature they see at the footer.
Users will quickly learn that the only place they will ever see their signature in a text area would be their My Account > Edit page.
1) This will make it invisible with no penalty or extra code for fresh Drupal 6 installations.
2) Adding extra code that solves a (questionable?) part of a problem isn't required in this instance.
Users that post comments will quickly realise Drupal comments & signature system will function in line with what they expect at any BB system and will adapt accordingly. The only thing we need to do is state this clearly in the UPGRADE.txt and on the Drupal 5.x > 6.x upgrade pages to inform site admins. They can then take necessary measures under their discretion whether adding a global announcement to their users or in a mailing list to their members etc.
Comment #7
Gman CreditAttribution: Gman commented+1 on including it in the comment.tpl.php of the themes. A great way to let admin/designers who know some CSS to theme the sigs. I was trying to contemplate a solution since I hadn't read Steven's reply, but without any noticable break between the end of a comment, and the included old signature, there is no way get rid of those old non-current comments sigs.
Mostly I am subscribing, as I hope to try this out soon. Also, I like how this leave open the ability for a contrib module to extend/transform the sigs at a later date. Keep the core slim, but with ability to expand.
Comment #8
webchickThe nice thing about this being included in the theme is that you could conceivably do code like:
I actually kind of prefer this kind of "exact" fix to attempting a "best guess" upgrade path... the best we could do is go through all of the comments in the comment table, check to see if the author's current signature is found (at the very end of the signature), and remove it. This doesn't do anything for users who have had multiple signatures over time.
And yes, doing things this way in no way prevents a contrib module from extending signatures further (or even reverting to the old behaviour); rather, it should in fact be _easier_ now, because the signature is not coupled with the comment body.
Comment #9
Dries CreditAttribution: Dries commentedJust wanted to point out that I agree with the proposed solution.
I looked at the code and it looks good. I wasn't able to test it, but I'll do that soon. Feel free to help though.
One detail: typically two dashes (--) are used to separate the signature from the body. At least, that's what they recommend for e-mail, and is what e-mail clients pick up.
Comment #10
webchickYep, that's what I originally had (dash-dash-space-newline), but Steven pointed out that since it's the Web and not e-mail, we should use emdash instead.
Comment #11
Dries CreditAttribution: Dries commentedPatch no longer applies. Feel free to RTBC this after you re-rolled it. (I still think two dashes are more 'natural' but I don't really care all that much about it.)
Comment #12
webchickSo in satisfying the "other people use other sites more often than yours" rule, I went out to discover what other BB systems are using as signature separators. ;)
Phorum appears not to use a signature separator.
PHPBB 2.x and vBulletin use:
IPB uses:
SMF uses a
<hr />
.PHPBB 3.x uses a div styled to look like a
<hr />
:----
It seems to me that all the forum systems using a bunch of ---s or ___s are in fact trying to simulate the look of a horizontal rule separating the text body from the signature. So why not just bite the bullet and use a horizontal rule? This way there isn't extra meaningless text in the post for robots and blind people to try and parse.
I looked up some stuff on the
<hr />
tag itself, but it appears that generally it's frowned upon as being presentational rather than semantic.Therefore, I'm going with PHPBB 3.x's approach, and styling the signature div. This allows to also ditch a non-semantic
<br />
tag as well. Hooray!Comment #13
webchickthin doesn't appeat to be cross-browser compliant... here's a version using 1px instead for the border. Screenshot forthcoming.
Per Dries, I've marked this RTBC.
Comment #14
webchickScreenshot
Comment #15
webchickkkaefer reviewed and found several bugs, which are fixed in this patch:
1. I forgot to change themes/engines/phptemplate/comment.tpl.php. Whoops!
2. I forgot to add the signature stuff into theme_comment
3. the correct class should be clear-block and not clear, which is Garland-specific.
Thanks, kkaefer!
Comment #16
webchickMissed silly theme_comment. ;)
Comment #17
webchickkkaefer noted an XSS vuln in theme_comment.. moving the check_markup into the comment.module logic, which unfortunately means I need to duplicate it 12,000 times. :P
Comment #18
Dries CreditAttribution: Dries commentedIt looks good to me -- I've committed this part to CVS HEAD. We can refine this as necessary in part 2 of 2.
Comment #19
webchickOH MAN! :D
This is officially the best day EVER! :D Thank you thank you thank you!!
Theming docs updated: http://drupal.org/node/132442
Comment #20
kkaefer CreditAttribution: kkaefer commentedPart 2: http://drupal.org/node/132446
Comment #21
Steven CreditAttribution: Steven commentedGray? In Garland? Please.
Comment #22
webchickActually, looks like the user.css hunk was never committed.
But Steven schooled me in some design-fu over IRC, and he's right; an emdash looks much less cluttered than "yet another bar that goes all the way across the screen."
So here they are in emdashes. And even better, I kept the
<br />
out of the patch... since the signature gets wrapped in<p>
, we don't need it.Comment #23
Steven CreditAttribution: Steven commentedWe should still wrap the dash in a div IMO, so that we always have it a separate block level element. Some input formats may not output paragraphs tags.
Other than that, this is much better. Commited to HEAD. Thanks, webchick!
Comment #24
webchickWhen I was working on the 'part 2' patch, I discovered a much better way to handle parts of this one.
Rather than doing the logic for $comment->signature 1500 times in comment.module, this one does it once in user_comment(). It also adds a theme function which is called from theme_comment, so that:
a) when/if this is eventually re-used for nodes we don't have duplicate code.
b) the output isn't hard-coded into comment.module, but in user.module where it belongs.
I marked this RTBC because this patch was already reviewed as part of http://drupal.org/node/132446 and the only complaints were related to the node stuff which isn't part of this patch. Hope that's ok.
Comment #25
webchickOh. I should also add that cleaning this up makes it MUCH easier to add in a "disable" option for signatures, as I only have to put the logic in user_comment(). :)
Comment #26
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #27
(not verified) CreditAttribution: commented