Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Remove public uses of "liked" and "disliked"
Browse files Browse the repository at this point in the history
Replacing with "upvoted" and "downvoted" everywhere respectively.

This keeps the /liked and /disliked paths for user pages working for API
clients, but does a 301 redirect for non-API clients.
  • Loading branch information
Deimos committed May 21, 2015
1 parent 5e954ec commit 35339be
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 26 deletions.
31 changes: 22 additions & 9 deletions r2/r2/controllers/listingcontroller.py
Expand Up @@ -739,8 +739,8 @@ def title(self):
'comments': _("comments by %(user)s"),
'submitted': _("submitted by %(user)s"),
'gilded': _("gilded by %(user)s"),
'liked': _("liked by %(user)s"),
'disliked': _("disliked by %(user)s"),
'upvoted': _("upvoted by %(user)s"),
'downvoted': _("downvoted by %(user)s"),
'saved': _("saved by %(user)s"),
'hidden': _("hidden by %(user)s"),
'promoted': _("promoted by %(user)s")}
Expand All @@ -760,10 +760,10 @@ def keep(item):
return False

if c.user == self.vuser:
if not item.likes and self.where == 'liked':
if not item.likes and self.where == 'upvoted':
g.stats.simple_event("vote.missing_votes_by_account")
return False
if item.likes is not False and self.where == 'disliked':
if item.likes is not False and self.where == 'downvoted':
g.stats.simple_event("vote.missing_votes_by_account")
return False
if self.where == 'saved' and not item.saved:
Expand Down Expand Up @@ -810,10 +810,10 @@ def query(self):
else:
q = queries.get_gilded_user(self.vuser)

elif self.where in ('liked', 'disliked'):
elif self.where in ('upvoted', 'downvoted'):
sup.set_sup_header(self.vuser, self.where)
self.check_modified(self.vuser, self.where)
if self.where == 'liked':
if self.where == 'upvoted':
q = queries.get_liked(self.vuser)
else:
q = queries.get_disliked(self.vuser)
Expand Down Expand Up @@ -851,9 +851,22 @@ def query(self):
@listing_api_doc(section=api_section.users, uri='/user/{username}/{where}',
uri_variants=['/user/{username}/' + where for where in [
'overview', 'submitted', 'comments',
'liked', 'disliked', 'hidden', 'saved',
'gilded']])
'upvoted', 'downvoted', 'hidden',
'saved', 'gilded']])
def GET_listing(self, where, vuser, sort, time, show, **env):
# continue supporting /liked and /disliked paths for API clients
# but 301 redirect non-API users to the new location
changed_wheres = {"liked": "upvoted", "disliked": "downvoted"}
new_where = changed_wheres.get(where)
if new_where:
where = new_where
if not is_api():
path = "/".join(("/user", vuser.name, where))
query_string = request.environ.get('QUERY_STRING')
if query_string:
path += "?" + query_string
return self.redirect(path, code=301)

self.where = where
self.sort = sort
self.time = time
Expand Down Expand Up @@ -881,7 +894,7 @@ def GET_listing(self, where, vuser, sort, time, show, **env):
c.user_is_sponsor and where == "promoted")):
return self.abort404()

if where in ('liked', 'disliked') and not votes_visible(vuser):
if where in ('upvoted', 'downvoted') and not votes_visible(vuser):
return self.abort403()

