## The contents of this file are subject to the Common Public Attribution ## License Version 1.0. (the "License"); you may not use this file except in ## compliance with the License. You may obtain a copy of the License at ## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public ## License Version 1.1, but Sections 14 and 15 have been added to cover use of ## software over a computer network and provide for limited attribution for the ## Original Developer. In addition, Exhibit A has been modified to be ## consistent with Exhibit B. ## ## Software distributed under the License is distributed on an "AS IS" basis, ## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for ## the specific language governing rights and limitations under the License. ## ## The Original Code is reddit. ## ## The Original Developer is the Initial Developer. The Initial Developer of ## the Original Code is reddit Inc. ## ## All portions of the code written by reddit are Copyright (c) 2006-2012 ## reddit Inc. All Rights Reserved. ############################################################################### <%! from r2.lib.template_helpers import get_domain, static, style_line, choose_width from r2.lib.utils import query_string from r2.lib.strings import Score %> <%namespace file="printable.html" import="arrow, score" /> <%namespace file="utils.html" import="img_link" /> <%def name="submiturl(url, title='')">${("http://%s/submit" % get_domain(cname = c.cname, subreddit = not c.cname)) + query_string(dict(url=url, title=title))} <%def name="submitlink(url, title='', text='submit')"> ${text} <%def name="class_def(class_number, width=None)"> <% like_cls = "unvoted" if getattr(thing, "likes", None): like_cls = "likes" elif getattr(thing, "likes", None) is False: like_cls = "dislikes" %>
${caller.body()}
<%def name="button1(thing)"> <%self:class_def class_number="1" width="${choose_width(thing, thing.width)}">
%if thing._fullname: %if thing.vote: ${arrow(thing, 1, thing.likes)} ${arrow(thing, 0, thing.likes == False)} ${score(thing, thing.likes, scores = map(Score.safepoints, thing.voting_score), tag='div')} %else: ${thing.score} %endif %else: ${submitlink(thing.url, thing.title)} %endif
<%def name="button2(thing)"> <%self:class_def class_number="2"> %if thing._fullname: %if thing.vote: ${arrow(thing, 1, thing.likes)} ${score(thing, thing.likes, tag='div')} ${arrow(thing, 0, thing.likes == False)} %else:  
${thing.score}  
%endif %else: ${submitlink(thing.url, thing.title, 'submit to')} %endif %if thing.bgcolor:
%else:
%endif reddit
<%def name="button3(thing)"> <%self:class_def class_number="3">
%if thing._fullname: %if thing.vote: ${arrow(thing, 1, thing.likes)} ${score(thing, thing.likes, tag='div')} ${arrow(thing, 0, thing.likes == False)} %else:  
${thing.score}  
%endif %else: ${submitlink(thing.url, thing.title, unsafe('
'))} ${submitlink(thing.url, thing.title, '?')} ${submitlink(thing.url, thing.title, unsafe('
'))} %endif
${img_link('submit', '/static/blog_snoo.gif', capture(submiturl, thing.url, thing.title), target=thing.target)}
<%def name="button4(thing)"> <%self:class_def class_number="2"> %if thing._fullname: %if thing.vote: ${arrow(thing, 1, thing.likes)} ${score(thing, thing.likes, tag='div')} ${arrow(thing, 0, thing.likes == False)} %else:  
${thing.score}  
%endif %else: ${submitlink(thing.url, thing.title, 'submit to')} %endif <%def name="button5(thing)"> <%self:class_def class_number="5" width="${choose_width(thing, thing.width)}"> ${img_link('submit', '/static/blog_snoo.gif', capture(submiturl, thing.url, thing.title), _class="left")} <% # this button style submits to the cname as a default c.cname = hasattr(c.site, "domain") and bool(c.site.domain) submitlink = capture(submiturl, thing.url, thing.title) if thing._fullname: fullname = thing._fullname ups = thing.upvotes downs = thing.downvotes link = "http://%s%s" % (get_domain(cname = c.cname, subreddit = False), thing.make_permalink_slow()) else: fullname = "" ups = 0 downs = 0 link = submitlink if c.user_is_loggedin and thing._fullname: dir = 1 if thing.likes else 0 if thing.likes is None else -1 ups = ups - (1 if dir > 0 else 0) downs = downs - (1 if dir < 0 else 0) else: dir = 0 other_votes = float(ups + downs) ups = [ups, ups, ups + 1] downs = [downs + 1, downs, downs] votes = [other_votes + 1, other_votes, other_votes + 1] up_pct = [int( 100 * ups[i] / votes[i]) if votes[i] else "--" for i in range(len(votes))] down_pct = [int( 100 * downs[i] / votes[i]) if votes[i] else "--" for i in range(len(votes))] def controversy_text(_up_pct): if isinstance(_up_pct, str): return "" p = abs(50 - _up_pct) msg = "%s" if p <= 5: return msg % (3, _("quite controversial")) elif p <= 15: return msg % (2, _("controversial")) elif p <= 25: return msg % (1, _("uncontroversial")) else: return msg % (0, _("quite uncontroversial")) controversy = map(controversy_text, up_pct) %>