Closed
Bug 441652
Opened 17 years ago
Closed 11 years ago
Add hook for user identity in templates
Categories
(Bugzilla :: Extensions, enhancement)
Bugzilla
Extensions
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: docwhat, Unassigned)
Details
Attachments
(2 files)
|
1.76 KB,
patch
|
LpSolit
:
review-
|
Details | Diff | Splinter Review |
|
2.65 KB,
patch
|
LpSolit
:
review-
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9) Gecko/2008061004 Firefox/3.0
Build Identifier: 3.0.4
I want to be able to control how usernames are displayed.
Example:
Turn: <a href="mailto:user@example.com">user@example.com</a>
Into: <a href="mailto:user@example.com"><img src="http://www.gravatar.com/avatar.php?gravatar_id=4896dfe0c18a330c61121677891c4325&size=16"/>user</a>
Ciao!
Reproducible: Always
Updated•17 years ago
|
OS: Mac OS X → All
Hardware: PC → All
Summary: Add hook for users → Add hook for user identity in templates
Updated•17 years ago
|
Assignee: ui → guy.pyrzak
Comment 1•17 years ago
|
||
Attachment #332087 -
Flags: review?(mkanat)
Attachment #332087 -
Flags: review?(LpSolit)
Comment 2•17 years ago
|
||
Comment on attachment 332087 [details] [diff] [review]
Patch v1
This won't help IMO. If someone wants to hide email addresses or want something else to be displayed (versus than having something else to be added), the hook won't be of any help AFAIK.
Attachment #332087 -
Flags: review?(LpSolit) → review-
| Reporter | ||
Comment 3•17 years ago
|
||
Yeah, that would let me add something before hand (gravatars in the example above). But I actually want to change the username into something different as well.
This might be better:
[% PROCESS "global/user.html.tmpl" user_id=whatever_id user_email=whatever_email user_realname=whatever_realname %]
Where only user_id is required, the rest would be used if available.
Another niceness would be "global/user.txt.tmpl" for emails.
The only bummer is that this could be really slow for things like the CC list where all the users are looked up. I suppose there could be a function that caches all the users and if we know we're going to use them we could look it all up at once.
Alternatively, we could add a flag that says what the purpose of this is, and wouldn't lookup extra info from the DB if it's part of a list.
Ciao!
Comment 4•17 years ago
|
||
Ah, I thought he just wanted the gravitar thing (which this would be good enough for) I missed the part with the email. The solution that I will do is load the values into a variable and print the variable, if the hook wants to change the variable it can. Thanks for catching that Lp.
Updated•17 years ago
|
Attachment #332087 -
Flags: review?(mkanat)
Comment 5•17 years ago
|
||
changes to the html to makes developers can easily replace the username output with a hook.
Attachment #333566 -
Flags: review?(LpSolit)
Comment 6•17 years ago
|
||
Comment on attachment 333566 [details] [diff] [review]
Patch v2
>Index: template/en/default/bug/comments.html.tmpl
> <a class="fn email" href="mailto:[% comment.author.email FILTER html %]">
>- [% (comment.author.name || comment.author.login) FILTER html %]
>+ [% SET user_identity_output = (comment.author.name || comment.author.login) %]
>+ [% Hook.process("user_identity") %]
>+ [% user_identity_output FILTER html %]
> </a>
This won't help. Assuming the hook wants to display the name + login, you only pass the name, so it has no change to do anything with it.
>Index: template/en/default/bug/edit.html.tmpl
>-[%# The contents of this file are subject to the Mozilla Public
>+[%# The contents of this file are subject to the Mozilla Public
Huh?
>@@ -249,6 +249,7 @@
> %]
>+
> <br>
Unrelated change (you are 900 lines above what you are editing). Remove that.
>- ><span class="fn">[% user.name FILTER html %]</span
>+ >[% SET user_identity_output = user.name %]
>+ [% Hook.process("user_identity") %]
>+ <span class="fn">[% user_identity_output FILTER html %]</span
Same problem here. What can the hook do with the user name?
>- [% user.email FILTER html %]</a>
>+ [% SET user_identity_output = user.email %]
>+ [% Hook.process("user_identity") %][% user_identity_output FILTER html %]</a>
Same here.
Probably better is to pass user name + login to the hook, and let it do what it wants with them.
Attachment #333566 -
Flags: review?(LpSolit) → review-
Comment 7•17 years ago
|
||
Actually, your comments are incorrect (other than the BR and the random other thing). The hook has access to all of the information in memory, in this case it has access to the user object, so the extension writer can do whatever they want and pass it back into the user_identity_output. All the extension writer has to do is replace the user_identity_output string with whatever information they please and it will work. So other than the miscellaneous "hu stuff" I would request that you re-review this, perhaps try to write an extension and reconsider.
Comment 8•17 years ago
|
||
Comment on attachment 333566 [details] [diff] [review]
Patch v2
Please re-review taking my comment in mind. If you'd like I will write a extension to prove that the hooks do what this bug requests.
Attachment #333566 -
Flags: review?(mkanat)
Attachment #333566 -
Flags: review?(LpSolit)
Attachment #333566 -
Flags: review-
Comment 9•17 years ago
|
||
I'd like to have this for 3.2, if someone disagrees feel free to bump it.
Target Milestone: --- → Bugzilla 3.2
Comment 10•17 years ago
|
||
Comment on attachment 333566 [details] [diff] [review]
Patch v2
Ah yes, sorry about that; you're right (I had INCLUDE in mind, not PROCESS). Anyway, your patch doesn't work:
>Index: template/en/default/bug/comments.html.tmpl
>+ [% Hook.process("user_identity") %]
This hook is called inside a BLOCK, so you have to pass the file name as 2nd argument. And example can be found in bug/show-multiple.html.tmpl
>Index: template/en/default/bug/edit.html.tmpl
>+ [% Hook.process("user_identity") %]
Same here.
Attachment #333566 -
Flags: review?(mkanat)
Attachment #333566 -
Flags: review?(LpSolit)
Attachment #333566 -
Flags: review-
Updated•16 years ago
|
Component: User Interface → Extensions
Comment 11•16 years ago
|
||
Bugzilla 3.2 is restricted to security bugs only. Moreover, this bug is either assigned to nobody or got no traction for several months now. Rather than retargetting it at each new release, I'm clearing the target milestone and the bug will be retargetted to some sensible release when someone starts fixing this bug for real (Bugzilla 3.8 more likely).
Target Milestone: Bugzilla 3.2 → ---
Updated•12 years ago
|
Assignee: guy.pyrzak → extensions
Comment 12•11 years ago
|
||
The way to do this would be to replace template/en/default/global/user.html.tmpl with a custom template.
Gerv
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•