if ((where in ('saved', 'hidden') or
Expand Down
4 changes: 2 additions & 2 deletions r2/r2/lib/menus.py
Expand Up @@ -163,8 +163,8 @@ def __getattr__(self, attr):

overview = _("overview"),
submitted = _("submitted"),
liked = _("liked"),
disliked = _("disliked"),
upvoted = _("upvoted"),
downvoted = _("downvoted"),
hidden = _("hidden {toolbar}"),
deleted = _("deleted"),
reported = _("reported"),
Expand Down
8 changes: 5 additions & 3 deletions r2/r2/lib/pages/pages.py
Expand Up @@ -2086,9 +2086,11 @@ def build_toolbars(self):
NamedButton('gilded')]

if votes_visible(self.user):
main_buttons += [NamedButton('liked'),
NamedButton('disliked'),
NamedButton('hidden')]
main_buttons += [
NamedButton('upvoted'),
NamedButton('downvoted'),
NamedButton('hidden'),
]

if c.user_is_loggedin and (c.user._id == self.user._id or
c.user_is_admin):
Expand Down
4 changes: 2 additions & 2 deletions r2/r2/templates/frametoolbar.html
Expand Up @@ -178,8 +178,8 @@
</%def>

%if getattr(thing, "votable", True):
${arrow("up", thing.upstyle, _("like"))}
${arrow("down", thing.downstyle, _("dislike"))}
${arrow("up", thing.upstyle, _("upvote"))}
${arrow("down", thing.downstyle, _("downvote"))}
%endif
</span>

Expand Down
8 changes: 4 additions & 4 deletions r2/r2/templates/preffeeds.html
Expand Up @@ -61,11 +61,11 @@ <h1>${_("Private RSS feeds")}</h1>
<tr>
<th>private profile pages</th>
<td class="prefright">
<%self:feedbuttons path="/user/${c.user.name}/liked"></%self:feedbuttons>
${_("links you've liked")}
<%self:feedbuttons path="/user/${c.user.name}/upvoted"></%self:feedbuttons>
${_("links you've upvoted")}
<br/>
<%self:feedbuttons path="/user/${c.user.name}/disliked"></%self:feedbuttons>
${_("links you've disliked")}
<%self:feedbuttons path="/user/${c.user.name}/downvoted"></%self:feedbuttons>
${_("links you've downvoted")}
<br/>
<%self:feedbuttons path="/user/${c.user.name}/hidden"></%self:feedbuttons>
${_("links you've hidden")}
Expand Down
8 changes: 4 additions & 4 deletions r2/r2/templates/prefoptions.html
Expand Up @@ -186,11 +186,11 @@
${_("(such as the source subreddit or the content author's url/name)")}
</span>
</p>
<p>${checkbox(_("don't show links after I've liked them"), "hide_ups")}
<p>${checkbox(_("don't show me submissions after I've upvoted them"), "hide_ups")}
&#32;
<span class="details">${_("(except my own)")}</span>
</p>
<p>${checkbox(_("don't show links after I've disliked them"), "hide_downs")}
<p>${checkbox(_("don't show me submissions after I've downvoted them"), "hide_downs")}
&#32;
<span class="details">${_("(except my own)")}</span>
</p>
Expand Down Expand Up @@ -315,8 +315,8 @@
&#32;
<span class="details">
<%
link1 = format_html('&#32;<a href="/user/%s/liked">/user/%s/liked</a>&#32;', c.user.name, c.user.name)
link2 = format_html('&#32;<a href="/user/%s/disliked">/user/%s/disliked</a>', c.user.name, c.user.name)
link1 = format_html('&#32;<a href="/user/%s/upvoted">/user/%s/upvoted</a>&#32;', c.user.name, c.user.name)
link2 = format_html('&#32;<a href="/user/%s/downvoted">/user/%s/downvoted</a>', c.user.name, c.user.name)
%>
(${_wsf("let everyone see %(link1)s and %(link2)s", link1=link1, link2=link2)})
</span>
Expand Down
4 changes: 2 additions & 2 deletions r2/r2/templates/widgetdemopanel.html
Expand Up @@ -135,8 +135,8 @@ <h2>${_("which links do you want to display?")}</h2>
onfocus="this.parentNode.firstChild.checked='checked'">
<option value="submitted">${_("submitted by")}</option>
<option value="saved">${_("saved by")}</option>
<option value="liked">${_("liked by")}</option>
<option value="disliked">${_("disliked by")}</option>
<option value="liked">${_("upvoted by")}</option>
<option value="disliked">${_("downvoted by")}</option>
</select>
</%def>
<%def name="text_input(name)" buffered="True">
Expand Down

0 comments on commit 35339be

Please sign in to comment.