Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added comment karma and locale formatting to header #395

Closed
wants to merge 2 commits into from

4 participants

@Deimos
Owner

No description provided.

@kemitche kemitche commented on the diff
r2/r2/templates/redditheader.compact
@@ -86,7 +86,7 @@
%if c.user_is_loggedin:
<div class="menuitem">
${plain_link(c.user.name, "/user/%s/" % c.user.name, _sr_path=False)}
- &nbsp;(<b>${c.user.safe_karma}</b>)
+ &nbsp;(<b>${locale.format("%d", c.user.safe_karma, True)}</b> / <b>${locale.format("%d", c.user.comment_karma, True)}</b>)

"locale" doesn't seem to be imported (and I don't believe would work the way you expect; since it's interpreter-wide, locale-settings won't pick up the user's settings)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Saturate

I like the idea of comment karma in the header, I don't get why it is not there to begin with.

@spladug
Owner

Not sure if you're still interested in this pull request, but locale is not the module you want to use here as @kemitche pointed out. Specifically, locale is interpreter-wide and therefore not the actual locale the user's expecting. You'd want to use babel for this, or potentially the format_number util in template_helpers (which uses babel itself).

:nail_care:

@Deimos Deimos closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  r2/r2/templates/redditheader.compact
@@ -20,6 +20,7 @@
## CondeNet, Inc. All Rights Reserved.
################################################################################
<%!
+ import locale
from r2.lib.template_helpers import static, s3_https_if_secure
from r2.models.subreddit import DefaultSR
@@ -86,7 +87,7 @@
%if c.user_is_loggedin:
<div class="menuitem">
${plain_link(c.user.name, "/user/%s/" % c.user.name, _sr_path=False)}
- &nbsp;(<b>${c.user.safe_karma}</b>)
+ &nbsp;(<b>${locale.format("%d", c.user.safe_karma, True)}</b> / <b>${locale.format("%d", c.user.comment_karma, True)}</b>)

"locale" doesn't seem to be imported (and I don't believe would work the way you expect; since it's interpreter-wide, locale-settings won't pick up the user's settings)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
</div>
<div class="menuitem">
${plain_link("reddits", "/reddits/mine", _sr_path=False)}
View
3  r2/r2/templates/redditheader.html
@@ -21,6 +21,7 @@
################################################################################
<%!
+ import locale
from r2.lib.template_helpers import static, s3_https_if_secure, add_sr
from r2.models import Sub, FakeSubreddit
from r2.models.subreddit import DefaultSR
@@ -76,7 +77,7 @@
%else:
<span class="user">
${plain_link(c.user.name, "/user/%s/" % c.user.name, _sr_path=False)}
- &nbsp;(<b>${c.user.safe_karma}</b>)
+ &nbsp;(<b>${locale.format("%d", c.user.safe_karma, True)}</b> / <b>${locale.format("%d", c.user.comment_karma, True)}</b>)
</span>
${separator("|")}
Something went wrong with that request. Please try again.